2011-03-06 20:14:06 -05:00
|
|
|
<?php
|
2011-03-08 19:48:56 -05:00
|
|
|
/**
|
|
|
|
*
|
2014-05-27 20:18:06 +02:00
|
|
|
* This file is part of the phpBB Forum Software package.
|
|
|
|
*
|
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see
|
|
|
|
* the docs/CREDITS.txt file.
|
2011-03-08 19:48:56 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-09-10 14:01:09 +02:00
|
|
|
namespace phpbb;
|
|
|
|
|
|
|
|
class error_collector
|
2011-03-06 20:14:06 -05:00
|
|
|
{
|
|
|
|
var $errors;
|
|
|
|
|
2013-07-14 16:28:30 -04:00
|
|
|
function __construct()
|
2011-03-06 20:14:06 -05:00
|
|
|
{
|
|
|
|
$this->errors = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
function install()
|
|
|
|
{
|
|
|
|
set_error_handler(array(&$this, 'error_handler'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function uninstall()
|
|
|
|
{
|
|
|
|
restore_error_handler();
|
|
|
|
}
|
|
|
|
|
|
|
|
function error_handler($errno, $msg_text, $errfile, $errline)
|
|
|
|
{
|
|
|
|
$this->errors[] = array($errno, $msg_text, $errfile, $errline);
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_errors()
|
|
|
|
{
|
|
|
|
$text = '';
|
|
|
|
foreach ($this->errors as $error)
|
|
|
|
{
|
|
|
|
if (!empty($text))
|
|
|
|
{
|
|
|
|
$text .= "<br />\n";
|
|
|
|
}
|
2011-09-18 00:55:24 +02:00
|
|
|
|
2011-03-06 20:14:06 -05:00
|
|
|
list($errno, $msg_text, $errfile, $errline) = $error;
|
2011-09-18 00:55:24 +02:00
|
|
|
|
|
|
|
// Prevent leakage of local path to phpBB install
|
2011-09-18 22:32:25 +02:00
|
|
|
$errfile = phpbb_filter_root_path($errfile);
|
2011-09-18 00:55:24 +02:00
|
|
|
|
|
|
|
$text .= "Errno $errno: $msg_text at $errfile line $errline";
|
2011-03-06 20:14:06 -05:00
|
|
|
}
|
2011-09-18 00:55:24 +02:00
|
|
|
|
2011-03-06 20:14:06 -05:00
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
}
|