7 * @package WordPress |
7 * @package WordPress |
8 * @subpackage Multisite |
8 * @subpackage Multisite |
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( __DIR__ ) . '/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 |
17 |
18 ms_file_constants(); |
18 ms_file_constants(); |
19 |
19 |
20 error_reporting( 0 ); |
20 error_reporting( 0 ); |
21 |
21 |
22 if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) { |
22 if ( '1' == $current_blog->archived || '1' == $current_blog->spam || '1' == $current_blog->deleted ) { |
23 status_header( 404 ); |
23 status_header( 404 ); |
24 die( '404 — File not found.' ); |
24 die( '404 — File not found.' ); |
25 } |
25 } |
26 |
26 |
27 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] ); |
27 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] ); |
39 $mimetype = $mime['type']; |
39 $mimetype = $mime['type']; |
40 } else { |
40 } else { |
41 $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 ); |
41 $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 ); |
42 } |
42 } |
43 |
43 |
44 header( 'Content-Type: ' . $mimetype ); // always send this |
44 header( 'Content-Type: ' . $mimetype ); // Always send this. |
45 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) { |
45 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) { |
46 header( 'Content-Length: ' . filesize( $file ) ); |
46 header( 'Content-Length: ' . filesize( $file ) ); |
47 } |
47 } |
48 |
48 |
49 // Optional support for X-Sendfile and X-Accel-Redirect |
49 // Optional support for X-Sendfile and X-Accel-Redirect. |
50 if ( WPMU_ACCEL_REDIRECT ) { |
50 if ( WPMU_ACCEL_REDIRECT ) { |
51 header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); |
51 header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); |
52 exit; |
52 exit; |
53 } elseif ( WPMU_SENDFILE ) { |
53 } elseif ( WPMU_SENDFILE ) { |
54 header( 'X-Sendfile: ' . $file ); |
54 header( 'X-Sendfile: ' . $file ); |
59 $etag = '"' . md5( $last_modified ) . '"'; |
59 $etag = '"' . md5( $last_modified ) . '"'; |
60 header( "Last-Modified: $last_modified GMT" ); |
60 header( "Last-Modified: $last_modified GMT" ); |
61 header( 'ETag: ' . $etag ); |
61 header( 'ETag: ' . $etag ); |
62 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); |
62 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); |
63 |
63 |
64 // Support for Conditional GET - use stripslashes to avoid formatting.php dependency |
64 // Support for conditional GET - use stripslashes() to avoid formatting.php dependency. |
65 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; |
65 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; |
66 |
66 |
67 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { |
67 if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { |
68 $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; |
68 $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; |
69 } |
69 } |
70 |
70 |
71 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); |
71 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); |
72 // If string is empty, return 0. If not, attempt to parse into a timestamp |
72 // If string is empty, return 0. If not, attempt to parse into a timestamp. |
73 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; |
73 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; |
74 |
74 |
75 // Make a timestamp for our most recent modification... |
75 // Make a timestamp for our most recent modification... |
76 $modified_timestamp = strtotime( $last_modified ); |
76 $modified_timestamp = strtotime( $last_modified ); |
77 |
77 |