[ticket/12261] Remove web root path from login redirect url

The redirect url must be relative to the ucp.php and not relative to the
current page.

PHPBB3-12261
This commit is contained in:
Joas Schilling 2014-03-10 10:15:38 +01:00
parent 4b6f3f8b0f
commit b876c07377

View file

@ -2419,7 +2419,7 @@ function reapply_sid($url)
*/ */
function build_url($strip_vars = false) function build_url($strip_vars = false)
{ {
global $user, $phpbb_root_path; global $config, $user, $phpEx, $phpbb_root_path;
$page = $user->page['page']; $page = $user->page['page'];
@ -2432,6 +2432,12 @@ function build_url($strip_vars = false)
// URL // URL
if ($url_parts === false || empty($url_parts['scheme']) || empty($url_parts['host'])) if ($url_parts === false || empty($url_parts['scheme']) || empty($url_parts['host']))
{ {
// Remove 'app.php/' from the page, when rewrite is enabled
if ($config['enable_mod_rewrite'] && strpos($page, 'app.' . $phpEx . '/') === 0)
{
$page = substr($page, strlen('app.' . $phpEx . '/'));
}
$page = $phpbb_root_path . $page; $page = $phpbb_root_path . $page;
} }
@ -4893,6 +4899,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
$hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f')); $hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f'));
$notification_mark_hash = generate_link_hash('mark_all_notifications_read'); $notification_mark_hash = generate_link_hash('mark_all_notifications_read');
$redirect_url = $phpbb_path_helper->remove_web_root_path(build_url());
// The following assigns all _common_ variables that may be used at any point in a template. // The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array( $template->assign_vars(array(
'SITENAME' => $config['sitename'], 'SITENAME' => $config['sitename'],
@ -4977,7 +4985,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_TOPIC_ID' => $topic_id, 'S_TOPIC_ID' => $topic_id,
'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_admin_path}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_admin_path}index.$phpEx", false, true, $user->session_id)),
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())), 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => $redirect_url)),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false,