Пример #1
0
function error_fatal($type, $message, $file, $line = 0)
{
    switch ($type) {
        case E_USER_ERROR:
            $type_str = 'Error';
            break;
        case E_WARNING:
        case E_USER_WARNING:
            $type_str = 'Warning';
            break;
        case E_NOTICE:
        case E_USER_NOTICE:
            $type_str = 'Notice';
            break;
        case QUICKSILVER_QUERY_ERROR:
            $type_str = 'Query Error';
            break;
        default:
            $type_str = 'Unknown Error';
    }
    if (strstr($file, 'eval()')) {
        $split = preg_split('/[\\(\\)]/', $file);
        $file = $split[0];
        $line = $split[1];
        $message .= ' (in evaluated code)';
    }
    $details = null;
    if ($type != QUICKSILVER_QUERY_ERROR) {
        if (strpos($message, 'mysql_fetch_array(): supplied argument') === false) {
            $lines = null;
            $details2 = null;
            if (function_exists('debug_backtrace')) {
                $backtrace = debug_backtrace();
                if (strpos($message, 'Template not found') !== false) {
                    $file = $backtrace[2]['file'];
                    $line = $backtrace[2]['line'];
                }
            }
            if (file_exists($file)) {
                $lines = file($file);
            }
            if ($lines) {
                $details2 = "\n\t\t\t\t<span class='header'>Code:</span><br />\n\t\t\t\t<span class='code'>" . error_getlines($lines, $line) . '</span>';
            }
        } else {
            $details2 = "\n\t\t\t<span class='header'>MySQL Said:</span><br />" . mysql_error() . '<br />';
        }
        $details .= "\n\t\t<span class='header'>{$type_str} [{$type}]:</span><br />\n\t\tThe error was reported on line <b>{$line}</b> of <b>{$file}</b><br /><br />{$details2}";
    } else {
        $details .= "\n\t\t<span class='header'>{$type_str} [{$line}]:</span><br />\n\t\tThis type of error is reported by MySQL.\n\t\t<br /><br /><span class='header'>Query:</span><br />{$file}<br />";
    }
    $checkbug = error_report($type, $message, $file, $line);
    $temp_querystring = str_replace("&", "&amp;", $_SERVER['QUERY_STRING']);
    return "\n\t<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n\t<html>\n\t<head>\n\t<title>Quicksilver Forums Error</title>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n\n\t<style type='text/css'>\n\tbody {font-size:12px; font-family: verdana, arial, helvetica, sans-serif; color:#000000; background-color:#ffffff}\n\thr {height:1px}\n\t.large  {font-weight:bold; font-size:18px; color:#660000; background-color:transparent}\n\t.header {font-weight:bold; font-size:12px; color:#660000; background-color:transparent}\n\t.error  {font-weight:bold; font-size:12px; color:#ff0000; background-color:transparent}\n\t.small  {font-weight:bold; font-size:10px; color:#000000; background-color:transparent}\n\t.code   {font-weight:normal; font-size:12px; font-family:courier new, fixedsys, serif}\n\t</style>\n\t</head>\n\n\t<body>\n\t<span class='large'>Quicksilver Forums has exited with an error</span><br /><br />\n\n\t<hr>\n\t<span class='error'>{$message}</span>\n\t<hr><br />\n\n\t{$details}\n\n\t<br /><hr><br />\n\t<a href='http://developer.berlios.de/bugs/?group_id=5008' class='small'>Check status of problem (recommended)</a><br />\n\t<a href='{$_SERVER['PHP_SELF']}?{$temp_querystring}&amp;debug=1' class='small'>View debug information (advanced)</a><br />\n\t<a href='{$_SERVER['PHP_SELF']}' class='small'>Return to the board</a>\n\t</body>\n\t</html>";
}
Пример #2
0
function error($type, $message, $file, $line = 0)
{
    global $settings;
    if (!(error_reporting() & $type)) {
        return;
    }
    switch ($type) {
        case E_USER_ERROR:
            $type_str = 'Error';
            break;
        case E_WARNING:
        case E_USER_WARNING:
            $type_str = 'Warning';
            break;
        case E_NOTICE:
        case E_USER_NOTICE:
            $type_str = 'Notice';
            break;
        case E_STRICT:
            $type_str = 'Strict Standards';
            break;
        case SANDBOX_QUERY_ERROR:
            $type_str = 'Query Error';
            break;
        default:
            $type = -1;
            $type_str = 'Unknown Error';
    }
    $details = null;
    $backtrace = get_backtrace();
    if ($type != SANDBOX_QUERY_ERROR) {
        if (strpos($message, 'mysql_fetch_array(): supplied argument') === false) {
            $lines = null;
            $details2 = null;
            if (file_exists($file)) {
                $lines = file($file);
            }
            if ($lines) {
                $details2 = "Code:\n" . error_getlines($lines, $line);
            }
        } else {
            $details2 = "MySQL Said:\n" . mysql_error() . "\n";
        }
        $details .= "{$type_str} [{$type}]:\n\n\t\tThe error was reported on line {$line} of {$file}\n\n\n\t\t{$details2}";
    } else {
        $details .= "{$type_str} [{$line}]:\n\n\t\tThis type of error is reported by MySQL.\n\n\n\t\tQuery:\n{$file}\n";
    }
    // IIS does not use $_SERVER['QUERY_STRING'] in the same way as Apache and might not set it
    if (isset($_SERVER['QUERY_STRING'])) {
        $querystring = str_replace('&', '&amp;', $_SERVER['QUERY_STRING']);
    } else {
        $querystring = '';
    }
    // DO NOT allow this information into the error reports!!!
    $details = str_replace($settings['db_name'], '****', $details);
    $details = str_replace($settings['db_pass'], '****', $details);
    $details = str_replace($settings['db_user'], '****', $details);
    $details = str_replace($settings['db_host'], '****', $details);
    $backtrace = str_replace($settings['db_name'], '****', $backtrace);
    $backtrace = str_replace($settings['db_pass'], '****', $backtrace);
    $backtrace = str_replace($settings['db_user'], '****', $backtrace);
    $backtrace = str_replace($settings['db_host'], '****', $backtrace);
    // Don't send it if this isn't available. Spamming mail servers is a bad bad thing.
    // This will also email the user agent string, in case errors are being generated by evil bots.
    if (isset($settings['error_email'])) {
        $headers = "From: Your Sandbox Site <{$settings['error_email']}>\r\n" . "X-Mailer: PHP/" . phpversion();
        $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'N/A';
        $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
        $error_report = "Sandbox has exited with an error!\n";
        $error_report .= "The error details are as follows:\n\nURL: http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?" . $querystring . "\n";
        $error_report .= "Querying user agent: " . $agent . "\n";
        $error_report .= "Querying IP: " . $ip . "\n\n";
        $error_report .= $message . "\n\n" . $details . "\n\n" . $backtrace;
        $error_report = str_replace("&nbsp;", " ", html_entity_decode($error_report));
        @mail($settings['error_email'], "Sandbox Error Report", $error_report, $headers);
    }
    header('HTTP/1.0 500 Internal Server Error');
    exit("\n<!DOCTYPE html>\n<html lang=\"en-US\">\n <head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n  <meta name=\"robots\" content=\"noodp\" />\n  <meta name=\"generator\" content=\"Sandbox\" />\n  <title>Fatal Error</title>\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"./skins/Default/styles.css\" />\n </head>\n <body>\n <div id=\"container\">\n  <div id=\"header\">\n   <div id=\"company\">\n    <div class=\"logo\"></div>\n    <div class=\"title\">\n     <h1>Sandbox: Fatal Error</h1>\n     <p style=\"font-size:11px\">Klingon: ... There has been an incident on Praxis ...<br />Captain Sulu: An \"incident\"?<br />Commander Rand: Do we report this, sir?<br />Captain Sulu: Are you kidding?</p>\n    </div>\n   </div>\n   <ul id=\"navigation\">\n    <li><a href=\"/\">Home</a></li>\n   </ul>\n  </div>\n\n  <div id=\"fullscreen\">\n   <div class=\"article\">\n    <div class=\"title\" style=\"color:yellow\">Fatal Error</div>\n    The Sandbox software has experienced a fatal error and is unable to process your request at this time. Unfortunately any data you may have sent has been lost, and we apologize for the inconvenience.<br /><br />\n    A detailed report on exactly what went wrong has been sent to the site owner and will be investigated and resolved as quickly as possible.\n   </div>\n  </div>\n\n  <div id=\"bottom\">&nbsp;</div>\n </div>\n <div id=\"footer\">Powered by Sandbox &copy; 2006-2015 Sam O'Connor [<a href=\"http://www.kiasyn.com\">Kiasyn</a>] and Roger Libiez [<a href=\"http://www.iguanadons.net\">Samson</a>]</div>\n</body>\n</html>");
}