From 4fd7a402bcc13f45b1a25fd3960de6aa9e7dc24e Mon Sep 17 00:00:00 2001 From: donncha Date: Wed, 24 Oct 2007 08:35:33 +0000 Subject: Added "Content-length" and cleanup. props momo360modena and dsilverman, fixes #473 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1128 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-content/blogs.php | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'wp-content') diff --git a/wp-content/blogs.php b/wp-content/blogs.php index bdf5aca..e19fb9d 100644 --- a/wp-content/blogs.php +++ b/wp-content/blogs.php @@ -2,12 +2,8 @@ define( 'SHORTINIT', true ); // this prevents most of WP from being loaded require_once( dirname( dirname( __FILE__) ) . '/wp-config.php' ); // absolute includes are faster -if ( - $current_blog->archived == '1' || - $current_blog->spam == '1' || - $current_blog->deleted == '1' -) { - header("HTTP/1.1 404 Not Found"); +if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) { + header('HTTP/1.1 404 Not Found'); die('404 — File not found.'); } @@ -55,7 +51,7 @@ function wp_check_filetype($filename, $mimes = null) { $type = false; $ext = false; - foreach ($mimes as $ext_preg => $mime_match) { + foreach ( (array)$mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; if ( preg_match($ext_preg, $filename, $ext_matches) ) { $type = $mime_match; @@ -69,13 +65,13 @@ function wp_check_filetype($filename, $mimes = null) { endif; -$file = constant( "ABSPATH" ) . constant( "UPLOADS" ) . str_replace( '..', '', $_GET[ 'file' ] ); +$file = constant( 'ABSPATH' ) . constant( 'UPLOADS' ) . str_replace( '..', '', $_GET[ 'file' ] ); if ( !is_file( $file ) ) { - header("HTTP/1.1 404 Not Found"); + header('HTTP/1.1 404 Not Found'); die('404 — File not found.'); } -if( function_exists( "mime_content_type" ) ) { +if( function_exists( 'mime_content_type' ) ) { $mime[ 'type' ] = mime_content_type( $file ); } else { $mime = wp_check_filetype( $_SERVER[ 'REQUEST_URI' ] ); @@ -86,21 +82,20 @@ if( $mime[ 'type' ] != false ) { $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); $mimetype = "image/$ext"; } -header( 'Content-type: ' . $mimetype ); // always send this +@header( 'Content-type: ' . $mimetype ); // always send this +@header( 'Content-Length: ' . filesize( $file ) ); -$timestamp = filemtime( $file ); - -$last_modified = gmdate('D, d M Y H:i:s', $timestamp); +$last_modified = gmdate('D, d M Y H:i:s', filemtime( $file )); $etag = '"' . md5($last_modified) . '"'; @header( "Last-Modified: $last_modified GMT" ); @header( 'ETag: ' . $etag ); - -$expire = gmdate('D, d M Y H:i:s', time() + 100000000); -@header( "Expires: $expire GMT" ); +@header( 'Expires: ' . gmdate('D, d M Y H:i:s', time() + 100000000) . ' GMT' ); // Support for Conditional GET -if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); -else $client_etag = false; +if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) + $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); +else + $client_etag = false; $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']); // If string is empty, return 0. If not, attempt to parse into a timestamp -- cgit