changes to how testactions work
This commit is contained in:
36
dev_mvc/model/testactions/TestAction.php
Normal file
36
dev_mvc/model/testactions/TestAction.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class TestAction{
|
||||
function TestAction(){
|
||||
if(isset($_POST['auth'])){
|
||||
if($_POST['auth'] == getenv('ADMIN_ACTION_KEY')){
|
||||
execute();
|
||||
}else{
|
||||
self::logMessage('you have no authorization to do that', 'FAILURE');
|
||||
}
|
||||
}else{
|
||||
self::logMessage('you have no authorization to do that', 'FAILURE');
|
||||
}
|
||||
self::returnLogAsText();
|
||||
}
|
||||
function execute(){
|
||||
self::logMessage('Unoverridden execute called on TestAction: '.$this, 'FAILURE');
|
||||
}
|
||||
public static $log = [];
|
||||
public static $status;
|
||||
public static function logMessage($message, $status = "OK"){
|
||||
$loginput = [];
|
||||
$loginput['message'] = $message;
|
||||
$loginput['status'] = $status;
|
||||
arr_push(self::log, $loginput);
|
||||
return;
|
||||
}
|
||||
public static function returnLogAsJson(){
|
||||
echo(json_encode(self::$log));
|
||||
return;
|
||||
}
|
||||
public static function returnLogAsText(){
|
||||
for($i = 0; $i<sizeof(self::$log); $i++){
|
||||
echo("[".self::log[i]['stats']."] ".self::log[i]['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user