From a686a2f057bdd3d76fbc6bd785b651bcc58c58f6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Jun 2023 16:42:27 +0200 Subject: [PATCH] [ticket/13276] Support PHPBB_USE_BOARD_URL_PATH in web root path PHPBB3-13276 --- phpBB/includes/functions.php | 13 +++---------- phpBB/includes/functions_content.php | 2 +- phpBB/includes/functions_posting.php | 6 +++--- phpBB/phpbb/avatar/driver/local.php | 2 +- phpBB/phpbb/avatar/driver/upload.php | 2 +- phpBB/phpbb/path_helper.php | 5 +++++ phpBB/phpbb/textformatter/s9e/renderer.php | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1234e1aa7b..59dad0d5cd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3695,15 +3695,11 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false) { if ($lazy) { - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; // 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. $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; + $web_path = $phpbb_path_helper->get_web_root_path(); $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; @@ -3891,15 +3887,12 @@ function page_header($page_title = '', $display_online_list = false, $item_id = $db->sql_freeresult($result); } - // Determine board url - we may need it later - $board_url = generate_board_url() . '/'; // 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. /* @var $phpbb_path_helper \phpbb\path_helper */ $phpbb_path_helper = $phpbb_container->get('path_helper'); - $corrected_path = $phpbb_path_helper->get_web_root_path(); - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; + $web_path = $phpbb_path_helper->get_web_root_path(); // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; @@ -4002,7 +3995,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = '_SID' => $_SID, 'SESSION_ID' => $user->session_id, 'ROOT_PATH' => $web_path, - 'BOARD_URL' => $board_url, + 'BOARD_URL' => generate_board_url() . '/', 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index a73f074f42..1824533f22 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1088,7 +1088,7 @@ function smiley_text($text, $force_option = false) } else { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); + $root_path = $phpbb_path_helper->get_web_root_path(); /** * Event to override the root_path for smilies diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f5271672a4..f296606aeb 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -189,7 +189,7 @@ function generate_smilies($mode, $forum_id) if (count($smilies)) { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); + $root_path = $phpbb_path_helper->get_web_root_path(); foreach ($smilies as $row) { @@ -420,7 +420,7 @@ function update_post_information($type, $ids, $return_update_sql = false) */ function posting_gen_topic_icons($mode, $icon_id) { - global $phpbb_root_path, $config, $template, $cache; + global $phpbb_root_path, $phpbb_path_helper, $config, $template, $cache; // Grab icons $icons = $cache->obtain_icons(); @@ -432,7 +432,7 @@ function posting_gen_topic_icons($mode, $icon_id) if (count($icons)) { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + $root_path = $phpbb_path_helper->get_web_root_path(); foreach ($icons as $id => $data) { diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index 4b84e4201c..18a1005b2a 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -23,7 +23,7 @@ class local extends \phpbb\avatar\driver\driver */ public function get_data($row) { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path(); + $root_path = $this->path_helper->get_web_root_path(); return array( 'src' => $root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index a5b704b4ff..af39453d52 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -62,7 +62,7 @@ class upload extends \phpbb\avatar\driver\driver */ public function get_data($row) { - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path(); + $root_path = $this->path_helper->get_web_root_path(); return array( 'src' => $root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 167073fa25..7112412ec3 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -156,6 +156,11 @@ class path_helper return $this->web_root_path; } + if (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) + { + return $this->web_root_path = generate_board_url() . '/'; + } + // We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result. // Path info (e.g. /foo/bar) $path_info = $this->filesystem->clean_path($this->symfony_request->getPathInfo()); diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php index d3a4534d09..b7d4208000 100644 --- a/phpBB/phpbb/textformatter/s9e/renderer.php +++ b/phpBB/phpbb/textformatter/s9e/renderer.php @@ -139,7 +139,7 @@ class renderer implements \phpbb\textformatter\renderer_interface /** * @see smiley_text() */ - $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $path_helper->get_web_root_path(); + $root_path = $path_helper->get_web_root_path(); $this->set_smilies_path($root_path . $config['smilies_path']); }