Added "update" API
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
class MSController extends CController
|
||||
{
|
||||
public $layout='//layouts/main';
|
||||
public $layout = '//layouts/main';
|
||||
|
||||
public $breadcrumbs=array();
|
||||
public $breadcrumbs = array();
|
||||
|
||||
public $selectedNav = '';
|
||||
|
||||
|
||||
@@ -74,6 +74,11 @@ return ArrayX::merge(
|
||||
|
||||
'programupdates/' => 'programupdates/index',
|
||||
|
||||
'update.php' => 'api/update',
|
||||
'update.php/<Name>' => 'api/update2',
|
||||
'update' => 'api/update',
|
||||
'update/<Name>' => 'api/update2',
|
||||
|
||||
'downloads/details.php' => 'programs/index', // Compatibility
|
||||
'downloads/downloads.php' => 'programs/index', // Compatibility
|
||||
'downloads/<id>' => 'programs/view', // Compatibility
|
||||
|
||||
54
www/protected/controllers/APIController.php
Normal file
54
www/protected/controllers/APIController.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
5
www/protected/views/api/update.php
Normal file
5
www/protected/views/api/update.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/* @var $this APIController */
|
||||
/* @var $data ProgramUpdates */
|
||||
|
||||
print($data->Name."<hr>".$data->Version."<hr>".$data->Link);
|
||||
@@ -88,7 +88,7 @@
|
||||
?>
|
||||
|
||||
<div class="footer">
|
||||
Copyright © <?php echo date('Y'); ?> by Mike Schwörer.<br/>
|
||||
Copyright © <?php echo date('Y'); ?> by Mike Schwörer · <a href="/admin">admin</a><br/>
|
||||
All Rights Reserved.<br/>
|
||||
<?php echo Yii::powered(); ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user