diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-06-09 00:48:02 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-06-09 00:48:02 +0200 |
commit | edc5908e483bbd36f7dff641039ff0d37a4fdc5a (patch) | |
tree | 7e88b7fbebb750dd89f130a1d00ec80d63cbb302 /phpBB/phpbb/path_helper.php | |
parent | 638d43d6fea5b5c3c1690b23d7cbe7b9bcef48c9 (diff) | |
download | forums-edc5908e483bbd36f7dff641039ff0d37a4fdc5a.tar forums-edc5908e483bbd36f7dff641039ff0d37a4fdc5a.tar.gz forums-edc5908e483bbd36f7dff641039ff0d37a4fdc5a.tar.bz2 forums-edc5908e483bbd36f7dff641039ff0d37a4fdc5a.tar.xz forums-edc5908e483bbd36f7dff641039ff0d37a4fdc5a.zip |
[ticket/12099] Deduplicate path generation
PHPBB3-12099
Diffstat (limited to 'phpBB/phpbb/path_helper.php')
-rw-r--r-- | phpBB/phpbb/path_helper.php | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index b206f491d0..e63aa06a57 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -174,30 +174,17 @@ class path_helper $corrections = substr_count($path_info, '/'); /* - * If the script name (e.g. phpBB/app.php) exists in the - * requestUri (e.g. phpBB/app.php/foo/template), then we - * are have a non-rewritten URL. + * If the script name (e.g. phpBB/app.php) does not exists in the + * requestUri (e.g. phpBB/app.php/foo/template), then we are rewriting + * the URL. So we must reduce the slash count by 1. */ - if (strpos($request_uri, $script_name) === 0) + if (strpos($request_uri, $script_name) !== 0) { - /* - * Append ../ to the end of the phpbb_root_path as many times - * as / exists in path_info - */ - $this->web_root_path = $this->filesystem->clean_path(str_repeat('../', $corrections) . $this->phpbb_root_path); - } - else - { - /* - * If we're here it means we're at a re-written path, so we must - * correct the relative path for web URLs. We must append ../ - * to the end of the root path as many times as / exists in path_info - * less one time (because the script, e.g. /app.php, doesn't exist in - * the URL) - */ - $this->web_root_path = $this->filesystem->clean_path(str_repeat('../', $corrections - 1) . $this->phpbb_root_path); + $corrections--; } + // Prepend ../ to the phpbb_root_path as many times as / exists in path_info + $this->web_root_path = $this->filesystem->clean_path(str_repeat('../', $corrections) . $this->phpbb_root_path); return $this->web_root_path; } |