Make WordPress Core


Ignore:
Timestamp:
02/17/2004 02:50:57 AM (21 years ago)
Author:
rboren
Message:

Support PATH_INFO permalinks. Move rewrite rule generation to rewrite_rules().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-blog-header.php

    r863 r881  
    1010
    1111require($curpath.'/wp-config.php');
     12
     13/* Process PATH_INFO, if set. */
     14$path_info = array();
     15if (! empty($_SERVER['PATH_INFO'])) {
     16    // Fetch the rewrite rules.
     17    $rewrite = rewrite_rules('matches');
     18
     19    $pathinfo = $_SERVER['PATH_INFO'];
     20    // Trim leading '/'.
     21    $pathinfo = preg_replace("!^/!", '', $pathinfo);
     22
     23    if (! empty($rewrite)) {
     24        // Get the name of the file requesting path info.
     25        $req_uri = $HTTP_SERVER_VARS['REQUEST_URI'];
     26        $req_uri = str_replace($pathinfo, '', $req_uri);
     27        $req_uri = preg_replace("!/+$!", '', $req_uri);
     28        $req_uri = explode('/', $req_uri);
     29        $req_uri = $req_uri[count($req_uri)-1];
     30
     31        // Look for matches.
     32        $pathinfomatch = $pathinfo;
     33        foreach ($rewrite as $match => $query) {
     34            // If the request URI is the anchor of the match, prepend it
     35            // to the path info.
     36            if (preg_match("!^$req_uri!", $match)) {
     37                $pathinfomatch = $req_uri . '/' . $pathinfo;
     38            }
     39
     40            if (preg_match("!^$match!", $pathinfomatch, $matches)) {
     41                // Got a match.
     42                // Trim the query of everything up to the '?'.
     43                $query = preg_replace("!^.+\?!", '', $query);
     44
     45                // Substitute the substring matches into the query.
     46                eval("\$query = \"$query\";");
     47
     48                // Parse the query.
     49                parse_str($query, $path_info);
     50            }
     51        }
     52    }   
     53}
    1254
    1355$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', 'name', 'category_name', 'feed', 'author_name');
     
    1759        if (!isset($$wpvar)) {
    1860            if (empty($HTTP_POST_VARS[$wpvar])) {
    19                 if (empty($HTTP_GET_VARS[$wpvar])) {
     61                if (empty($HTTP_GET_VARS[$wpvar]) && empty($path_info[$wpvar])) {
    2062                    $$wpvar = '';
     63                } elseif (!empty($HTTP_GET_VARS[$wpvar])) {
     64                    $$wpvar = $HTTP_GET_VARS[$wpvar];
    2165                } else {
    22                     $$wpvar = $HTTP_GET_VARS[$wpvar];
     66                    $$wpvar = $path_info[$wpvar];
    2367                }
    2468            } else {
Note: See TracChangeset for help on using the changeset viewer.