From d892dfe084fda1cb48f228b0c89f20f9f2430403 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 18 Sep 2014 23:22:48 +0200 Subject: [ticket/13073] Add phpbb root path with mod rewrite enabled for proper routes PHPBB3-13073 --- phpBB/phpbb/controller/helper.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index e2932086db..5bca8edbaa 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -140,8 +140,16 @@ class helper // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url); - // We need to update the base url to move to the directory of the app.php file. - $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); + if (empty($this->config['enable_mod_rewrite'])) + { + // We need to update the base url to move to the directory of the app.php file. + $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); + } + else + { + // We need to append the phpbb_root_path for proper routes + $base_url .= preg_replace('#[\\/\\\]$#', '', preg_replace('#^\.#', '', $this->phpbb_root_path)); + } $base_url = $this->filesystem->clean_path($base_url); -- cgit v1.2.1 From eaef881e7d193f0f3fe4ce297091dd440d08e9b3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Sep 2014 12:03:04 +0200 Subject: [ticket/13073] Properly place comments in helper PHPBB3-13073 --- phpBB/phpbb/controller/helper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 5bca8edbaa..4b93cd505a 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -140,14 +140,13 @@ class helper // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url); + // We need to update the base url to move to the directory of the app.php file if (empty($this->config['enable_mod_rewrite'])) { - // We need to update the base url to move to the directory of the app.php file. $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); } else { - // We need to append the phpbb_root_path for proper routes $base_url .= preg_replace('#[\\/\\\]$#', '', preg_replace('#^\.#', '', $this->phpbb_root_path)); } -- cgit v1.2.1 From 4186ced4791cd8ea6c105d462f361be15eaff218 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Sep 2014 12:14:57 +0200 Subject: [ticket/13073] Use just one regex in helper route() PHPBB3-13073 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 4b93cd505a..6c78868dbb 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -147,7 +147,7 @@ class helper } else { - $base_url .= preg_replace('#[\\/\\\]$#', '', preg_replace('#^\.#', '', $this->phpbb_root_path)); + $base_url .= preg_replace('#^(?:(\.))+(?:(.+)?)+(?:([\\/\\\])$)#', '$2', $this->phpbb_root_path); } $base_url = $this->filesystem->clean_path($base_url); -- cgit v1.2.1 From 6fd54436ee4568cd2e70d08063a816e3ce1ff4bc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Sep 2014 13:50:56 +0200 Subject: [ticket/13073] Add path regex to get_preg_expression() and add unit tests We're now calling get_preg_expression() instead of hardcoding the regex into the helper route method. PHPBB3-13073 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 6c78868dbb..fc19b855c0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -147,7 +147,7 @@ class helper } else { - $base_url .= preg_replace('#^(?:(\.))+(?:(.+)?)+(?:([\\/\\\])$)#', '$2', $this->phpbb_root_path); + $base_url .= preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), '$2', $this->phpbb_root_path); } $base_url = $this->filesystem->clean_path($base_url); -- cgit v1.2.1