error.php: trim

This commit is contained in:
Zankaria 2024-06-23 14:21:10 +02:00
parent 8c97b3a3fb
commit 8dad968be1

View file

@ -28,22 +28,22 @@ $error_recursion=false;
function error($message, $priority = true, $debug_stuff = false) { function error($message, $priority = true, $debug_stuff = false) {
global $board, $mod, $config, $db_error, $error_recursion; global $board, $mod, $config, $db_error, $error_recursion;
if($error_recursion!==false){ if($error_recursion!==false){
die("Error recursion detected with " . $message . "<br>Original error:".$error_recursion); die("Error recursion detected with " . $message . "<br>Original error:".$error_recursion);
} }
$error_recursion=$message; $error_recursion=$message;
if (defined('STDIN')) { if (defined('STDIN')) {
// Running from CLI // Running from CLI
echo('Error: ' . $message . "\n"); echo('Error: ' . $message . "\n");
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die(); die();
} }
if(!empty($config)){ if(!empty($config)){
if ($config['syslog'] && $priority !== false) { if ($config['syslog'] && $priority !== false) {
// Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant. // Use LOG_NOTICE instead of LOG_ERR or LOG_WARNING because most error message are not significant.
_syslog($priority !== true ? $priority : LOG_NOTICE, $message); _syslog($priority !== true ? $priority : LOG_NOTICE, $message);
@ -77,7 +77,7 @@ function error($message, $priority = true, $debug_stuff = false) {
} }
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
die(Element('page.html', array( die(Element('page.html', array(
'config' => $config, 'config' => $config,
'title' => _('Error'), 'title' => _('Error'),