|
|
@ -15,21 +15,24 @@ function exception_handler(Exception $e){ |
|
|
|
|
|
|
|
set_exception_handler('exception_handler'); |
|
|
|
|
|
|
|
function fatal_error_handler(){ |
|
|
|
if (($error = error_get_last()) && $error['type'] == E_ERROR) { |
|
|
|
error('Caught fatal error: ' . $error['message'] . ' in ' . $error['file'] . ' at line ' . $error['line']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
register_shutdown_function('fatal_error_handler'); |
|
|
|
|
|
|
|
$error_recursion=false; |
|
|
|
|
|
|
|
function error($message, $priority = true, $debug_stuff = false) { |
|
|
|
global $board, $mod, $config, $db_error, $error_recursion; |
|
|
|
|
|
|
|
if($error_recursion!==false){ |
|
|
|
die("Error recursion detected with " . $message . "<br>Original error:".$error_recursion); |
|
|
|
} |
|
|
|
$error_recursion=$message; |
|
|
|
|
|
|
|
if(!empty($config)){ |
|
|
|
|
|
|
|
if ($config['syslog'] && $priority !== false) { |
|
|
|
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant. |
|
|
|
_syslog($priority !== true ? $priority : LOG_NOTICE, $message); |
|
|
|
} |
|
|
|
$error_recursion=$message; |
|
|
|
|
|
|
|
if (defined('STDIN')) { |
|
|
|
// Running from CLI |
|
|
@ -38,6 +41,13 @@ function error($message, $priority = true, $debug_stuff = false) { |
|
|
|
die(); |
|
|
|
} |
|
|
|
|
|
|
|
if(!empty($config)){ |
|
|
|
|
|
|
|
if ($config['syslog'] && $priority !== false) { |
|
|
|
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant. |
|
|
|
_syslog($priority !== true ? $priority : LOG_NOTICE, $message); |
|
|
|
} |
|
|
|
|
|
|
|
if ($config['debug']) { |
|
|
|
$debug_stuff=array(); |
|
|
|
if(isset($db_error)){ |
|
|
@ -55,7 +65,6 @@ function error($message, $priority = true, $debug_stuff = false) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Is there a reason to disable this? |
|
|
|
if (isset($_POST['json_response'])) { |
|
|
|
header('Content-Type: text/json; charset=utf-8'); |
|
|
|
$data=array('error'=>$message); |
|
|
|