really, FUCK YOU
This commit is contained in:
59
www/protected/controllers/ApiController.php
Normal file
59
www/protected/controllers/ApiController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
class APIController extends MSController
|
||||
{
|
||||
public $layout = false;
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function actionUpdate()
|
||||
{
|
||||
if (! isset($_GET['Name'])) {
|
||||
throw new CHttpException(404,'Invalid Request - [Name] missing');
|
||||
return;
|
||||
}
|
||||
|
||||
$Name = $_GET['Name'];
|
||||
|
||||
$this->actionUpdate2($Name);
|
||||
}
|
||||
|
||||
public function actionUpdate2($Name)
|
||||
{
|
||||
$data = ProgramUpdates::model()->findByAttributes(['Name' => $Name]);
|
||||
|
||||
if (! isset($_GET['Name'])) {
|
||||
throw new CHttpException(404,'Invalid Request - [Name] not found');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->render('update', ['data' => $data]);
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
$this->render('test', []);
|
||||
}
|
||||
}
|
||||
197
www/protected/controllers/BlogpostController.php
Normal file
197
www/protected/controllers/BlogpostController.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
class BlogPostController extends MSController
|
||||
{
|
||||
public $menu=array();
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow', // allow all users to perform 'index' and 'view' actions
|
||||
'actions'=>array('index','view', 'ajaxMarkdownPreview'),
|
||||
'users'=>array('*'),
|
||||
),
|
||||
array('allow', // allow authenticated user to perform 'create' and 'update' actions
|
||||
'actions'=>array('create','update','admin','delete'),
|
||||
'users'=>array('@'),
|
||||
),
|
||||
// array('allow', // allow admin user to perform 'admin' and 'delete' actions
|
||||
// 'actions'=>array(),
|
||||
// 'users'=>array('admin'),
|
||||
// ),
|
||||
array('deny', // deny everythign else to all users
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particular model.
|
||||
* @param integer $id the ID of the model to be displayed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$this->render('view',array(
|
||||
'model'=>$this->loadModel($id),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$this->layout = '//layouts/column2';
|
||||
|
||||
$model=new BlogPost;
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['BlogPost'])) {
|
||||
$model->attributes=$_POST['BlogPost'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('create',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a particular model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id the ID of the model to be updated
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$this->layout = '//layouts/column2';
|
||||
|
||||
$model=$this->loadModel($id);
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['BlogPost'])) {
|
||||
$model->attributes=$_POST['BlogPost'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('update',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a particular model.
|
||||
* If deletion is successful, the browser will be redirected to the 'admin' page.
|
||||
* @param integer $id the ID of the model to be deleted
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->layout = '//layouts/column2';
|
||||
|
||||
$this->loadModel($id)->delete();
|
||||
|
||||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
|
||||
if (!isset($_GET['ajax'])) {
|
||||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all models.
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->order = "Date DESC";
|
||||
|
||||
$all = BlogPost::model()->findAll($criteria);
|
||||
|
||||
$this->render('index',
|
||||
[
|
||||
'blogposts' => $all,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function actionAjaxMarkdownPreview() {
|
||||
if(Yii::app()->request->isAjaxRequest){
|
||||
$this->renderPartial('_ajaxMarkdownPreview',
|
||||
[
|
||||
'Content' => $_POST['Content'],
|
||||
],
|
||||
false, true);
|
||||
} else {
|
||||
throw new CHttpException(400,'Invalid request. This is a Ajax only action.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages all models.
|
||||
*/
|
||||
public function actionAdmin()
|
||||
{
|
||||
$this->layout = '//layouts/column2';
|
||||
|
||||
$model=new BlogPost('search');
|
||||
$model->unsetAttributes(); // clear any default values
|
||||
if (isset($_GET['BlogPost'])) {
|
||||
$model->attributes=$_GET['BlogPost'];
|
||||
}
|
||||
|
||||
$this->render('admin',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data model based on the primary key given in the GET variable.
|
||||
* If the data model is not found, an HTTP exception will be raised.
|
||||
* @param integer $id the ID of the model to be loaded
|
||||
* @return BlogPost the loaded model
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function loadModel($id)
|
||||
{
|
||||
$model=BlogPost::model()->findByPk($id);
|
||||
if ($model===null) {
|
||||
throw new CHttpException(404,'The requested page does not exist.');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the AJAX validation.
|
||||
* @param BlogPost $model the model to be validated
|
||||
*/
|
||||
protected function performAjaxValidation($model)
|
||||
{
|
||||
if (isset($_POST['ajax']) && $_POST['ajax']==='blog-post-form') {
|
||||
echo CActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
222
www/protected/controllers/HighscoresController.php
Normal file
222
www/protected/controllers/HighscoresController.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
class HighscoresController extends MSController //TODO-MS Test online if it all works
|
||||
{
|
||||
const ENTRYLIST_PAGESIZE = 20;
|
||||
|
||||
public $layout = false;
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function actionInsert($gameid, $check, $name, $rand, $points)
|
||||
{
|
||||
if (! is_numeric($gameid))
|
||||
throw new CHttpException(400, 'Invalid Request');
|
||||
if (! is_numeric($points))
|
||||
throw new CHttpException(400, 'Invalid Request');
|
||||
|
||||
$entry = new HighscoreEntries();
|
||||
$entry->GAME_ID = $gameid;
|
||||
$entry->POINTS = $points;
|
||||
$entry->PLAYER = $name;
|
||||
$entry->PLAYERID = -1;
|
||||
$entry->CHECKSUM = $check;
|
||||
$entry->TIMESTAMP = time();
|
||||
$entry->IP = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if ($entry->checkChecksum($rand))
|
||||
{
|
||||
if ($entry->save())
|
||||
{
|
||||
$this->actionListEntries($gameid);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Error while inserting';
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Nice try !';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
if (!isset($_GET["gameid"]))
|
||||
{
|
||||
$this->actionListGames();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->actionListEntries(intval(mysql_real_escape_string($_GET["gameid"])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function actionListEntries($gameid)
|
||||
{
|
||||
if (! is_numeric($gameid))
|
||||
throw new CHttpException(400, 'Invalid Request - [gameid] must be an integer');
|
||||
|
||||
if (!isset($_GET["start"]))
|
||||
{
|
||||
$start = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = intval(mysql_real_escape_string($_GET["start"])) - 1;
|
||||
if ($start < 0)
|
||||
{
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["highlight"]))
|
||||
{
|
||||
$highlight= intval(mysql_real_escape_string($_GET["highlight"]));
|
||||
}
|
||||
else
|
||||
$highlight = 0;
|
||||
|
||||
$game = HighscoreGames::model()->findByPk($gameid);
|
||||
|
||||
$this->render('listentries',
|
||||
[
|
||||
'game' => $game,
|
||||
'start' => $start,
|
||||
'highlight' => $highlight,
|
||||
'pagesize' => self::ENTRYLIST_PAGESIZE,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionListGames()
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
$games = HighscoreGames::model()->findAll($criteria);
|
||||
|
||||
$this->render('listgames',
|
||||
[
|
||||
'games' => $games,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionUpdate($gameid, $check, $name, $nameid, $rand, $points)
|
||||
{
|
||||
if (! is_numeric($gameid))
|
||||
throw new CHttpException(400, 'Invalid Request');
|
||||
if (! is_numeric($nameid))
|
||||
throw new CHttpException(400, 'Invalid Request');
|
||||
if (! is_numeric($points))
|
||||
throw new CHttpException(400, 'Invalid Request');
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->addCondition('GAME_ID = ' . $gameid);
|
||||
$criteria->addCondition('PLAYERID = ' . $nameid);
|
||||
|
||||
/* @var HighscoreEntries $entry */
|
||||
$entry = HighscoreEntries::model()->find($criteria);
|
||||
|
||||
if (is_null($entry))
|
||||
{
|
||||
$entry = new HighscoreEntries();
|
||||
$entry->GAME_ID = $gameid;
|
||||
$entry->POINTS = $points;
|
||||
$entry->PLAYER = $name;
|
||||
$entry->PLAYERID = -1;
|
||||
$entry->CHECKSUM = $check;
|
||||
$entry->TIMESTAMP = time();
|
||||
$entry->IP = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if ($entry->checkChecksum($rand))
|
||||
{
|
||||
if ($entry->save())
|
||||
{
|
||||
$this->actionListEntries($gameid);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Error while inserting';
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Nice try !';
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry->POINTS = $points;
|
||||
$entry->PLAYER = $name;
|
||||
$entry->CHECKSUM = $check;
|
||||
$entry->IP = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if ($entry->checkChecksum($rand))
|
||||
{
|
||||
$entry->update();
|
||||
$this->actionListEntries($gameid);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Nice try !';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function actionList_Top50($gameid)
|
||||
{
|
||||
if (! is_numeric($gameid))
|
||||
throw new CHttpException(400, 'Invalid Request - [gameid] must be an integer');
|
||||
|
||||
$game = HighscoreGames::model()->findByPk($gameid);
|
||||
|
||||
$this->render('list_top50',
|
||||
[
|
||||
'game' => $game,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNewID($gameid)
|
||||
{
|
||||
$connection=Yii::app()->db;
|
||||
$command=$connection->createCommand("SELECT MAX(PLAYERID)+1 AS NID FROM {{highscoreentries}} WHERE GAME_ID = $gameid");
|
||||
|
||||
$newid = $command->queryScalar();
|
||||
if ($newid < 1024) {
|
||||
$newid = 1024;
|
||||
}
|
||||
|
||||
print $newid;
|
||||
}
|
||||
}
|
||||
194
www/protected/controllers/LogController.php
Normal file
194
www/protected/controllers/LogController.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
class LogController extends MsController
|
||||
{
|
||||
public $layout='//layouts/column2';
|
||||
|
||||
public $menu=array();
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'actions'=>array('index', 'ajaxMarkdownPreview'),
|
||||
'users'=>array('*'),
|
||||
),
|
||||
array('allow',
|
||||
'actions'=>array('create','update','admin','delete','view'),
|
||||
'users'=>array('admin'),
|
||||
),
|
||||
array('deny',
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all models.
|
||||
*/
|
||||
public function actionIndex($logid)
|
||||
{
|
||||
$this->layout='//layouts/main';
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->order = "date DESC";
|
||||
|
||||
$all = Log::model()->findAll($criteria);
|
||||
/* @var $all Log[] */
|
||||
|
||||
$this->render('index',
|
||||
[
|
||||
'logs' => $all,
|
||||
'logid' => $logid,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAjaxMarkdownPreview() {
|
||||
if(Yii::app()->request->isAjaxRequest){
|
||||
$this->renderPartial('_ajaxMarkdownPreview',
|
||||
[
|
||||
'content' => $_POST['content'],
|
||||
],
|
||||
false, true);
|
||||
} else {
|
||||
throw new CHttpException(400,'Invalid request. This is a Ajax only action.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particular model.
|
||||
* @param integer $id the ID of the model to be displayed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$this->render('view',array(
|
||||
'model'=>$this->loadModel($id),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model=new Log;
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if(isset($_POST['Log']))
|
||||
{
|
||||
$model->attributes=$_POST['Log'];
|
||||
if($model->save())
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
|
||||
$this->render('create',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a particular model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id the ID of the model to be updated
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model=$this->loadModel($id);
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if(isset($_POST['Log']))
|
||||
{
|
||||
$model->attributes=$_POST['Log'];
|
||||
if($model->save())
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
|
||||
$this->render('update',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a particular model.
|
||||
* If deletion is successful, the browser will be redirected to the 'admin' page.
|
||||
* @param integer $id the ID of the model to be deleted
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
// if (Yii::app()->request->isPostRequest) {
|
||||
// we only allow deletion via POST request
|
||||
$this->loadModel($id)->delete();
|
||||
|
||||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
|
||||
if (!isset($_GET['ajax'])) {
|
||||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
|
||||
}
|
||||
// } else {
|
||||
// throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages all models.
|
||||
*/
|
||||
public function actionAdmin()
|
||||
{
|
||||
$model=new Log('search');
|
||||
$model->unsetAttributes(); // clear any default values
|
||||
if(isset($_GET['Log']))
|
||||
$model->attributes=$_GET['Log'];
|
||||
|
||||
$this->render('admin',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data model based on the primary key given in the GET variable.
|
||||
* If the data model is not found, an HTTP exception will be raised.
|
||||
* @param integer $id the ID of the model to be loaded
|
||||
* @return Log the loaded model
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function loadModel($id)
|
||||
{
|
||||
$model=Log::model()->findByPk($id);
|
||||
if($model===null)
|
||||
throw new CHttpException(404,'The requested page does not exist.');
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the AJAX validation.
|
||||
* @param Log $model the model to be validated
|
||||
*/
|
||||
protected function performAjaxValidation($model)
|
||||
{
|
||||
if(isset($_POST['ajax']) && $_POST['ajax']==='log-form')
|
||||
{
|
||||
echo CActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
153
www/protected/controllers/MsmainController.php
Normal file
153
www/protected/controllers/MsmainController.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
class MSMainController extends MSController
|
||||
{
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'actions'=>array('index', 'about', 'debugerror', 'error', 'login', 'logout'),
|
||||
'users'=>array('*'),
|
||||
),
|
||||
array('allow',
|
||||
'actions'=>array('admin'),
|
||||
'users'=>array('admin'),
|
||||
),
|
||||
array('deny',
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->order = "date DESC";
|
||||
|
||||
$all_log = Log::model()->findAll($criteria);
|
||||
/* @var $all_log Log[] */
|
||||
|
||||
$data = array();
|
||||
$data['program'] = ProgramHelper::GetDailyProg();
|
||||
$data['logs'] = $all_log;
|
||||
|
||||
$this->render('index', $data);
|
||||
}
|
||||
|
||||
public function actionError()
|
||||
{
|
||||
if($error=Yii::app()->errorHandler->error)
|
||||
{
|
||||
if(Yii::app()->request->isAjaxRequest)
|
||||
echo $error['message'];
|
||||
else
|
||||
$this->render('error', $error);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionDebugError()
|
||||
{
|
||||
if($error=Yii::app()->errorHandler->error)
|
||||
{
|
||||
if(Yii::app()->request->isAjaxRequest)
|
||||
echo $error['message'];
|
||||
else
|
||||
$this->render('debugerror', $error);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionAbout()
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$this->js_scripts[] = file_get_contents('protected/components/extendedGitGraph/script.js');
|
||||
|
||||
if(isset($_POST['SendMailForm']))
|
||||
{
|
||||
$model = new SendMailForm();
|
||||
|
||||
$model->attributes=$_POST['SendMailForm'];
|
||||
|
||||
if($model->validate()) {
|
||||
if ($model->send())
|
||||
{
|
||||
$data['alerts_success'][] = "Successfully send mail from " . $model->name;
|
||||
$data['model'] = new SendMailForm();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['alerts_error'][] = "Internal error while sending mail";
|
||||
$data['model'] = $model;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['model'] = $model;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['model'] = new SendMailForm();
|
||||
}
|
||||
|
||||
$this->render('about', $data);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
$model = new LoginForm();
|
||||
|
||||
// if it is ajax validation request
|
||||
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
|
||||
{
|
||||
echo TbActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
// collect user input data
|
||||
if(isset($_POST['LoginForm']))
|
||||
{
|
||||
$model->attributes=$_POST['LoginForm'];
|
||||
// validate user input and redirect to the previous page if valid
|
||||
if($model->validate() && $model->login())
|
||||
$this->redirect(Yii::app()->user->returnUrl);
|
||||
}
|
||||
// display the login form
|
||||
$this->render('login', array('model'=>$model));
|
||||
}
|
||||
|
||||
public function actionAdmin()
|
||||
{
|
||||
if (isset($_GET['do_egh_update']) && $_GET['do_egh_update'] == '1') {
|
||||
$this->layout = null;
|
||||
$this->render('admin_updateEGH', array());
|
||||
return;
|
||||
}
|
||||
|
||||
$this->render('admin', array());
|
||||
}
|
||||
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::app()->user->logout();
|
||||
$this->redirect(Yii::app()->homeUrl);
|
||||
}
|
||||
|
||||
public function action
|
||||
}
|
||||
283
www/protected/controllers/ProgramsController.php
Normal file
283
www/protected/controllers/ProgramsController.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
class ProgramsController extends MSController
|
||||
{
|
||||
const PROGS_INDEX_ROWSIZE = 4;
|
||||
const PROGS_INDEX_PAGESIZE = 16;
|
||||
|
||||
public $layout='//layouts/column2';
|
||||
|
||||
public $menu=array();
|
||||
|
||||
/**
|
||||
* @return array action filters
|
||||
*/
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the access control rules.
|
||||
* This method is used by the 'accessControl' filter.
|
||||
* @return array access control rules
|
||||
*/
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow', // allow all users to perform 'index' and 'view' actions
|
||||
'actions'=>array('index','view', 'download'),
|
||||
'users'=>array('*'),
|
||||
),
|
||||
array('allow', // allow authenticated user to perform 'create' and 'update' actions
|
||||
'actions'=>array('create','update','admin','delete'),
|
||||
'users'=>array('@'),
|
||||
),
|
||||
// array('allow', // allow admin user to perform 'admin' and 'delete' actions
|
||||
// 'actions'=>array(),
|
||||
// 'users'=>array('admin'),
|
||||
// ),
|
||||
array('deny', // deny everythign else to all users
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particular model.
|
||||
* @param integer $id the ID of the model to be displayed
|
||||
* @throws CHttpException when $id is integer
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$this->layout = '//layouts/main';
|
||||
|
||||
if (is_numeric($id))
|
||||
{
|
||||
if (Yii::app()->user->name == 'admin') {
|
||||
$model = $this->loadModelByID($id);
|
||||
} else {
|
||||
throw new CHttpException(400, "You can't access a program by ID");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$model = $this->loadModelByName($id);
|
||||
}
|
||||
|
||||
$this->render('view',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particular model.
|
||||
* @param integer $id the ID of the model to be displayed
|
||||
* @throws CHttpException when $id is integer
|
||||
*/
|
||||
public function actionDownload($id)
|
||||
{
|
||||
$this->layout = '//layouts/main';
|
||||
|
||||
if (is_numeric($id))
|
||||
{
|
||||
if (Yii::app()->user->name == 'admin') {
|
||||
$model = $this->loadModelByID($id);
|
||||
} else {
|
||||
throw new CHttpException(400, "You can't access a program by ID");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$model = $this->loadModelByName($id);
|
||||
}
|
||||
|
||||
$model->Downloads++;
|
||||
$model->save();
|
||||
|
||||
$this->redirect($model->getDirectDownloadLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model=new Program();
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['Program'])) {
|
||||
$model->attributes=$_POST['Program'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('create',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a particular model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id the ID of the model to be updated
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model=$this->loadModelByID($id);
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['Program'])) {
|
||||
$model->attributes=$_POST['Program'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->ID));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('update',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a particular model.
|
||||
* If deletion is successful, the browser will be redirected to the 'admin' page.
|
||||
* @param integer $id the ID of the model to be deleted
|
||||
* @throws CHttpException on invalid request
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
// if (Yii::app()->request->isPostRequest) {
|
||||
// we only allow deletion via POST request
|
||||
|
||||
$model = $this->loadModelByID($id);
|
||||
|
||||
$model->deleteDescriptions();
|
||||
$model->delete();
|
||||
|
||||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
|
||||
if (!isset($_GET['ajax'])) {
|
||||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
|
||||
}
|
||||
// } else {
|
||||
// throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all models.
|
||||
*/
|
||||
public function actionIndex($categoryfilter)
|
||||
{
|
||||
$this->layout = '//layouts/main';
|
||||
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$criteria = new CDbCriteria;
|
||||
$criteria->order = "Sterne DESC, add_date DESC";
|
||||
if (! empty($categoryfilter))
|
||||
$criteria->addCondition("Kategorie = :cat");
|
||||
$criteria->params[':cat'] = $categoryfilter;
|
||||
$criteria->addCondition("visible=1");
|
||||
|
||||
$all = Program::model()->findAll($criteria);
|
||||
/* @var $all Program[] */
|
||||
|
||||
$pagecount = ceil(count($all) / self::PROGS_INDEX_PAGESIZE);
|
||||
|
||||
$all = array_slice($all, ($page - 1) * self::PROGS_INDEX_PAGESIZE, self::PROGS_INDEX_PAGESIZE);
|
||||
|
||||
$rowcount = ceil((count($all) / self::PROGS_INDEX_ROWSIZE));
|
||||
|
||||
$progdata = array();
|
||||
for ($i = 0; $i < $rowcount; $i++) {
|
||||
$progdata[] = array();
|
||||
foreach (array_slice($all, $i * self::PROGS_INDEX_ROWSIZE, self::PROGS_INDEX_ROWSIZE) as $record) {
|
||||
$progdata[$i][] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
//#######
|
||||
|
||||
$data = array();
|
||||
$data['page'] = $page;
|
||||
$data['pagecount'] = $pagecount;
|
||||
$data['rowcount'] = $rowcount;
|
||||
$data['data'] = $progdata;
|
||||
$data['category'] = $categoryfilter;
|
||||
|
||||
$this->render('index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages all models.
|
||||
*/
|
||||
public function actionAdmin()
|
||||
{
|
||||
$model=new Program('search');
|
||||
$model->unsetAttributes(); // clear any default values
|
||||
if (isset($_GET['Program'])) {
|
||||
$model->attributes=$_GET['Program'];
|
||||
}
|
||||
|
||||
$this->render('admin',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data model based on the primary key given in the GET variable.
|
||||
* If the data model is not found, an HTTP exception will be raised.
|
||||
* @param integer $id the ID of the model to be loaded
|
||||
* @return Program the loaded model
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function loadModelByID($id)
|
||||
{
|
||||
$model=Program::model()->findByPk($id);
|
||||
if ($model===null) {
|
||||
throw new CHttpException(404,'The requested Programm (by ID) does not exist.');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data model based on the name of Program
|
||||
* If the data model is not found, an HTTP exception will be raised.
|
||||
* @param string $name the ID of the model to be loaded
|
||||
* @return Program the loaded model
|
||||
* @throws CHttpException
|
||||
*/
|
||||
public function loadModelByName($name)
|
||||
{
|
||||
$model=Program::model()->findByAttributes(['Name' => $name]);
|
||||
if ($model===null) {
|
||||
throw new CHttpException(404,'The requested programm (by Name) does not exist.');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the AJAX validation.
|
||||
* @param Program $model the model to be validated
|
||||
*/
|
||||
protected function performAjaxValidation($model)
|
||||
{
|
||||
if (isset($_POST['ajax']) && $_POST['ajax']==='program-form') {
|
||||
echo CActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
127
www/protected/controllers/ProgramupdatesController.php
Normal file
127
www/protected/controllers/ProgramupdatesController.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
class ProgramUpdatesController extends MSController
|
||||
{
|
||||
public $menu=array();
|
||||
|
||||
public $layout='//layouts/column2';
|
||||
|
||||
public function filters()
|
||||
{
|
||||
return array(
|
||||
'accessControl', // perform access control for CRUD operations
|
||||
'postOnly + delete', // we only allow deletion via POST request
|
||||
);
|
||||
}
|
||||
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow', // allow admin user to perform 'admin' and 'delete' actions
|
||||
'actions'=>array('index','view','create','update','admin','delete'),
|
||||
'users'=>array('admin'),
|
||||
),
|
||||
array('deny', // deny all users
|
||||
'users'=>array('*'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function actionView($id)
|
||||
{
|
||||
$this->render('view',array(
|
||||
'model'=>$this->loadModel($id),
|
||||
));
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
$model=new ProgramUpdates;
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['ProgramUpdates'])) {
|
||||
$model->attributes=$_POST['ProgramUpdates'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->Name));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('create',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model=$this->loadModel($id);
|
||||
|
||||
// Uncomment the following line if AJAX validation is needed
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['ProgramUpdates'])) {
|
||||
$model->attributes=$_POST['ProgramUpdates'];
|
||||
if ($model->save()) {
|
||||
$this->redirect(array('view','id'=>$model->Name));
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('update',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
public function actionDelete($id)
|
||||
{
|
||||
if (Yii::app()->request->isPostRequest) {
|
||||
// we only allow deletion via POST request
|
||||
$this->loadModel($id)->delete();
|
||||
|
||||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
|
||||
if (!isset($_GET['ajax'])) {
|
||||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
|
||||
}
|
||||
} else {
|
||||
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
|
||||
}
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$dataProvider=new CActiveDataProvider('ProgramUpdates');
|
||||
$this->render('index',array(
|
||||
'dataProvider'=>$dataProvider,
|
||||
));
|
||||
}
|
||||
|
||||
public function actionAdmin()
|
||||
{
|
||||
$model=new ProgramUpdates('search');
|
||||
$model->unsetAttributes(); // clear any default values
|
||||
if (isset($_GET['ProgramUpdates'])) {
|
||||
$model->attributes=$_GET['ProgramUpdates'];
|
||||
}
|
||||
|
||||
$this->render('admin',array(
|
||||
'model'=>$model,
|
||||
));
|
||||
}
|
||||
|
||||
public function loadModel($id)
|
||||
{
|
||||
$model=ProgramUpdates::model()->findByPk($id);
|
||||
if ($model===null) {
|
||||
throw new CHttpException(404,'The requested page does not exist.');
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
protected function performAjaxValidation($model)
|
||||
{
|
||||
if (isset($_POST['ajax']) && $_POST['ajax']==='program-updates-form') {
|
||||
echo CActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user