diff options
Diffstat (limited to 'includes/session.php')
| -rwxr-xr-x | includes/session.php | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/includes/session.php b/includes/session.php index 4559e8d3b1..4456237bec 100755 --- a/includes/session.php +++ b/includes/session.php @@ -203,7 +203,51 @@ require WT_ROOT.'includes/functions/functions_date.php'; require WT_ROOT.'includes/functions/functions_charts.php'; require WT_ROOT.'includes/functions/functions_utf-8.php'; -set_error_handler('wt_error_handler'); +// Set a custom error handler +set_error_handler(function ($errno, $errstr, $errfile, $errline) { + if ((error_reporting() > 0)&&($errno<2048)) { + if (WT_ERROR_LEVEL==0) { + return; + } + $fmt_msg="<br>ERROR {$errno}: {$errstr}<br>"; + $log_msg="ERROR {$errno}: {$errstr};"; + // Although debug_backtrace should always exist in PHP5, without this check, PHP sometimes crashes. + // Possibly calling it generates an error, which causes infinite recursion?? + if ($errno < 16 && function_exists("debug_backtrace") && strstr($errstr, "headers already sent by") === false) { + $backtrace = debug_backtrace(); + $num = count($backtrace); + if (WT_ERROR_LEVEL == 1) { + $num = 1; + } + for ($i = 0; $i < $num; $i++) { + if ($i === 0) { + $fmt_msg .= "0 Error occurred on "; + $log_msg .= "\n0 Error occurred on "; + } else { + $fmt_msg .= "{$i} called from "; + $log_msg .= "\n{$i} called from "; + } + if (isset($backtrace[$i]["line"]) && isset($backtrace[$i]["file"])) { + $fmt_msg .= "line <b>{$backtrace[$i]['line']}</b> of file <b>".basename($backtrace[$i]['file'])."</b>"; + $log_msg .= "line {$backtrace[$i]['line']} of file ".basename($backtrace[$i]['file']); + } + if ($i<$num-1) { + $fmt_msg .= " in function <b>".$backtrace[$i+1]['function']."</b>"; + $log_msg .= " in function ".$backtrace[$i+1]['function']; + } + $fmt_msg .= "<br>"; + } + } + echo $fmt_msg; + if (function_exists('AddToLog')) { + AddToLog($log_msg, 'error'); + } + if ($errno == 1) { + die(); + } + } + return false; +}); // Load our configuration file, so we can connect to the database if (file_exists(WT_ROOT.'data/config.ini.php')) { |
