Changeset 6020
- Timestamp:
- 02/05/12 20:12:23 (4 months ago)
- File:
-
- 1 edited
-
trunk/core/errorhandler.core.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/errorhandler.core.php
r6006 r6020 91 91 * @link http://php.net/manual/de/errorfunc.constants.php 92 92 */ 93 $errorTypes = array ( 1 => 'E_ERROR', # fatal run-time errors, like php is failing memory allocation 94 2 => 'E_WARNING', # Run-time warnings (non-fatal errors) 95 4 => 'E_PARSE', # compile-time parse errors - generated by the parser 96 8 => 'E_NOTICE', # Run-time notices (could be an indicator for an error) 97 16 => 'E_CORE_ERROR', # PHP Core reports errors in PHP's initial startup 98 32 => 'E_CORE_WARNING', # PHP Core reports warning (non-fatal errors) 99 64 => 'E_COMPILE_ERROR', # Zend Script Engine reports fatal compile-time errors 100 128 => 'E_COMPILE_WARNING', # Zend Script Engine reports compile-time warnings (non-fatal errors) 101 256 => 'E_USER_ERROR', # trigger_error() / user_error() reports user-defined error 102 512 => 'E_USER_WARNING', # trigger_error() / user_error() reports user-defined warning 103 1024 => 'E_USER_NOTICE', # trigger_error() / user_error() reports user-defined notice 104 #2047 => 'E_ALL 2047 PHP <5.2.x', # all errors and warnings + old value of E_ALL of PHP Version below 5.2.x 105 2048 => 'E_STRICT', # PHP suggests codechanges to ensure interoperability / forwad compat 106 4096 => 'E_RECOVERABLE_ERROR', # catchable fatal error, if not catched it's an e_error (since PHP 5.2.0) 107 #6143 => 'E_ALL 6143 PHP5.2.x', # all errors and warnings + old value of E_ALL of PHP Version 5.2.x 108 8191 => 'E_ALL 8191', # PHP 6 -> 8191 109 8192 => 'E_DEPRECATED', # notice marker for 'in future' deprecated php-functions (since PHP 5.3.0) 110 16384 => 'E_USER_DEPRECATED', # trigger_error() / user_error() reports user-defined deprecated functions 111 30719 => 'E_ALL 30719 PHP5.3.x', # all errors and warnings - E_ALL of PHP Version 5.3.x 112 32767 => 'E_ALL 32767 PHP6' # all errors and warnings - E_ALL of PHP Version 6 113 ); 93 $errorTypes = array ( 94 1 => 'E_ERROR', # fatal run-time errors, like php is failing memory allocation 95 2 => 'E_WARNING', # Run-time warnings (non-fatal errors) 96 4 => 'E_PARSE', # compile-time parse errors - generated by the parser 97 8 => 'E_NOTICE', # Run-time notices (could be an indicator for an error) 98 16 => 'E_CORE_ERROR', # PHP Core reports errors in PHP's initial startup 99 32 => 'E_CORE_WARNING', # PHP Core reports warning (non-fatal errors) 100 64 => 'E_COMPILE_ERROR', # Zend Script Engine reports fatal compile-time errors 101 128 => 'E_COMPILE_WARNING', # Zend Script Engine reports compile-time warnings (non-fatal errors) 102 256 => 'E_USER_ERROR', # trigger_error() / user_error() reports user-defined error 103 512 => 'E_USER_WARNING', # trigger_error() / user_error() reports user-defined warning 104 1024 => 'E_USER_NOTICE', # trigger_error() / user_error() reports user-defined notice 105 #2047 => 'E_ALL 2047 PHP <5.2.x', # all errors and warnings + old value of E_ALL of PHP Version below 5.2.x 106 2048 => 'E_STRICT', # PHP suggests codechanges to ensure interoperability / forwad compat 107 4096 => 'E_RECOVERABLE_ERROR', # catchable fatal error, if not catched it's an e_error (since PHP 5.2.0) 108 #6143 => 'E_ALL 6143 PHP5.2.x', # all errors and warnings + old value of E_ALL of PHP Version 5.2.x 109 8191 => 'E_ALL 8191', # PHP 6 -> 8191 110 8192 => 'E_DEPRECATED', # notice marker for 'in future' deprecated php-functions (since PHP 5.3.0) 111 16384 => 'E_USER_DEPRECATED', # trigger_error() / user_error() reports user-defined deprecated functions 112 30719 => 'E_ALL 30719 PHP5.3.x', # all errors and warnings - E_ALL of PHP Version 5.3.x 113 32767 => 'E_ALL 32767 PHP6' # all errors and warnings - E_ALL of PHP Version 6 114 ); 114 115 115 116 # check if the error number exists in the errortypes array … … 160 161 if ( defined('DEBUG') and DEBUG == 1 ) 161 162 { 162 # SMARTY ERRORS are thrown by trigger_error() - so they bubble up as E_USER_ERROR 163 # and in order to handle smarty errors with a seperated error display 164 # we need to detect, if an E_USER_ERROR is incoming from SMARTY or from a template_c file (extension tpl.php) 163 /** 164 * SMARTY ERRORS are thrown by trigger_error() - so they bubble up as E_USER_ERROR. 165 * 166 * In order to handle smarty errors with an seperated error display, 167 * we need to detect, if an E_USER_ERROR is either incoming from 168 * SMARTY or from a template_c file (extension tpl.php). 169 */ 165 170 if( (true === (bool) mb_strpos(mb_strtolower($errorfile),'smarty')) or 166 171 (true === (bool) mb_strpos(mb_strtolower($errorfile),'tpl.php')) ) … … 202 207 * @param string $errorline contains the line of error 203 208 * @param $errorcontext $errorline contains context 209 * @return string HTML with Smarty Error Text and Link. 204 210 */ 205 211 private static function smarty_error_display( $errornumber, $errorname, $errorstring, $errorfile, $errorline, $errorcontext ) 206 212 { 207 # small errorreport 208 $errormessage = ''; 209 $errormessage .= '<span>'; 210 $errormessage .= '<h3><font color="#ff0000">» Smarty Template Error «</font></h3>'; 211 $errormessage .= '<u>'. $errorname . ' (' . $errornumber .'): </u><br/>'; 212 $errormessage .= '<b>'. wordwrap($errorstring,50,"\n") .'</b><br/>'; 213 $errormessage .= 'File: '. $errorfile. '<br/>Line: ' .$errorline; 214 $errormessage .= self::getTemplateEditorLink($errorfile, $errorline, $errorcontext); 215 $errormessage .= '<br/></span>'; 216 217 return $errormessage; 213 $html = ''; 214 $html .= '<span>'; 215 $html .= '<h3><font color="#ff0000">» Smarty Template Error «</font></h3>'; 216 $html .= '<u>'. $errorname . ' (' . $errornumber .'): </u><br/>'; 217 $html .= '<b>'. wordwrap($errorstring,50,"\n") .'</b><br/>'; 218 $html .= 'File: '. $errorfile. '<br/>Line: ' .$errorline; 219 $html .= self::getTemplateEditorLink($errorfile, $errorline, $errorcontext); 220 $html .= '<br/></span>'; 221 222 return $html; 218 223 } 219 224 … … 279 284 280 285 # Header 281 $ errormessage= '<html><head>';282 $ errormessage.= '<title>Clansuite Error | ' . $trimed_errorstring . ' | Code: ' . $errornumber . '</title>';283 $ errormessage.= '<link rel="stylesheet" href="' . WWW_ROOT_THEMES_CORE . 'css/error.css" type="text/css" />';284 $ errormessage.= '</head>';286 $html = '<html><head>'; 287 $html .= '<title>Clansuite Error | ' . $trimed_errorstring . ' | Code: ' . $errornumber . '</title>'; 288 $html .= '<link rel="stylesheet" href="' . WWW_ROOT_THEMES_CORE . 'css/error.css" type="text/css" />'; 289 $html .= '</head>'; 285 290 286 291 # Body 287 $ errormessage.= '<body>';292 $html .= '<body>'; 288 293 289 294 # Fieldset colored 290 $ errormessage.= '<fieldset class="error_red">';295 $html .= '<fieldset class="error_red">'; 291 296 292 297 # Errorlogo 293 $ errormessage.= '<div style="float: left; margin: 5px; margin-right: 25px; padding: 20px;">';294 $ errormessage.= '<img src="' . WWW_ROOT_THEMES_CORE . 'images/Clansuite-Toolbar-Icon-64-error.png" style="border: 2px groove #000000;"/></div>';298 $html .= '<div style="float: left; margin: 5px; margin-right: 25px; padding: 20px;">'; 299 $html .= '<img src="' . WWW_ROOT_THEMES_CORE . 'images/Clansuite-Toolbar-Icon-64-error.png" style="border: 2px groove #000000;"/></div>'; 295 300 296 301 # Fieldset Legend 297 $ errormessage.= '<legend>Clansuite Error [ ' . $trimed_errorstring . ' ] </legend>';302 $html .= '<legend>Clansuite Error [ ' . $trimed_errorstring . ' ] </legend>'; 298 303 299 304 # Error Messages 300 $ errormessage.= '<table>';301 $ errormessage.= '<tr><td>';305 $html .= '<table>'; 306 $html .= '<tr><td>'; 302 307 303 308 # The inner Error Table 304 $ errormessage.= '<table>';305 $ errormessage.= '<tr><td colspan="2"><h3>Error [' . $errorstring . ']</h3></td></tr>';306 $ errormessage.= '<tr><td width="25%"><strong>Type: </strong></td><td>' . $errorname . ' '. $errornumber . '</td></tr>';307 $ errormessage.= '<tr><td><strong>Path: </strong></td><td>' . dirname($errorfile) . '</td></tr>';308 $ errormessage.= '<tr><td><strong>File: </strong></td><td>' . basename($errorfile) . '</td></tr>';309 $ errormessage.= '<tr><td><strong>Line: </strong></td><td>' . $errorline . '</td></tr>';310 $ errormessage.= '</table>';309 $html .= '<table>'; 310 $html .= '<tr><td colspan="2"><h3>Error [' . $errorstring . ']</h3></td></tr>'; 311 $html .= '<tr><td width="25%"><strong>Type: </strong></td><td>' . $errorname . ' '. $errornumber . '</td></tr>'; 312 $html .= '<tr><td><strong>Path: </strong></td><td>' . dirname($errorfile) . '</td></tr>'; 313 $html .= '<tr><td><strong>File: </strong></td><td>' . basename($errorfile) . '</td></tr>'; 314 $html .= '<tr><td><strong>Line: </strong></td><td>' . $errorline . '</td></tr>'; 315 $html .= '</table>'; 311 316 312 317 # Error Context 313 $ errormessage.= '<tr><td colspan="2"><h3>Context</h3>';314 $ errormessage.= self::getErrorContext($errorfile, $errorline, 8) . '</td></tr>';318 $html .= '<tr><td colspan="2"><h3>Context</h3>'; 319 $html .= self::getErrorContext($errorfile, $errorline, 8) . '</td></tr>'; 315 320 316 321 # Add Debug Backtracing 317 $ errormessage.= '<tr><td>' . self::getDebugBacktrace($trimed_errorstring) . '</td></tr>';322 $html .= '<tr><td>' . self::getDebugBacktrace($trimed_errorstring) . '</td></tr>'; 318 323 319 324 # … … 321 326 322 327 # Environmental Informations at Errortime ( $errorcontext is not displayed ) 323 $ errormessage.= '<tr><td><table width="95%">';324 $ errormessage.= '<tr><td colspan="2"><h3>Server Environment</h3></td></tr>';325 $ errormessage.= '<tr><td><strong>Date: </strong></td><td>' . date('r') . '</td></tr>';326 $ errormessage.= '<tr><td><strong>Remote: </strong></td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>';327 $ errormessage.= '<tr><td><strong>Request: </strong></td><td>' . htmlentities($_SERVER['QUERY_STRING'], ENT_QUOTES) . '</td></tr>';328 $ errormessage.= '<tr><td><strong>PHP: </strong></td><td>' . PHP_VERSION .' '. PHP_EXTRA_VERSION . '</td></tr>';329 $ errormessage.= '<tr><td><strong>Server: </strong></td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>';330 $ errormessage.= '<tr><td><strong>Agent: </strong></td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>';331 $ errormessage.= '<tr><td><strong>Clansuite: </strong></td><td>' . CLANSUITE_VERSION . ' ' . CLANSUITE_VERSION_STATE;332 $ errormessage.= ' (' . CLANSUITE_VERSION_NAME . ') [Revision #' . CLANSUITE_REVISION . ']</td></tr>';333 $ errormessage.= '</table>';328 $html .= '<tr><td><table width="95%">'; 329 $html .= '<tr><td colspan="2"><h3>Server Environment</h3></td></tr>'; 330 $html .= '<tr><td><strong>Date: </strong></td><td>' . date('r') . '</td></tr>'; 331 $html .= '<tr><td><strong>Remote: </strong></td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>'; 332 $html .= '<tr><td><strong>Request: </strong></td><td>' . htmlentities($_SERVER['QUERY_STRING'], ENT_QUOTES) . '</td></tr>'; 333 $html .= '<tr><td><strong>PHP: </strong></td><td>' . PHP_VERSION .' '. PHP_EXTRA_VERSION . '</td></tr>'; 334 $html .= '<tr><td><strong>Server: </strong></td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>'; 335 $html .= '<tr><td><strong>Agent: </strong></td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>'; 336 $html .= '<tr><td><strong>Clansuite: </strong></td><td>' . CLANSUITE_VERSION . ' ' . CLANSUITE_VERSION_STATE; 337 $html .= ' (' . CLANSUITE_VERSION_NAME . ') [Revision #' . CLANSUITE_REVISION . ']</td></tr>'; 338 $html .= '</table>'; 334 339 335 340 # Backlink to Bugtracker with Errormessage -> http://trac.clansuite.com/newticket 336 $ errormessage.= self::getBugtrackerMessage($errorstring, $errorfile, $errorline, $errorcontext);341 $html .= self::getBugtrackerMessage($errorstring, $errorfile, $errorline, $errorcontext); 337 342 338 343 # close html elements: table 339 $ errormessage.= '</table>';344 $html .= '</table>'; 340 345 341 346 # Footer with Support-Backlinks 342 $ errormessage.= Clansuite_Errorhandler::getSupportBacklinks();347 $html .= Clansuite_Errorhandler::getSupportBacklinks(); 343 348 344 349 # close all html elements: fieldset, body+page 345 $ errormessage.= '</fieldset><br /><br />';346 $ errormessage.= '</body></html>';350 $html .= '</fieldset><br /><br />'; 351 $html .= '</body></html>'; 347 352 348 353 # Output the errormessage 349 return $ errormessage;354 return $html; 350 355 } 351 356 … … 357 362 * @return string $backtrace_string contains the backtrace 358 363 */ 359 public static function getDebugBacktrace($ backtrace = null)364 public static function getDebugBacktrace($trace = null) 360 365 { 361 366 # provide backtrace only when we are in Clansuite DEBUG Mode, otherwise just return … … 366 371 367 372 # if a trace is incoming, then this trace comes from an exception 368 if(isset($ backtrace) === false)373 if(isset($trace) === false) 369 374 { 370 375 # else (normally) the errorhandler has to fetch the backtrace 371 $ backtrace = debug_backtrace();376 $trace = debug_backtrace(); 372 377 373 378 /** … … 380 385 * 3) trigger_error() [php core function call] 381 386 */ 382 $ backtrace = array_slice($backtrace, 3);387 $trace = array_slice($trace, 3); 383 388 } 384 389 385 390 # prepare a new backtrace_string 386 $ backtrace_string= '';387 $ backtrace_string.= '<tr><td width="95%"><h3>Backtrace</h3>';388 $ backtrace_string.= '<table class="cs-backtrace-table" width="95%">';391 $trace_html = ''; 392 $trace_html .= '<tr><td width="95%"><h3>Backtrace</h3>'; 393 $trace_html .= '<table class="cs-backtrace-table" width="95%">'; 389 394 390 395 # table row 1 - header 391 $ backtrace_string.= '<tr><th width="2%">Callstack</th><th>Function (recent function calls last)</th><th width="40%">Location</th></tr>';392 393 $backtraces_count = count($ backtrace)-1;396 $trace_html .= '<tr><th width="2%">Callstack</th><th>Function (recent function calls last)</th><th width="40%">Location</th></tr>'; 397 398 $backtraces_count = count($trace)-1; 394 399 for($i = 0; $i <= $backtraces_count; $i++) 395 400 { 396 $ backtrace_string.= '<tr>';401 $trace_html .= '<tr>'; 397 402 398 403 # Call # 399 $ backtrace_string.= '<td align="center">'.(($backtraces_count-$i)+1).'</td>';400 401 if(isset($ backtrace[$i]['class']) === false)402 { 403 $ backtrace_string.= '<td>[PHP Core Function called]</td>';404 $trace_html .= '<td align="center">'.(($backtraces_count-$i)+1).'</td>'; 405 406 if(isset($trace[$i]['class']) === false) 407 { 408 $trace_html .= '<td>[PHP Core Function called]</td>'; 404 409 } 405 410 else 406 411 { 407 $ backtrace_string .= '<td>' . $backtrace[$i]['class'] . '::' . $backtrace[$i]['function'] . '(';408 409 if(true === isset($ backtrace[$i]['args']) and empty($backtrace[$i]['args']) === false)412 $trace_html .= '<td>' . $trace[$i]['class'] . '::' . $trace[$i]['function'] . '('; 413 414 if(true === isset($trace[$i]['args']) and empty($trace[$i]['args']) === false) 410 415 { 411 $backtrace_counter_j = count($ backtrace[$i]['args']) - 1;416 $backtrace_counter_j = count($trace[$i]['args']) - 1; 412 417 for($j = 0; $j <= $backtrace_counter_j; $j++) 413 418 { 414 $ backtrace_string .= self::formatBacktraceArgument($backtrace[$i]['args'][$j]);419 $trace_html .= self::formatBacktraceArgument($trace[$i]['args'][$j]); 415 420 416 421 # if we have several arguments to loop over … … 418 423 { 419 424 # we split them by comma 420 $ backtrace_string.= ', ';425 $trace_html .= ', '; 421 426 } 422 427 } 423 428 } 424 429 425 $ backtrace_string.= ')</td>';426 } 427 428 if(true === isset($ backtrace[$i]['file']))429 { 430 $ backtrace_string .= '<td>' . self::getFileLink($backtrace[$i]['file'], $backtrace[$i]['line']) . '</td>';430 $trace_html .= ')</td>'; 431 } 432 433 if(true === isset($trace[$i]['file'])) 434 { 435 $trace_html .= '<td>' . self::getFileLink($trace[$i]['file'], $trace[$i]['line']) . '</td>'; 431 436 } 432 437 433 438 # spacer 434 $ backtrace_string.= '</tr>';439 $trace_html .= '</tr>'; 435 440 } 436 441 437 442 # spacer 438 $ backtrace_string.= '</table></td></tr>';443 $trace_html .= '</table></td></tr>'; 439 444 440 445 # returns the Backtrace String 441 return $ backtrace_string;446 return $trace_html; 442 447 } 443 448
Note: See TracChangeset
for help on using the changeset viewer.
