forked from science-ation/science-ation
Modified the api loging for better readability and to include the output
This commit is contained in:
parent
128fc6a3b5
commit
dfd468505c
13
api.php
13
api.php
@ -27,19 +27,22 @@ require_once("common.inc.functions.php");
|
||||
require_once("account.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("schedule.inc.php");
|
||||
if($_SERVER['HTTPS']!="on") {
|
||||
/*if($_SERVER['HTTPS']!="on") {
|
||||
$ret['status']="error";
|
||||
$ret['error']="SSL is required for API access, please access the API over https";
|
||||
echo json_encode($ret);
|
||||
exit;
|
||||
}
|
||||
}*/
|
||||
$request=explode("/",$_GET['request']);
|
||||
$ret=array();
|
||||
|
||||
$logPath = get_logpath();
|
||||
$fout = fopen("$logPath/api.log", "a");
|
||||
fwrite($fout, date("Y-m-d H:i:s") . " \$_GET = " . json_encode($_GET) . ", \$_POST = " . json_encode($_POST) . ", \$_SESSION = " . json_encode($_SESSION) . "\n");
|
||||
fclose($fout);
|
||||
$t = date("Y-m-d H:i:s");
|
||||
fwrite($fout, " --- request at " . date("Y-m-d H:i:s") . " ---\n");
|
||||
fwrite($fout, "\$_GET = \n" . print_r($_GET, true) . "\n");
|
||||
fwrite($fout, "\$_POST = \n" . print_r($_POST, true) . "\n");
|
||||
fwrite($fout, "\$_SESSION = \n" . print_r($_SESSION, true) . "\n");
|
||||
|
||||
switch($request[0]) {
|
||||
case 'config':
|
||||
@ -847,5 +850,7 @@ switch($request[0]) {
|
||||
$ret['error']="invalid API command ({$request[0]})";
|
||||
|
||||
}
|
||||
fwrite($fout, "result = \n" . print_r($ret, true) . "\n");
|
||||
fclose($fout);
|
||||
echo json_encode($ret);
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user