" . htmlentities($shortMsg) . "\n" . "An error has occurred. We apologise for the inconvenience and ask you to try again later.
\n" . "Most likely, the webmaster is working on fixing this error at this very moment.

\n" . "Go back to home to if refreshing this page does not help.\n"; // Run htmlentities over all, regardless $details = array(); $details[] = "Date: " . strftime('%Y-%m-%d %H:%M:%S.') . sprintf('%06d', (int)substr(microtime(), 2, 6)); $details[] = "Detailed message:\n " . htmlentities($detailedMsg); $details[] = "Croak namespace/object: [" . htmlentities($namespace) . "]"; if (isset($_SERVER['REMOTE_ADDR'])) $details[] = "Caller IP: [" . htmlentities($_SERVER['REMOTE_ADDR']) . "]"; if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) $details[] = "Viewed URL: " . htmlentities("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]") . " ($_SERVER[REQUEST_METHOD])"; if (isset($_SERVER['HTTP_REFERER'])) $details[] = "Referrer URL: " . htmlentities($_SERVER['HTTP_REFERER']); if (isset($_SERVER['HTTP_USER_AGENT'])) $details[] = "User-Agent: " . htmlentities($_SERVER['HTTP_USER_AGENT']); // The backtrace $backtrace = ''; $back = debug_backtrace(); while ($backtraceShift--) array_shift($back); foreach($back as $k => $v) { $backtrace .= sprintf(" %-20s %s()\n", htmlentities(basename(@$v['file'])) . ':' . htmlentities(@$v['line']), htmlentities(@$v['function'])); } // Client data (not secret) $cookie = serialize($_COOKIE); $post = serialize($_POST); // Session data (secret!) $session = serialize(@$_SESSION); $server = serialize($_SERVER); // Send the message by mail if appropriate if (KJW_EMAIL_ERRORS_TO != '') { require_once(dirname(__FILE__) . '/KjwMail.php'); kjwmail_sendplain( KJW_EMAIL_ERRORS_TO, 'KjwLib::kjw_croak: ' . substr($shortMsg, 0, 40), $shortTextMsg . "\n[DETAILS]\n * " . implode("\n * ", $details) . "\n\n[BACKTRACE]\n$backtrace\n" . "[POST]\n $post\n\n[COOKIE]\n $cookie\n\n[SESSION]\n $session\n\n[SERVER]\n $server\n\n" ); } // Add the message to a trace log kjw_trace($shortMsg, 'ERROR', $namespace); kjw_trace("DETAILS\n * " . implode("\n * ", $details), 'DEBUG', $namespace); kjw_trace("BACKTRACE\n$backtrace", 'DEBUG', $namespace); kjw_trace("POST = $post", 'DEBUG', $namespace); kjw_trace("COOKIE = $cookie", 'DEBUG', $namespace); kjw_trace("SESSION = $session", 'DEBUG', $namespace); kjw_trace("SERVER = $server", 'DEBUG', $namespace); // Display the message if (!$print_html) { echo $shortTextMsg; if (KJW_EMAIL_ERRORS_TO == '') echo "\n[DETAILS]\n * ", implode("\n * ", $details), "\n\n[BACKTRACE]\n", $backtrace; } else { // Break out of all sorts of html crapzola. echo "
\n"; // Assemble total message $totalMsg = "
$shortHtmlMsg
\n"; if (KJW_EMAIL_ERRORS_TO == '') $totalMsg .= "
[DETAILS]\n * " . implode("\n * ", $details)
					. "\n\n[BACKTRACE]\n$backtrace
\n"; $totalMsg .= "
"; // Echo the message echo $totalMsg; // Echo it again, in a script so it replaces the entire body. echo ""; echo ""; } // And finally.. die(-1); } /** * Initialize constants/defines. */ if (!defined('KJW_DEBUG')) define('KJW_DEBUG', false); if (!defined('KJW_STDLOG')) // Where to write log output. if (defined('STDERR')) // If we have stderr, write there, else don't write. define('KJW_STDLOG', STDERR); if (!defined('KJW_DIE_ON_TRANSIENT_ERROR')) // KjwSql uses this when connection fails. define('KJW_DIE_ON_TRANSIENT_ERROR', false); if (!defined('KJW_EMAIL_ERRORS_TO')) // Mail the errors instead of displaying them.. define('KJW_EMAIL_ERRORS_TO', ''); /** * Initialize error handler. */ set_error_handler('kjw_error_handler'); ?>