Changeset 2627
- Timestamp:
- 06/10/2005 11:15:13 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-atom.php
r2625 r2627 1 1 <?php 2 2 3 if (empty($feed)) { 4 $blog = 1; 5 $feed = 'atom'; 6 $doing_rss = 1; 7 require('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('feed=atom'); 8 6 } 9 7 -
trunk/wp-blog-header.php
r2623 r2627 12 12 require_once( dirname(__FILE__) . '/wp-config.php'); 13 13 14 $query_vars = array(); 14 wp(); 15 gzip_compression(); 15 16 16 // Process PATH_INFO and 404. 17 if ((isset($_GET['error']) && $_GET['error'] == '404') || 18 ((! empty($_SERVER['PATH_INFO'])) && 19 ('/' != $_SERVER['PATH_INFO']) && 20 (false === strpos($_SERVER['PATH_INFO'], '.php')) 21 )) { 22 23 // If we match a rewrite rule, this will be cleared. 24 $error = '404'; 25 26 // Fetch the rewrite rules. 27 $rewrite = $wp_rewrite->wp_rewrite_rules(); 28 29 if (! empty($rewrite)) { 30 $pathinfo = $_SERVER['PATH_INFO']; 31 $req_uri = $_SERVER['REQUEST_URI']; 32 $home_path = parse_url(get_settings('home')); 33 $home_path = $home_path['path']; 34 35 // Trim path info from the end and the leading home path from the 36 // front. For path info requests, this leaves us with the requesting 37 // filename, if any. For 404 requests, this leaves us with the 38 // requested permalink. 39 $req_uri = str_replace($pathinfo, '', $req_uri); 40 $req_uri = str_replace($home_path, '', $req_uri); 41 $req_uri = trim($req_uri, '/'); 42 $pathinfo = trim($pathinfo, '/'); 43 44 // The requested permalink is in $pathinfo for path info requests and 45 // $req_uri for other requests. 46 if (! empty($pathinfo)) { 47 $request = $pathinfo; 48 } else { 49 $request = $req_uri; 50 } 51 52 // Look for matches. 53 $request_match = $request; 54 foreach ($rewrite as $match => $query) { 55 // If the requesting file is the anchor of the match, prepend it 56 // to the path info. 57 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) { 58 $request_match = $req_uri . '/' . $request; 59 } 60 61 if (preg_match("!^$match!", $request_match, $matches)) { 62 // Got a match. 63 // Trim the query of everything up to the '?'. 64 $query = preg_replace("!^.+\?!", '', $query); 65 66 // Substitute the substring matches into the query. 67 eval("\$query = \"$query\";"); 68 69 // Parse the query. 70 parse_str($query, $query_vars); 71 72 // If we're processing a 404 request, clear the error var 73 // since we found something. 74 if (isset($_GET['error'])) { 75 unset($_GET['error']); 76 } 77 78 if (isset($error)) { 79 unset($error); 80 } 81 82 break; 83 } 84 } 85 } 86 } 87 88 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup'); 89 90 $wpvarstoreset = apply_filters('query_vars', $wpvarstoreset); 91 92 for ($i=0; $i<count($wpvarstoreset); $i += 1) { 93 $wpvar = $wpvarstoreset[$i]; 94 if (!isset($$wpvar)) { 95 if (empty($_POST[$wpvar])) { 96 if (empty($_GET[$wpvar]) && empty($query_vars[$wpvar])) { 97 $$wpvar = ''; 98 } elseif (!empty($_GET[$wpvar])) { 99 $$wpvar = $_GET[$wpvar]; 100 } else { 101 $$wpvar = $query_vars[$wpvar]; 102 } 103 } else { 104 $$wpvar = $_POST[$wpvar]; 105 } 106 } 107 } 108 109 // Sending HTTP headers 110 @header('X-Pingback: '. get_bloginfo('pingback_url')); 111 112 if ( !empty($error) && '404' == $error ) { 113 status_header( 404 ); 114 } else if ( empty($feed) ) { 115 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 116 } else { 117 // We're showing a feed, so WP is indeed the only thing that last changed 118 if ( $withcomments ) 119 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; 120 else 121 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 122 $wp_etag = '"' . md5($wp_last_modified) . '"'; 123 @header("Last-Modified: $wp_last_modified"); 124 @header("ETag: $wp_etag"); 125 126 // Support for Conditional GET 127 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); 128 else $client_etag = false; 129 130 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); 131 // If string is empty, return 0. If not, attempt to parse into a timestamp 132 $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; 133 134 // Make a timestamp for our most recent modification... 135 $wp_modified_timestamp = strtotime($wp_last_modified); 136 137 if ( ($client_last_modified && $client_etag) ? 138 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : 139 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { 140 status_header( 304 ); 141 exit; 142 } 143 } 144 145 $use_gzipcompression = get_settings('gzipcompression'); 146 147 $more_wpvars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging'); 148 149 // Construct the query string. 150 $query_string = ''; 151 foreach (array_merge($wpvarstoreset, $more_wpvars) as $wpvar) { 152 if ($$wpvar != '') { 153 $query_string .= (strlen($query_string) < 1) ? '' : '&'; 154 $query_string .= $wpvar . '=' . rawurlencode($$wpvar); 155 } 156 } 157 158 $query_string = apply_filters('query_string', $query_string); 159 160 update_category_cache(); 161 get_currentuserinfo(); 162 163 // Call query posts to do the work. 164 $posts = & query_posts($query_string); 165 166 // Extract updated query vars back into global namespace. 167 extract($wp_query->query_vars); 168 169 if ( is_single() || is_page() ) { 170 $more = 1; 171 $single = 1; 172 } 173 174 // Issue a 404 if a permalink request doesn't match any posts. Don't issue a 175 // 404 if one was already issued, if the request was a search, or if the 176 // request was a regular query string request rather than a permalink request. 177 if ( (0 == count($posts)) && !is_404() && !is_search() 178 && ( isset($rewrite) || (!empty($_SERVER['QUERY_STRING']) && 179 (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) { 180 $wp_query->is_404 = true; 181 status_header( 404 ); 182 } else { 183 status_header( 200 ); 184 } 185 186 if ($pagenow != 'post.php' && $pagenow != 'edit.php') { 187 if ( get_settings('gzipcompression') ) 188 gzip_compression(); 189 } 190 191 // Template redirection 192 if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) { 193 do_action('template_redirect'); 194 if ( is_feed() && empty($doing_rss) ) { 195 include(ABSPATH . '/wp-feed.php'); 196 exit; 197 } else if ( is_trackback() && empty($doing_trackback) ) { 198 include(ABSPATH . '/wp-trackback.php'); 199 exit; 200 } else if ( is_404() && get_404_template() ) { 201 include(get_404_template()); 202 exit; 203 } else if ( is_search() && get_search_template() ) { 204 include(get_search_template()); 205 exit; 206 } else if ( is_home() && get_home_template() ) { 207 include(get_home_template()); 208 exit; 209 } else if ( is_single() && get_single_template() ) { 210 include(get_single_template()); 211 exit; 212 } else if ( is_page() && get_page_template() ) { 213 include(get_page_template()); 214 exit; 215 } else if ( is_category() && get_category_template()) { 216 include(get_category_template()); 217 exit; 218 } else if ( is_author() && get_author_template() ) { 219 include(get_author_template()); 220 exit; 221 } else if ( is_date() && get_date_template() ) { 222 include(get_date_template()); 223 exit; 224 } else if ( is_archive() && get_archive_template() ) { 225 include(get_archive_template()); 226 exit; 227 } else if ( is_comments_popup() && get_comments_popup_template() ) { 228 include(get_comments_popup_template()); 229 exit; 230 } else if ( is_paged() && get_paged_template() ) { 231 include(get_paged_template()); 232 exit; 233 } else if ( file_exists(TEMPLATEPATH . "/index.php") ) { 234 include(TEMPLATEPATH . "/index.php"); 235 exit; 236 } 237 } else { 238 // Process feeds and trackbacks even if not using themes. 239 if ( is_feed() && empty($doing_rss) ) { 240 include(ABSPATH . '/wp-feed.php'); 241 exit; 242 } else if ( is_trackback() && empty($doing_trackback) ) { 243 include(ABSPATH . '/wp-trackback.php'); 244 exit; 245 } 246 } 17 require_once(ABSPATH . WPINC . '/template-loader.php'); 247 18 248 19 endif; -
trunk/wp-commentsrss2.php
r2543 r2627 1 1 <?php 2 if ( empty($feed) ) { 3 $feed = 'rss2'; 4 $withcomments = 1; 5 $doing_rss = 1; 6 require('wp-blog-header.php'); 2 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('feed=rss2&withcomments=1'); 7 6 } 8 7 -
trunk/wp-includes/classes.php
r2535 r2627 662 662 } 663 663 } 664 }665 666 // Make a global instance.667 if (! isset($wp_query)) {668 $wp_query = new WP_Query();669 664 } 670 665 … … 1292 1287 } 1293 1288 1294 // Make a global instance. 1295 if (! isset($wp_rewrite)) { 1296 $wp_rewrite = new WP_Rewrite(); 1289 class WP { 1290 var $public_query_vars = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup'); 1291 1292 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging'); 1293 1294 var $query_vars; 1295 var $query_string; 1296 var $did_permalink = false; 1297 1298 function parse_request($extra_query_vars = '') { 1299 global $wp_rewrite; 1300 1301 $this->query_vars = array(); 1302 1303 if (! empty($extra_query_vars)) 1304 parse_str($extra_query_vars, $extra_query_vars); 1305 1306 // Process PATH_INFO and 404. 1307 if ((isset($_GET['error']) && $_GET['error'] == '404') || 1308 ((! empty($_SERVER['PATH_INFO'])) && 1309 ('/' != $_SERVER['PATH_INFO']) && 1310 (false === strpos($_SERVER['PATH_INFO'], '.php')) 1311 )) { 1312 1313 $this->did_permalink = true; 1314 1315 // If we match a rewrite rule, this will be cleared. 1316 $error = '404'; 1317 1318 // Fetch the rewrite rules. 1319 $rewrite = $wp_rewrite->wp_rewrite_rules(); 1320 1321 if (! empty($rewrite)) { 1322 $pathinfo = $_SERVER['PATH_INFO']; 1323 $req_uri = $_SERVER['REQUEST_URI']; 1324 $home_path = parse_url(get_settings('home')); 1325 $home_path = $home_path['path']; 1326 1327 // Trim path info from the end and the leading home path from the 1328 // front. For path info requests, this leaves us with the requesting 1329 // filename, if any. For 404 requests, this leaves us with the 1330 // requested permalink. 1331 $req_uri = str_replace($pathinfo, '', $req_uri); 1332 $req_uri = str_replace($home_path, '', $req_uri); 1333 $req_uri = trim($req_uri, '/'); 1334 $pathinfo = trim($pathinfo, '/'); 1335 1336 // The requested permalink is in $pathinfo for path info requests and 1337 // $req_uri for other requests. 1338 if (! empty($pathinfo)) { 1339 $request = $pathinfo; 1340 } else { 1341 $request = $req_uri; 1342 } 1343 1344 // Look for matches. 1345 $request_match = $request; 1346 foreach ($rewrite as $match => $query) { 1347 // If the requesting file is the anchor of the match, prepend it 1348 // to the path info. 1349 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) { 1350 $request_match = $req_uri . '/' . $request; 1351 } 1352 1353 if (preg_match("!^$match!", $request_match, $matches)) { 1354 // Got a match. 1355 // Trim the query of everything up to the '?'. 1356 $query = preg_replace("!^.+\?!", '', $query); 1357 1358 // Substitute the substring matches into the query. 1359 eval("\$query = \"$query\";"); 1360 1361 // Parse the query. 1362 parse_str($query, $query_vars); 1363 1364 // If we're processing a 404 request, clear the error var 1365 // since we found something. 1366 if (isset($_GET['error'])) { 1367 unset($_GET['error']); 1368 } 1369 1370 if (isset($error)) { 1371 unset($error); 1372 } 1373 1374 break; 1375 } 1376 } 1377 } 1378 } 1379 1380 $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); 1381 1382 for ($i=0; $i<count($this->public_query_vars); $i += 1) { 1383 $wpvar = $this->public_query_vars[$i]; 1384 if (isset($extra_query_vars[$wpvar])) 1385 $this->query_vars[$wpvar] = $extra_query_vars[$wpvar]; 1386 elseif (isset($GLOBALS[$wpvar])) 1387 $this->query_vars[$wpvar] = $GLOBALS[$wpvar]; 1388 elseif (!empty($_POST[$wpvar])) 1389 $this->query_vars[$wpvar] = $_POST[$wpvar]; 1390 elseif (!empty($_GET[$wpvar])) 1391 $this->query_vars[$wpvar] = $_GET[$wpvar]; 1392 elseif (!empty($query_vars[$wpvar])) 1393 $this->query_vars[$wpvar] = $query_vars[$wpvar]; 1394 else 1395 $this->query_vars[$wpvar] = ''; 1396 } 1397 } 1398 1399 function send_headers() { 1400 @header('X-Pingback: '. get_bloginfo('pingback_url')); 1401 if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) { 1402 status_header( 404 ); 1403 } else if ( empty($this->query_vars['feed']) ) { 1404 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 1405 } else { 1406 // We're showing a feed, so WP is indeed the only thing that last changed 1407 if ( $this->query_vars['withcomments'] ) 1408 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; 1409 else 1410 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 1411 $wp_etag = '"' . md5($wp_last_modified) . '"'; 1412 @header("Last-Modified: $wp_last_modified"); 1413 @header("ETag: $wp_etag"); 1414 1415 // Support for Conditional GET 1416 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); 1417 else $client_etag = false; 1418 1419 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); 1420 // If string is empty, return 0. If not, attempt to parse into a timestamp 1421 $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; 1422 1423 // Make a timestamp for our most recent modification... 1424 $wp_modified_timestamp = strtotime($wp_last_modified); 1425 1426 if ( ($client_last_modified && $client_etag) ? 1427 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : 1428 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { 1429 status_header( 304 ); 1430 exit; 1431 } 1432 } 1433 } 1434 1435 function build_query_string() { 1436 $this->query_string = ''; 1437 1438 foreach ($this->public_query_vars as $wpvar) { 1439 if (isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) { 1440 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 1441 $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); 1442 } 1443 } 1444 1445 foreach ($this->private_query_vars as $wpvar) { 1446 if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar]) { 1447 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 1448 $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]); 1449 } 1450 } 1451 1452 $this->query_string = apply_filters('query_string', $this->query_string); 1453 } 1454 1455 function register_globals() { 1456 global $wp_query; 1457 // Extract updated query vars back into global namespace. 1458 foreach ($wp_query->query_vars as $key => $value) { 1459 $GLOBALS[$key] = $value; 1460 } 1461 1462 $GLOBALS['query_string'] = & $this->query_string; 1463 $GLOBALS['posts'] = & $wp_query->posts; 1464 $GLOBALS['post'] = & $wp_query->post; 1465 1466 if ( is_single() || is_page() ) { 1467 $GLOBALS['more'] = 1; 1468 $GLOBALS['single'] = 1; 1469 } 1470 } 1471 1472 function prime_caches() { 1473 update_category_cache(); 1474 get_currentuserinfo(); 1475 } 1476 1477 function query_posts() { 1478 $this->build_query_string(); 1479 query_posts($this->query_string); 1480 } 1481 1482 function handle_404() { 1483 global $wp_query; 1484 // Issue a 404 if a permalink request doesn't match any posts. Don't 1485 // issue a 404 if one was already issued, if the request was a search, 1486 // or if the request was a regular query string request rather than a 1487 // permalink request. 1488 if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() 1489 && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && 1490 (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) { 1491 $wp_query->is_404 = true; 1492 status_header( 404 ); 1493 } else { 1494 status_header( 200 ); 1495 } 1496 } 1497 1498 function main($query_args = '') { 1499 $this->parse_request($query_args); 1500 $this->send_headers(); 1501 $this->prime_caches(); 1502 $this->query_posts(); 1503 $this->handle_404(); 1504 $this->register_globals(); 1505 } 1506 1507 function WP() { 1508 // Empty. 1509 } 1297 1510 } 1298 1511 -
trunk/wp-includes/functions.php
r2623 r2627 1850 1850 } 1851 1851 1852 function wp($query_vars = '') { 1853 global $wp; 1854 $wp->main($query_vars); 1855 } 1856 1852 1857 function status_header( $header ) { 1853 1858 if ( 200 == $header ) { -
trunk/wp-rdf.php
r2625 r2627 1 1 <?php /* RDF 1.0 generator, original version by garym@teledyn.com */ 2 2 3 if (empty($feed)) { 4 $blog = 1; // enter your blog's ID 5 $feed = 'rdf'; 6 $doing_rss = 1; 7 require('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('feed=rdf'); 8 6 } 9 7 -
trunk/wp-rss.php
r2625 r2627 1 1 <?php 2 2 3 if (empty($feed)) { 4 $blog = 1; 5 $feed = 'rss'; 6 $doing_rss = 1; 7 require('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('feed=rss'); 8 6 } 9 7 -
trunk/wp-rss2.php
r2625 r2627 1 1 <?php 2 2 3 if (empty($feed)) { 4 $blog = 1; 5 $feed = 'rss2'; 6 $doing_rss = 1; 7 require('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('feed=rss2'); 8 6 } 9 7 -
trunk/wp-settings.php
r2516 r2627 146 146 register_shutdown_function('shutdown_action_hook'); 147 147 148 // Everything is loaded. 148 $wp_query = new WP_Query(); 149 $wp_rewrite = new WP_Rewrite(); 150 $wp = new WP(); 151 152 // Everything is loaded and initialized. 149 153 do_action('init'); 150 154 ?> -
trunk/wp-trackback.php
r2563 r2627 1 1 <?php 2 require_once( dirname(__FILE__) . '/wp-config.php' );3 2 4 if ( empty($doing_trackback) ) { 5 $doing_trackback = true; 6 $tb = true; 7 require_once('wp-blog-header.php'); 3 if (empty($wp)) { 4 require_once('wp-config.php'); 5 wp('tb=1'); 8 6 } 9 7
Note: See TracChangeset
for help on using the changeset viewer.