fleshing out json output feature
This commit is contained in:
parent
91e0333e19
commit
94881f499b
@ -67,8 +67,11 @@ class MVCController{
|
||||
|
||||
//check if testaction is valid
|
||||
if(file_exists($this->testaction)){
|
||||
|
||||
echo('"output": [');
|
||||
//execute testaction
|
||||
include_once($this->testaction);
|
||||
echo("]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,11 +4,16 @@
|
||||
class TestUtils{
|
||||
public static $log = [];
|
||||
public static $status;
|
||||
public static function log($output, $status = "OK"){
|
||||
public static function log($output, $status = "OK",$addComma = false){
|
||||
$loginput = [];
|
||||
$loginput['message'] = $output;
|
||||
$loginput['status'] = $status;
|
||||
echo(json_encode($loginput));
|
||||
if($addComma){
|
||||
echo(',');
|
||||
}
|
||||
echo("\n");
|
||||
return;
|
||||
}
|
||||
public static function returnLog(){
|
||||
echo(json_encode(self::$log));
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
function echol($output)
|
||||
{
|
||||
echo $output."\n";
|
||||
}
|
||||
require_once('./controller/TestUtils.php');
|
||||
|
||||
//date_default_timezone_set('Europe/Amsterdam');
|
||||
require_once('./controller/MVCController.php');
|
||||
@ -13,4 +10,5 @@ $mvcController->executeModel();
|
||||
if(!isset($_POST['testaction'])){
|
||||
include_once("./view/content_pagetemplate.php");
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once('./controller/TestUtils.php');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ if(isset($_POST['auth'])){
|
||||
}else{
|
||||
TestUtils::log('you have no authorization to do that', 'FAILURE');
|
||||
}
|
||||
TestUtils::returnLog();
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user