forked from science-ation/science-ation
Added logging to the API, and separated the log file creation into a common function
This commit is contained in:
parent
a6544f40c4
commit
128fc6a3b5
@ -1,15 +1,10 @@
|
||||
<?
|
||||
|
||||
//make sure logs folder exists, and htaccess it to deny access
|
||||
if(!file_exists("../data/logs"))
|
||||
@mkdir("../data/logs");
|
||||
|
||||
if(!file_exists("../data/logs/.htaccess"))
|
||||
@file_put_contents("../data/logs/.htaccess","Order Deny,Allow\r\nDeny From All\r\n");
|
||||
require_once('../common.inc.functions.php');
|
||||
$logPath = get_logpath();
|
||||
|
||||
//add PHP_SELF just so when we do a process listing on the server we know which fair its running for
|
||||
//the argument does not get used by the script at all
|
||||
exec("nice php judges_sa.php {$_SERVER['PHP_SELF']} >../data/logs/judge_scheduler_".date("YmdHis").".log 2>&1 &");
|
||||
exec("nice php judges_sa.php {$_SERVER['PHP_SELF']} > $logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &");
|
||||
usleep(1500000); // 1.5 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon
|
||||
header("Location: judges_scheduler_status.php");
|
||||
exit;
|
||||
|
6
api.php
6
api.php
@ -23,6 +23,7 @@
|
||||
?>
|
||||
<?
|
||||
include "common.inc.php";
|
||||
require_once("common.inc.functions.php");
|
||||
require_once("account.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("schedule.inc.php");
|
||||
@ -35,6 +36,11 @@ if($_SERVER['HTTPS']!="on") {
|
||||
$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);
|
||||
|
||||
switch($request[0]) {
|
||||
case 'config':
|
||||
switch($request[1]){
|
||||
|
@ -863,3 +863,17 @@ function get_conference_info($conferenceId){
|
||||
}
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
//make sure logs folder exists, and htaccess it to deny access, and return the full path
|
||||
function get_logpath(){
|
||||
$q = mysql_fetch_assoc(mysql_query("SELECT val FROM config WHERE var = 'SFIABDIRECTORY'"));
|
||||
$directory = $_SERVER["DOCUMENT_ROOT"] . $q['val'] . '/data/logs';
|
||||
|
||||
if(!file_exists($directory))
|
||||
@mkdir($directory);
|
||||
|
||||
if(!file_exists($directory . "/.htaccess"))
|
||||
@file_put_contents($directory . "/.htaccess","Order Deny,Allow\r\nDeny From All\r\n");
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user