| | 376 | $location = wp_sanitize_redirect($location); |
|---|
| | 377 | |
|---|
| | 378 | if ( $is_IIS ) { |
|---|
| | 379 | header("Refresh: 0;url=$location"); |
|---|
| | 380 | } else { |
|---|
| | 381 | if ( php_sapi_name() != 'cgi-fcgi' ) |
|---|
| | 382 | status_header($status); // This causes problems on IIS and some FastCGI setups |
|---|
| | 383 | header("Location: $location"); |
|---|
| | 384 | } |
|---|
| | 385 | } |
|---|
| | 386 | endif; |
|---|
| | 387 | |
|---|
| | 388 | if ( !function_exists('wp_sanitize_redirect') ) : |
|---|
| | 389 | /** |
|---|
| | 390 | * sanitizes a URL for use in a redirect |
|---|
| | 391 | * @return string redirect-sanitized URL |
|---|
| | 392 | **/ |
|---|
| | 393 | function wp_sanitize_redirect($location) { |
|---|
| 408 | | if ( $location{0} == '/' ) { |
|---|
| 409 | | if ( $location{1} == '/' ) |
|---|
| 410 | | $location = get_option('home') . '/'; |
|---|
| 411 | | } else { |
|---|
| 412 | | if ( substr($location, 0, strlen(get_option('home'))) != get_option('home') ) |
|---|
| 413 | | $location = get_option('home') . '/'; |
|---|
| 414 | | } |
|---|
| | 419 | |
|---|
| | 420 | // Need to look at the URL the way it will end up in wp_redirect() |
|---|
| | 421 | $location = wp_sanitize_redirect($location); |
|---|
| | 422 | |
|---|
| | 423 | // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//' |
|---|
| | 424 | if ( substr($location, 0, 2) == '//' ) |
|---|
| | 425 | $location = 'http:' . $location; |
|---|
| | 426 | |
|---|
| | 427 | $lp = parse_url($location); |
|---|
| | 428 | $wpp = parse_url(get_option('home')); |
|---|
| | 429 | |
|---|
| | 430 | if ( isset($lp['host']) && $lp['host'] != $wpp['host'] ) |
|---|
| | 431 | $location = get_option('siteurl') . '/wp-admin/'; |
|---|