From 8b36e6be3a3d132034e7450720e0e8c25c3ffe2c Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 13 Mar 2005 16:36:09 +0000 Subject: [PATCH] Introducing wp_redirect(), first cut. http://mosquito.wordpress.org/view.php?id=592 Props: Toby Simmons git-svn-id: http://svn.automattic.com/wordpress/trunk@2436 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/link-manager.php | 4 ++-- wp-admin/options.php | 2 +- wp-admin/profile.php | 2 +- wp-comments-post.php | 3 +-- wp-includes/functions.php | 13 +++++++++++++ wp-includes/vars.php | 1 + wp-login.php | 2 +- wp-pass.php | 3 +-- 8 files changed, 21 insertions(+), 9 deletions(-) diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 3efb69762d..f4fcd61190 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -243,7 +243,7 @@ switch ($action) { WHERE link_id=$link_id"); } // end if save setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); - header('Location: ' . $this_file); + wp_redirect($this_file); break; } // end Save @@ -267,7 +267,7 @@ switch ($action) { } $links_show_cat_id = $cat_id; setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); - header('Location: '.$this_file); + wp_redirect($this_file); break; } // end Delete diff --git a/wp-admin/options.php b/wp-admin/options.php index 090f698439..1edfbc3f5b 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -84,7 +84,7 @@ case 'update': $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']); $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); - header('Location: ' . $goback); + wp_redirect($goback); break; default: diff --git a/wp-admin/profile.php b/wp-admin/profile.php index 97e0b0ab9f..3e71b2fb59 100644 --- a/wp-admin/profile.php +++ b/wp-admin/profile.php @@ -86,7 +86,7 @@ case 'update': $result = $wpdb->query("UPDATE $wpdb->users SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description', user_nicename = '$newuser_nicename' WHERE ID = $user_ID"); - header('Location: profile.php?updated=true'); + wp_redirect('profile.php?updated=true'); break; case 'IErightclick': diff --git a/wp-comments-post.php b/wp-comments-post.php index f0ce7f74bc..6833c2c572 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -52,6 +52,5 @@ header('Pragma: no-cache'); $location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to']; -header("Location: $location"); - +wp_redirect($location); ?> \ No newline at end of file diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d45e569fc2..e1965ac3e8 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1711,6 +1711,19 @@ function auth_redirect() { } endif; +// Cookie safe redirect. Works around IIS Set-Cookie bug. +// http://support.microsoft.com/kb/q176113/ +if ( !function_exists('wp_redirect') ) : +function wp_redirect($location) { + global $is_IIS; + + if ($is_IIS) + header("Refresh: 0;url=$location"); + else + header("Location: $location"); +} +endif; + function is_plugin_page() { global $plugin_page; diff --git a/wp-includes/vars.php b/wp-includes/vars.php index 5021d4ef82..494f28544c 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -35,6 +35,7 @@ $is_IE = (($is_macIE) || ($is_winIE)); // Server detection $is_apache = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? 1 : 0; +$is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0; // if the config file does not provide the smilies array, let's define it here if (!isset($wpsmiliestrans)) { diff --git a/wp-login.php b/wp-login.php index ae7c863b8a..9ae31b6d24 100644 --- a/wp-login.php +++ b/wp-login.php @@ -184,7 +184,7 @@ default: wp_setcookie($user_login, $user_pass); } do_action('wp_login', $user_login); - header("Location: $redirect_to"); + wp_redirect($redirect_to); exit(); } else { if ($using_cookie) diff --git a/wp-pass.php b/wp-pass.php index 24b0160514..d7d23a66ce 100644 --- a/wp-pass.php +++ b/wp-pass.php @@ -7,6 +7,5 @@ if ( get_magic_quotes_gpc() ) // 10 days setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH); -header('Location: ' . $_SERVER['HTTP_REFERER']); - +wp_redirect($_SERVER['HTTP_REFERER']); ?> \ No newline at end of file