Changeset 1128

Show
Ignore:
Timestamp:
10/24/07 08:35:33 (1 year ago)
Author:
donncha
Message:

Added "Content-length" and cleanup. props momo360modena and dsilverman, fixes #473

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-content/blogs.php

    r1044 r1128  
    33require_once( dirname( dirname( __FILE__) ) . '/wp-config.php' ); // absolute includes are faster 
    44 
    5 if (  
    6         $current_blog->archived == '1' ||  
    7         $current_blog->spam == '1' || 
    8         $current_blog->deleted == '1'  
    9 ) { 
    10         header("HTTP/1.1 404 Not Found"); 
     5if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) { 
     6        header('HTTP/1.1 404 Not Found'); 
    117        die('404 — File not found.'); 
    128} 
     
    5652        $ext = false; 
    5753 
    58         foreach ($mimes as $ext_preg => $mime_match) { 
     54        foreach ( (array)$mimes as $ext_preg => $mime_match ) { 
    5955                $ext_preg = '!\.(' . $ext_preg . ')$!i'; 
    6056                if ( preg_match($ext_preg, $filename, $ext_matches) ) { 
     
    7066 
    7167 
    72 $file = constant( "ABSPATH" ) . constant( "UPLOADS" ) . str_replace( '..', '', $_GET[ 'file' ] ); 
     68$file = constant( 'ABSPATH' ) . constant( 'UPLOADS' ) . str_replace( '..', '', $_GET[ 'file' ] ); 
    7369if ( !is_file( $file ) ) { 
    74         header("HTTP/1.1 404 Not Found"); 
     70        header('HTTP/1.1 404 Not Found'); 
    7571        die('404 — File not found.'); 
    7672} 
    7773 
    78 if( function_exists( "mime_content_type" ) ) { 
     74if( function_exists( 'mime_content_type' ) ) { 
    7975        $mime[ 'type' ] = mime_content_type( $file ); 
    8076} else { 
     
    8783        $mimetype = "image/$ext"; 
    8884} 
    89 header( 'Content-type: ' . $mimetype ); // always send this 
     85@header( 'Content-type: ' . $mimetype ); // always send this 
     86@header( 'Content-Length: ' . filesize( $file ) ); 
    9087 
    91 $timestamp = filemtime( $file ); 
    92  
    93 $last_modified = gmdate('D, d M Y H:i:s', $timestamp); 
     88$last_modified = gmdate('D, d M Y H:i:s', filemtime( $file )); 
    9489$etag = '"' . md5($last_modified) . '"'; 
    9590@header( "Last-Modified: $last_modified GMT" ); 
    9691@header( 'ETag: ' . $etag ); 
    97  
    98 $expire = gmdate('D, d M Y H:i:s', time() + 100000000); 
    99 @header( "Expires: $expire GMT" ); 
     92@header( 'Expires: ' . gmdate('D, d M Y H:i:s', time() + 100000000) . ' GMT' ); 
    10093 
    10194// Support for Conditional GET 
    102 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); 
    103 else $client_etag = false; 
     95if (isset($_SERVER['HTTP_IF_NONE_MATCH']))  
     96        $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); 
     97else 
     98        $client_etag = false; 
    10499 
    105100$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);