[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 // Set to 1 if receiving a blank page (template failure). 12 define("MANUAL_WARNINGS", 0); 13 14 // Define Custom MyBB error handler constants with a value not used by php's error handler. 15 define("MYBB_SQL", 20); 16 define("MYBB_TEMPLATE", 30); 17 define("MYBB_GENERAL", 40); 18 define("MYBB_NOT_INSTALLED", 41); 19 define("MYBB_NOT_UPGRADED", 42); 20 define("MYBB_INSTALL_DIR_EXISTS", 43); 21 define("MYBB_SQL_LOAD_ERROR", 44); 22 define("MYBB_CACHE_NO_WRITE", 45); 23 define("MYBB_CACHEHANDLER_LOAD_ERROR", 46); 24 25 if(!defined("E_RECOVERABLE_ERROR")) 26 { 27 // This constant has been defined since PHP 5.2. 28 define("E_RECOVERABLE_ERROR", 4096); 29 } 30 31 if(!defined("E_DEPRECATED")) 32 { 33 // This constant has been defined since PHP 5.3. 34 define("E_DEPRECATED", 8192); 35 } 36 37 if(!defined("E_USER_DEPRECATED")) 38 { 39 // This constant has been defined since PHP 5.3. 40 define("E_USER_DEPRECATED", 16384); 41 } 42 43 class errorHandler { 44 45 /** 46 * Array of all of the error types 47 * 48 * @var array 49 */ 50 public $error_types = array( 51 E_ERROR => 'Error', 52 E_WARNING => 'Warning', 53 E_PARSE => 'Parsing Error', 54 E_NOTICE => 'Notice', 55 E_CORE_ERROR => 'Core Error', 56 E_CORE_WARNING => 'Core Warning', 57 E_COMPILE_ERROR => 'Compile Error', 58 E_COMPILE_WARNING => 'Compile Warning', 59 E_DEPRECATED => 'Deprecated Warning', 60 E_USER_ERROR => 'User Error', 61 E_USER_WARNING => 'User Warning', 62 E_USER_NOTICE => 'User Notice', 63 E_USER_DEPRECATED => 'User Deprecated Warning', 64 E_STRICT => 'Runtime Notice', 65 E_RECOVERABLE_ERROR => 'Catchable Fatal Error', 66 MYBB_SQL => 'MyBB SQL Error', 67 MYBB_TEMPLATE => 'MyBB Template Error', 68 MYBB_GENERAL => 'MyBB Error', 69 MYBB_NOT_INSTALLED => 'MyBB Error', 70 MYBB_NOT_UPGRADED => 'MyBB Error', 71 MYBB_INSTALL_DIR_EXISTS => 'MyBB Error', 72 MYBB_SQL_LOAD_ERROR => 'MyBB Error', 73 MYBB_CACHE_NO_WRITE => 'MyBB Error', 74 MYBB_CACHEHANDLER_LOAD_ERROR => 'MyBB Error', 75 ); 76 77 /** 78 * Array of MyBB error types 79 * 80 * @var array 81 */ 82 public $mybb_error_types = array( 83 MYBB_SQL, 84 MYBB_TEMPLATE, 85 MYBB_GENERAL, 86 MYBB_NOT_INSTALLED, 87 MYBB_NOT_UPGRADED, 88 MYBB_INSTALL_DIR_EXISTS, 89 MYBB_SQL_LOAD_ERROR, 90 MYBB_CACHE_NO_WRITE, 91 MYBB_CACHEHANDLER_LOAD_ERROR, 92 ); 93 94 /** 95 * Array of all of the error types to ignore 96 * 97 * @var array 98 */ 99 public $ignore_types = array( 100 E_DEPRECATED, 101 E_NOTICE, 102 E_USER_NOTICE, 103 E_STRICT 104 ); 105 106 /** 107 * String of all the warnings collected 108 * 109 * @var string 110 */ 111 public $warnings = ""; 112 113 /** 114 * Is MyBB in an errornous state? (Have we received an error?) 115 * 116 * @var boolean 117 */ 118 public $has_errors = false; 119 120 /** 121 * Display errors regardless of related settings (useful during initialization stage) 122 * 123 * @var boolean 124 */ 125 public $force_display_errors = false; 126 127 /** 128 * Initializes the error handler 129 * 130 */ 131 function __construct() 132 { 133 // Lets set the error handler in here so we can just do $handler = new errorHandler() and be all set up. 134 $error_types = E_ALL; 135 foreach($this->ignore_types as $bit) 136 { 137 $error_types = $error_types & ~$bit; 138 } 139 error_reporting($error_types); 140 set_error_handler(array(&$this, "error_callback"), $error_types); 141 } 142 143 /** 144 * Passes relevant arguments for error processing. 145 * 146 * @param string $type The error type (i.e. E_ERROR, E_FATAL) 147 * @param string $message The error message 148 * @param string $file The error file 149 * @param integer $line The error line 150 */ 151 function error_callback($type, $message, $file=null, $line=0) 152 { 153 return $this->error($type, $message, $file, $line); 154 } 155 156 /** 157 * Processes an error. 158 * 159 * @param string $type The error type (i.e. E_ERROR, E_FATAL) 160 * @param string $message The error message 161 * @param string $file The error file 162 * @param integer $line The error line 163 * @param boolean $allow_output Whether or not output is permitted 164 * @return boolean True if parsing was a success, otherwise assume a error 165 */ 166 function error($type, $message, $file=null, $line=0, $allow_output=true) 167 { 168 global $mybb; 169 170 // Error reporting turned off for this type 171 if((error_reporting() & $type) == 0) 172 { 173 return true; 174 } 175 176 if(in_array($type, $this->ignore_types)) 177 { 178 return true; 179 } 180 181 if(isset($file)) 182 { 183 $file = str_replace(MYBB_ROOT, "", $file); 184 } 185 else 186 { 187 $file = ""; 188 } 189 190 if($type == MYBB_SQL || strpos(strtolower($this->error_types[$type]), 'warning') === false) 191 { 192 $this->has_errors = true; 193 } 194 195 // For some reason in the installer this setting is set to "<" 196 $accepted_error_types = array('both', 'error', 'warning', 'none'); 197 if(isset($mybb->settings['errortypemedium']) && in_array($mybb->settings['errortypemedium'], $accepted_error_types)) 198 { 199 $errortypemedium = $mybb->settings['errortypemedium']; 200 } 201 else 202 { 203 $errortypemedium = "none"; 204 } 205 206 if(isset($mybb->settings['errorlogmedium'])) 207 { 208 $errorlogmedium = $mybb->settings['errorlogmedium']; 209 } 210 else 211 { 212 $errorlogmedium = 'none'; 213 } 214 215 if(defined("IN_TASK")) 216 { 217 global $task; 218 219 require_once MYBB_ROOT."inc/functions_task.php"; 220 221 $filestr = ''; 222 if($file) 223 { 224 $filestr = " - Line: $line - File: $file"; 225 } 226 227 add_task_log($task, "{$this->error_types[$type]} - [$type] ".var_export($message, true)."{$filestr}"); 228 } 229 230 // Saving error to log file. 231 if($errorlogmedium == "log" || $errorlogmedium == "both") 232 { 233 $this->log_error($type, $message, $file, $line); 234 } 235 236 // Are we emailing the Admin a copy? 237 if($errorlogmedium == "mail" || $errorlogmedium == "both") 238 { 239 $this->email_error($type, $message, $file, $line); 240 } 241 242 if($allow_output === true) 243 { 244 // SQL Error 245 if($type == MYBB_SQL) 246 { 247 $this->output_error($type, $message, $file, $line); 248 } 249 // PHP Error 250 elseif(strpos(strtolower($this->error_types[$type]), 'warning') === false) 251 { 252 $this->output_error($type, $message, $file, $line); 253 } 254 // PHP Warning 255 elseif(in_array($errortypemedium, array('warning', 'both'))) 256 { 257 global $templates; 258 259 $warning = "<strong>{$this->error_types[$type]}</strong> [$type] $message - Line: $line - File: $file PHP ".PHP_VERSION." (".PHP_OS.")<br />\n"; 260 if(is_object($templates) && method_exists($templates, "get") && !defined("IN_ADMINCP")) 261 { 262 $this->warnings .= $warning; 263 $this->warnings .= $this->generate_backtrace(); 264 } 265 else 266 { 267 echo "<div class=\"php_warning\">{$warning}".$this->generate_backtrace()."</div>"; 268 } 269 } 270 } 271 272 return true; 273 } 274 275 /** 276 * Returns all the warnings 277 * 278 * @return string|bool The warnings or false if no warnings exist 279 */ 280 function show_warnings() 281 { 282 global $lang, $templates; 283 284 if(empty($this->warnings)) 285 { 286 return false; 287 } 288 289 // Incase a template fails and we're receiving a blank page. 290 if(MANUAL_WARNINGS) 291 { 292 echo $this->warnings."<br />"; 293 } 294 295 if(!$lang->warnings) 296 { 297 $lang->warnings = "The following warnings occurred:"; 298 } 299 300 $template_exists = false; 301 302 if(!is_object($templates) || !method_exists($templates, 'get')) 303 { 304 if(@file_exists(MYBB_ROOT."inc/class_templates.php")) 305 { 306 @require_once MYBB_ROOT."inc/class_templates.php"; 307 $templates = new templates; 308 $template_exists = true; 309 } 310 } 311 else 312 { 313 $template_exists = true; 314 } 315 316 $warning = ''; 317 if($template_exists == true) 318 { 319 eval("\$warning = \"".$templates->get("php_warnings")."\";"); 320 } 321 322 return $warning; 323 } 324 325 /** 326 * Triggers a user created error 327 * Example: $error_handler->trigger("Some Warning", E_USER_ERROR); 328 * 329 * @param string $message Message 330 * @param string|int $type Type 331 */ 332 function trigger($message="", $type=E_USER_ERROR) 333 { 334 global $lang; 335 336 if(!$message) 337 { 338 if(isset($lang->unknown_user_trigger)) 339 { 340 $message = $lang->unknown_user_trigger; 341 } 342 else 343 { 344 $message .= 'An unknown error has been triggered.'; 345 } 346 } 347 348 if(in_array($type, $this->mybb_error_types)) 349 { 350 $this->error($type, $message); 351 } 352 else 353 { 354 trigger_error($message, $type); 355 } 356 } 357 358 /** 359 * Logs the error in the specified error log file. 360 * 361 * @param string $type Warning type 362 * @param string $message Warning message 363 * @param string $file Warning file 364 * @param integer $line Warning line 365 */ 366 function log_error($type, $message, $file, $line) 367 { 368 global $mybb; 369 370 if($type == MYBB_SQL) 371 { 372 $message = "SQL Error: {$message['error_no']} - {$message['error']}\nQuery: {$message['query']}"; 373 } 374 375 // Do not log something that might be executable 376 $message = str_replace('<?', '< ?', $message); 377 378 $back_trace = $this->generate_backtrace(false, 2); 379 380 if($back_trace) 381 { 382 $back_trace = "\t<back_trace>{$back_trace}</back_trace>\n"; 383 } 384 385 $error_data = "<error>\n"; 386 $error_data .= "\t<dateline>".TIME_NOW."</dateline>\n"; 387 $error_data .= "\t<script>".$file."</script>\n"; 388 $error_data .= "\t<line>".$line."</line>\n"; 389 $error_data .= "\t<type>".$type."</type>\n"; 390 $error_data .= "\t<friendly_type>".$this->error_types[$type]."</friendly_type>\n"; 391 $error_data .= "\t<message>".$message."</message>\n"; 392 $error_data .= $back_trace; 393 $error_data .= "</error>\n\n"; 394 395 if( 396 isset($mybb->settings['errorloglocation']) && 397 trim($mybb->settings['errorloglocation']) != "" && 398 substr($mybb->settings['errorloglocation'], -4) !== '.php' 399 ) 400 { 401 @error_log($error_data, 3, $mybb->settings['errorloglocation']); 402 } 403 else 404 { 405 @error_log($error_data, 0); 406 } 407 } 408 409 /** 410 * Emails the error in the specified error log file. 411 * 412 * @param string $type Warning type 413 * @param string $message Warning message 414 * @param string $file Warning file 415 * @param integer $line Warning line 416 * @return bool returns false if no admin email is set 417 */ 418 function email_error($type, $message, $file, $line) 419 { 420 global $mybb; 421 422 if(empty($mybb->settings['adminemail'])) 423 { 424 return false; 425 } 426 427 if($type == MYBB_SQL) 428 { 429 $message = "SQL Error: {$message['error_no']} - {$message['error']}\nQuery: {$message['query']}"; 430 } 431 432 if(function_exists('debug_backtrace')) 433 { 434 ob_start(); 435 debug_print_backtrace(); 436 $trace = ob_get_contents(); 437 ob_end_clean(); 438 439 $back_trace = "\nBack Trace: {$trace}"; 440 } 441 else 442 { 443 $back_trace = ''; 444 } 445 446 $message = "Your copy of MyBB running on {$mybb->settings['bbname']} ({$mybb->settings['bburl']}) has experienced an error. Details of the error include:\n---\nType: $type\nFile: $file (Line no. $line)\nMessage\n$message{$back_trace}"; 447 448 @my_mail($mybb->settings['adminemail'], "MyBB error on {$mybb->settings['bbname']}", $message, $mybb->settings['adminemail']); 449 450 return true; 451 } 452 453 /** 454 * @param string $type 455 * @param string $message 456 * @param string $file 457 * @param int $line 458 */ 459 function output_error($type, $message, $file, $line) 460 { 461 global $mybb, $parser, $lang; 462 463 if(isset($mybb->settings['bbname'])) 464 { 465 $bbname = $mybb->settings['bbname']; 466 } 467 else 468 { 469 $bbname = "MyBB"; 470 } 471 472 // For some reason in the installer this setting is set to "<" 473 $accepted_error_types = array('both', 'error', 'warning', 'none'); 474 if(isset($mybb->settings['errortypemedium']) && in_array($mybb->settings['errortypemedium'], $accepted_error_types)) 475 { 476 $errortypemedium = $mybb->settings['errortypemedium']; 477 } 478 else 479 { 480 $errortypemedium = "none"; 481 } 482 483 $show_details = ( 484 $this->force_display_errors || 485 in_array($errortypemedium, array('both', 'error')) || 486 defined("IN_INSTALL") || 487 defined("IN_UPGRADE") 488 ); 489 490 if($type == MYBB_SQL) 491 { 492 $title = "MyBB SQL Error"; 493 $error_message = "<p>MyBB has experienced an internal SQL error and cannot continue.</p>"; 494 if($show_details) 495 { 496 $message['query'] = htmlspecialchars_uni($message['query']); 497 $message['error'] = htmlspecialchars_uni($message['error']); 498 $error_message .= "<dl>\n"; 499 $error_message .= "<dt>SQL Error:</dt>\n<dd>{$message['error_no']} - {$message['error']}</dd>\n"; 500 if($message['query'] != "") 501 { 502 $error_message .= "<dt>Query:</dt>\n<dd>{$message['query']}</dd>\n"; 503 } 504 $error_message .= "</dl>\n"; 505 } 506 } 507 else 508 { 509 $title = "MyBB Internal Error"; 510 $error_message = "<p>MyBB has experienced an internal error and cannot continue.</p>"; 511 if($show_details) 512 { 513 $error_message .= "<dl>\n"; 514 $error_message .= "<dt>Error Type:</dt>\n<dd>{$this->error_types[$type]} ($type)</dd>\n"; 515 $error_message .= "<dt>Error Message:</dt>\n<dd>{$message}</dd>\n"; 516 if(!empty($file)) 517 { 518 $error_message .= "<dt>Location:</dt><dd>File: {$file}<br />Line: {$line}</dd>\n"; 519 if(!@preg_match('#config\.php|settings\.php#', $file) && @file_exists($file)) 520 { 521 $code_pre = @file($file); 522 523 $code = ""; 524 525 if(isset($code_pre[$line-4])) 526 { 527 $code .= $line-3 . ". ".$code_pre[$line-4]; 528 } 529 530 if(isset($code_pre[$line-3])) 531 { 532 $code .= $line-2 . ". ".$code_pre[$line-3]; 533 } 534 535 if(isset($code_pre[$line-2])) 536 { 537 $code .= $line-1 . ". ".$code_pre[$line-2]; 538 } 539 540 $code .= $line . ". ".$code_pre[$line-1]; // The actual line. 541 542 if(isset($code_pre[$line])) 543 { 544 $code .= $line+1 . ". ".$code_pre[$line]; 545 } 546 547 if(isset($code_pre[$line+1])) 548 { 549 $code .= $line+2 . ". ".$code_pre[$line+1]; 550 } 551 552 if(isset($code_pre[$line+2])) 553 { 554 $code .= $line+3 . ". ".$code_pre[$line+2]; 555 } 556 557 unset($code_pre); 558 559 $parser_exists = false; 560 561 if(!is_object($parser) || !method_exists($parser, 'mycode_parse_php')) 562 { 563 if(@file_exists(MYBB_ROOT."inc/class_parser.php")) 564 { 565 @require_once MYBB_ROOT."inc/class_parser.php"; 566 $parser = new postParser; 567 $parser_exists = true; 568 } 569 } 570 else 571 { 572 $parser_exists = true; 573 } 574 575 if($parser_exists) 576 { 577 $code = $parser->mycode_parse_php($code, true); 578 } 579 else 580 { 581 $code = @nl2br($code); 582 } 583 584 $error_message .= "<dt>Code:</dt><dd>{$code}</dd>\n"; 585 } 586 } 587 $backtrace = $this->generate_backtrace(); 588 if($backtrace && !in_array($type, $this->mybb_error_types)) 589 { 590 $error_message .= "<dt>Backtrace:</dt><dd>{$backtrace}</dd>\n"; 591 } 592 $error_message .= "</dl>\n"; 593 } 594 } 595 596 if(isset($lang->settings['charset'])) 597 { 598 $charset = $lang->settings['charset']; 599 } 600 else 601 { 602 $charset = 'UTF-8'; 603 } 604 605 $contact_site_owner = ''; 606 $is_in_contact = defined('THIS_SCRIPT') && THIS_SCRIPT === 'contact.php'; 607 if( 608 !empty($mybb->settings['contactlink']) && 609 ( 610 !empty($mybb->settings['contact']) && 611 !$is_in_contact && 612 ( 613 $mybb->settings['contactlink'] == "contact.php" && 614 ( 615 !isset($mybb->user['uid']) || 616 ($mybb->settings['contact_guests'] != 1 && $mybb->user['uid'] == 0) || 617 $mybb->user['uid'] > 0 618 ) 619 ) || 620 $mybb->settings['contactlink'] != "contact.php" 621 ) 622 ) 623 { 624 if( 625 !my_validate_url($mybb->settings['contactlink'], true, true) && 626 my_substr($mybb->settings['contactlink'], 0, 7) != 'mailto:' 627 ) 628 { 629 $mybb->settings['contactlink'] = $mybb->settings['bburl'].'/'.$mybb->settings['contactlink']; 630 } 631 632 $contact_site_owner = <<<HTML 633 If this problem persists, please <a href="{$mybb->settings['contactlink']}">contact the site owner</a>. 634 HTML; 635 } 636 637 $additional_name = ''; 638 $docs_link = 'https://docs.mybb.com'; 639 $common_issues_link = 'https://docs.mybb.com/1.8/faq/'; 640 $support_link = 'https://community.mybb.com/'; 641 642 if(isset($lang->settings['docs_link'])) 643 { 644 $docs_link = $lang->settings['docs_link']; 645 } 646 647 if(isset($lang->settings['common_issues_link'])) 648 { 649 $common_issues_link = $lang->settings['common_issues_link']; 650 } 651 652 if(isset($lang->settings['support_link'])) 653 { 654 $support_link = $lang->settings['support_link']; 655 } 656 657 658 if(isset($lang->settings['additional_name'])) 659 { 660 $additional_name = $lang->settings['additional_name']; 661 } 662 663 $contact = <<<HTML 664 <p> 665 <strong>If you're a visitor of this website</strong>, please wait a few minutes and try again.{$contact_site_owner} 666 </p> 667 668 <p> 669 <strong>If you are the site owner</strong>, please check the <a href="{$docs_link}">MyBB{$additional_name} Documentation</a> for help resolving <a href="{$common_issues_link}">common issues</a>, or get technical help on the <a href="{$support_link}">MyBB{$additional_name} Community Forums</a>. 670 </p> 671 HTML; 672 673 if(!headers_sent() && !defined("IN_INSTALL") && !defined("IN_UPGRADE")) 674 { 675 @header('HTTP/1.1 503 Service Temporarily Unavailable'); 676 @header('Status: 503 Service Temporarily Unavailable'); 677 @header('Retry-After: 1800'); 678 @header("Content-type: text/html; charset={$charset}"); 679 680 $file_name = basename($_SERVER['SCRIPT_FILENAME']); 681 if(function_exists('htmlspecialchars_uni')) 682 { 683 $file_name = htmlspecialchars_uni($file_name); 684 } 685 else 686 { 687 $file_name = htmlspecialchars($file_name); 688 } 689 690 echo <<<EOF 691 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 692 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 693 <head profile="http://gmpg.org/xfn/11"> 694 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 695 <title>{$bbname} - Internal Error</title> 696 <style type="text/css"> 697 body { background: #efefef; color: #000; font-family: Tahoma,Verdana,Arial,Sans-Serif; font-size: 12px; text-align: center; line-height: 1.4; } 698 a:link { color: #026CB1; text-decoration: none; } 699 a:visited { color: #026CB1; text-decoration: none; } 700 a:hover, a:active { color: #000; text-decoration: underline; } 701 #container { width: 600px; padding: 20px; background: #fff; border: 1px solid #e4e4e4; margin: 100px auto; text-align: left; -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } 702 h1 { margin: 0; background: url({$file_name}?action=mybb_logo) no-repeat; height: 82px; width: 248px; } 703 #content { border: 1px solid #026CB1; background: #fff; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } 704 h2 { font-size: 12px; padding: 4px; background: #026CB1; color: #fff; margin: 0; } 705 .invisible { display: none; } 706 #error { padding: 6px; } 707 #footer { font-size: 12px; border-top: 1px dotted #DDDDDD; padding-top: 10px; } 708 dt { font-weight: bold; } 709 </style> 710 </head> 711 <body> 712 <div id="container"> 713 <div id="logo"> 714 <h1><a href="https://mybb.com/" title="MyBB"><span class="invisible">MyBB</span></a></h1> 715 </div> 716 717 <div id="content"> 718 <h2>{$title}</h2> 719 720 <div id="error"> 721 {$error_message} 722 <p id="footer">{$contact}</p> 723 </div> 724 </div> 725 </div> 726 </body> 727 </html> 728 EOF; 729 } 730 else 731 { 732 echo <<<EOF 733 <style type="text/css"> 734 #mybb_error_content { border: 1px solid #026CB1; background: #fff; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } 735 #mybb_error_content a:link { color: #026CB1; text-decoration: none; } 736 #mybb_error_content a:visited { color: #026CB1; text-decoration: none; } 737 #mybb_error_content a:hover, a:active { color: #000; text-decoration: underline; } 738 #mybb_error_content h2 { font-size: 12px; padding: 4px; background: #026CB1; color: #fff; margin: 0; border-bottom: none; } 739 #mybb_error_error { padding: 6px; } 740 #mybb_error_footer { font-size: 12px; border-top: 1px dotted #DDDDDD; padding-top: 10px; } 741 #mybb_error_content dt { font-weight: bold; } 742 </style> 743 <div id="mybb_error_content"> 744 <h2>{$title}</h2> 745 <div id="mybb_error_error"> 746 {$error_message} 747 <p id="mybb_error_footer">{$contact}</p> 748 </div> 749 </div> 750 EOF; 751 } 752 753 exit(1); 754 } 755 756 /** 757 * Generates a backtrace if the server supports it. 758 * 759 * @return string The generated backtrace 760 */ 761 function generate_backtrace($html=true, $strip=1) 762 { 763 $backtrace = ''; 764 if(function_exists("debug_backtrace")) 765 { 766 $trace = debug_backtrace(1<<1 /* DEBUG_BACKTRACE_IGNORE_ARGS */); 767 768 if($html) 769 { 770 $backtrace = "<table style=\"width: 100%; margin: 10px 0; border: 1px solid #aaa; border-collapse: collapse; border-bottom: 0;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n"; 771 $backtrace .= "<thead><tr>\n"; 772 $backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">File</th>\n"; 773 $backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Line</th>\n"; 774 $backtrace .= "<th style=\"border-bottom: 1px solid #aaa; background: #ccc; padding: 4px; text-align: left; font-size: 11px;\">Function</th>\n"; 775 $backtrace .= "</tr></thead>\n<tbody>\n"; 776 } 777 778 // Strip off calls from trace 779 $trace = array_slice($trace, $strip); 780 781 $i = 0; 782 783 foreach($trace as $call) 784 { 785 if(empty($call['file'])) $call['file'] = "[PHP]"; 786 if(empty($call['line'])) $call['line'] = " "; 787 if(!empty($call['class'])) $call['function'] = $call['class'].$call['type'].$call['function']; 788 $call['file'] = str_replace(MYBB_ROOT, "/", $call['file']); 789 790 if($html) 791 { 792 $backtrace .= "<tr>\n"; 793 $backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['file']}</td>\n"; 794 $backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['line']}</td>\n"; 795 $backtrace .= "<td style=\"font-size: 11px; padding: 4px; border-bottom: 1px solid #ccc;\">{$call['function']}</td>\n"; 796 $backtrace .= "</tr>\n"; 797 } 798 else 799 { 800 $backtrace .= "#{$i} {$call['function']}() called at [{$call['file']}:{$call['line']}]\n"; 801 } 802 803 $i++; 804 } 805 806 if($html) 807 { 808 $backtrace .= "</tbody></table>\n"; 809 } 810 } 811 return $backtrace; 812 } 813 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |