[wp-cvs] wordpress wp-blog-header.php,1.82,1.83
Ryan Boren
rboren at users.sourceforge.net
Fri Aug 27 20:59:40 UTC 2004
Update of /cvsroot/cafelog/wordpress
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29278
Modified Files:
wp-blog-header.php
Log Message:
404 permalink handler.
Index: wp-blog-header.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-blog-header.php,v
retrieving revision 1.82
retrieving revision 1.83
diff -C2 -d -r1.82 -r1.83
*** wp-blog-header.php 24 Aug 2004 08:42:55 -0000 1.82
--- wp-blog-header.php 27 Aug 2004 20:59:37 -0000 1.83
***************
*** 9,40 ****
require_once( dirname(__FILE__) . '/wp-includes/wp-l10n.php');
! // Process PATH_INFO, if set.
! $path_info = array();
! if ( !empty( $_SERVER['PATH_INFO'] ) ) {
// Fetch the rewrite rules.
$rewrite = rewrite_rules('matches');
- $pathinfo = $_SERVER['PATH_INFO'];
- // Trim leading '/'.
- $pathinfo = preg_replace('!^/!', '', $pathinfo);
-
if (! empty($rewrite)) {
! // Get the name of the file requesting path info.
! $req_uri = $_SERVER['REQUEST_URI'];
$req_uri = str_replace($pathinfo, '', $req_uri);
! $req_uri = preg_replace("!/+$!", '', $req_uri);
! $req_uri = explode('/', $req_uri);
! $req_uri = $req_uri[count($req_uri)-1];
// Look for matches.
! $pathinfomatch = $pathinfo;
foreach ($rewrite as $match => $query) {
! // If the request URI is the anchor of the match, prepend it
// to the path info.
! if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
! $pathinfomatch = $req_uri . '/' . $pathinfo;
! }
! if (preg_match("!^$match!", $pathinfomatch, $matches)) {
// Got a match.
// Trim the query of everything up to the '?'.
--- 9,54 ----
require_once( dirname(__FILE__) . '/wp-includes/wp-l10n.php');
! $query_vars = array();
!
! // Process PATH_INFO and 404.
! if ((isset($_GET['error']) && $_GET['error'] == '404') ||
! (! empty( $_SERVER['PATH_INFO']))) {
!
// Fetch the rewrite rules.
$rewrite = rewrite_rules('matches');
if (! empty($rewrite)) {
! $pathinfo = $_SERVER['PATH_INFO'];
! $req_uri = $_SERVER['REQUEST_URI'];
! $home_path = parse_url(get_settings('home'));
! $home_path = $home_path['path'];
!
! // Trim path info from the end and the leading home path from the
! // front. For path info requests, this leaves us with the requesting
! // filename, if any. For 404 requests, this leaves us with the
! // requested permalink.
$req_uri = str_replace($pathinfo, '', $req_uri);
! $req_uri = str_replace($home_path, '', $req_uri);
! $req_uri = trim($req_uri, '/');
! $pathinfo = trim($pathinfo, '/');
!
! // The requested permalink is in $pathinfo for path info requests and
! // $req_uri for other requests.
! if (! empty($pathinfo)) {
! $request = $pathinfo;
! } else {
! $request = $req_uri;
! }
// Look for matches.
! $request_match = $request;
foreach ($rewrite as $match => $query) {
! // If the requesting file is the anchor of the match, prepend it
// to the path info.
! if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
! $request_match = $req_uri . '/' . $request;
! }
! if (preg_match("!^$match!", $request_match, $matches)) {
// Got a match.
// Trim the query of everything up to the '?'.
***************
*** 45,56 ****
// Parse the query.
! parse_str($query, $path_info);
break;
}
}
! }
}
! $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
--- 59,77 ----
// Parse the query.
! parse_str($query, $query_vars);
!
! // If we're processing a 404 request, clear the error var
! // since we found something.
! if (isset($_GET['error'])) {
! unset($_GET['error']);
! }
!
break;
}
}
! }
}
! $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'error');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
***************
*** 58,67 ****
if (!isset($$wpvar)) {
if (empty($_POST[$wpvar])) {
! if (empty($_GET[$wpvar]) && empty($path_info[$wpvar])) {
$$wpvar = '';
} elseif (!empty($_GET[$wpvar])) {
$$wpvar = $_GET[$wpvar];
} else {
! $$wpvar = $path_info[$wpvar];
}
} else {
--- 79,88 ----
if (!isset($$wpvar)) {
if (empty($_POST[$wpvar])) {
! if (empty($_GET[$wpvar]) && empty($query_vars[$wpvar])) {
$$wpvar = '';
} elseif (!empty($_GET[$wpvar])) {
$$wpvar = $_GET[$wpvar];
} else {
! $$wpvar = $query_vars[$wpvar];
}
} else {
***************
*** 200,203 ****
--- 221,229 ----
include(ABSPATH . 'wp-content/search.php');
exit;
+ } else if (is_404() && (! isset($wp_did_404)) &&
+ file_exists(ABSPATH . 'wp-content/404.php')) {
+ $wp_did_404 = true;
+ include(ABSPATH . 'wp-content/404.php');
+ exit;
} else if (is_feed() && $pagenow != 'wp-feed.php') {
include(dirname(__FILE__) . '/wp-feed.php');
More information about the cvs
mailing list