using wp cookie-safe redirect; this should be hopefully 'free' (= shouldn't have drawbacks)

This commit is contained in:
real_nowhereman 2008-03-17 20:27:00 +00:00
parent 12b3af6073
commit 0d6ef5c515
3 changed files with 24 additions and 36 deletions

View File

@ -26,37 +26,6 @@ if ( !defined('COOKIE_DOMAIN') )
} }
// Cookie safe redirect. Works around IIS Set-Cookie bug.
// http://support.microsoft.com/kb/q176113/
if ( !function_exists('wp_redirect') ) :
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%]|i', '', $location);
# $location = wp_kses_no_null($location);
$location = preg_replace('/\0+/', '', $location);
$location = preg_replace('/(\\\\0)+/', '', $location);
$strip = array('%0d', '%0a');
$location = str_replace($strip, '', $location);
if ( $is_IIS ) {
header("Refresh: 0;url=$location");
} else {
if ( php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location");
}
}
endif;
if ( !function_exists('wp_get_cookie_login') ): if ( !function_exists('wp_get_cookie_login') ):
function wp_get_cookie_login() { function wp_get_cookie_login() {
if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ) if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) )

View File

@ -236,8 +236,8 @@ if (!function_exists('fnmatch')) {
if (!$absolute_path) if (!$absolute_path)
$location = BLOG_BASEURL . $location; $location = BLOG_BASEURL . $location;
header("Location: $location"); wp_redirect($location);
exit(); exit();
} }

View File

@ -247,16 +247,35 @@ endif;
// Cookie safe redirect. Works around IIS Set-Cookie bug. // Cookie safe redirect. Works around IIS Set-Cookie bug.
// http://support.microsoft.com/kb/q176113/ // http://support.microsoft.com/kb/q176113/
if ( !function_exists('wp_redirect') ) : if ( !function_exists('wp_redirect') ) :
function wp_redirect($location) { function wp_redirect($location, $status = 302) {
global $is_IIS; global $is_IIS;
if ($is_IIS) $location = apply_filters('wp_redirect', $location, $status);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%]|i', '', $location);
# $location = wp_kses_no_null($location);
$location = preg_replace('/\0+/', '', $location);
$location = preg_replace('/(\\\\0)+/', '', $location);
$strip = array('%0d', '%0a');
$location = str_replace($strip, '', $location);
if ( $is_IIS ) {
header("Refresh: 0;url=$location"); header("Refresh: 0;url=$location");
else } else {
if ( php_sapi_name() != 'cgi-fcgi' )
utils_status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location"); header("Location: $location");
}
} }
endif; endif;
if ( !function_exists('wp_setcookie') ) : if ( !function_exists('wp_setcookie') ) :
function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') {
if ( !$already_md5 ) if ( !$already_md5 )