function die_miserable_death($error, $anchor = '') { global $APPLICATION_NAME, $LANGUAGE, $login, $TROUBLE_URL, $settings; // Make sure app name is set. $appStr = empty($APPLICATION_NAME) ? 'WebCalendar' : $APPLICATION_NAME; $url = $TROUBLE_URL; if (!empty($anchor)) { $args = explode('#', $TROUBLE_URL); $url = $args[0] . '#' . $anchor; } $h2_label = $appStr . ' ' . 'Error'; $title = $appStr . ': ' . 'Fatal Error'; $trouble_label = 'Troubleshooting Help'; $user_BGCOLOR = '#FFFFFF'; // Include a stack trace if mode is set to dev $trace = ''; if ($settings['mode'] == 'dev') { if (function_exists("assert_backtrace")) { $trace = "<div style=\"border: 1px solid black\\; margin: 20px;\">" . "<b>Stack Trace:</b><br/><blockquote>" . "<pre>" . assert_backtrace() . "</pre></blockquote></div>\n"; } } echo <<<EOT <html> <head><title>{$title}</title></head> <body bgcolor ="{$user_BGCOLOR}"> <h2>{$h2_label}</h2> <p>{$error}</p> {$trace} <hr /> <p><a href="{$url}" target="_blank">{$trouble_label}</a></p> </body> </html> EOT; exit; }
function assert_handler($script, $line, $msg = '') { if (empty($msg)) { $msg = 'Assertion failed<br />' . "\n"; } $trace = function_exists('debug_backtrace') ? assert_backtrace() : basename($script) . ': ' . $line . ' ' . $msg; $msg .= (function_exists('debug_backtrace') ? '<b>Stack Trace:</b><br /><br />' : '') . '<blockquote><tt>' . nl2br($trace) . '</tt></blockquote>'; if (function_exists('die_miserable_death')) { die_miserable_death($msg); } else { echo '<html><head><title>WebCalendar Error</title></head> <body><h2>WebCalendar Error</h2><p>' . $msg . '</p></body></html> '; exit; } }