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