⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wp-blog-header.php

📁 是一个优秀的语义个人发布平台
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

if (!file_exists(dirname(__FILE__).'/' . 'wp-config.php'))
    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.");

require_once(dirname(__FILE__).'/' . '/wp-config.php');

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 '?'.
                $query = preg_replace("!^.+\?!", '', $query);

                // Substitute the substring matches into the query.
                eval("\$query = \"$query\";");

                // Parse the query.
                parse_str($query, $path_info);
            }
        }
    }    
}

$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');

    for ($i=0; $i<count($wpvarstoreset); $i += 1) {
        $wpvar = $wpvarstoreset[$i];
        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 {
                $$wpvar = $_POST[$wpvar];
            }
        }
    }


// Sending HTTP headers

if (!isset($doing_rss) || !$doing_rss) {
	// It is presumptious to think that WP is the only thing that might change on the page.
	@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");                 // Date in the past
	@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
	@header("Cache-Control: no-store, no-cache, must-revalidate");     // HTTP/1.1
	@header("Cache-Control: post-check=0, pre-check=0", false);
	@header("Pragma: no-cache");                                     // HTTP/1.0
	@header ('X-Pingback: '. get_settings('siteurl') . '/xmlrpc.php');
} else {

	// We're showing a feed, so WP is indeed the only thing that last changed
	$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
	$wp_etag = '"'.md5($wp_last_modified).'"';
	@header('Last Modified: '.$wp_last_modified);
	@header('ETag: '.$wp_etag);
	@header ('X-Pingback: ' . get_settings('siteurl') . '/xmlrpc.php');

	// Support for Conditional GET
	if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) $client_last_modified = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
	else $client_last_modified = false;
	if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
	else $client_etag = false;

	if ( ($client_last_modified && $client_etag) ?
	    (($client_last_modified == $wp_last_modified) && ($client_etag == $wp_etag)) :
	    (($client_last_modified == $wp_last_modified) || ($client_etag == $wp_etag)) ) {
		if ( preg_match('/cgi/',php_sapi_name()) ) {
		    header('HTTP/1.1 304 Not Modified');
		    echo "\r\n\r\n";
		    exit;
		} else {
		    if (version_compare(phpversion(),'4.3.0','>=')) {
		        header('Not Modified', TRUE, 304);
		    } else {
		        header('HTTP/1.x 304 Not Modified');
		    }
		}
	}

}

// Getting settings from DB
if (isset($doing_rss) && $doing_rss == 1)
    $posts_per_page=get_settings('posts_per_rss');
if (!isset($posts_per_page) || $posts_per_page == 0)
    $posts_per_page = get_settings('posts_per_page');
if (!isset($what_to_show))
    $what_to_show = get_settings('what_to_show');
$archive_mode = get_settings('archive_mode');
$use_gzipcompression = get_settings('gzipcompression');

// First let's clear some variables
$whichcat = '';
$whichauthor = '';
$result = '';
$where = '';
$limits = '';
$distinct = '';
$join = '';

if ($pagenow != 'post.php') { timer_start(); }

if (isset($showposts) && $showposts) {
    $showposts = (int)$showposts;
    $posts_per_page = $showposts;
}

$add_hours = intval(get_settings('gmt_offset'));
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";

// If a month is specified in the querystring, load that month
if ('' != $m) {
    $m = '' . preg_replace('|[^0-9]|', '', $m);
    $where .= ' AND YEAR(post_date)=' . substr($m, 0, 4);
    if (strlen($m)>5)
        $where .= ' AND MONTH(post_date)=' . substr($m, 4, 2);
    if (strlen($m)>7)
        $where .= ' AND DAYOFMONTH(post_date)=' . substr($m, 6, 2);
    if (strlen($m)>9)
        $where .= ' AND HOUR(post_date)=' . substr($m, 8, 2);
    if (strlen($m)>11)
        $where .= ' AND MINUTE(post_date)=' . substr($m, 10, 2);
    if (strlen($m)>13)
        $where .= ' AND SECOND(post_date)=' . substr($m, 12, 2);
}

if ('' != $hour) {
	$hour = '' . intval($hour);
	$where .= " AND HOUR(post_date)='$hour'";
}

if ('' != $minute) {
	$minute = '' . intval($minute);
	$where .= " AND MINUTE(post_date)='$minute'";
}

if ('' != $second) {
	$second = '' . intval($second);
	$where .= " AND SECOND(post_date)='$second'";
}

if ('' != $year) {
    $year = '' . intval($year);
    $where .= " AND YEAR(post_date)='$year'";
}

if ('' != $monthnum) {
    $monthnum = '' . intval($monthnum);
    $where .= " AND MONTH(post_date)='$monthnum'";
}

if ('' != $day) {
    $day = '' . intval($day);
    $where .= " AND DAYOFMONTH(post_date)='$day'";
}

if ('' != $name) {
    $name = preg_replace('/[^a-z0-9-_]/', '', $name);
    $where .= " AND post_name = '$name'";
}

if ('' != $w) {
    $w = ''.intval($w);
    $where .= " AND WEEK(post_date, 1)='$w'";
}

// If a post number is specified, load that post
if (($p != '') && ($p != 'all')) {
    $p = intval($p);
    $where = ' AND ID = '.$p;
}

// If a search pattern is specified, load the posts that match
if (!empty($s)) {
    $s = addslashes_gpc($s);
    $search = ' AND (';
    $s = preg_replace('/, +/', ' ', $s);
    $s = str_replace(',', ' ', $s);
    $s = str_replace('"', ' ', $s);
    $s = trim($s);
    if ($exact) {
        $n = '';
    } else {
        $n = '%';
    }
    if (!$sentence) {
        $s_array = explode(' ',$s);
        $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
        for ( $i = 1; $i < count($s_array); $i = $i + 1) {
            $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
        }
        $search .= ' OR (post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\')';
        $search .= ')';
    } else {
        $search = ' AND ((post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\'))';
    }
}

// Category stuff
$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
foreach ($dogs as $catt) {
    $cache_categories[$catt->cat_ID] = $catt;
}

if ((empty($cat)) || ($cat == 'all') || ($cat == '0') || 
	// Bypass cat checks if fetching specific posts
	(
		intval($year) || intval($monthnum) || intval($day) || intval($w) ||
		intval($p) || !empty($name) || !empty($s)
	)
		) {
    $whichcat='';
} else {
    $cat = ''.urldecode($cat).'';
    $cat = addslashes_gpc($cat);
    if (stristr($cat,'-')) {
        // Note: if we have a negative, we ignore all the positives. It must
        // always mean 'everything /except/ this one'. We should be able to do
        // multiple negatives but we don't :-(
        $eq = '!=';
        $andor = 'AND';
        $cat = explode('-',$cat);
        $cat = intval($cat[1]);
    } else {
        $eq = '=';
        $andor = 'OR';
    }
    $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
    $cat_array = explode(' ',$cat);
    $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
    $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
    for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
            $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -