mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/10369] DRY code to remove phpbb path from errfile.
PHPBB3-10369
This commit is contained in:
parent
7b3f6cb219
commit
9006984d5a
2 changed files with 24 additions and 6 deletions
|
@ -42,8 +42,6 @@ class phpbb_error_collector
|
||||||
|
|
||||||
function format_errors()
|
function format_errors()
|
||||||
{
|
{
|
||||||
$phpbb_root_path = phpbb_realpath(dirname(__FILE__) . '/../');
|
|
||||||
|
|
||||||
$text = '';
|
$text = '';
|
||||||
foreach ($this->errors as $error)
|
foreach ($this->errors as $error)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +53,7 @@ class phpbb_error_collector
|
||||||
list($errno, $msg_text, $errfile, $errline) = $error;
|
list($errno, $msg_text, $errfile, $errline) = $error;
|
||||||
|
|
||||||
// Prevent leakage of local path to phpBB install
|
// Prevent leakage of local path to phpBB install
|
||||||
$errfile = str_replace(array($phpbb_root_path, '\\'), array('', '/'), $errfile);
|
$errfile = phpbb_filter_errfile($errfile);
|
||||||
|
|
||||||
$text .= "Errno $errno: $msg_text at $errfile line $errline";
|
$text .= "Errno $errno: $msg_text at $errfile line $errline";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3816,9 +3816,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
||||||
|
|
||||||
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
|
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
|
||||||
{
|
{
|
||||||
// remove complete path to installation, with the risk of changing backslashes meant to be there
|
$errfile = phpbb_filter_errfile($errfile);
|
||||||
$errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
|
$msg_text = phpbb_filter_errfile($msg_text);
|
||||||
$msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
|
|
||||||
$error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice';
|
$error_name = ($errno === E_WARNING) ? 'PHP Warning' : 'PHP Notice';
|
||||||
echo '<b>[phpBB Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
|
echo '<b>[phpBB Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
|
||||||
|
|
||||||
|
@ -3996,6 +3995,27 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes absolute path to phpBB root directory from error messages
|
||||||
|
* and converts backslashes to forward slashes.
|
||||||
|
*
|
||||||
|
* @param string $errfile Absolute file path
|
||||||
|
* (e.g. /var/www/phpbb3/phpBB/includes/functions.php)
|
||||||
|
* @return string Relative file path
|
||||||
|
* (e.g. /includes/functions.php)
|
||||||
|
*/
|
||||||
|
function phpbb_filter_errfile($errfile)
|
||||||
|
{
|
||||||
|
static $root_path;
|
||||||
|
|
||||||
|
if (empty($root_path))
|
||||||
|
{
|
||||||
|
$root_path = phpbb_realpath(dirname(__FILE__) . '/../');
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_replace(array($root_path, '\\'), array('', '/'), $errfile);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the session table to get information about online guests
|
* Queries the session table to get information about online guests
|
||||||
* @param int $item_id Limits the search to the item with this id
|
* @param int $item_id Limits the search to the item with this id
|
||||||
|
|
Loading…
Add table
Reference in a new issue