2003-12-10 19:22:36 -05:00
< ? php
2004-05-12 03:55:37 -04:00
if ( ! file_exists ( dirname ( __FILE__ ) . '/' . 'wp-config.php' ))
2004-05-18 16:05:40 -04:00
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. " );
2003-12-10 19:22:36 -05:00
2004-05-12 03:55:37 -04:00
require_once ( dirname ( __FILE__ ) . '/' . '/wp-config.php' );
2003-12-10 19:22:36 -05:00
2004-05-14 16:46:05 -04:00
require_once ( dirname ( __FILE__ ) . '/' . 'wp-includes/wp-l10n.php' );
2004-05-09 01:54:17 -04:00
// Process PATH_INFO, if set.
2004-02-16 21:50:57 -05:00
$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.
2004-04-20 18:56:47 -04:00
$req_uri = $_SERVER [ 'REQUEST_URI' ];
2004-02-16 21:50:57 -05:00
$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.
2004-03-14 11:43:55 -05:00
if (( ! empty ( $req_uri )) && ( strpos ( $match , $req_uri ) === 0 )) {
2004-02-16 21:50:57 -05:00
$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 );
2004-06-02 01:16:44 -04:00
break ;
2004-02-16 21:50:57 -05:00
}
}
}
}
2004-05-05 03:34:41 -04:00
$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' );
2003-12-10 19:22:36 -05:00
2004-01-27 01:35:07 -05:00
for ( $i = 0 ; $i < count ( $wpvarstoreset ); $i += 1 ) {
$wpvar = $wpvarstoreset [ $i ];
if ( ! isset ( $$wpvar )) {
2004-04-20 18:56:47 -04:00
if ( empty ( $_POST [ $wpvar ])) {
if ( empty ( $_GET [ $wpvar ]) && empty ( $path_info [ $wpvar ])) {
2004-01-27 01:35:07 -05:00
$$wpvar = '' ;
2004-04-20 18:56:47 -04:00
} elseif ( ! empty ( $_GET [ $wpvar ])) {
$$wpvar = $_GET [ $wpvar ];
2004-02-16 21:50:57 -05:00
} else {
$$wpvar = $path_info [ $wpvar ];
2004-01-27 01:35:07 -05:00
}
} else {
2004-04-20 18:56:47 -04:00
$$wpvar = $_POST [ $wpvar ];
2004-01-27 01:35:07 -05:00
}
}
}
2003-12-10 19:22:36 -05:00
2004-05-31 19:35:32 -04:00
if ( $feed != '' ) {
$doing_rss = 1 ;
}
if ( $tb == 1 ) {
$doing_trackback = 1 ;
}
2003-12-10 19:22:36 -05:00
2004-05-09 01:54:17 -04:00
// Sending HTTP headers
2004-02-21 22:29:54 -05:00
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
2004-02-26 11:15:48 -05:00
@ header ( 'X-Pingback: ' . get_settings ( 'siteurl' ) . '/xmlrpc.php' );
2004-02-21 22:29:54 -05:00
} else {
2004-03-30 22:54:58 -05:00
2004-02-21 22:29:54 -05:00
// We're showing a feed, so WP is indeed the only thing that last changed
2004-05-21 18:33:47 -04:00
$wp_last_modified = mysql2date ( 'D, d M Y H:i:s' , get_lastpostmodified ( 'GMT' ), 0 ) . ' GMT' ;
2004-03-31 16:19:58 -05:00
$wp_etag = '"' . md5 ( $wp_last_modified ) . '"' ;
@ header ( 'Last Modified: ' . $wp_last_modified );
@ header ( 'ETag: ' . $wp_etag );
2004-02-26 11:15:48 -05:00
@ header ( 'X-Pingback: ' . get_settings ( 'siteurl' ) . '/xmlrpc.php' );
2004-03-30 22:54:58 -05:00
2004-03-31 16:19:58 -05:00
// Support for Conditional GET
2004-05-10 03:51:50 -04:00
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 ;
2004-03-31 16:19:58 -05:00
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 )) ) {
2004-05-21 18:33:47 -04:00
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' );
}
}
2004-03-30 22:54:58 -05:00
}
2004-03-31 16:19:58 -05:00
2004-02-21 22:29:54 -05:00
}
2003-12-10 19:22:36 -05:00
2004-05-09 01:54:17 -04:00
// Getting settings from DB
2003-12-10 19:22:36 -05:00
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' );
2004-05-18 14:37:57 -04:00
if ( ! isset ( $what_to_show ))
$what_to_show = get_settings ( 'what_to_show' );
2003-12-10 19:22:36 -05:00
if ( isset ( $showposts ) && $showposts ) {
$showposts = ( int ) $showposts ;
2004-01-27 01:35:07 -05:00
$posts_per_page = $showposts ;
2003-12-10 19:22:36 -05:00
}
2004-05-23 22:55:39 -04:00
$archive_mode = get_settings ( 'archive_mode' );
$use_gzipcompression = get_settings ( 'gzipcompression' );
2004-02-24 23:08:54 -05:00
2004-05-23 22:55:39 -04:00
$more_wpvars = array ( 'posts_per_page' , 'what_to_show' , 'showposts' );
2004-02-10 23:51:19 -05:00
2004-05-23 22:55:39 -04:00
// Construct the query string.
$query_string = '' ;
foreach ( array_merge ( $wpvarstoreset , $more_wpvars ) as $wpvar ) {
if ( $$wpvar != '' ) {
$query_string .= ( strlen ( $query_string ) < 1 ) ? '' : '&' ;
$query_string .= $wpvar . '=' . rawurlencode ( $$wpvar );
2004-02-10 23:51:19 -05:00
}
}
2004-05-23 22:55:39 -04:00
if ( $pagenow != 'post.php' ) { timer_start (); }
2003-12-10 19:22:36 -05:00
2004-05-23 22:55:39 -04:00
// Update some caches.
update_category_cache ();
2003-12-10 19:22:36 -05:00
2004-05-23 22:55:39 -04:00
// Call query posts to do the work.
$posts = query_posts ( $query_string );
2003-12-10 19:22:36 -05:00
2004-05-23 22:55:39 -04:00
// Update per post caches.
update_post_caches ( $posts );
2003-12-10 19:22:36 -05:00
2004-05-23 22:55:39 -04:00
if ( 1 == count ( $posts )) {
if ( $p || $name ) {
$more = 1 ;
$single = 1 ;
2004-01-27 01:35:07 -05:00
}
2004-05-23 22:55:39 -04:00
if ( $s && empty ( $paged )) { // If they were doing a search and got one result
if ( ! strstr ( $_SERVER [ 'PHP_SELF' ], 'wp-admin' )) // And not in admin section
header ( 'Location: ' . get_permalink ( $posts [ 0 ] -> ID ));
2004-01-27 01:35:07 -05:00
}
2003-12-10 19:22:36 -05:00
}
2004-05-31 19:35:32 -04:00
if ( $pagenow != 'wp-feed.php' && $feed != '' ) {
require ( dirname ( __FILE__ ) . '/wp-feed.php' );
exit ;
}
if ( $pagenow != 'wp-trackback.php' && $tb == 1 ) {
require ( dirname ( __FILE__ ) . '/wp-trackback.php' );
exit ;
}
2004-01-07 12:36:54 -05:00
if ( $pagenow != 'post.php' && $pagenow != 'edit.php' ) {
2004-06-10 06:01:45 -04:00
if ( get_settings ( 'gzipcompression' ) )
2004-01-27 01:35:07 -05:00
gzip_compression ();
2003-12-10 19:22:36 -05:00
}
2004-05-24 04:22:18 -04:00
?>