wp/wp-includes/ms-files.php
changeset 7 cf61fcea0001
parent 0 d970ebf37754
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     9  */
     9  */
    10 
    10 
    11 define( 'SHORTINIT', true );
    11 define( 'SHORTINIT', true );
    12 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    12 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    13 
    13 
    14 if( !is_multisite() )
    14 if ( !is_multisite() )
    15 	die( 'Multisite support not enabled' );
    15 	die( 'Multisite support not enabled' );
    16 
    16 
    17 ms_file_constants();
    17 ms_file_constants();
    18 
    18 
    19 error_reporting( 0 );
    19 error_reporting( 0 );
    28 	status_header( 404 );
    28 	status_header( 404 );
    29 	die( '404 — File not found.' );
    29 	die( '404 — File not found.' );
    30 }
    30 }
    31 
    31 
    32 $mime = wp_check_filetype( $file );
    32 $mime = wp_check_filetype( $file );
    33 if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
    33 if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
    34 	$mime[ 'type' ] = mime_content_type( $file );
    34 	$mime[ 'type' ] = mime_content_type( $file );
    35 
    35 
    36 if( $mime[ 'type' ] )
    36 if ( $mime[ 'type' ] )
    37 	$mimetype = $mime[ 'type' ];
    37 	$mimetype = $mime[ 'type' ];
    38 else
    38 else
    39 	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
    39 	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
    40 
    40 
    41 header( 'Content-Type: ' . $mimetype ); // always send this
    41 header( 'Content-Type: ' . $mimetype ); // always send this
    58 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
    58 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
    59 
    59 
    60 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
    60 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency
    61 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
    61 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
    62 
    62 
    63 if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
    63 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
    64 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
    64 	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
    65 
    65 
    66 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
    66 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
    67 // If string is empty, return 0. If not, attempt to parse into a timestamp
    67 // If string is empty, return 0. If not, attempt to parse into a timestamp
    68 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
    68 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
    78 	exit;
    78 	exit;
    79 }
    79 }
    80 
    80 
    81 // If we made it this far, just serve the file
    81 // If we made it this far, just serve the file
    82 readfile( $file );
    82 readfile( $file );
       
    83 flush();