Better headers for CGI enviroments
git-svn-id: http://svn.automattic.com/wordpress/trunk@2623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
aa209f78de
commit
09adfadae0
|
@ -7,10 +7,7 @@ else
|
||||||
require_once(ABSPATH . 'wp-admin/admin-functions.php');
|
require_once(ABSPATH . 'wp-admin/admin-functions.php');
|
||||||
auth_redirect();
|
auth_redirect();
|
||||||
|
|
||||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
nocache_headers();
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
|
|
||||||
update_category_cache();
|
update_category_cache();
|
||||||
|
|
||||||
|
|
|
@ -107,14 +107,11 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sending HTTP headers
|
// Sending HTTP headers
|
||||||
|
@header('X-Pingback: '. get_bloginfo('pingback_url'));
|
||||||
|
|
||||||
if ( !empty($error) && '404' == $error ) {
|
if ( !empty($error) && '404' == $error ) {
|
||||||
if ( preg_match('/cgi/', php_sapi_name()) )
|
status_header( 404 );
|
||||||
@header('Status: 404 Not Found');
|
|
||||||
else
|
|
||||||
@header('HTTP/1.x 404 Not Found');
|
|
||||||
} else if ( empty($feed) ) {
|
} else if ( empty($feed) ) {
|
||||||
@header('X-Pingback: '. get_bloginfo('pingback_url'));
|
|
||||||
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||||
} else {
|
} else {
|
||||||
// We're showing a feed, so WP is indeed the only thing that last changed
|
// We're showing a feed, so WP is indeed the only thing that last changed
|
||||||
|
@ -125,7 +122,6 @@ if ( !empty($error) && '404' == $error ) {
|
||||||
$wp_etag = '"' . md5($wp_last_modified) . '"';
|
$wp_etag = '"' . md5($wp_last_modified) . '"';
|
||||||
@header("Last-Modified: $wp_last_modified");
|
@header("Last-Modified: $wp_last_modified");
|
||||||
@header("ETag: $wp_etag");
|
@header("ETag: $wp_etag");
|
||||||
@header('X-Pingback: ' . get_bloginfo('pingback_url'));
|
|
||||||
|
|
||||||
// Support for Conditional GET
|
// Support for Conditional GET
|
||||||
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
|
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
|
||||||
|
@ -141,17 +137,8 @@ if ( !empty($error) && '404' == $error ) {
|
||||||
if ( ($client_last_modified && $client_etag) ?
|
if ( ($client_last_modified && $client_etag) ?
|
||||||
(($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
|
(($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
|
||||||
(($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
|
(($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
|
||||||
if ( preg_match('/cgi/',php_sapi_name()) ) {
|
status_header( 304 );
|
||||||
header('Status: 304 Not Modified');
|
|
||||||
echo "\r\n\r\n";
|
|
||||||
exit;
|
exit;
|
||||||
} else {
|
|
||||||
if ( version_compare(phpversion(), '4.3.0', '>=') )
|
|
||||||
header('Not Modified', TRUE, 304);
|
|
||||||
else
|
|
||||||
header('HTTP/1.x 304 Not Modified');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,10 +178,9 @@ if ( (0 == count($posts)) && !is_404() && !is_search()
|
||||||
&& ( isset($rewrite) || (!empty($_SERVER['QUERY_STRING']) &&
|
&& ( isset($rewrite) || (!empty($_SERVER['QUERY_STRING']) &&
|
||||||
(false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
|
(false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
|
||||||
$wp_query->is_404 = true;
|
$wp_query->is_404 = true;
|
||||||
if ( preg_match('/cgi/', php_sapi_name()) )
|
status_header( 404 );
|
||||||
@header('Status: 404 Not Found');
|
} else {
|
||||||
else
|
status_header( 200 );
|
||||||
@header('HTTP/1.x 404 Not Found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
|
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
|
||||||
|
|
|
@ -52,10 +52,7 @@ setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time()
|
||||||
setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH);
|
setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH);
|
||||||
setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH);
|
setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH);
|
||||||
|
|
||||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
nocache_headers();
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
|
|
||||||
$location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to'];
|
$location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to'];
|
||||||
|
|
||||||
|
|
|
@ -1849,4 +1849,36 @@ function wp_remote_fopen( $uri ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function status_header( $header ) {
|
||||||
|
if ( 200 == $header ) {
|
||||||
|
$text = 'OK';
|
||||||
|
} elseif ( 301 == $header ) {
|
||||||
|
$text = 'Moved Permanently';
|
||||||
|
} elseif ( 302 == $header ) {
|
||||||
|
$text = 'Moved Temporarily';
|
||||||
|
} elseif ( 304 == $header ) {
|
||||||
|
$text = 'Not Modified';
|
||||||
|
} elseif ( 404 == $header ) {
|
||||||
|
$text = 'Not Found';
|
||||||
|
} elseif ( 410 == $header ) {
|
||||||
|
$text = 'Gone';
|
||||||
|
}
|
||||||
|
if ( preg_match('/cgi/',php_sapi_name()) ) {
|
||||||
|
@header("Status: $header $text");
|
||||||
|
echo "\r\n\r\n";
|
||||||
|
} else {
|
||||||
|
if ( version_compare(phpversion(), '4.3.0', '>=') )
|
||||||
|
@header($text, TRUE, $header);
|
||||||
|
else
|
||||||
|
@header("HTTP/1.x $header $text");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nocache_headers() {
|
||||||
|
@ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
||||||
|
@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||||
|
@ header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
||||||
|
@ header('Pragma: no-cache');
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -106,10 +106,7 @@ function auth_redirect() {
|
||||||
if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
|
if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) &&
|
||||||
!wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
|
!wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
|
||||||
(empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
|
(empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
|
||||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
nocache_headers();
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
|
|
||||||
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
|
||||||
exit();
|
exit();
|
||||||
|
|
11
wp-login.php
11
wp-login.php
|
@ -4,10 +4,8 @@ require( dirname(__FILE__) . '/wp-config.php' );
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
$error = '';
|
$error = '';
|
||||||
|
|
||||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
nocache_headers();
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
|
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
|
||||||
|
|
||||||
if ( defined('RELOCATE') ) { // Move flag is set
|
if ( defined('RELOCATE') ) { // Move flag is set
|
||||||
|
@ -24,10 +22,7 @@ case 'logout':
|
||||||
|
|
||||||
wp_clearcookie();
|
wp_clearcookie();
|
||||||
do_action('wp_logout');
|
do_action('wp_logout');
|
||||||
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
|
nocache_headers();
|
||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
||||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
wp_redirect('wp-login.php');
|
wp_redirect('wp-login.php');
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue