From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/phpbb/controller/helper.php | 139 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 phpBB/phpbb/controller/helper.php (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php new file mode 100644 index 0000000000..74410ddfd1 --- /dev/null +++ b/phpBB/phpbb/controller/helper.php @@ -0,0 +1,139 @@ +template = $template; + $this->user = $user; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } + + /** + * Automate setting up the page and creating the response object. + * + * @param string $handle The template handle to render + * @param string $page_title The title of the page to output + * @param int $status_code The status code to be sent to the page header + * @return Response object containing rendered page + */ + public function render($template_file, $page_title = '', $status_code = 200) + { + page_header($page_title); + + $this->template->set_filenames(array( + 'body' => $template_file, + )); + + page_footer(true, false, false); + + return new Response($this->template->assign_display('body'), $status_code); + } + + /** + * Generate a URL + * + * @param string $route The route to travel + * @param mixed $params String or array of additional url parameters + * @param bool $is_amp Is url using & (true) or & (false) + * @param string $session_id Possibility to use a custom session id instead of the global one + * @return string The URL already passed through append_sid() + */ + public function url($route, $params = false, $is_amp = true, $session_id = false) + { + $route_params = ''; + if (($route_delim = strpos($route, '?')) !== false) + { + $route_params = substr($route, $route_delim); + $route = substr($route, 0, $route_delim); + } + + if (is_array($params) && !empty($params)) + { + $params = array_merge(array( + 'controller' => $route, + ), $params); + } + else if (is_string($params) && $params) + { + $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; + } + else + { + $params = array('controller' => $route); + } + + return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); + } + + /** + * Output an error, effectively the same thing as trigger_error + * + * @param string $message The error message + * @param string $code The error code (e.g. 404, 500, 503, etc.) + * @return Response A Reponse instance + */ + public function error($message, $code = 500) + { + $this->template->assign_vars(array( + 'MESSAGE_TEXT' => $message, + 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), + )); + + return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); + } +} -- cgit v1.2.1 From 913e5a1f2e847c922f8b48e2c069ba204a976e51 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 10:51:46 -0700 Subject: [ticket/11215] Make controller helper url() method use correct format PHPBB3-11215 --- phpBB/phpbb/controller/helper.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 74410ddfd1..a14354973e 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -35,6 +35,12 @@ class phpbb_controller_helper */ protected $user; + /** + * Request object + * @var phpbb_request + */ + protected $request; + /** * phpBB root path * @var string @@ -55,10 +61,11 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request $request, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; + $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -102,22 +109,16 @@ class phpbb_controller_helper $route = substr($route, 0, $route_delim); } - if (is_array($params) && !empty($params)) - { - $params = array_merge(array( - 'controller' => $route, - ), $params); - } - else if (is_string($params) && $params) - { - $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; - } - else - { - $params = array('controller' => $route); - } + $request_uri = $this->request->variable('REQUEST_URI', '', false, phpbb_request::SERVER); + $script_name = $this->request->variable('SCRIPT_NAME', '', false, phpbb_request::SERVER); + + // If the app.php file is being used (no rewrite) keep it in the URL. + // Otherwise, don't include it. + $route_prefix = $this->phpbb_root_path; + $parts = explode('/', $script_name); + $route_prefix .= strpos($request_uri, $script_name) === 0 ? array_pop($parts) . '/' : ''; - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); + return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From a1b4c6f82a01591a121d47d32c57b93870aa946a Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 12:53:37 -0700 Subject: [ticket/11215] Fix helper_url_test.php tests PHPBB3-11215 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index a14354973e..4d240f9380 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -61,7 +61,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request $request, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request_interface $request, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From 010da72f64ce325c27fb68c5c142ec01e1e53e61 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 3 Sep 2013 16:16:23 -0700 Subject: [ticket/11824] Add option for mod_rewrite PHPBB3-11824 --- phpBB/phpbb/controller/helper.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 4d240f9380..3f6ef24ce0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -36,10 +36,10 @@ class phpbb_controller_helper protected $user; /** - * Request object - * @var phpbb_request + * config object + * @var phpbb_config */ - protected $request; + protected $config; /** * phpBB root path @@ -61,11 +61,11 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request_interface $request, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, phpbb_config $config, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; - $this->request = $request; + $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -109,14 +109,12 @@ class phpbb_controller_helper $route = substr($route, 0, $route_delim); } - $request_uri = $this->request->variable('REQUEST_URI', '', false, phpbb_request::SERVER); - $script_name = $this->request->variable('SCRIPT_NAME', '', false, phpbb_request::SERVER); - - // If the app.php file is being used (no rewrite) keep it in the URL. - // Otherwise, don't include it. + // If enable_mod_rewrite is false, we not need to include app.php $route_prefix = $this->phpbb_root_path; - $parts = explode('/', $script_name); - $route_prefix .= strpos($request_uri, $script_name) === 0 ? array_pop($parts) . '/' : ''; + if (empty($this->config['enable_mod_rewrite'])) + { + $route_prefix .= 'app.' . $this->php_ext . '/'; + } return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id); } -- cgit v1.2.1 From ee44dff3be8510b55984eef9e7fa7f261333ef1e Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 13 Sep 2013 07:28:00 -0700 Subject: [ticket/11824] Fix comment wording PHPBB3-11824 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 3f6ef24ce0..50bbad5fce 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -109,7 +109,7 @@ class phpbb_controller_helper $route = substr($route, 0, $route_delim); } - // If enable_mod_rewrite is false, we not need to include app.php + // If enable_mod_rewrite is false, we need to include app.php $route_prefix = $this->phpbb_root_path; if (empty($this->config['enable_mod_rewrite'])) { -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/phpbb/controller/helper.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 74410ddfd1..f1cc29f21b 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -7,6 +7,8 @@ * */ +namespace phpbb\controller; + /** * @ignore */ @@ -21,17 +23,17 @@ use Symfony\Component\HttpFoundation\Response; * Controller helper class, contains methods that do things for controllers * @package phpBB3 */ -class phpbb_controller_helper +class helper { /** * Template object - * @var phpbb_template + * @var \phpbb\template\template */ protected $template; /** * User object - * @var phpbb_user + * @var \phpbb\user */ protected $user; @@ -50,12 +52,12 @@ class phpbb_controller_helper /** * Constructor * - * @param phpbb_template $template Template object - * @param phpbb_user $user User object + * @param \phpbb\template\template $template Template object + * @param \phpbb\user $user User object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; @@ -81,7 +83,7 @@ class phpbb_controller_helper page_footer(true, false, false); - return new Response($this->template->assign_display('body'), $status_code); + return new \Response($this->template->assign_display('body'), $status_code); } /** -- cgit v1.2.1 From fe36375a36ec4f816eb07b41630b6c9fa7ff12c8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Sep 2013 18:29:08 +0200 Subject: [ticket/11700] Fix extension loading with namespaces class loader now expects all classes to be prefixed with a backslash when resolving paths PHPBB3-11700 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 6e45374643..07483a91eb 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -91,7 +91,7 @@ class helper page_footer(true, false, false); - return new \Response($this->template->assign_display('body'), $status_code); + return new Response($this->template->assign_display('body'), $status_code); } /** -- cgit v1.2.1 From 7aa8f6461f1e85cf91931f56b95384e54fec07c2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:05:28 +0100 Subject: [task/code-sniffer] Remove the IN_PHPBB check side-effect from class files. PHPBB3-11980 --- phpBB/phpbb/controller/helper.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 07483a91eb..05a05d1e57 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -9,14 +9,6 @@ namespace phpbb\controller; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\HttpFoundation\Response; /** -- cgit v1.2.1 From 51273f6fb1421b68c1931c3960f68cd483f1ee95 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Mar 2014 12:32:38 +0100 Subject: [ticket/12090] Pass route name to url() to allow admins to change the routes PHPBB3-12090 --- phpBB/phpbb/controller/helper.php | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 05a05d1e57..daa52ec672 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -10,6 +10,8 @@ namespace phpbb\controller; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Generator\UrlGenerator; +use Symfony\Component\Routing\RequestContext; /** * Controller helper class, contains methods that do things for controllers @@ -56,13 +58,17 @@ class helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\extension\finder $finder, \phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + + $provider = new \phpbb\controller\provider(); + $this->route_collection = $provider->import_paths_from_finder($finder)->find($this->phpbb_root_path); + } /** @@ -87,21 +93,33 @@ class helper } /** - * Generate a URL + * Generate a URL to a route * - * @param string $route The route to travel - * @param mixed $params String or array of additional url parameters + * @param string $route Name of the route to travel + * @param array $params String or array of additional url parameters * @param bool $is_amp Is url using & (true) or & (false) * @param string $session_id Possibility to use a custom session id instead of the global one * @return string The URL already passed through append_sid() */ - public function url($route, $params = false, $is_amp = true, $session_id = false) + public function route($route, array $params = array(), $is_amp = true, $session_id = false) { - $route_params = ''; - if (($route_delim = strpos($route, '?')) !== false) + $anchor = ''; + if (isset($params['#'])) + { + $anchor = '#' . $params['#']; + unset($params['#']); + } + $url_generator = new UrlGenerator($this->route_collection, new RequestContext()); + $route_url = $url_generator->generate($route, $params); + + if (strpos($route_url, '/') === 0) + { + $route_url = substr($route_url, 1); + } + + if ($is_amp) { - $route_params = substr($route, $route_delim); - $route = substr($route, 0, $route_delim); + $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url); } // If enable_mod_rewrite is false, we need to include app.php @@ -111,7 +129,7 @@ class helper $route_prefix .= 'app.' . $this->php_ext . '/'; } - return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id); + return append_sid($route_prefix . $route_url . $anchor, false, $is_amp, $session_id); } /** -- cgit v1.2.1 From 07c07171f9b70a49b592473b8a8400d3838333a3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Mar 2014 16:32:43 +0100 Subject: [ticket/12090] Make provider a service and inject it into the helper PHPBB3-12090 --- phpBB/phpbb/controller/helper.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index daa52ec672..c97e0883f4 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -58,16 +58,14 @@ class helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(\phpbb\extension\finder $finder, \phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - - $provider = new \phpbb\controller\provider(); - $this->route_collection = $provider->import_paths_from_finder($finder)->find($this->phpbb_root_path); + $this->route_collection = $provider->find($this->phpbb_root_path); } -- cgit v1.2.1 From 436b1d3577cd1b66af568023e566d2de53c255a0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Mar 2014 18:22:32 +0100 Subject: [ticket/12090] Fix parameter list of controller helper constructor PHPBB3-12090 --- phpBB/phpbb/controller/helper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index c97e0883f4..8e33aaf605 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -53,8 +53,9 @@ class helper * Constructor * * @param \phpbb\template\template $template Template object - * @param \phpbb\user $user User object - * @param \phpbb\config\config $config Config object + * @param \phpbb\user $user User object + * @param \phpbb\config\config $config Config object + * @param \phpbb\controller\provider $provider Path provider * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ -- cgit v1.2.1 From 2eb24d0ace239324086002db4582eaaddd07aa28 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Mar 2014 18:38:21 +0100 Subject: [ticket/12090] Split finding routes and returning routes into 2 methods PHPBB3-12090 --- phpBB/phpbb/controller/helper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 8e33aaf605..2d11a54c08 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -66,8 +66,7 @@ class helper $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - $this->route_collection = $provider->find($this->phpbb_root_path); - + $this->route_collection = $provider->find($this->phpbb_root_path)->get_routes(); } /** -- cgit v1.2.1 From b29c4c635865444cacb67407c767951c83040036 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Mar 2014 19:03:15 +0100 Subject: [ticket/12090] Move find() call to container and fix tests PHPBB3-12090 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 2d11a54c08..10fdbb1375 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -66,7 +66,7 @@ class helper $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - $this->route_collection = $provider->find($this->phpbb_root_path)->get_routes(); + $this->route_collection = $provider->get_routes(); } /** -- cgit v1.2.1 From 18bed2ea476849fce3774783d728a763ab3e7138 Mon Sep 17 00:00:00 2001 From: geetakshi Date: Wed, 19 Mar 2014 19:55:55 +0530 Subject: [ticket/11360] Change second parameter in page_header function PHPBB3-11360 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 10fdbb1375..98758c0371 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -79,7 +79,7 @@ class helper */ public function render($template_file, $page_title = '', $status_code = 200) { - page_header($page_title); + page_header($page_title, true); $this->template->set_filenames(array( 'body' => $template_file, -- cgit v1.2.1 From 5afb06102b4343971947278a1633791597342a6f Mon Sep 17 00:00:00 2001 From: geetakshi Date: Thu, 20 Mar 2014 17:15:43 +0530 Subject: [ticket/11360] Avoiding online list where not required PHPBB3-11360 --- phpBB/phpbb/controller/helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 98758c0371..54c30c93fc 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -77,9 +77,9 @@ class helper * @param int $status_code The status code to be sent to the page header * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200) + public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false) { - page_header($page_title, true); + page_header($page_title, $display_online_list); $this->template->set_filenames(array( 'body' => $template_file, -- cgit v1.2.1 From dc6e2be884fdb8d869e7da03984014fd18e30ae2 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 2 May 2014 23:03:03 +0200 Subject: [ticket/11497] Remove 'ext.finder' from services' list PHPBB3-11497 --- phpBB/phpbb/controller/helper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 54c30c93fc..9f9f45d730 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -56,16 +56,18 @@ class helper * @param \phpbb\user $user User object * @param \phpbb\config\config $config Config object * @param \phpbb\controller\provider $provider Path provider + * @param \phpbb\extension\manager $manager Extension manager object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $provider->set_ext_finder($manager->get_finder()); $this->route_collection = $provider->get_routes(); } -- cgit v1.2.1 From 0d893d65eb2823aae449a9201941798e450a9be1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 3 May 2014 13:41:32 +0200 Subject: [ticket/11497] Generate the list of the routes in controller_helper PHPBB3-11497 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 9f9f45d730..ab3e3b3556 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -68,7 +68,7 @@ class helper $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->set_ext_finder($manager->get_finder()); - $this->route_collection = $provider->get_routes(); + $this->route_collection = $provider->find('./')->get_routes(); } /** -- cgit v1.2.1 From 8d9133a30e576d9f4315bc914b56c7be5481ebf4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 3 May 2014 14:00:47 +0200 Subject: [ticket/11497] Use a mock object to define the root folder for the finder PHPBB3-11497 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index ab3e3b3556..9f1a3864ef 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -68,7 +68,7 @@ class helper $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->set_ext_finder($manager->get_finder()); - $this->route_collection = $provider->find('./')->get_routes(); + $this->route_collection = $provider->find($phpbb_root_path)->get_routes(); } /** -- cgit v1.2.1 From 346c6f39980fe060b57549a8364f2e5dece1eb83 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 5 May 2014 18:20:14 +0200 Subject: [ticket/11497] Rename set_ext_finder in find_routing_files PHPBB3-11497 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 9f1a3864ef..959a24f277 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -67,7 +67,7 @@ class helper $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - $provider->set_ext_finder($manager->get_finder()); + $provider->find_routing_files($manager->get_finder()); $this->route_collection = $provider->find($phpbb_root_path)->get_routes(); } -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/controller/helper.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 959a24f277..7b232294f0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -15,7 +19,6 @@ use Symfony\Component\Routing\RequestContext; /** * Controller helper class, contains methods that do things for controllers -* @package phpBB3 */ class helper { -- cgit v1.2.1 From 358a10d8a9e244572568e89cdb87fd83f42759cf Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 15 Jun 2014 12:38:00 +0200 Subject: [ticket/12715] Cleanup comments in \phpbb\controller\* PHPBB3-12715 --- phpBB/phpbb/controller/helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 7b232294f0..930bc42a98 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -101,7 +101,7 @@ class helper * @param string $route Name of the route to travel * @param array $params String or array of additional url parameters * @param bool $is_amp Is url using & (true) or & (false) - * @param string $session_id Possibility to use a custom session id instead of the global one + * @param string|bool $session_id Possibility to use a custom session id instead of the global one * @return string The URL already passed through append_sid() */ public function route($route, array $params = array(), $is_amp = true, $session_id = false) @@ -139,8 +139,8 @@ class helper * Output an error, effectively the same thing as trigger_error * * @param string $message The error message - * @param string $code The error code (e.g. 404, 500, 503, etc.) - * @return Response A Reponse instance + * @param int $code The error code (e.g. 404, 500, 503, etc.) + * @return Response A Response instance */ public function error($message, $code = 500) { -- cgit v1.2.1 From 9374d14e275d2ec1317558a7d7ba93ab71a2a4c1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 8 Jul 2014 00:04:11 +0200 Subject: [ticket/12787] Add controller_helper::get_current_url() PHPBB3-12787 --- phpBB/phpbb/controller/helper.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 930bc42a98..e330fb5b6d 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -40,6 +40,9 @@ class helper */ protected $config; + /* @var \phpbb\symfony_request */ + protected $symfony_request; + /** * phpBB root path * @var string @@ -60,14 +63,16 @@ class helper * @param \phpbb\config\config $config Config object * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object + * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; + $this->symfony_request = $symfony_request; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); @@ -151,4 +156,14 @@ class helper return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); } + + /** + * Return the current url + * + * @return string + */ + public function get_current_url() + { + return generate_board_url(true) . $this->symfony_request->getRequestUri(); + } } -- cgit v1.2.1 From ffcf45abf32fc1343fe1d4edfd15828782ab4832 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Mon, 19 May 2014 03:07:32 +0300 Subject: [ticket/12557] Fix doc block errors found by Sami pt1 PHPBB3-12557 --- phpBB/phpbb/controller/helper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index e330fb5b6d..30ab09105f 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -85,6 +85,8 @@ class helper * @param string $handle The template handle to render * @param string $page_title The title of the page to output * @param int $status_code The status code to be sent to the page header + * @param bool $display_online_list Do we display online users list + * * @return Response object containing rendered page */ public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false) -- cgit v1.2.1 From 6ac8d17af66900c87b4524c92e0cc26535ded7b0 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Tue, 20 May 2014 18:58:42 +0300 Subject: [ticket/12557] Fix doc block errors found by Sami More corrections. PHPBB3-12557 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 30ab09105f..80e5e63083 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -82,7 +82,7 @@ class helper /** * Automate setting up the page and creating the response object. * - * @param string $handle The template handle to render + * @param string $template_file The template handle to render * @param string $page_title The title of the page to output * @param int $status_code The status code to be sent to the page header * @param bool $display_online_list Do we display online users list -- cgit v1.2.1 From 80067467805d4b1664777cf3553c39fc32cfdb65 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Thu, 7 Aug 2014 13:19:49 +0300 Subject: [ticket/12557] Fix php file description PHPBB3-12557 --- phpBB/phpbb/controller/helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 80e5e63083..dd89d0504a 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -50,7 +50,7 @@ class helper protected $phpbb_root_path; /** - * PHP extension + * PHP file extension * @var string */ protected $php_ext; @@ -65,7 +65,7 @@ class helper * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param string $phpbb_root_path phpBB root path - * @param string $php_ext PHP extension + * @param string $php_ext PHP file extension */ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) { -- cgit v1.2.1 From cb3eb84665db10e6fe55e11e694d39e742f313a4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 16:45:53 +0200 Subject: [ticket/13034] Fix the route generated for the frontend not in the phpbb root PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index dd89d0504a..931a489535 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -119,27 +119,23 @@ class helper $anchor = '#' . $params['#']; unset($params['#']); } - $url_generator = new UrlGenerator($this->route_collection, new RequestContext()); - $route_url = $url_generator->generate($route, $params); - if (strpos($route_url, '/') === 0) - { - $route_url = substr($route_url, 1); - } + $context = new RequestContext(); + $context->fromRequest($this->symfony_request); + + $script_name = $this->symfony_request->getScriptName(); + $page_name = substr($script_name, -1, 1) == '/' ? '' : basename($script_name); + $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); + + $url_generator = new UrlGenerator($this->route_collection, $context); + $route_url = $url_generator->generate($route, $params); if ($is_amp) { $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url); } - // If enable_mod_rewrite is false, we need to include app.php - $route_prefix = $this->phpbb_root_path; - if (empty($this->config['enable_mod_rewrite'])) - { - $route_prefix .= 'app.' . $this->php_ext . '/'; - } - - return append_sid($route_prefix . $route_url . $anchor, false, $is_amp, $session_id); + return append_sid($route_url . $anchor, false, $is_amp, $session_id, true); } /** -- cgit v1.2.1 From b9e7ed004c5830ce2a965702e6c8dc570291cf9b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 14 Sep 2014 23:41:15 +0200 Subject: [ticket/13034] Use utf8_basename PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 931a489535..6ad6dd1e24 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -124,7 +124,7 @@ class helper $context->fromRequest($this->symfony_request); $script_name = $this->symfony_request->getScriptName(); - $page_name = substr($script_name, -1, 1) == '/' ? '' : basename($script_name); + $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); $url_generator = new UrlGenerator($this->route_collection, $context); -- cgit v1.2.1 From 06f42f433bfb43b43d147d78bd04a35b7529cde4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 15 Sep 2014 20:25:20 +0200 Subject: [ticket/13034] Add comment PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 6ad6dd1e24..afa3c4dfa9 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -125,6 +125,8 @@ class helper $script_name = $this->symfony_request->getScriptName(); $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); + + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); $url_generator = new UrlGenerator($this->route_collection, $context); -- cgit v1.2.1 From 68ad7685bc12050cf6779d41f6ac36e8fe1a98e1 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 15 Sep 2014 23:47:05 +0200 Subject: [ticket/13034] Update the base url to move to the root dir PHPBB3-13034 --- phpBB/phpbb/controller/helper.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index afa3c4dfa9..e5e54fac00 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -43,6 +43,11 @@ class helper /* @var \phpbb\symfony_request */ protected $symfony_request; + /** + * @var \phpbb\filesystem The filesystem object + */ + protected $filesystem; + /** * phpBB root path * @var string @@ -64,15 +69,17 @@ class helper * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object + * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; + $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); @@ -126,8 +133,17 @@ class helper $script_name = $this->symfony_request->getScriptName(); $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); + $base_url = $context->getBaseUrl(); + // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it. - $context->setBaseUrl(str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $context->getBaseUrl())); + $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); + + $base_url = $this->filesystem->clean_path($base_url); + + $context->setBaseUrl($base_url); $url_generator = new UrlGenerator($this->route_collection, $context); $route_url = $url_generator->generate($route, $params); -- cgit v1.2.1 From dab6b99bcda411027d040c3b985460990f2a117a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 17:12:25 +0200 Subject: [ticket/13036] Make the reference type configurable when generating a route PHPBB3-13036 --- phpBB/phpbb/controller/helper.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index e5e54fac00..77fe5cb3a8 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -15,6 +15,7 @@ namespace phpbb\controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGenerator; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RequestContext; /** @@ -115,10 +116,11 @@ class helper * @param string $route Name of the route to travel * @param array $params String or array of additional url parameters * @param bool $is_amp Is url using & (true) or & (false) - * @param string|bool $session_id Possibility to use a custom session id instead of the global one + * @param string|bool $session_id Possibility to use a custom session id instead of the global one + * @param bool|string $reference_type The type of reference to be generated (one of the constants) * @return string The URL already passed through append_sid() */ - public function route($route, array $params = array(), $is_amp = true, $session_id = false) + public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) { $anchor = ''; if (isset($params['#'])) @@ -146,7 +148,7 @@ class helper $context->setBaseUrl($base_url); $url_generator = new UrlGenerator($this->route_collection, $context); - $route_url = $url_generator->generate($route, $params); + $route_url = $url_generator->generate($route, $params, $reference_type); if ($is_amp) { -- cgit v1.2.1 From bb5d6a2551f7329162424f1ae0edcd711b4bd5e6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 4 Sep 2014 23:20:06 +0200 Subject: [ticket/13036] Add unit tests PHPBB3-13036 --- phpBB/phpbb/controller/helper.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 77fe5cb3a8..e2932086db 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -155,6 +155,11 @@ class helper $route_url = str_replace(array('&', '&'), array('&', '&'), $route_url); } + if ($reference_type === UrlGeneratorInterface::RELATIVE_PATH && empty($this->config['enable_mod_rewrite'])) + { + $route_url = 'app.' . $this->php_ext . '/' . $route_url; + } + return append_sid($route_url . $anchor, false, $is_amp, $session_id, true); } -- cgit v1.2.1 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/helper.php') 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/helper.php') 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/helper.php') 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/helper.php') 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 From a159899d028d56f09efd79dd3e3abf5b3a7abc7b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 28 Sep 2014 23:32:56 +0200 Subject: [ticket/13113] Updates the base url only when the front-end isn't app.php PHPBB3-13113 --- phpBB/phpbb/controller/helper.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index fc19b855c0..187e455d48 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -140,14 +140,17 @@ 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 if the current script is not app.php + if ($page_name !== 'app.php') { - $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); - } - else - { - $base_url .= preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), '$2', $this->phpbb_root_path); + if (empty($this->config['enable_mod_rewrite'])) + { + $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url); + } + else + { + $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 From 0dfe1d0d8b007ec7b7cae0715cfb2e5f4e33bad4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 12 Nov 2014 11:44:56 +0100 Subject: [ticket/13280] Output escaping for the symfony request object PHPBB3-13280 --- phpBB/phpbb/controller/helper.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 187e455d48..52e6947c2c 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -44,6 +44,9 @@ class helper /* @var \phpbb\symfony_request */ protected $symfony_request; + /* @var \phpbb\request\request_interface */ + protected $request; + /** * @var \phpbb\filesystem The filesystem object */ @@ -70,16 +73,18 @@ class helper * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object + * @param \phpbb\request\request_interface $request phpBB request object * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; + $this->request = $request; $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; @@ -153,7 +158,7 @@ class helper } } - $base_url = $this->filesystem->clean_path($base_url); + $base_url = $this->request->escape($this->filesystem->clean_path($base_url), true); $context->setBaseUrl($base_url); @@ -197,6 +202,6 @@ class helper */ public function get_current_url() { - return generate_board_url(true) . $this->symfony_request->getRequestUri(); + return generate_board_url(true) . $this->request->escape($this->symfony_request->getRequestUri(), true); } } -- cgit v1.2.1 From b00d02496e9ec8281a6e0d6637772c55a7011c60 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 22 Nov 2014 23:10:19 +0100 Subject: [ticket/13361] Improve the exception listener PHPBB3-13361 --- phpBB/phpbb/controller/helper.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 52e6947c2c..7ee90b10ba 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -184,6 +184,8 @@ class helper * @param string $message The error message * @param int $code The error code (e.g. 404, 500, 503, etc.) * @return Response A Response instance + * + * @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead. */ public function error($message, $code = 500) { -- cgit v1.2.1 From afe99f90506153c22d5d3791c3f5467938e835cf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 29 Jan 2015 19:08:32 +0100 Subject: [ticket/13553] Add a method to the controller helper to display a message PHPBB3-13553 --- phpBB/phpbb/controller/helper.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 7ee90b10ba..85ecd87c5f 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -188,10 +188,25 @@ class helper * @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead. */ public function error($message, $code = 500) + { + return $this->message($message, false, $code); + } + + /** + * Output a message + * + * In case of an error, please throw an exception instead + * + * @param string $message The message to display + * @param string|false $title Title for the message + * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.) + * @return Response A Response instance + */ + public function message($message, $title = false, $code = 200) { $this->template->assign_vars(array( 'MESSAGE_TEXT' => $message, - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), + 'MESSAGE_TITLE' => ($title === false) ? $this->user->lang('INFORMATION') : $title, )); return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); -- cgit v1.2.1 From 7127d08c8f6e858a42d832aa0eb18c8196875e45 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 30 Jan 2015 15:07:37 -0800 Subject: [ticket/13553] Message helper should accept a lang key var PHPBB3-13553 --- phpBB/phpbb/controller/helper.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 85ecd87c5f..d135f487e0 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -189,7 +189,7 @@ class helper */ public function error($message, $code = 500) { - return $this->message($message, false, $code); + return $this->message($message, array(), false, $code); } /** @@ -197,15 +197,17 @@ class helper * * In case of an error, please throw an exception instead * - * @param string $message The message to display - * @param string|false $title Title for the message + * @param string $message The message to display (must be a language variable) + * @param array $parameters The parameters to use with the language var + * @param string|bool $title Title for the message * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.) * @return Response A Response instance */ - public function message($message, $title = false, $code = 200) + public function message($message, array $parameters = array(), $title = false, $code = 200) { + array_unshift($parameters, $message); $this->template->assign_vars(array( - 'MESSAGE_TEXT' => $message, + 'MESSAGE_TEXT' => call_user_func_array(array($this->user, 'lang'), $parameters), 'MESSAGE_TITLE' => ($title === false) ? $this->user->lang('INFORMATION') : $title, )); -- cgit v1.2.1 From ab4b1afd98b1a9ba532390373b88b518c3d98ece Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 30 Jan 2015 15:19:42 -0800 Subject: [ticket/13553] Make title var accept a lang key var PHPBB3-13553 --- phpBB/phpbb/controller/helper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index d135f487e0..8b0efae08a 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -189,7 +189,7 @@ class helper */ public function error($message, $code = 500) { - return $this->message($message, array(), false, $code); + return $this->message($message, array(), 'INFORMATION', $code); } /** @@ -199,16 +199,16 @@ class helper * * @param string $message The message to display (must be a language variable) * @param array $parameters The parameters to use with the language var - * @param string|bool $title Title for the message + * @param string $title Title for the message (must be a language variable) * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.) * @return Response A Response instance */ - public function message($message, array $parameters = array(), $title = false, $code = 200) + public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200) { array_unshift($parameters, $message); $this->template->assign_vars(array( 'MESSAGE_TEXT' => call_user_func_array(array($this->user, 'lang'), $parameters), - 'MESSAGE_TITLE' => ($title === false) ? $this->user->lang('INFORMATION') : $title, + 'MESSAGE_TITLE' => $this->user->lang($title), )); return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); -- cgit v1.2.1 From e6bbde2bffc4ff90de1b754d3682bc7f1ca1d67c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 30 Jan 2015 15:28:25 -0800 Subject: [ticket/13553] Use defined title value in page headers too PHPBB3-13553 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 8b0efae08a..c6c470e91b 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -211,7 +211,7 @@ class helper 'MESSAGE_TITLE' => $this->user->lang($title), )); - return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); + return $this->render('message_body.html', $this->user->lang($title), $code); } /** -- cgit v1.2.1 From 25b54791f9cc64f3e861a169a8a70d69c0cc2131 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 11 Feb 2015 13:03:22 +0100 Subject: [ticket/13493] Append page name to base url if it doesn't contain it PHPBB3-13493 --- phpBB/phpbb/controller/helper.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index c6c470e91b..dc802751fb 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -142,6 +142,12 @@ class helper $base_url = $context->getBaseUrl(); + // Append page name if base URL does not contain it + if (!empty($page_name) && strpos($base_url, '/' . $page_name) === false) + { + $base_url .= '/' . $page_name; + } + // 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); -- cgit v1.2.1 From 66279e1a57b7d715f651c118637fdf257e2bf846 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 9 May 2015 20:48:14 +0200 Subject: [ticket/13827] Correctly return JSON instead of HTML when valled from AJAX PHPBB3-13827 --- phpBB/phpbb/controller/helper.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index dc802751fb..8b86fb965d 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -212,12 +212,29 @@ class helper public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200) { array_unshift($parameters, $message); + $message_text = call_user_func_array(array($this->user, 'lang'), $parameters); + $message_title = $this->user->lang($title); + + if ($this->request->is_ajax()) + { + global $refresh_data; + + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $message_title, + 'MESSAGE_TEXT' => $message_text, + 'S_USER_WARNING' => false, + 'S_USER_NOTICE' => false, + 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null + )); + } + $this->template->assign_vars(array( - 'MESSAGE_TEXT' => call_user_func_array(array($this->user, 'lang'), $parameters), - 'MESSAGE_TITLE' => $this->user->lang($title), + 'MESSAGE_TEXT' => $message_text, + 'MESSAGE_TITLE' => $message_title, )); - return $this->render('message_body.html', $this->user->lang($title), $code); + return $this->render('message_body.html', $message_title, $code); } /** -- cgit v1.2.1 From 502214bf066237ac96009e727ab34ed4f4ddbbec Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 May 2015 17:13:47 +0200 Subject: [ticket/13827] Use JsonResponse instead of our hacky json_response with exit() PHPBB3-13827 --- phpBB/phpbb/controller/helper.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 8b86fb965d..a07a396e73 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -13,6 +13,7 @@ namespace phpbb\controller; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -219,14 +220,16 @@ class helper { global $refresh_data; - $json_response = new \phpbb\json_response; - $json_response->send(array( - 'MESSAGE_TITLE' => $message_title, - 'MESSAGE_TEXT' => $message_text, - 'S_USER_WARNING' => false, - 'S_USER_NOTICE' => false, - 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null - )); + return new JsonResponse( + array( + 'MESSAGE_TITLE' => $message_title, + 'MESSAGE_TEXT' => $message_text, + 'S_USER_WARNING' => false, + 'S_USER_NOTICE' => false, + 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null + ), + $code + ); } $this->template->assign_vars(array( -- cgit v1.2.1 From cc060a2611095abe67dbf07346755df4d67881e6 Mon Sep 17 00:00:00 2001 From: Zoddo Date: Sun, 30 Aug 2015 23:08:20 +0200 Subject: [ticket/11468] Allow controllers to set paramters of page_header() PHPBB3-11468 --- phpBB/phpbb/controller/helper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index a07a396e73..79378c2434 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -100,12 +100,14 @@ class helper * @param string $page_title The title of the page to output * @param int $status_code The status code to be sent to the page header * @param bool $display_online_list Do we display online users list + * @param int $item_id Restrict online users to item id + * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id * * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false) + public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum') { - page_header($page_title, $display_online_list); + page_header($page_title, $display_online_list, $item_id, $item); $this->template->set_filenames(array( 'body' => $template_file, -- cgit v1.2.1 From 62a261930073837d10993fae81202517bc04e122 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 18:01:31 +0100 Subject: [ticket/14483] Do not send headers by default on access via controller PHPBB3-14483 --- phpBB/phpbb/controller/helper.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 79378c2434..08a63639b9 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -102,12 +102,13 @@ class helper * @param bool $display_online_list Do we display online users list * @param int $item_id Restrict online users to item id * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id + * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers. * * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum') + public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false) { - page_header($page_title, $display_online_list, $item_id, $item); + page_header($page_title, $display_online_list, $item_id, $item, $send_headers); $this->template->set_filenames(array( 'body' => $template_file, @@ -115,7 +116,9 @@ class helper page_footer(true, false, false); - return new Response($this->template->assign_display('body'), $status_code); + $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array(); + + return new Response($this->template->assign_display('body'), $status_code, $headers); } /** -- cgit v1.2.1 From 1a5fbd4bd06e7ae7a89637c0977da2fed8cd62fb Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Mar 2016 18:43:29 +0200 Subject: [ticket/13683] Respects force_server_vars settings when generating URLs PHPBB3-13683 --- phpBB/phpbb/controller/helper.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 08a63639b9..75b7515540 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -143,6 +143,14 @@ class helper $context = new RequestContext(); $context->fromRequest($this->symfony_request); + if ($this->config['force_server_vars']) { + $context->setHost($this->config['server_name']); + $context->setScheme(substr($this->config['server_protocol'], -4)); + $context->setHttpPort($this->config['server_port']); + $context->setHttpsPort($this->config['server_port']); + $context->setBaseUrl($this->config['script_path'] . '/app.php'); + } + $script_name = $this->symfony_request->getScriptName(); $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name); -- cgit v1.2.1 From 0b1ed8dbbb3792b97726282fdc630cc242def2ad Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Mar 2016 19:59:15 +0200 Subject: [ticket/13683] Fix more cases PHPBB3-13683 --- phpBB/phpbb/controller/helper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 75b7515540..dbf7a9307a 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -143,12 +143,13 @@ class helper $context = new RequestContext(); $context->fromRequest($this->symfony_request); - if ($this->config['force_server_vars']) { + if ($this->config['force_server_vars']) + { $context->setHost($this->config['server_name']); $context->setScheme(substr($this->config['server_protocol'], -4)); $context->setHttpPort($this->config['server_port']); $context->setHttpsPort($this->config['server_port']); - $context->setBaseUrl($this->config['script_path'] . '/app.php'); + $context->setBaseUrl($this->config['script_path']); } $script_name = $this->symfony_request->getScriptName(); @@ -166,7 +167,7 @@ class helper $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 the current script is not app.php - if ($page_name !== 'app.php') + if ($page_name !== 'app.php' && !$this->config['force_server_vars']) { if (empty($this->config['enable_mod_rewrite'])) { -- cgit v1.2.1 From 0647eea742bef8d6ee932462f3775e45a6a05bd6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 29 Mar 2016 19:13:09 +0200 Subject: [ticket/13683] Updates tests PHPBB3-13683 --- phpBB/phpbb/controller/helper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index dbf7a9307a..cc0dfdb607 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -71,7 +71,8 @@ class helper * @param \phpbb\template\template $template Template object * @param \phpbb\user $user User object * @param \phpbb\config\config $config Config object - * @param \phpbb\controller\provider $provider Path provider + * + * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param \phpbb\request\request_interface $request phpBB request object @@ -146,7 +147,7 @@ class helper if ($this->config['force_server_vars']) { $context->setHost($this->config['server_name']); - $context->setScheme(substr($this->config['server_protocol'], -4)); + $context->setScheme(substr($this->config['server_protocol'], 0, -3)); $context->setHttpPort($this->config['server_port']); $context->setHttpsPort($this->config['server_port']); $context->setBaseUrl($this->config['script_path']); -- cgit v1.2.1 From bfc09e2b399f880536561c610286ddda60daabf2 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 30 Mar 2016 22:22:38 +0200 Subject: [ticket/13683] Removes extra / in script_path PHPBB3-13683 --- phpBB/phpbb/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/controller/helper.php') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index cc0dfdb607..ce6bfba981 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -150,7 +150,7 @@ class helper $context->setScheme(substr($this->config['server_protocol'], 0, -3)); $context->setHttpPort($this->config['server_port']); $context->setHttpsPort($this->config['server_port']); - $context->setBaseUrl($this->config['script_path']); + $context->setBaseUrl(rtrim($this->config['script_path'], '/')); } $script_name = $this->symfony_request->getScriptName(); -- cgit v1.2.1