Make WordPress Core


Ignore:
Timestamp:
07/06/2004 05:58:48 PM (22 years ago)
Author:
saxmatt
Message:

http://mosquito.wordpress.org/bug_view_page.php?bug_id=0000150 and various formatting cleanups.

File:
1 edited

Legend:

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

    r1449 r1452  
    11<?php
    22
    3 if (!file_exists(dirname(__FILE__).'/' . 'wp-config.php'))
     3if ( !file_exists( dirname(__FILE__) . '/wp-config.php') )
    44    die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='wp-admin/setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
    55
    6 require_once(dirname(__FILE__).'/' . '/wp-config.php');
     6require_once( dirname(__FILE__) . '/wp-config.php');
    77
    8 require_once(dirname(__FILE__).'/' . 'wp-includes/wp-l10n.php');
     8require_once( dirname(__FILE__) . '/wp-includes/wp-l10n.php');
    99
    1010// Process PATH_INFO, if set.
    1111$path_info = array();
    12 if (! empty($_SERVER['PATH_INFO'])) {
     12if ( !empty( $_SERVER['PATH_INFO'] ) ) {
    1313    // Fetch the rewrite rules.
    1414    $rewrite = rewrite_rules('matches');
     
    1616    $pathinfo = $_SERVER['PATH_INFO'];
    1717    // Trim leading '/'.
    18     $pathinfo = preg_replace("!^/!", '', $pathinfo);
     18    $pathinfo = preg_replace('!^/!', '', $pathinfo);
    1919
    2020    if (! empty($rewrite)) {
     
    5353$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');
    5454
    55     for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    56         $wpvar = $wpvarstoreset[$i];
    57         if (!isset($$wpvar)) {
    58             if (empty($_POST[$wpvar])) {
    59                 if (empty($_GET[$wpvar]) && empty($path_info[$wpvar])) {
    60                     $$wpvar = '';
    61                 } elseif (!empty($_GET[$wpvar])) {
    62                     $$wpvar = $_GET[$wpvar];
    63                 } else {
    64                     $$wpvar = $path_info[$wpvar];
    65                 }
    66             } else {
    67                 $$wpvar = $_POST[$wpvar];
    68             }
    69         }
    70     }
    71 
    72 if ($feed != '') {
    73     $doing_rss = 1;
     55for ($i=0; $i<count($wpvarstoreset); $i += 1) {
     56    $wpvar = $wpvarstoreset[$i];
     57    if (!isset($$wpvar)) {
     58        if (empty($_POST[$wpvar])) {
     59            if (empty($_GET[$wpvar]) && empty($path_info[$wpvar])) {
     60                $$wpvar = '';
     61            } elseif (!empty($_GET[$wpvar])) {
     62                $$wpvar = $_GET[$wpvar];
     63            } else {
     64                $$wpvar = $path_info[$wpvar];
     65            }
     66        } else {
     67            $$wpvar = $_POST[$wpvar];
     68        }
     69    }
    7470}
    7571
    76 if ($tb == 1) {
    77     $doing_trackback = 1;
     72if ('' != $feed) {
     73    $doing_rss = true;
     74}
     75
     76if (1 == $tb) {
     77    $doing_trackback = true;
    7878}
    7979
    8080// Sending HTTP headers
    8181
    82 if (!isset($doing_rss) || !$doing_rss) {
    83     // It is presumptious to think that WP is the only thing that might change on the page.
    84     @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");                 // Date in the past
    85     @header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
    86     @header("Cache-Control: no-store, no-cache, must-revalidate");     // HTTP/1.1
    87     @header("Cache-Control: post-check=0, pre-check=0", false);
    88     @header("Pragma: no-cache");                                     // HTTP/1.0
     82if ( !isset($doing_rss) || !$doing_rss ) {
    8983    @header ('X-Pingback: '. get_settings('siteurl') . '/xmlrpc.php');
    9084} else {
    91 
    9285    // We're showing a feed, so WP is indeed the only thing that last changed
    9386    $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
    94     $wp_etag = '"'.md5($wp_last_modified).'"';
     87    $wp_etag = '"' . md5($wp_last_modified) . '"';
    9588    @header('Last-Modified: '.$wp_last_modified);
    9689    @header('ETag: '.$wp_etag);
     
    118111        }
    119112    }
    120 
    121113}
    122114
    123115// Getting settings from DB
    124 if (isset($doing_rss) && $doing_rss == 1)
    125     $posts_per_page=get_settings('posts_per_rss');
    126 if (!isset($posts_per_page) || $posts_per_page == 0)
     116if ( isset($doing_rss) && $doing_rss == 1 )
     117    $posts_per_page = get_settings('posts_per_rss');
     118if ( !isset($posts_per_page) || $posts_per_page == 0 )
    127119    $posts_per_page = get_settings('posts_per_page');
    128 if (!isset($what_to_show))
     120if ( !isset($what_to_show) )
    129121    $what_to_show = get_settings('what_to_show');
    130 if (isset($showposts) && $showposts) {
    131     $showposts = (int)$showposts;
     122if ( isset($showposts) && $showposts ) {
     123    $showposts = (int) $showposts;
    132124    $posts_per_page = $showposts;
    133125}
     126
    134127$archive_mode = get_settings('archive_mode');
    135128$use_gzipcompression = get_settings('gzipcompression');
     
    140133$query_string = '';
    141134foreach (array_merge($wpvarstoreset, $more_wpvars) as $wpvar) {
    142     if ($$wpvar != '') {
    143         $query_string .= (strlen($query_string) < 1) ? '' : '&';
    144         $query_string .= $wpvar . '=' . rawurlencode($$wpvar);
    145     }
     135    if ($$wpvar != '') {
     136        $query_string .= (strlen($query_string) < 1) ? '' : '&';
     137        $query_string .= $wpvar . '=' . rawurlencode($$wpvar);
     138    }
    146139}
    147140
     
    150143$wp_query_state->parse_query($query_string);
    151144
    152 // Update some caches.
    153145update_category_cache();
    154146
     
    157149
    158150if (1 == count($posts)) {
    159     if ($p || $name) {
    160         $more = 1;
    161         $single = 1;
    162     }
    163     if ($s && empty($paged)) { // If they were doing a search and got one result
    164         if (!strstr($_SERVER['PHP_SELF'], 'wp-admin')) // And not in admin section
    165             header('Location: ' . get_permalink($posts[0]->ID));
    166     }
     151    if ($p || $name) {
     152        $more = 1;
     153        $single = 1;
     154    }
     155    if ( $s && empty($paged) && !strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { // If they were doing a search and got one result
     156        header('Location: ' . get_permalink($posts[0]->ID));
     157    }
    167158}
    168159
    169160if ($pagenow != 'wp-feed.php' && $feed != '') {
    170     require(dirname(__FILE__) . '/wp-feed.php');
    171     exit;
     161    require(dirname(__FILE__) . '/wp-feed.php');
     162    exit;
    172163}
    173164
    174165if ($pagenow != 'wp-trackback.php' && $tb == 1) {
    175     require(dirname(__FILE__) . '/wp-trackback.php');
    176     exit;
     166    require(dirname(__FILE__) . '/wp-trackback.php');
     167    exit;
    177168}
    178169
    179170if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
    180     if ( get_settings('gzipcompression') )
    181         gzip_compression();
     171    if ( get_settings('gzipcompression') )
     172        gzip_compression();
    182173}
    183174
Note: See TracChangeset for help on using the changeset viewer.