コード例 #1
0
ファイル: startup.php プロジェクト: exussum12/phpbb
function installer_msg_handler($errno, $msg_text, $errfile, $errline)
{
    global $phpbb_installer_container;
    if (error_reporting() == 0) {
        return true;
    }
    switch ($errno) {
        case E_NOTICE:
        case E_WARNING:
        case E_USER_WARNING:
        case E_USER_NOTICE:
            $msg = '[phpBB debug] "' . $msg_text . '" in file ' . $errfile . ' on line ' . $errline;
            try {
                /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
                $iohandler = $phpbb_installer_container->get('installer.helper.iohandler');
                $iohandler->add_warning_message($msg);
            } catch (\phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception $e) {
                print $msg;
            }
            break;
        case E_USER_ERROR:
            $msg = '<b>General Error:</b><br />' . $msg_text . '<br /> in file ' . $errfile . ' on line ' . $errline;
            $backtrace = get_backtrace();
            if ($backtrace) {
                $msg .= '<br /><br />BACKTRACE<br />' . $backtrace;
            }
            throw new \phpbb\exception\runtime_exception($msg);
            break;
        case E_DEPRECATED:
            return true;
            break;
    }
    return false;
}
コード例 #2
0
ファイル: function.php プロジェクト: thruthesky/backend
/**
 *
 * It yields error message if the $code is not TRUE or it echoes a number.
 *
 * @param $code
 * @param null $good
 * @param null $bad
 */
function test($code, $good = null, $bad = null)
{
    static $_count_test = 0;
    $_count_test++;
    $tree = get_backtrace();
    if ($code) {
        echo "{$_count_test} ";
    } else {
        echo "\nERROR: ({$_count_test})\n{$bad}\n{$tree}\n";
        exit;
    }
}
コード例 #3
0
ファイル: error.php プロジェクト: BackupTheBerlios/qsf-svn
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;
    $backtrace = null;
    if (strpos($message, 'Template not found') === false) {
        $backtrace = get_backtrace();
    }
    if ($type != QUICKSILVER_QUERY_ERROR) {
        if (strpos($message, 'mysql_fetch_array(): supplied argument') === false) {
            $lines = null;
            $details2 = null;
            if (strpos($message, 'Template not found') !== false) {
                $backtrace = "";
                $trace = debug_backtrace();
                $file = $trace[2]['file'];
                $line = $trace[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);
    // IIS does not use $_SERVER['QUERY_STRING'] in the same way as Apache and might not set it
    if (isset($_SERVER['QUERY_STRING'])) {
        $temp_querystring = str_replace("&", "&amp;", $_SERVER['QUERY_STRING']);
    } else {
        $temp_querystring = "";
    }
    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\n\t{$backtrace}\n\n\t<br /><hr><br />\n\t<a href='http://forums.quicksilverforums.com/index.php?a=forum&amp;f=6' 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>";
}
コード例 #4
0
/**
* Error and message handler, call with trigger_error if read
*/
function msg_handler($errno, $msg_text, $errfile, $errline)
{
    global $cache, $db, $auth, $template, $config, $user, $request;
    global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text;
    // Do not display notices if we suppress them via @
    if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) {
        return;
    }
    // Message handler is stripping text. In case we need it, we are possible to define long text...
    if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
        $msg_text = $msg_long_text;
    }
    if (!defined('E_DEPRECATED')) {
        define('E_DEPRECATED', 8192);
    }
    switch ($errno) {
        case E_NOTICE:
        case E_WARNING:
            // Check the error reporting level and return if the error level does not match
            // If DEBUG is defined the default level is E_ALL
            if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) {
                return;
            }
            if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) {
                $errfile = phpbb_filter_root_path($errfile);
                $msg_text = phpbb_filter_root_path($msg_text);
                $error_name = $errno === E_WARNING ? 'PHP Warning' : 'PHP Notice';
                echo '<b>[phpBB Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
                // we are writing an image - the user won't see the debug, so let's place it in the log
                if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) {
                    add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text);
                }
                // echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n";
            }
            return;
            break;
        case E_USER_ERROR:
            if (!empty($user) && !empty($user->lang)) {
                $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
                $msg_title = !isset($msg_title) ? $user->lang['GENERAL_ERROR'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title);
                $l_return_index = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $phpbb_root_path . '">', '</a>');
                $l_notify = '';
                if (!empty($config['board_contact'])) {
                    $l_notify = '<p>' . sprintf($user->lang['NOTIFY_ADMIN_EMAIL'], $config['board_contact']) . '</p>';
                }
            } else {
                $msg_title = 'General Error';
                $l_return_index = '<a href="' . $phpbb_root_path . '">Return to index page</a>';
                $l_notify = '';
                if (!empty($config['board_contact'])) {
                    $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . $config['board_contact'] . '">' . $config['board_contact'] . '</a></p>';
                }
            }
            $log_text = $msg_text;
            $backtrace = get_backtrace();
            if ($backtrace) {
                $log_text .= '<br /><br />BACKTRACE<br />' . $backtrace;
            }
            if (defined('IN_INSTALL') || defined('DEBUG') || isset($auth) && $auth->acl_get('a_')) {
                $msg_text = $log_text;
                // If this is defined there already was some output
                // So let's not break it
                if (defined('IN_DB_UPDATE')) {
                    echo '<div class="errorbox">' . $msg_text . '</div>';
                    $db->sql_return_on_error(true);
                    phpbb_end_update($cache, $config);
                }
            }
            if ((defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) {
                // let's avoid loops
                $db->sql_return_on_error(true);
                add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $log_text);
                $db->sql_return_on_error(false);
            }
            // Do not send 200 OK, but service unavailable on errors
            send_status_line(503, 'Service Unavailable');
            garbage_collection();
            // Try to not call the adm page data...
            echo '<!DOCTYPE html>';
            echo '<html dir="ltr">';
            echo '<head>';
            echo '<meta charset="utf-8">';
            echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
            echo '<title>' . $msg_title . '</title>';
            echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
            echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
            echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
            echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
            echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } ';
            echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
            echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
            echo "\n" . '/* ]]> */' . "\n";
            echo '</style>';
            echo '</head>';
            echo '<body id="errorpage">';
            echo '<div id="wrap">';
            echo '	<div id="page-header">';
            echo '		' . $l_return_index;
            echo '	</div>';
            echo '	<div id="acp">';
            echo '	<div class="panel">';
            echo '		<div id="content">';
            echo '			<h1>' . $msg_title . '</h1>';
            echo '			<div>' . $msg_text . '</div>';
            echo $l_notify;
            echo '		</div>';
            echo '	</div>';
            echo '	</div>';
            echo '	<div id="page-footer">';
            echo '		Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited';
            echo '	</div>';
            echo '</div>';
            echo '</body>';
            echo '</html>';
            exit_handler();
            // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
            exit;
            break;
        case E_USER_WARNING:
        case E_USER_NOTICE:
            define('IN_ERROR_HANDLER', true);
            if (empty($user->data)) {
                $user->session_begin();
            }
            // We re-init the auth array to get correct results on login/logout
            $auth->acl($user->data);
            if (empty($user->lang)) {
                $user->setup();
            }
            if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER') {
                send_status_line(404, 'Not Found');
            }
            $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
            $msg_title = !isset($msg_title) ? $user->lang['INFORMATION'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title);
            if (!defined('HEADER_INC')) {
                if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) {
                    adm_page_header($msg_title);
                } else {
                    page_header($msg_title);
                }
            }
            $template->set_filenames(array('body' => 'message_body.html'));
            $template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => $errno == E_USER_WARNING ? true : false, 'S_USER_NOTICE' => $errno == E_USER_NOTICE ? true : false));
            if ($request->is_ajax()) {
                global $refresh_data;
                $json_response = new \phpbb\json_response();
                $json_response->send(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => $errno == E_USER_WARNING ? true : false, 'S_USER_NOTICE' => $errno == E_USER_NOTICE ? true : false, 'REFRESH_DATA' => !empty($refresh_data) ? $refresh_data : null));
            }
            // We do not want the cron script to be called on error messages
            define('IN_CRON', true);
            if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) {
                adm_page_footer();
            } else {
                page_footer();
            }
            exit_handler();
            break;
            // PHP4 compatibility
        // PHP4 compatibility
        case E_DEPRECATED:
            return true;
            break;
    }
    // If we notice an error not handled here we pass this back to PHP by returning false
    // This may not work for all php versions
    return false;
}
コード例 #5
0
ファイル: global.php プロジェクト: biggtfish/Sandbox
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>");
}
コード例 #6
0
function titania_backtrace($exception = false)
{
    if (titania::$config->display_backtrace == 3 || titania::$config->display_backtrace == 2 && titania::$access_level == TITANIA_ACCESS_TEAMS || titania::$config->display_backtrace == 1 && phpbb::$auth->acl_get('a_')) {
        if ($exception !== false) {
            return '<br /><br /><pre>' . var_export($exception->getTrace(), true) . '</pre>';
        }
        return '<br /><br /><pre>' . get_backtrace() . '</pre>';
    }
}
コード例 #7
0
ファイル: DatabaseLayer.php プロジェクト: thruthesky/backend
 public function getErrorString()
 {
     if (sys()->isSapcms1()) {
         $str = $this->db->error;
         $str .= "<hr>";
         $str .= get_backtrace();
         return $str;
     } else {
         return $this->db->error;
     }
 }
コード例 #8
0
ファイル: mysql.php プロジェクト: ALTUN69/icy_phoenix
 /**
  * Errors handling
  */
 function sql_error($sql = '')
 {
     global $lang;
     // Set var to retrieve errored status
     $this->sql_error_triggered = true;
     $this->sql_error_sql = $sql;
     $this->sql_error_returned = $this->_sql_error();
     if (!$this->return_on_error && !defined('IN_INSTALL')) {
         $message = '<b>SQL ERROR [ ' . SQL_LAYER . ' ]</b><br /><br />' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']';
         // Show complete SQL error and path to administrators only
         // Additionally show complete error on installation or if extended debug mode is enabled
         // The DEBUG_EXTRA constant is for development only!
         if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') && DEBUG_EXTRA == true) {
             $backtrace = get_backtrace();
             $message .= $sql ? '<br /><br /><b>SQL</b><br /><br />' . htmlspecialchars($sql) : '';
             $message .= $backtrace ? '<br /><br /><b>BACKTRACE</b><br />' . $backtrace : '';
             $message .= '<br />';
         } else {
             // If error occurs in initiating the session we need to use a pre-defined language string
             // This could happen if the connection could not be established for example (then we are not able to grab the default language)
             if (!isset($lang['SQL_ERROR_OCCURRED'])) {
                 $message .= '<br /><br />An sql error occurred while fetching this page. Please contact site administrator if this problem persists.';
             } else {
                 $message .= '<br /><br />' . $lang['SQL_ERROR_OCCURRED'];
             }
         }
         if ($this->transaction) {
             $this->sql_transaction('rollback');
         }
         global $msg_code;
         $msg_code = CRITICAL_MESSAGE;
         $message = '<div style="text-align: left;">' . $message . '</div>';
         if (strlen($message) > 1024) {
             // We need to define $msg_long_text here to circumvent text stripping.
             global $msg_long_text;
             $msg_long_text = $message;
             @trigger_error(false, E_USER_NOTICE);
         }
         @trigger_error($message, E_USER_NOTICE);
         /*
         $msg_text = $message;
         $msg_title = isset($lang['Error']) ? $lang['Error'] : 'Error';
         message_die($msg_code, $msg_text, $msg_title, __LINE__, __FILE__, $sql);
         */
     }
     if ($this->transaction) {
         $this->sql_transaction('rollback');
     }
     return $this->sql_error_returned;
 }
コード例 #9
0
ファイル: functions.php プロジェクト: melvingb/phpbb3.1-STK
/**
 * Support Toolkit Error handler
 *
 * A wrapper for the phpBB `msg_handler` function, which is mainly used
 * to update variables before calling the actual msg_handler and is able
 * to handle various special cases.
 *
 * @global type $stk_no_error
 * @global string $phpbb_root_path
 * @param type $errno
 * @param string $msg_text
 * @param type $errfile
 * @param type $errline
 * @return boolean
 */
function stk_msg_handler($errno, $msg_text, $errfile, $errline)
{
    // First and foremost handle the case where phpBB calls trigger error
    // but the STK really needs to continue.
    global $critical_repair, $stk_no_error, $user;
    if (!isset($user->lang['STK_FATAL_ERROR'])) {
        stk_add_lang('common');
    }
    if ($stk_no_error === true) {
        return true;
    }
    // Do not display notices if we suppress them via @
    if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) {
        return;
    }
    if (!defined('E_DEPRECATED')) {
        define('E_DEPRECATED', 8192);
    }
    // Ignore Strict and Deprecated notices
    if (in_array($errno, array(E_STRICT, E_DEPRECATED))) {
        return true;
    }
    // We encounter an error while in the ERK, this need some special treatment
    $error_level = array(E_ERROR => 'Fatal error', E_WARNING => 'Runtime Error', E_PARSE => 'Parse error', E_NOTICE => 'Notice');
    switch ($errno) {
        case E_ERROR:
        case E_PARSE:
        case E_WARNING:
        case E_NOTICE:
        case E_CORE_ERROR:
        case E_COMPILE_ERROR:
        case E_USER_ERROR:
        case E_RECOVERABLE_ERROR:
            $backtrace = get_backtrace();
            $msg_text = '<br /><b>[phpBB Debug] PHP ' . $error_level[$errno] . ':</b> in file ' . phpbb_filter_root_path($errfile) . ' on line <b>' . $errline . ': ' . $msg_text . '</b><br />' . $backtrace . '';
            break;
        default:
            break;
    }
    if (defined('IN_ERK')) {
        $critical_repair->trigger_error($msg_text, $errno == E_USER_ERROR ? false : true);
    } else {
        if (!defined('IN_STK')) {
            // We're encountering an error before the STK is fully loaded
            // Set out own message if needed
            if ($errno == E_USER_ERROR) {
                $msg_text = $user->lang['STK_FATAL_ERROR'];
            }
            if (!isset($critical_repair)) {
                $critical_repair = new critical_repair();
            }
            $critical_repair->trigger_error($msg_text, $errno == E_USER_ERROR ? false : true);
        }
    }
    //-- Normal phpBB msg_handler
    global $cache, $db, $auth, $template, $config, $user;
    global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text;
    // Message handler is stripping text. In case we need it, we are possible to define long text...
    if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
        $msg_text = $msg_long_text;
    }
    if (!defined('E_DEPRECATED')) {
        define('E_DEPRECATED', 8192);
    }
    switch ($errno) {
        case E_NOTICE:
        case E_WARNING:
            // Check the error reporting level and return if the error level does not match
            // If DEBUG is defined the default level is E_ALL
            if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) {
                return;
            }
            if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false) {
                $errfile = stk_filter_root_path($errfile);
                $msg_text = stk_filter_root_path($msg_text);
                $error_name = $errno === E_WARNING ? 'PHP Warning' : 'PHP Notice';
                echo '<b>[phpBB Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
                // we are writing an image - the user won't see the debug, so let's place it in the log
                if (defined('IMAGE_OUTPUT') || defined('IN_CRON')) {
                    add_log('critical', 'LOG_IMAGE_GENERATION_ERROR', $errfile, $errline, $msg_text);
                }
                echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n";
            }
            return;
            break;
        case E_USER_ERROR:
            if (!empty($user) && !empty($user->lang)) {
                $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
                $msg_title = !isset($msg_title) ? $user->lang['GENERAL_ERROR'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title);
                $l_return_index = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $phpbb_root_path . '">', '</a>');
                $l_notify = '';
                if (!empty($config['board_contact'])) {
                    $l_notify = '<p>' . sprintf($user->lang['NOTIFY_ADMIN_EMAIL'], $config['board_contact']) . '</p>';
                }
            } else {
                $msg_title = 'General Error';
                $l_return_index = '<a href="' . $phpbb_root_path . '">Return to index page</a>';
                $l_notify = '';
                if (!empty($config['board_contact'])) {
                    $l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:' . $config['board_contact'] . '">' . $config['board_contact'] . '</a></p>';
                }
            }
            $log_text = $msg_text;
            $backtrace = get_backtrace();
            if ($backtrace) {
                $log_text .= '<br /><br />BACKTRACE<br />' . $backtrace;
            }
            if (defined('IN_INSTALL') || defined('DEBUG_EXTRA') || isset($auth) && $auth->acl_get('a_')) {
                $msg_text = $log_text;
            }
            if ((defined('DEBUG') || defined('IN_CRON') || defined('IMAGE_OUTPUT')) && isset($db)) {
                // let's avoid loops
                $db->sql_return_on_error(true);
                add_log('critical', 'LOG_GENERAL_ERROR', $msg_title, $log_text);
                $db->sql_return_on_error(false);
            }
            // Do not send 200 OK, but service unavailable on errors
            stk_send_status_line(503, 'Service Unavailable');
            garbage_collection();
            // Try to not call the adm page data...
            echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="' . $user->lang['DIRECTION'] . '" lang="' . $user->lang['USER_LANG'] . '" xml:lang="' . $user->lang['USER_LANG'] . '">';
            echo '<head>';
            echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
            echo '<title>' . $msg_title . '</title>';
            echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
            echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
            echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
            echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
            echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } ';
            echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
            echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
            echo "\n" . '/* ]]> */' . "\n";
            echo '</style>';
            echo '</head>';
            echo '<body id="errorpage">';
            echo '<div id="wrap">';
            echo '	<div id="page-header">';
            echo '		' . $l_return_index;
            echo '	</div>';
            echo '	<div id="acp">';
            echo '	<div class="panel">';
            echo '		<div id="content">';
            echo '			<h1>' . $msg_title . '</h1>';
            echo '			<div>' . $msg_text . '</div>';
            echo $l_notify;
            echo '		</div>';
            echo '	</div>';
            echo '	</div>';
            echo '	<div id="page-footer">';
            echo '		Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group';
            echo '	</div>';
            echo '</div>';
            echo '</body>';
            echo '</html>';
            exit_handler();
            // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
            exit;
            break;
        case E_USER_WARNING:
        case E_USER_NOTICE:
            define('IN_ERROR_HANDLER', true);
            if (empty($user->data)) {
                $user->session_begin();
            }
            // We re-init the auth array to get correct results on login/logout
            $auth->acl($user->data);
            if (empty($user->lang)) {
                $user->setup();
            }
            if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER') {
                stk_send_status_line(404, 'Not Found');
            }
            $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
            $msg_title = !isset($msg_title) ? $user->lang['INFORMATION'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title);
            if (!defined('HEADER_INC')) {
                if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) {
                    adm_page_header($msg_title);
                } else {
                    page_header($msg_title, false);
                }
            }
            $template->set_filenames(array('body' => 'message_body.html'));
            $template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => $errno == E_USER_WARNING ? true : false, 'S_USER_NOTICE' => $errno == E_USER_NOTICE ? true : false));
            // We do not want the cron script to be called on error messages
            define('IN_CRON', true);
            if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) {
                adm_page_footer();
            } else {
                page_footer();
            }
            exit_handler();
            break;
            // PHP4 compatibility
        // PHP4 compatibility
        case E_DEPRECATED:
            return true;
            break;
    }
    // If we notice an error not handled here we pass this back to PHP by returning false
    // This may not work for all php versions
    return false;
}
コード例 #10
0
/**
* Custom Error handler, call with trigger_error if required.
*/
function msg_handler($errno, $errtext, $errfile, $errline)
{
    $replevel = error_reporting();
    // If the @ error suppression operator was used, error_reporting is temporarily set to 0
    if ($replevel == 0) {
        return;
    }
    // This checks whether the error should be shown - according to what we set before with error_reporting()
    if (($errno & $replevel) != $errno) {
        return;
    }
    global $db, $config, $error_handler_history;
    $errdate = date("Y-m-d H:i:s (T)");
    $errortype = array(E_RECOVERABLE_ERROR => "PHP Error", E_WARNING => "PHP Warning", E_NOTICE => "PHP Notice", E_DEPRECATED => "PHP Deprecated", E_STRICT => "PHP Strict", E_USER_ERROR => "Viscacha Error", E_USER_WARNING => "Viscacha Warning", E_USER_NOTICE => "Viscacha Notice", E_USER_DEPRECATED => "Viscacha Deprecated");
    log_handler($errno, $errtext, $errfile, $errline);
    switch ($errno) {
        case E_WARNING:
        case E_NOTICE:
        case E_USER_WARNING:
        case E_USER_NOTICE:
            echo "<br /><strong>{$errortype[$errno]}</strong>: {$errtext} (File: <tt>{$errfile}</tt> on line <tt>{$errline}</tt>)";
            $error_handler_history[] = compact('errno', 'errtext', 'errfile', 'errline');
            return true;
            // Avoid PHP error handler
            break;
        case E_USER_ERROR:
        case E_RECOVERABLE_ERROR:
            if (isset($db) && is_a($db, 'DB_Driver')) {
                $db->close();
            }
            while (ob_get_length() !== false) {
                ob_end_clean();
            }
            ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<title>Viscacha <?php 
            echo $config['version'];
            ?>
 &raquo; Error</title>
		<style type="text/css">
		<!--
		body { color: #000; background-color: #fafafa; font-size: 12px; line-height: 130%; font-family: sans-serif; margin: auto 10%; border: 1px solid #aaa; }
		p { margin: 0; padding: 2px 5px 2px 15px; }
		a { color: #a80000; }
		a:hover { color: #000; }
		h1 { text-align: center; padding: 10px; margin: 0 0 20px 0; background-color: #eee; border-bottom: 1px solid #aaaaaa; }
		h3 { padding: 0 5px; margin: 20px 0 7px 0; color: #a80000; border-bottom: 1px solid #eee; }
		.code { background: #fff; border: 1px solid #ddd; margin: 2px 5px 2px 15px; padding: 2px; font-family: monospace; list-style: none; }
		.lineone { padding: 0 5px; margin: 2px 0; background:#f9f9f9; }
		.linetwo { padding: 0 5px; margin: 2px 0; background: #fcfcfc; }
		.mark { padding: 0 5px; margin: 2px 0; background: #eedddd; color: #880000; font-weight: bold; }
		.center { text-align: center; }
		-->
		</style>
	</head>
	<body>
		<h1><?php 
            echo $errortype[$errno];
            ?>
</h1>
		<p class="center">
			[<a href="<?php 
            echo $config['furl'];
            ?>
/index.php">Return to Index</a>]
			<?php 
            if (check_hp($_SERVER['HTTP_REFERER'])) {
                ?>
			&nbsp;&nbsp;[<a href="<?php 
                echo htmlspecialchars($_SERVER['HTTP_REFERER']);
                ?>
">Return to last Page</a>]
			<?php 
            }
            ?>
		</p>
		<h3>Error Message</h3>
		<p><?php 
            echo $errtext;
            ?>
</p>
		<h3>Error Details</h3>
		<p>
			<strong>File:</strong> <?php 
            echo $errfile;
            ?>
<br />
			<strong>Line:</strong> <?php 
            echo $errline;
            ?>
<br />
			<strong>Date:</strong> <?php 
            echo $errdate;
            ?>
		</p>
		<h3>Code Snippet</h3>
		<?php 
            echo getErrorCodeSnippet($errfile, $errline);
            ?>
		<h3>Backtrace</h3>
		<?php 
            echo get_backtrace(2);
            ?>
		<?php 
            if (count($error_handler_history) > 0) {
                ?>
		<h3>Previous Notices and Warnings</h3>
		<p>Additionally <?php 
                echo count($error_handler_history);
                ?>
 notices and/or warnings occured:</p>
		<ul>
		<?php 
                foreach ($error_handler_history as $e) {
                    ?>
			<li>
				<strong><?php 
                    echo $errortype[$e['errno']];
                    ?>
</strong>: <?php 
                    echo $e['errtext'];
                    ?>
<br />
				File: <tt><?php 
                    echo $e['errfile'];
                    ?>
</tt> - Line: <tt><?php 
                    echo $e['errline'];
                    ?>
</tt>
			</li>
		<?php 
                }
                ?>
		</ul>
		<?php 
            }
            ?>
		<h3>Contact</h3>
		<p>Please notify the board administrator: <a href="mailto:<?php 
            echo $config['forenmail'];
            ?>
"><?php 
            echo $config['forenmail'];
            ?>
</a></p>
		<h3>Copyright</h3>
		<p>
			Powered by <strong><a href="http://www.viscacha.org" target="_blank">Viscacha <?php 
            echo $config['version'];
            ?>
</a></strong><br />
			Copyright &copy; 2004-2009, The Viscacha Project
		</p>
	</body>
</html>
			<?php 
            exit;
            break;
        default:
            // E_STRICT
            return;
            // Do nothing
            break;
    }
}
コード例 #11
0
/**
* Error and message handler, call with trigger_error if reqd
*/
function msg_handler($errno, $msg_text, $errfile, $errline)
{
	global $db, $template, $msg_title, $msg_long_text;

	include('./lib/lang/error.php');
	
	$msg_title = (isset($lang_error[$msg_text.'_TITLE'])) ? $lang_error[$msg_text.'_TITLE'] : $msg_text.'_TITLE';
	$msg_text = (isset($lang_error[$msg_text.'_DESC'])) ? $lang_error[$msg_text.'_DESC'] : $msg_text.'_DESC';

	switch ($errno)
	{
		case E_NOTICE:
		case E_WARNING:

			// Check the error reporting level and return if the error level does not match
			// If DEBUG is defined the default level is E_ALL
			if (($errno & ((defined('DEBUG')) ? E_ALL : error_reporting())) == 0)
			{
				return;
			}

			if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
			{
				// flush the content, else we get a white page if output buffering is on
				if ((int) @ini_get('output_buffering') === 1 || strtolower(@ini_get('output_buffering')) === 'on')
				{
					@ob_flush();
				}
				
				echo '<b>[Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
				if(defined('DEBUG'))
				{
					echo '<br /><br />BACKTRACE<br />' . get_backtrace() . '<br />' . "\n";
				}
			}

			return;

		break;

		case E_USER_ERROR:

			$msg_title = 'General Error';
			$l_return_index = '<a href="./">Return to index page</a>';
			$l_notify = '<p>Please notify the board administrator or webmaster: <a href="mailto:webmaster@electricnation.nl?subject=Your Sexy Site&amp;body=Fix this shit, niggers.">webmaster@electricnation.nl</a></p>';
						
			$db->sql_close();
			
			// Do not send 200 OK, but service unavailable on errors
			header('HTTP/1.1 503 Service Unavailable');

			echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
			echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
			echo '<head>';
			echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
			echo '<title>' . $msg_title . '</title>';
			echo '</head>';
			echo '<body id="errorpage">';
			echo '<div id="wrap">';
			echo '	<div id="page-header">';
			echo '		' . $l_return_index;
			echo '	</div>';
			echo '	<div id="acp">';
			echo '	<div class="panel">';
			echo '		<div id="content">';
			echo '			<h1>' . $msg_title . '</h1>';

			echo '			<div>' . $msg_text . '</div>';

			echo $l_notify;

			echo '		</div>';
			echo '	</div>';
			echo '	</div>';
			echo '</div>';
			echo '</body>';
			echo '</html>';

			// On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
			exit;
		break;
		case E_USER_WARNING:
		case E_USER_NOTICE:
			if(!defined('ROOT_URL'))
			{
				page_header();
			}
			$template->assign_vars(array(
				'MESSAGE_TITLE'	=> $msg_title,
				'MESSAGE_TEXT'	=> $msg_text,
			));
			
			$template->set_filenames(array(
				'error'	=> 'error_body.html',
			));
			
			$template->display('error');
			$db->sql_close();
			exit;
		break;
	}

	// If we notice an error not handled here we pass this back to PHP by returning false
	// This may not work for all php versions
	return false;
}
コード例 #12
0
function test($code, $good = null, $bad = null)
{
    static $_count_test = 0;
    global $global_test_error;
    $_count_test++;
    $tree = get_backtrace();
    if ($code) {
        $path = path_run(2);
        echo "<span style='font-size:100%;color:#7f7c85;' title='{$good} {$path}'>{$_count_test}</span> ";
    } else {
        echo "<span style='font-size:160%;color:red;' title='{$bad}'>{$_count_test}</span> ";
        $global_test_error[] = $bad . $tree;
    }
}
コード例 #13
0
 /**
  * gym_error(($errno, $msg_text, $errfile, $errline)
  * Will properly handle error for all cases, admin always get full debug
  * Partly based on msg_handler()
  * @access private
  */
 function gym_error($errno = 0, $msg_key = '', $errfile = '', $errline = '', $sql = '')
 {
     global $user, $phpbb_seo, $auth, $phpbb_root_path, $phpEx, $msg_title;
     $http_codes = array(204 => 'HTTP/1.1 204 No Content', 400 => 'HTTP/1.1 400 Bad Request', 401 => 'HTTP/1.1 401 Unauthorized', 403 => 'HTTP/1.1 403 Forbidden', 404 => 'HTTP/1.1 404 Not Found', 405 => 'HTTP/1.1 405 Method Not Allowed', 406 => 'HTTP/1.1 406 Not Acceptable', 410 => 'HTTP/1.1 410 Gone', 500 => 'HTTP/1.1 500 Internal Server Error', 503 => 'HTTP/1.1 503 Service Unavailable');
     $header = isset($http_codes[$errno]) ? $http_codes[$errno] : '';
     $return_url = append_sid("{$phpbb_root_path}index.{$phpEx}");
     if (!empty($user) && !empty($user->lang)) {
         $msg_title = empty($msg_key) ? !empty($user->lang['GYM_ERROR_' . $errno]) ? $user->lang['GYM_ERROR_' . $errno] : (!empty($header) ? $header : $user->lang['GENERAL_ERROR']) : (!empty($user->lang[$msg_key]) ? $user->lang[$msg_key] : $msg_key);
         $msg_text = !empty($user->lang[$msg_key . '_EXPLAIN']) ? $user->lang[$msg_key . '_EXPLAIN'] : (!empty($user->lang['GYM_ERROR_' . $errno . '_EXPLAIN']) ? $user->lang['GYM_ERROR_' . $errno . '_EXPLAIN'] : (!empty($msg_key) ? $msg_key : (!empty($header) ? $header : $msg_title)));
         $l_return_index = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $return_url . '">', '</a>');
         if (($errno == 500 || $errno == 503) && !empty($config['board_contact'])) {
             $msg_text .= '<p>' . sprintf($user->lang['NOTIFY_ADMIN_EMAIL'], $config['board_contact']) . '</p>';
         }
     } else {
         $msg_title = 'GYM Sitemaps General Error';
         $l_return_index = '<a href="' . $return_url . '">Return to index page</a>';
         if (($errno == 500 || $errno == 503) && !empty($config['board_contact'])) {
             $msg_text .= '<p>Please notify the board administrator or webmaster: <a href="mailto:' . $config['board_contact'] . '">' . $config['board_contact'] . '</a></p>';
         }
     }
     $msg_text .= '<br/><br/>' . $l_return_index;
     if (@$auth->acl_get('a_')) {
         if (!empty($user->lang[$msg_key . '_EXPLAIN_ADMIN'])) {
             $msg_text .= '<br/><br/>' . $user->lang[$msg_key . '_EXPLAIN_ADMIN'];
         }
         if (defined('DEBUG')) {
             $msg_text .= '</p><br/><h2>Debug :</h2><p>' . (!empty($errfile) ? "<br/><b>File :</b> " . utf8_htmlspecialchars($errfile) . "<br/>" : '');
             $msg_text .= !empty($errline) ? "<br/><b>Line :</b> " . utf8_htmlspecialchars($errline) . "<br/>" : '';
             $msg_text .= !empty($sql) ? "<br/><b>Sql :</b>  " . utf8_htmlspecialchars($sql) . "<br/>" : '';
             $msg_text .= '</p><div style="font-size:12px">' . get_backtrace() . '</div><p>';
         }
     }
     if (!empty($header)) {
         header($header);
     }
     meta_refresh(5, $return_url);
     trigger_error($msg_text);
     $this->safe_exit();
     return;
 }
コード例 #14
0
/**
* Error and message handler, call with trigger_error if required
*/
function msg_handler($errno, $errtext, $errfile, $errline)
{
    global $db, $config;
    $errdate = date("Y-m-d H:i:s (T)");
    $errortype = array(E_ERROR => "PHP Error", E_WARNING => "PHP Warning", E_NOTICE => "PHP Notice", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice");
    if ($config['error_log'] == 1) {
        switch ($errno) {
            case E_WARNING:
            case E_NOTICE:
            case E_USER_WARNING:
            case E_USER_NOTICE:
            case E_USER_ERROR:
            case E_ERROR:
                $errlogfile = 'data/errlog_php.inc.php';
                $new = array();
                if (file_exists($errlogfile)) {
                    $lines = file($errlogfile);
                    foreach ($lines as $row) {
                        $row = trim($row);
                        if (!empty($row)) {
                            $new[] = $row;
                        }
                    }
                } else {
                    $new = array();
                }
                $errtext2 = str_replace(array("\r\n", "\n", "\r", "\t"), " ", $errtext);
                $sru = str_replace(array("\r\n", "\n", "\r", "\t"), " ", $_SERVER['REQUEST_URI']);
                $new[] = $errno . "\t" . $errtext2 . "\t" . $errfile . "\t" . $errline . "\t" . $sru . "\t" . time() . "\t" . PHP_VERSION . " (" . PHP_OS . ")";
                file_put_contents($errlogfile, implode("\n", $new));
                break;
        }
    }
    switch ($errno) {
        case E_WARNING:
        case E_NOTICE:
        case E_USER_WARNING:
        case E_USER_NOTICE:
            echo "<br /><strong>" . $errortype[$errno] . "</strong>: " . $errtext . " (File: <tt>" . $errfile . "</tt> on line <tt>" . $errline . "</tt>)";
            break;
        case E_USER_ERROR:
        case E_ERROR:
            if (isset($db)) {
                $db->close();
            }
            if (function_exists('ob_clean')) {
                @ob_clean();
            }
            ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<title>Viscacha <?php 
            echo $config['version'];
            ?>
 &raquo; Error</title>
		<style type="text/css">
		<!--
		body{
			color: #000000;
			background-color: #FAFAFA;
			font-size: 12px;
			line-height: 130%;
			font-family: Sans-Serif;
			margin-left: 10%;
			margin-right: 10%;
			border: 1px solid #aaaaaa;
		}
		p {
			margin: 0px;
			padding: 2px;
			padding-left: 15px;
			padding-right: 5px;
		}
		a {
			color: #A80000;
		}
		a:hover {
			color: #000000;
		}
		h1 {
			text-align: center;
			padding: 10px;
			margin: 0px;
			margin-bottom: 20px;
			background-color: #eeeeee;
			border-bottom: 1px solid #aaaaaa;
		}
		h3 {
			padding: 0px;
			margin: 0px;
			padding-left: 5px;
			padding-right: 5px;
			margin-bottom: 7px;
			margin-top: 20px;
			color: #A80000;
			border-bottom: 1px solid #EEE;
		}
		.code {
			background: #FFFFFF;
			border: 1px solid #dddddd;
			margin-right: 5px;
			margin-bottom: 2px;
			margin-top: 2px;
			margin-left: 15px;
			padding: 2px;
			font-family: Monospace;
			list-style: none;
		}
		.lineone {
			padding:0 5px;
			margin:2px 0;
			background:#F9F9F9;
		}
		.center {
			text-align: center;
		}
		.linetwo {
			padding:0 5px;
			margin:2px 0;
			background:#FCFCFC;
		}
		.mark {
			padding:0 5px;
			margin:2px 0;
			background: #eedddd;
			color: #880000;
			font-weight: bold;
		}
		-->
		</style>
	</head>
	<body>
		<h1>General Error</h1>
		<p class="center">
			[<a href="<?php 
            echo $config['furl'];
            ?>
/index.php">Return to Index</a>]
			<?php 
            if (check_hp($_SERVER['HTTP_REFERER'])) {
                ?>
			&nbsp;&nbsp;[<a href="<?php 
                echo htmlspecialchars($_SERVER['HTTP_REFERER']);
                ?>
">Return to last Page</a>]
			<?php 
            }
            ?>
		</p>
		<h3>Error Message</h3>
		<p><strong><?php 
            echo $errortype[$errno];
            ?>
</strong>: <?php 
            echo $errtext;
            ?>
</p>
		<h3>Error Details</h3>
		<p>
			File: <?php 
            echo $errfile;
            ?>
<br />
			Line: <?php 
            echo $errline;
            ?>
<br />
			Date: <?php 
            echo $errdate;
            ?>
<br />
		</p>
		<h3>Code Snippet</h3>
		<?php 
            echo getErrorCodeSnippet($errfile, $errline);
            ?>
		<h3>Backtrace</h3>
		<?php 
            echo get_backtrace();
            ?>
		<h3>Contact</h3>
		<p>Please notify the board administrator: <a href="mailto:<?php 
            echo $config['forenmail'];
            ?>
"><?php 
            echo $config['forenmail'];
            ?>
</a></p>
		<h3>Copyright</h3>
		<p>
			<strong><a href="http://www.viscacha.org" target="_blank">Viscacha <?php 
            echo $config['version'];
            ?>
</a></strong><br />
			Copyright &copy; by MaMo Net
		</p>
	</body>
</html>
			<?php 
            exit;
            break;
    }
}
コード例 #15
0
 /**
  * Log error messages
  *
  * @param string $message
  * @param bool   $log_in_file
  * @param bool   $exit
  * @param int    $error_type
  * @param array  $args
  *
  * @return null
  * @access private
  */
 private function log_error($message, $log_in_file = false, $exit = false, $error_type = E_USER_NOTICE, $args = array())
 {
     $error_timestamp = date('d-M-Y H:i:s Z');
     $backtrace = '';
     if ($this->ppde_controller_main->use_sandbox()) {
         $backtrace = get_backtrace();
         $backtrace = html_entity_decode(strip_tags(str_replace(array('<br />', "\n\n"), "\n", $backtrace)));
     }
     $message = str_replace('<br />', ';', $message);
     if (sizeof($args)) {
         $message .= "\n[args]\n";
         foreach ($args as $key => $value) {
             $value = urlencode($value);
             $message .= $key . ' = ' . $value . ";\n";
         }
         unset($value);
     }
     if ($log_in_file) {
         error_log(sprintf('[%s] %s %s', $error_timestamp, $message, $backtrace), 3, $this->root_path . 'store/ppde_transactions.log');
     }
     if ($exit) {
         trigger_error($message, $error_type);
     }
 }
コード例 #16
0
ファイル: dbal.php プロジェクト: bryanveloso/sayonarane
 /**
  * display sql error page
  */
 function sql_error($sql = '')
 {
     global $auth, $user, $config;
     // Set var to retrieve errored status
     $this->sql_error_triggered = true;
     $this->sql_error_sql = $sql;
     $this->sql_error_returned = $this->_sql_error();
     if (!$this->return_on_error) {
         $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]<br /><br />' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']';
         // Show complete SQL error and path to administrators only
         // Additionally show complete error on installation or if extended debug mode is enabled
         // The DEBUG_EXTRA constant is for development only!
         if (isset($auth) && $auth->acl_get('a_') || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) {
             // Print out a nice backtrace...
             $backtrace = get_backtrace();
             $message .= $sql ? '<br /><br />SQL<br /><br />' . htmlspecialchars($sql) : '';
             $message .= $backtrace ? '<br /><br />BACKTRACE<br />' . $backtrace : '';
             $message .= '<br />';
         } else {
             // If error occurs in initiating the session we need to use a pre-defined language string
             // This could happen if the connection could not be established for example (then we are not able to grab the default language)
             if (!isset($user->lang['SQL_ERROR_OCCURRED'])) {
                 $message .= '<br /><br />An sql error occurred while fetching this page. Please contact an administrator if this problem persists.';
             } else {
                 if (!empty($config['board_contact'])) {
                     $message .= '<br /><br />' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>');
                 } else {
                     $message .= '<br /><br />' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', '');
                 }
             }
         }
         if ($this->transaction) {
             $this->sql_transaction('rollback');
         }
         if (strlen($message) > 1024) {
             // We need to define $msg_long_text here to circumvent text stripping.
             global $msg_long_text;
             $msg_long_text = $message;
             trigger_error(false, E_USER_ERROR);
         }
         trigger_error($message, E_USER_ERROR);
     }
     if ($this->transaction) {
         $this->sql_transaction('rollback');
     }
     return $this->sql_error_returned;
 }
コード例 #17
0
ファイル: dbal.php プロジェクト: Ganonmaster/Roadsterspot
<?php