Changeset 42343 for trunk/src/wp-includes/ms-files.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/ms-files.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-files.php
r38662 r42343 12 12 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); 13 13 14 if ( ! is_multisite() )14 if ( ! is_multisite() ) { 15 15 die( 'Multisite support not enabled' ); 16 } 16 17 17 18 ms_file_constants(); … … 24 25 } 25 26 26 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file'] );27 if ( ! is_file( $file ) ) {27 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] ); 28 if ( ! is_file( $file ) ) { 28 29 status_header( 404 ); 29 30 die( '404 — File not found.' ); … … 31 32 32 33 $mime = wp_check_filetype( $file ); 33 if ( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) ) 34 $mime[ 'type' ] = mime_content_type( $file ); 34 if ( false === $mime['type'] && function_exists( 'mime_content_type' ) ) { 35 $mime['type'] = mime_content_type( $file ); 36 } 35 37 36 if ( $mime[ 'type' ] )37 $mimetype = $mime[ 'type'];38 else 38 if ( $mime['type'] ) { 39 $mimetype = $mime['type']; 40 } else { 39 41 $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 ); 42 } 40 43 41 44 header( 'Content-Type: ' . $mimetype ); // always send this 42 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) 45 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) { 43 46 header( 'Content-Length: ' . filesize( $file ) ); 47 } 44 48 45 49 // Optional support for X-Sendfile and X-Accel-Redirect … … 53 57 54 58 $last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); 55 $etag = '"' . md5( $last_modified ) . '"';59 $etag = '"' . md5( $last_modified ) . '"'; 56 60 header( "Last-Modified: $last_modified GMT" ); 57 61 header( 'ETag: ' . $etag ); … … 61 65 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; 62 66 63 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) 67 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { 64 68 $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; 69 } 65 70 66 71 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); … … 69 74 70 75 // Make a timestamp for our most recent modification... 71 $modified_timestamp = strtotime( $last_modified);76 $modified_timestamp = strtotime( $last_modified ); 72 77 73 78 if ( ( $client_last_modified && $client_etag ) 74 ? ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) )75 : ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) )79 ? ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) 80 : ( ( $client_modified_timestamp >= $modified_timestamp ) || ( $client_etag == $etag ) ) 76 81 ) { 77 82 status_header( 304 );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)