Changeset 3111
- Timestamp:
- 11/16/2005 10:54:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/classes.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r3108 r3111 1413 1413 1414 1414 // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. 1415 if ((isset($_GET['error']) && $_GET['error'] == '404') || 1416 ((! empty($_SERVER['PATH_INFO'])) && 1417 ('/' != $_SERVER['PATH_INFO']) && 1418 (false === strpos($_SERVER['PATH_INFO'], '.php')) 1419 ) || 1420 (false === strpos($_SERVER['REQUEST_URI'], '.php')) 1421 ) { 1422 1423 $this->did_permalink = true; 1424 1415 1416 // Fetch the rewrite rules. 1417 $rewrite = $wp_rewrite->wp_rewrite_rules(); 1418 1419 if (! empty($rewrite)) { 1425 1420 // If we match a rewrite rule, this will be cleared. 1426 1421 $error = '404'; 1427 1428 // Fetch the rewrite rules. 1429 $rewrite = $wp_rewrite->wp_rewrite_rules(); 1430 1431 if (! empty($rewrite)) { 1432 $pathinfo = $_SERVER['PATH_INFO']; 1433 $pathinfo_array = explode('?', $pathinfo); 1434 $pathinfo = $pathinfo_array[0]; 1435 $req_uri = $_SERVER['REQUEST_URI']; 1436 $req_uri_array = explode('?', $req_uri); 1437 $req_uri = $req_uri_array[0]; 1438 $home_path = parse_url(get_settings('home')); 1439 $home_path = $home_path['path']; 1440 1441 // Trim path info from the end and the leading home path from the 1442 // front. For path info requests, this leaves us with the requesting 1443 // filename, if any. For 404 requests, this leaves us with the 1444 // requested permalink. 1445 $req_uri = str_replace($pathinfo, '', $req_uri); 1446 $req_uri = str_replace($home_path, '', $req_uri); 1447 $req_uri = trim($req_uri, '/'); 1448 $pathinfo = trim($pathinfo, '/'); 1449 1450 // The requested permalink is in $pathinfo for path info requests and 1451 // $req_uri for other requests. 1452 if (! empty($pathinfo) && ($wp_rewrite->index != $pathinfo)) { 1453 $request = $pathinfo; 1454 } else { 1455 $request = $req_uri; 1456 } 1457 1458 // Look for matches. 1459 $request_match = $request; 1460 foreach ($rewrite as $match => $query) { 1461 // If the requesting file is the anchor of the match, prepend it 1462 // to the path info. 1463 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { 1464 $request_match = $req_uri . '/' . $request; 1465 } 1466 1467 if (preg_match("!^$match!", $request_match, $matches)) { 1468 // Got a match. 1469 // Trim the query of everything up to the '?'. 1470 $query = preg_replace("!^.+\?!", '', $query); 1471 1472 // Substitute the substring matches into the query. 1473 eval("\$query = \"$query\";"); 1474 1475 // Parse the query. 1476 parse_str($query, $query_vars); 1477 1478 // If we're processing a 404 request, clear the error var 1479 // since we found something. 1480 if (isset($_GET['error'])) { 1481 unset($_GET['error']); 1482 } 1483 1484 if (isset($error)) { 1485 unset($error); 1486 } 1487 1488 break; 1489 } 1490 } 1491 1492 // If req_uri is empty, the home page was requested. Unset error. 1493 if ( empty($req_uri) ) { 1422 $this->did_permalink = true; 1423 1424 $pathinfo = $_SERVER['PATH_INFO']; 1425 $pathinfo_array = explode('?', $pathinfo); 1426 $pathinfo = $pathinfo_array[0]; 1427 $req_uri = $_SERVER['REQUEST_URI']; 1428 $req_uri_array = explode('?', $req_uri); 1429 $req_uri = $req_uri_array[0]; 1430 $self = $_SERVER['PHP_SELF']; 1431 $home_path = parse_url(get_settings('home')); 1432 $home_path = $home_path['path']; 1433 1434 // Trim path info from the end and the leading home path from the 1435 // front. For path info requests, this leaves us with the requesting 1436 // filename, if any. For 404 requests, this leaves us with the 1437 // requested permalink. 1438 $req_uri = str_replace($pathinfo, '', $req_uri); 1439 $req_uri = str_replace($home_path, '', $req_uri); 1440 $req_uri = trim($req_uri, '/'); 1441 $pathinfo = trim($pathinfo, '/'); 1442 $self = str_replace($home_path, '', $self); 1443 $self = trim($self, '/'); 1444 1445 // The requested permalink is in $pathinfo for path info requests and 1446 // $req_uri for other requests. 1447 if (! empty($pathinfo) && ($wp_rewrite->index != $pathinfo)) { 1448 $request = $pathinfo; 1449 } else { 1450 $request = $req_uri; 1451 } 1452 1453 // Look for matches. 1454 $request_match = $request; 1455 foreach ($rewrite as $match => $query) { 1456 // If the requesting file is the anchor of the match, prepend it 1457 // to the path info. 1458 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) { 1459 $request_match = $req_uri . '/' . $request; 1460 } 1461 1462 if (preg_match("!^$match!", $request_match, $matches)) { 1463 // Got a match. 1464 // Trim the query of everything up to the '?'. 1465 $query = preg_replace("!^.+\?!", '', $query); 1466 1467 // Substitute the substring matches into the query. 1468 eval("\$query = \"$query\";"); 1469 1470 // Parse the query. 1471 parse_str($query, $query_vars); 1472 1473 // If we're processing a 404 request, clear the error var 1474 // since we found something. 1494 1475 if (isset($_GET['error'])) { 1495 1476 unset($_GET['error']); … … 1499 1480 unset($error); 1500 1481 } 1482 1483 break; 1484 } 1485 } 1486 1487 // If req_uri is empty or if it is a request for ourself, unset error. 1488 if ( empty($request) || $req_uri == $self ) { 1489 if (isset($_GET['error'])) { 1490 unset($_GET['error']); 1491 } 1492 1493 if (isset($error)) { 1494 unset($error); 1501 1495 } 1502 1496 }
Note: See TracChangeset
for help on using the changeset viewer.