. #------------------------------ # $Revision: 2643 $ # $Author: al $ # $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $ #------------------------------ ### Error API ### # set up error_handler() as the new default error handling function set_error_handler( 'error_handler' ); ######################################### # SECURITY NOTE: these globals are initialized here to prevent them # being spoofed if register_globals is turned on # $g_error_parameters = array(); $g_error_handled = false; $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 # 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 "
$t_error_description
"; PRINT ''; if ( null === $g_error_proceed_url ) { PRINT lang_get( 'error_no_proceed' ); } else { PRINT "" . lang_get( 'proceed' ) . ''; } PRINT '
'; if ( ON == config_get( 'show_detailed_errors' ) ) { PRINT 'Previous non-fatal errors occurred. Page contents follow.
'; PRINT '$t_error_type: $t_error_description
"; } else { # do nothing } if ( $t_lang_pushed ) { lang_pop(); } $g_error_parameters = array(); $g_error_handled = true; $g_error_proceed_url = null; } # --------------- # Print out the error details including context function error_print_details( $p_file, $p_line, $p_context ) { ?>Full path: |
Line: |
' . string_html_entities( $t_frame['file'] ) . ' | ' . $t_frame['line'] . ' | ' . ( isset( $t_frame['function'] ) ? $t_frame['function'] : '???' ) . ' | '; $t_args = array(); if ( isset( $t_frame['params'] ) ) { foreach( $t_frame['params'] as $t_value ) { $t_args[] = error_build_parameter_string( $t_value ); } } PRINT '( ' . string_html_entities( implode( $t_args, ', ' ) ) . ' ) |
Filename | Line | Function | Args |
---|---|---|---|
' . string_html_entities( $t_frame['file'] ) . ' | ' . (isset( $t_frame['line'] ) ? $t_frame['line'] : '-') . ' | ' . $t_frame['function'] . ' | '; $t_args = array(); if ( isset( $t_frame['args'] ) ) { foreach( $t_frame['args'] as $t_value ) { $t_args[] = error_build_parameter_string( $t_value ); } } PRINT '( ' . string_html_entities( implode( $t_args, ', ' ) ) . ' ) |