First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
if (!isset($loggingFlag)) $loggingFlag = false;
|
||||
$logFile = 0;
|
||||
$logTime = 0;
|
||||
$globalModuleName = "";
|
||||
|
||||
$studentLoggingFlag = true;
|
||||
$studentLogFile = 0;
|
||||
|
||||
$logFileName = "/m/data1/app.hotlunches.net/errorlog.log";
|
||||
|
||||
if (isset($selectedLogFileName) && strlen($selectedLogFileName)) {
|
||||
if (is_file($selectedLogFileName)) $logFileName = $selectedLogFileName;
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('startLog')) {
|
||||
function startLog($moduleName="") {
|
||||
global $loggingFlag, $logFileName, $logFile, $globalModuleName, $logTime, $school_num, $school_record, $currentDBMode, $db_dbname;
|
||||
$loggingFlag = true;
|
||||
if (!is_resource($logFile)) $logFile = fopen($logFileName,"a");
|
||||
|
||||
if (strlen($moduleName) > 0) $globalModuleName = $moduleName;
|
||||
|
||||
fwrite($logFile,"-------------------------------------------\n");
|
||||
fwrite($logFile,"-- $globalModuleName --\n");
|
||||
$now = time();
|
||||
$logTime = microtime(true);
|
||||
fwrite($logFile,"-- " . date("Y-m-d H:i:s",$now) . " --\n");
|
||||
if (isset($school_num)) fwrite($logFile,"-- $school_num --\n");
|
||||
|
||||
if (isset($_SERVER) && array_key_exists('REMOTE_ADDR', $_SERVER)) {
|
||||
$user_ip = $_SERVER["REMOTE_ADDR"];
|
||||
fwrite($logFile,"-- $user_ip --\n");
|
||||
}
|
||||
|
||||
if (isset($school_record) && array_key_exists('school_name',$school_record))
|
||||
fwrite($logFile,"-- " . $school_record['school_name'] . " --\n");
|
||||
|
||||
if (isset($_SESSION) && is_array($_SESSION)) {
|
||||
if (array_key_exists('UserInfo',$_SESSION) && array_key_exists('userid',$_SESSION['UserInfo'])) {
|
||||
$userid = $_SESSION['UserInfo']['userid'];
|
||||
fwrite($logFile,"-- $userid --\n");
|
||||
}
|
||||
}
|
||||
|
||||
fwrite($logFile, "-- currentDBMode: $currentDBMode --\n");
|
||||
fwrite($logFile, "-- currentDB: $db_dbname --\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('writeLog')) {
|
||||
function writeLog($text,$moduleName="") {
|
||||
global $loggingFlag, $logFileName, $logFile, $globalModuleName, $logTime;
|
||||
|
||||
if (!$loggingFlag) return;
|
||||
|
||||
if (strlen($moduleName) > 0) $globalModuleName = $moduleName;
|
||||
else {
|
||||
if (strlen($globalModuleName) == 0) {
|
||||
$moduleName = str_replace("/","",str_replace("/","",$_SERVER['PHP_SELF']));
|
||||
$globalModuleName = $moduleName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_resource($logFile)) {
|
||||
$logFile = fopen($logFileName,"a");
|
||||
fwrite($logFile,"$moduleName: **** Log File Not Open ****\n");
|
||||
}
|
||||
|
||||
if (is_array($text)) $text = print_r($text,true);
|
||||
else $text = strval($text);
|
||||
|
||||
if (strlen($globalModuleName) > 0) fwrite($logFile,"$globalModuleName: ");
|
||||
$incr = microtime(true) - $logTime;
|
||||
fwrite($logFile,trim($text) . " (" . number_format($incr,3) . ")\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('logExit')) {
|
||||
function logExit($text,$moduleName="") {
|
||||
global $loggingFlag, $logFile, $globalModuleName;
|
||||
|
||||
if (strlen($moduleName) > 0) $globalModuleName = $moduleName;
|
||||
writeLog($text,$moduleName);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('endLog')) {
|
||||
function endLog() {
|
||||
global $loggingFlag, $logFile;
|
||||
|
||||
if (!$loggingFlag) return;
|
||||
$loggingFlag = false;
|
||||
fclose($logFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('startStudentLog')) {
|
||||
function startStudentLog() {
|
||||
global $studentLoggingFlag, $studentLogFile;
|
||||
if ($studentLoggingFlag && !is_resource($studentLogFile)) $studentLogFile = fopen("student.log","a");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('writeStudentLog')) {
|
||||
function writeStudentLog($text) {
|
||||
global $studentLoggingFlag, $studentLogFile, $school_num;
|
||||
if (!$studentLoggingFlag) return;
|
||||
if (!is_resource($studentLogFile)) return;
|
||||
|
||||
$time = date("Y-m-d H:i:s",time());
|
||||
fwrite($studentLogFile,$school_num . " " . $time . " - " . trim($text) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('logQuery')) {
|
||||
function logQuery($school_num,$table_name,$query,$module="") {
|
||||
$logFile = fopen("query.log","a");
|
||||
$time = date("Y-m-d H:i:s",time());
|
||||
$userid = '';
|
||||
if (array_key_exists('userid', $_SESSION['UserInfo'])) $userid = $_SESSION['UserInfo']['userid'];
|
||||
fprintf($logFile,"%d|%s|%s|%s|%s|%s\n",$school_num,$table_name,$time,$query,$module,$userid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user