aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php90
1 files changed, 26 insertions, 64 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index bf973fe141..49d4e03921 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,8 +7,6 @@
*
*/
-use Symfony\Component\HttpFoundation\Request;
-
/**
* @ignore
*/
@@ -2411,9 +2409,9 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
*/
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
- global $_SID, $_EXTRA_URL, $phpbb_hook;
+ global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem;
global $phpbb_dispatcher;
- global $symfony_request, $phpbb_root_path;
+ global $symfony_request, $phpbb_root_path, $phpbb_container;
if ($params === '' || (is_array($params) && empty($params)))
{
@@ -2421,10 +2419,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
$params = false;
}
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
- if ($corrected_path)
+ // Update the root path with the correct relative web path
+ if ($phpbb_filesystem instanceof phpbb_filesystem)
{
- $url = substr($corrected_path . $url, strlen($phpbb_root_path));
+ $url = $phpbb_filesystem->update_web_root_path($url, $symfony_request);
}
$append_sid_overwrite = false;
@@ -2816,8 +2814,22 @@ function build_url($strip_vars = false)
{
global $user, $phpbb_root_path;
+ $page = $user->page['page'];
+
+ // We need to be cautious here.
+ // On some situations, the redirect path is an absolute URL, sometimes a relative path
+ // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
+ // else we use the URL directly.
+ $url_parts = @parse_url($page);
+
+ // URL
+ if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
+ {
+ $page = $phpbb_root_path . $page;
+ }
+
// Append SID
- $redirect = append_sid($user->page['page'], false, false);
+ $redirect = append_sid($page, false, false);
// Add delimiter if not there...
if (strpos($redirect, '?') === false)
@@ -2872,19 +2884,7 @@ function build_url($strip_vars = false)
$redirect .= ($query) ? '?' . $query : '';
}
- // We need to be cautious here.
- // On some situations, the redirect path is an absolute URL, sometimes a relative path
- // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
- // else we use the URL directly.
- $url_parts = @parse_url($redirect);
-
- // URL
- if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
- {
- return str_replace('&', '&', $redirect);
- }
-
- return $phpbb_root_path . str_replace('&', '&', $redirect);
+ return str_replace('&', '&', $redirect);
}
/**
@@ -5081,7 +5081,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
{
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
- global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request;
+ global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request, $adm_relative_path;
if (defined('HEADER_INC'))
{
@@ -5241,7 +5241,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $corrected_path = $phpbb_filesystem->get_web_root_path($symfony_request);
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output
@@ -5380,7 +5381,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_FORUM_ID' => $forum_id,
'S_TOPIC_ID' => $topic_id,
- 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)),
+ 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_root_path}{$adm_relative_path}index.$phpEx", false, true, $user->session_id)),
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
@@ -5745,45 +5746,6 @@ function phpbb_create_symfony_request(phpbb_request $request)
array_walk_recursive($get_parameters, $sanitizer);
array_walk_recursive($post_parameters, $sanitizer);
- $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
+ $symfony_request = new Symfony\Component\HttpFoundation\Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
return $symfony_request;
}
-
-/**
-* Get a relative root path from the current URL
-*
-* @param Request $symfony_request Symfony Request object
-*/
-function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '')
-{
- global $phpbb_container;
-
- static $path;
- if (null !== $path)
- {
- return $path;
- }
-
- $path_info = $symfony_request->getPathInfo();
- if ($path_info === '/')
- {
- $path = $phpbb_root_path;
- return $path;
- }
-
- $filesystem = $phpbb_container->get('filesystem');
- $path_info = $filesystem->clean_path($path_info);
-
- // Do not count / at start of path
- $corrections = substr_count(substr($path_info, 1), '/');
-
- // When URL Rewriting is enabled, app.php is optional. We have to
- // correct for it not being there
- if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false)
- {
- $corrections -= 1;
- }
-
- $path = $phpbb_root_path . str_repeat('../', $corrections);
- return $path;
-}