[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/phpbb/ -> error_collector.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb;
  15  
  16  class error_collector
  17  {
  18      var $errors;
  19      var $error_types;
  20  
  21      /**
  22       * Constructor.
  23       *
  24       * The variable $error_types may be set to a mask of PHP error types that
  25       * the collector should keep, e.g. `E_ALL`. If unset, the current value of
  26       * the error_reporting() function will be used to determine which errors
  27       * the collector will keep.
  28       *
  29       * @see https://tracker.phpbb.com/browse/PHPBB3-13306
  30       * @param int|null $error_types
  31       */
  32  	function __construct($error_types = null)
  33      {
  34          $this->errors = array();
  35          $this->error_types = $error_types;
  36      }
  37  
  38  	function install()
  39      {
  40          set_error_handler(array(&$this, 'error_handler'), ($this->error_types !== null) ? $this->error_types : error_reporting());
  41      }
  42  
  43  	function uninstall()
  44      {
  45          restore_error_handler();
  46      }
  47  
  48  	function error_handler($errno, $msg_text, $errfile, $errline)
  49      {
  50          $this->errors[] = array($errno, $msg_text, $errfile, $errline);
  51      }
  52  
  53  	function format_errors()
  54      {
  55          $text = '';
  56          foreach ($this->errors as $error)
  57          {
  58              if (!empty($text))
  59              {
  60                  $text .= "<br />\n";
  61              }
  62  
  63              list($errno, $msg_text, $errfile, $errline) = $error;
  64  
  65              // Prevent leakage of local path to phpBB install
  66              $errfile = phpbb_filter_root_path($errfile);
  67  
  68              $text .= "Errno $errno: $msg_text at $errfile line $errline";
  69          }
  70  
  71          return $text;
  72      }
  73  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1