4 ///////////////////////////////////////////////////////
6 //function CWwwLog() {}
9 * Return the log directory. Create it if it does not exist, or return false if creation failed.
11 function getSafeLogDir() {
12 $LogRelativePath = '/log';
13 $pathInfo = pathinfo(__FILE__
);
14 $logPath = $pathInfo['dirname'].$LogRelativePath;
15 if (!is_dir($logPath))
17 $res = mkdir($LogPath, 0700);
18 return $res ?
$logPath : false;
23 function logStr($str) {
28 ///////////////////////////////////////////////////////
30 function errorMsgBlock($errNum=GENERIC_ERROR_NUM
) // $mixedArgs
32 $args = func_get_args();
33 return '0:'.call_user_func_array('errorMsg', $args);
37 ///////////////////////////////////////////////////////
38 // Callback called on end of output buffering
39 function ob_callback_r2login($buffer)
41 // Log only in case of error or malformed result string
42 $blockHd = substr($buffer, 0, 2);
45 $logFile = new CWwwLog();
46 $logFile->logStr(str_replace("\n",'\n',$buffer));
48 return $buffer; // sent to output
52 ///////////////////////////////////////////////////////
53 // Callback called on error
54 function err_callback($errno, $errmsg, $filename, $linenum, $vars)
56 // don't log "PHP ERROR/2048 Only variables should be passed by reference"
57 if($errno == 2048) return;
59 $logFile = new CWwwLog();
60 $logFile->logStr("PHP ERROR/$errno $errmsg ($filename:$linenum)");
61 // Never die after an error
64 function dieError($errNum=GENERIC_ERROR_NUM
) // $mixedArgs
66 $args = func_get_args();
67 die('0:'.call_user_func_array('errorMsg', $args));