Beispiel #1
0
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    # also suppress php 5 strict warnings
    if (0 == error_reporting() || 2048 == $p_type) {
        return;
    }
    $t_lang_pushed = false;
    # flush any language overrides to return to user's natural default
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            lang_push(lang_get_default());
            $t_lang_pushed = true;
        }
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        $t_method = 'none';
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = $p_error;
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = $p_error;
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            #shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    if ('halt' == $t_method) {
        $t_old_contents = ob_get_contents();
        # ob_end_clean() still seems to call the output handler which
        #  outputs the headers indicating compression. If we had
        #  PHP > 4.2.0 we could use ob_clean() instead but as it is
        #  we need to disable compression.
        compress_disable();
        if (ob_get_length()) {
            ob_end_clean();
        }
        # don't send the page header information if it has already been sent
        if ($g_error_send_page_header) {
            html_page_top1();
            if ($p_error != ERROR_DB_QUERY_FAILED) {
                html_page_top2();
            } else {
                html_page_top2a();
            }
        }
        print '<br /><div align="center"><table class="width50" cellspacing="1">';
        print "<tr><td class=\"form-title\">{$t_error_type}</td></tr>";
        print "<tr><td><p class=\"center\" style=\"color:red\">{$t_error_description}</p></td></tr>";
        print '<tr><td><p class="center">';
        if (null === $g_error_proceed_url) {
            print lang_get('error_no_proceed');
        } else {
            print "<a href=\"{$g_error_proceed_url}\">" . lang_get('proceed') . '</a>';
        }
        print '</p></td></tr>';
        if (ON == config_get('show_detailed_errors')) {
            print '<tr><td>';
            error_print_details($p_file, $p_line, $p_context);
            print '</td></tr>';
            print '<tr><td>';
            error_print_stack_trace();
            print '</td></tr>';
        }
        print '</table></div>';
        if ($g_error_handled && !is_blank($t_old_contents)) {
            print '<p>Previous non-fatal errors occurred.  Page contents follow.</p>';
            print '<div style="border: solid 1px black;padding: 4px">';
            print $t_old_contents;
            print '</div>';
        }
        if ($p_error != ERROR_DB_QUERY_FAILED) {
            html_page_bottom1();
        } else {
            html_body_end();
            html_end();
        }
        exit;
    } else {
        if ('inline' == $t_method) {
            print "<p style=\"color:red\">{$t_error_type}: {$t_error_description}</p>";
        } else {
            # do nothing
        }
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_handled = true;
    $g_error_proceed_url = null;
}
Beispiel #2
0
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param integer $p_type    Contains the level of the error raised, as an integer.
 * @param string  $p_error   Contains the error message, as a string.
 * @param string  $p_file    Contains the filename that the error was raised in, as a string.
 * @param integer $p_line    Contains the line number the error was raised at, as an integer.
 * @param array   $p_context To the active symbol table at the point the error occurred (optional).
 * @return void
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, array $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    $t_error_location = 'in \'' . $p_file . '\' line ' . $p_line;
    $t_error_description = '\'' . $p_error . '\' ' . $t_error_location;
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            break;
        case E_STRICT:
            $t_error_type = 'STRICT NOTICE';
            break;
        case E_RECOVERABLE_ERROR:
            # This should generally be considered fatal (like E_ERROR)
            $t_error_type = 'SYSTEM ERROR';
            break;
        case E_DEPRECATED:
            $t_error_type = 'DEPRECATED';
            break;
        case E_USER_ERROR:
            $t_error_type = 'APPLICATION ERROR #' . $p_error;
            $t_error_description = error_string($p_error);
            if ($t_method == DISPLAY_ERROR_INLINE) {
                $t_error_description .= ' (' . $t_error_location . ")\n" . error_string(ERROR_DISPLAY_USER_ERROR_INLINE);
            }
            break;
        case E_USER_WARNING:
            $t_error_type = 'APPLICATION WARNING #' . $p_error;
            $t_error_description = error_string($p_error) . ' (' . $t_error_location . ')';
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            break;
        case E_USER_DEPRECATED:
            # Get the parent of the call that triggered the error to facilitate
            # debugging with a more useful filename and line number
            $t_stack = debug_backtrace();
            $t_caller = $t_stack[2];
            $t_error_type = 'WARNING';
            $t_error_description = error_string($p_error) . ' (in ' . $t_caller['file'] . ' line ' . $t_caller['line'] . ')';
            if ($t_method == DISPLAY_ERROR_INLINE && php_sapi_name() != 'cli') {
                # Enqueue messages for later display with error_print_delayed()
                global $g_errors_delayed;
                $g_errors_delayed[] = $t_error_description;
                $g_error_handled = true;
                return;
            }
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = 'UNHANDLED ERROR TYPE (' . '<a href="http://php.net/errorfunc.constants">' . $p_type . '</a>)';
            $t_error_description = $p_error . ' (' . $t_error_location . ')';
    }
    $t_error_description = nl2br($t_error_description);
    if (php_sapi_name() == 'cli') {
        if (DISPLAY_ERROR_NONE != $t_method) {
            echo $t_error_type . ': ' . $t_error_description . "\n";
            if (ON == config_get_global('show_detailed_errors')) {
                echo "\n";
                debug_print_backtrace();
            }
        }
        if (DISPLAY_ERROR_HALT == $t_method) {
            exit(1);
        }
    } else {
        switch ($t_method) {
            case DISPLAY_ERROR_HALT:
                # disable any further event callbacks
                if (function_exists('event_clear_callbacks')) {
                    event_clear_callbacks();
                }
                $t_oblen = ob_get_length();
                if ($t_oblen > 0) {
                    $t_old_contents = ob_get_contents();
                    if (!error_handled()) {
                        # Retrieve the previously output header
                        if (false !== preg_match_all('|^(.*)(</head>.*$)|is', $t_old_contents, $t_result) && isset($t_result[1]) && isset($t_result[1][0])) {
                            $t_old_headers = $t_result[1][0];
                            unset($t_old_contents);
                        }
                    }
                }
                # We need to ensure compression is off - otherwise the compression headers are output.
                compress_disable();
                # then clean the buffer, leaving output buffering on.
                if ($t_oblen > 0) {
                    ob_clean();
                }
                # If HTML error output was disabled, set an error header and stop
                if (defined('DISABLE_INLINE_ERROR_REPORTING')) {
                    # @TODO Have a mapping for mantis error codes to appropiate HTTP error codes
                    header(' ', true, 400);
                    exit(1);
                }
                # don't send the page header information if it has already been sent
                if ($g_error_send_page_header) {
                    if ($t_html_api) {
                        html_page_top1();
                        if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                            html_page_top2();
                        } else {
                            html_page_top2a();
                        }
                    } else {
                        echo '<html><head><title>', $t_error_type, '</title></head><body>';
                    }
                } else {
                    # Output the previously sent headers, if defined
                    if (isset($t_old_headers)) {
                        echo $t_old_headers, "\n";
                        html_page_top2();
                    }
                }
                echo '<div id="error-msg">';
                echo '<div class="error-type">' . $t_error_type . '</div>';
                echo '<div class="error-description">', $t_error_description, '</div>';
                echo '<div class="error-info">';
                if (null === $g_error_proceed_url) {
                    echo lang_get('error_no_proceed');
                } else {
                    echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
                }
                echo '</div>';
                if (ON == config_get_global('show_detailed_errors')) {
                    echo '<div class="error-details">';
                    error_print_details($p_file, $p_line, $p_context);
                    echo '</div>';
                    echo '<div class="error-trace">';
                    error_print_stack_trace();
                    echo '</div>';
                }
                echo '</div>';
                if (isset($t_old_contents)) {
                    echo '<div class="warning">Previous non-fatal errors occurred.  Page contents follow.</div>';
                    echo '<div id="old-contents">';
                    echo $t_old_contents;
                    echo '</div>';
                }
                if ($t_html_api) {
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_bottom();
                    } else {
                        html_body_end();
                        html_end();
                    }
                } else {
                    echo '</body></html>', "\n";
                }
                exit(1);
            case DISPLAY_ERROR_INLINE:
                if (!defined('DISABLE_INLINE_ERROR_REPORTING')) {
                    echo '<div class="error-inline">', $t_error_type, ': ', $t_error_description, '</div>';
                }
                $g_error_handled = true;
                break;
            default:
                # do nothing - note we treat this as we've not handled an error, so any redirects go through.
        }
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param int p_type contains the level of the error raised, as an integer.
 * @param string p_error contains the error message, as a string.
 * @param string p_file contains the filename that the error was raised in, as a string.
 * @param int p_line contains the line number the error was raised at, as an integer.
 * @param array p_context to the active symbol table at the point the error occurred (optional)
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    switch ($t_method) {
        case 'halt':
            # disable any further event callbacks
            if (function_exists('event_clear_callbacks')) {
                event_clear_callbacks();
            }
            $t_oblen = ob_get_length();
            if (error_handled() && $t_oblen > 0) {
                $t_old_contents = ob_get_contents();
            }
            # We need to ensure compression is off - otherwise the compression headers are output.
            compress_disable();
            # then clean the buffer, leaving output buffering on.
            if ($t_oblen > 0) {
                ob_clean();
            }
            # don't send the page header information if it has already been sent
            if ($g_error_send_page_header) {
                if ($t_html_api) {
                    html_page_top1();
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_top2();
                    } else {
                        html_page_top2a();
                    }
                } else {
                    echo '<html><head><title>', $t_error_type, '</title></head><body>';
                }
            }
            echo '<br /><div align="center"><table class="width50" cellspacing="1">';
            echo '<tr><td class="form-title">', $t_error_type, '</td></tr>';
            echo '<tr><td><p class="center" style="color:red">', $t_error_description, '</p></td></tr>';
            echo '<tr><td><p class="center">';
            if (null === $g_error_proceed_url) {
                echo lang_get('error_no_proceed');
            } else {
                echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
            }
            echo '</p></td></tr>';
            if (ON == config_get_global('show_detailed_errors')) {
                echo '<tr><td>';
                error_print_details($p_file, $p_line, $p_context);
                echo '</td></tr>';
                echo '<tr><td>';
                error_print_stack_trace();
                echo '</td></tr>';
            }
            echo '</table></div>';
            if (isset($t_old_contents)) {
                echo '<p>Previous non-fatal errors occurred.  Page contents follow.</p>';
                echo '<div style="border: solid 1px black;padding: 4px">';
                echo $t_old_contents;
                echo '</div>';
            }
            if ($t_html_api) {
                if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                    html_page_bottom();
                } else {
                    html_body_end();
                    html_end();
                }
            } else {
                echo '</body></html>', "\n";
            }
            exit;
        case 'inline':
            echo '<p style="color:red">', $t_error_type, ': ', $t_error_description, '</p>';
            $g_error_handled = true;
            break;
        default:
            # do nothing - note we treat this as we've not handled an error, so any redirects go through.
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}
Beispiel #4
0
 function run($p_execute, $p_limit, $p_advanced)
 {
     if (!php_version_at_least('4.1.0')) {
         global $_SERVER;
     }
     if ($p_execute) {
         # Mark this as a long process and ignore user aborts
         helper_begin_long_process(true);
         # Disable compression so we can stream
         compress_disable();
         # Flush the output buffer
         @ob_end_flush();
         echo '<b>Please be patient, this may take a while...</b>';
     }
     # Form
     echo '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
     # Execute All Button
     echo "<input type=\"submit\" name=\"{$this->upgrade_file}_execute_all\" value=\"Execute All\" />";
     # Print All Button
     echo "<input type=\"submit\" name=\"{$this->upgrade_file}_print_all\" value=\"Print All\" /><br /><br />";
     if ($p_advanced) {
         # Execute Selected Button
         echo "<input type=\"submit\" name=\"{$this->upgrade_file}_execute_selected\" value=\"Execute Selected\" />";
         # Print Selected Button
         echo "<input type=\"submit\" name=\"{$this->upgrade_file}_print_selected\" value=\"Print Selected\" />";
     }
     # Table
     echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
     echo "<tr><td bgcolor=\"#e8e8e8\" colspan=\"3\"><span class=\"title\">{$this->upgrade_name}</span></td></tr>";
     # Headings
     echo '<tr bgcolor="#ffffff"><th width="70%">Description</th><th nowrap="nowrap">Upgrade ID</th><th width="30%">Status</th></tr>';
     $t_error = false;
     foreach ($this->item_array as $item) {
         $t_state = '';
         if ($item->is_applied()) {
             if (!$p_advanced) {
                 continue;
                 #next one
             }
             $t_state = 'disabled="disabled"';
             $t_color = '#00ff88';
             $t_message = 'Previously Applied';
         } else {
             if (null !== $p_limit && is_array($p_limit) && !in_array($item->id, $p_limit)) {
                 $t_color = '#ffff88';
                 $t_message = 'Skipped';
             } else {
                 if ($p_execute) {
                     if ($t_error) {
                         $t_state = 'checked="checked"';
                         $t_color = '#ff0088';
                         $t_message = 'Skipped due to previous error';
                         continue;
                         # next one
                     }
                     if ($item->execute()) {
                         $t_state = 'disabled="disabled"';
                         $t_color = '#00ff88';
                         $t_message = 'Applied';
                     } else {
                         $t_state = 'checked="checked"';
                         $t_color = '#ff0088';
                         $t_message = 'ERROR: ' . $item->error;
                         $t_error = true;
                     }
                 } else {
                     # not applied but not executing
                     $t_color = '#ff0088';
                     $t_message = 'Not Applied';
                     $t_state = 'checked="checked"';
                 }
             }
         }
         echo '<tr bgcolor="#ffffff"><td>';
         echo $item->description;
         # description
         echo '</td>';
         echo '<td nowrap="nowrap">';
         if ($p_advanced) {
             echo "<input type=\"checkbox\" name=\"{$this->upgrade_file}_execute_list[]\" value=\"{$item->id}\" {$t_state} /> ";
         }
         echo "{$item->id}</td>";
         echo "<td bgcolor=\"{$t_color}\">{$t_message}</td>";
         echo '</tr>';
     }
     echo '</table>';
     # Execute All Button
     echo "<br /><input type=\"submit\" name=\"{$this->upgrade_file}_execute_all\" value=\"Execute All\" />";
     # Print All Button
     echo "<input type=\"submit\" name=\"{$this->upgrade_file}_print_all\" value=\"Print All\" />";
     if ($p_advanced) {
         # Execute Selected Button
         echo "<input type=\"submit\" name=\"{$this->upgrade_file}_execute_selected\" value=\"Execute Selected\" />";
         # Print Selected Button
         echo "<input type=\"submit\" name=\"{$this->upgrade_file}_print_selected\" value=\"Print Selected\" />";
     }
 }
Beispiel #5
0
/**
 * Default error handler
 *
 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
 *  errors.
 *
 * E_USER_* are triggered by us and will contain an error constant in $p_error
 * The others, being system errors, will come with a string in $p_error
 *
 * @access private
 * @param int p_type contains the level of the error raised, as an integer.
 * @param string p_error contains the error message, as a string.
 * @param string p_file contains the filename that the error was raised in, as a string.
 * @param int p_line contains the line number the error was raised at, as an integer.
 * @param array p_context to the active symbol table at the point the error occurred (optional)
 * @uses lang_api.php
 * @uses config_api.php
 * @uses compress_api.php
 * @uses database_api.php (optional)
 * @uses html_api.php (optional)
 */
function error_handler($p_type, $p_error, $p_file, $p_line, $p_context)
{
    global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
    global $g_lang_overrides;
    global $g_error_send_page_header;
    # check if errors were disabled with @ somewhere in this call chain
    if (0 == error_reporting()) {
        return;
    }
    $t_lang_pushed = false;
    $t_db_connected = false;
    if (function_exists('db_is_connected')) {
        if (db_is_connected()) {
            $t_db_connected = true;
        }
    }
    $t_html_api = false;
    if (function_exists('html_end')) {
        $t_html_api = true;
    }
    # flush any language overrides to return to user's natural default
    if ($t_db_connected) {
        lang_push(lang_get_default());
        $t_lang_pushed = true;
    }
    $t_short_file = basename($p_file);
    $t_method_array = config_get_global('display_errors');
    if (isset($t_method_array[$p_type])) {
        $t_method = $t_method_array[$p_type];
    } else {
        if (isset($t_method_array[E_ALL])) {
            $t_method = $t_method_array[E_ALL];
        } else {
            $t_method = 'none';
        }
    }
    # build an appropriate error string
    switch ($p_type) {
        case E_WARNING:
            $t_error_type = 'SYSTEM WARNING';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_NOTICE:
            $t_error_type = 'SYSTEM NOTICE';
            $t_error_description = "'{$p_error}' in '{$p_file}' line {$p_line}";
            break;
        case E_USER_ERROR:
            $t_error_type = "APPLICATION ERROR #{$p_error}";
            $t_error_description = error_string($p_error);
            if ($t_method == DISPLAY_ERROR_INLINE) {
                $t_error_description .= "\n" . error_string(ERROR_DISPLAY_USER_ERROR_INLINE);
            }
            break;
        case E_USER_WARNING:
            $t_error_type = "APPLICATION WARNING #{$p_error}";
            $t_error_description = error_string($p_error);
            break;
        case E_USER_NOTICE:
            # used for debugging
            $t_error_type = 'DEBUG';
            $t_error_description = $p_error;
            break;
        default:
            # shouldn't happen, just display the error just in case
            $t_error_type = '';
            $t_error_description = $p_error;
    }
    $t_error_description = nl2br($t_error_description);
    switch ($t_method) {
        case DISPLAY_ERROR_HALT:
            # disable any further event callbacks
            if (function_exists('event_clear_callbacks')) {
                event_clear_callbacks();
            }
            $t_oblen = ob_get_length();
            if ($t_oblen > 0) {
                $t_old_contents = ob_get_contents();
                if (!error_handled()) {
                    # Retrieve the previously output header
                    if (false !== preg_match_all('|^(.*)(</head>.*$)|is', $t_old_contents, $result)) {
                        $t_old_headers = $result[1][0];
                        unset($t_old_contents);
                    }
                }
            }
            # We need to ensure compression is off - otherwise the compression headers are output.
            compress_disable();
            # then clean the buffer, leaving output buffering on.
            if ($t_oblen > 0) {
                ob_clean();
            }
            # don't send the page header information if it has already been sent
            if ($g_error_send_page_header) {
                if ($t_html_api) {
                    html_page_top1();
                    if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                        html_page_top2();
                    } else {
                        html_page_top2a();
                    }
                } else {
                    echo '<html><head><title>', $t_error_type, '</title></head><body>';
                }
            } else {
                # Output the previously sent headers, if defined
                if (isset($t_old_headers)) {
                    echo $t_old_headers, "\n";
                    html_page_top2();
                }
            }
            echo '<div id="error-msg">';
            echo '<div class="error-type">' . $t_error_type . '</div>';
            echo '<div class="error-description">', $t_error_description, '</div>';
            echo '<div class="error-info">';
            if (null === $g_error_proceed_url) {
                echo lang_get('error_no_proceed');
            } else {
                echo '<a href="', $g_error_proceed_url, '">', lang_get('proceed'), '</a>';
            }
            echo '</div>';
            if (ON == config_get_global('show_detailed_errors')) {
                echo '<div class="error-details">';
                error_print_details($p_file, $p_line, $p_context);
                echo '</div>';
                echo '<div class="error-trace">';
                error_print_stack_trace();
                echo '</div>';
            }
            echo '</div>';
            if (isset($t_old_contents)) {
                echo '<div class="warning">Previous non-fatal errors occurred.  Page contents follow.</div>';
                echo '<div id="old-contents">';
                echo $t_old_contents;
                echo '</div>';
            }
            if ($t_html_api) {
                if ($p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true) {
                    html_page_bottom();
                } else {
                    html_body_end();
                    html_end();
                }
            } else {
                echo '</body></html>', "\n";
            }
            exit;
        case DISPLAY_ERROR_INLINE:
            echo '<div class="error-inline">', $t_error_type, ': ', $t_error_description, '</div>';
            $g_error_handled = true;
            break;
        default:
            # do nothing - note we treat this as we've not handled an error, so any redirects go through.
    }
    if ($t_lang_pushed) {
        lang_pop();
    }
    $g_error_parameters = array();
    $g_error_proceed_url = null;
}