diff options
author | Nils Adermann <naderman@naderman.de> | 2011-09-18 23:20:45 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2011-09-18 23:20:45 +0200 |
commit | 94fead702a450dbbd25b58d68d132a9e476bae44 (patch) | |
tree | fce57c5add6337eb3cc78ae9ef5504e064fe75f5 /phpBB/includes/functions.php | |
parent | eb8b1c333fac415a4c4db22559d625cc50a9f9b6 (diff) | |
parent | 1b390f0b498f1eb977dd62dc06dd5753b0c7ea65 (diff) | |
download | forums-94fead702a450dbbd25b58d68d132a9e476bae44.tar forums-94fead702a450dbbd25b58d68d132a9e476bae44.tar.gz forums-94fead702a450dbbd25b58d68d132a9e476bae44.tar.bz2 forums-94fead702a450dbbd25b58d68d132a9e476bae44.tar.xz forums-94fead702a450dbbd25b58d68d132a9e476bae44.zip |
Merge remote-tracking branch 'github-bantu/ticket/10369' into develop-olympus
* github-bantu/ticket/10369:
[ticket/10369] Replace root path with "[ROOT]" as per IRC.
[ticket/10369] Add warning about paths outside of phpBB root not being filtered
[ticket/10369] Rename filter_errfile() to filter_root_path().
[ticket/10369] DRY code to remove phpbb path from errfile.
[ticket/10369] Always include errfile and errline in format_errors().
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 628f8ee123..e01bbe36d1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3816,9 +3816,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline) 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 = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile); - $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text); + $errfile = phpbb_filter_root_path($errfile); + $msg_text = phpbb_filter_root_path($msg_text); $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"; @@ -3997,6 +3996,29 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } /** +* 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) +* Please note that if $errfile is outside of the phpBB root, +* the root path will not be found and can not be filtered. +* @return string Relative file path +* (e.g. /includes/functions.php) +*/ +function phpbb_filter_root_path($errfile) +{ + static $root_path; + + if (empty($root_path)) + { + $root_path = phpbb_realpath(dirname(__FILE__) . '/../'); + } + + return str_replace(array($root_path, '\\'), array('[ROOT]', '/'), $errfile); +} + +/** * Queries the session table to get information about online guests * @param int $item_id Limits the search to the item with this id * @param string $item The name of the item which is stored in the session table as session_{$item}_id |