Codice PHP:
function exceptions_error_handler($severity, $message, $filename, $lineno) {
if (error_reporting() == 0) {
return;
}
if (error_reporting() & $severity) {
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
}
set_error_handler('exceptions_error_handler');
// This is a default exceptions-handler. For debugging, it's practical to get a readable
// trace dumped out at the top level, rather than just a blank screen.
// If you use something like Xdebug, you may want to skip this part, since it already gives
// a similar output.
// For production, you should replace this handler with something, which logs the error,
// and doesn't dump a trace. Failing to do so could be a security risk.
function debug_exception_handler($ex) {
if (php_sapi_name() == 'cli') {
echo "Error (code:".$ex->getCode().") :".$ex->getMessage()."\n at line ".$ex->getLine ()." in file ".$ex->getFile()."\n";
echo $ex->getTraceAsString()."\n";
} else {
echo "<p style='font-family:helvetica,sans-serif'>\n";
echo "[b]Error :[/b]".$ex->getMessage()."
\n";
echo "[b]Code :[/b]".$ex->getCode()."
\n";
echo "[b]File :[/b]".$ex->getFile()."
\n";
echo "[b]Line :[/b]".$ex->getLine()."</p>\n";
echo "<div style='font-family:garamond'>".nl2br(htmlspecialchars($ex->getTraceAsString()))."</div>\n";
}
exit(-1);
}
function prodution_exception_handler($ex) {
$msg = "Error :".$ex->getMessage().PHP_EOL;
$msg .= "Code :".$ex->getCode().PHP_EOL;
$msg .= "File :".$ex->getFile().PHP_EOL;
$msg .= "Line :".$ex->getLine().PHP_EOL;
$msg .= $ex->getTraceAsString();
$logDir= new w_FindPath('.','log');
error_log($msg, 3, $logDir->get().'index.log');
$output= <<<EOD
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex,nofollow" />
<meta name="content-language" content="it" />
<meta name="description" content="Error page" />
<meta name="keywords" content="Error page" />
<link rel="shortcut icon" href="favicon/favicon.ico" />
<title>Â_Bracelli Pagina di Errore</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
</head>
<body>
<div id="container">
<div id="header">
<h1>[url="/"][/url]</h1>
</div><div id="content">
<h1 style="margin-top:70px;width:800px" class="center">Server troppo occupato</h1>
<h2 style="width:800px" class="center">Spiacente, il sito non disponibile.</h2>
<h2 style="width:800px" class="center">Per favore, contatta il web master.</h2>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
EOD;
echo $output;
exit(-1);
}
(true)?set_exception_handler('debug_exception_handler'):set_exception_handler('prodution_exception_handler');
Update from http://konstrukt.dk/

Dai un occhio al codice di
http://forum.html.it/forum/showthrea...readid=1356221