[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Multisite upload handler. 4 * 5 * @since 3.0.0 6 * 7 * @package WordPress 8 * @subpackage Multisite 9 */ 10 11 define( 'MS_FILES_REQUEST', true ); 12 define( 'SHORTINIT', true ); 13 require_once dirname( __DIR__ ) . '/wp-load.php'; 14 15 if ( ! is_multisite() ) { 16 die( 'Multisite support not enabled' ); 17 } 18 19 ms_file_constants(); 20 21 if ( '1' === $current_blog->archived || '1' === $current_blog->spam || '1' === $current_blog->deleted ) { 22 status_header( 404 ); 23 die( '404 — File not found.' ); 24 } 25 26 $file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] ); 27 if ( ! is_file( $file ) ) { 28 status_header( 404 ); 29 die( '404 — File not found.' ); 30 } 31 32 $mime = wp_check_filetype( $file ); 33 if ( false === $mime['type'] && function_exists( 'mime_content_type' ) ) { 34 $mime['type'] = mime_content_type( $file ); 35 } 36 37 if ( $mime['type'] ) { 38 $mimetype = $mime['type']; 39 } else { 40 $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 ); 41 } 42 43 header( 'Content-Type: ' . $mimetype ); // Always send this. 44 if ( ! str_contains( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) { 45 header( 'Content-Length: ' . filesize( $file ) ); 46 } 47 48 // Optional support for X-Sendfile and X-Accel-Redirect. 49 if ( WPMU_ACCEL_REDIRECT ) { 50 header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); 51 exit; 52 } elseif ( WPMU_SENDFILE ) { 53 header( 'X-Sendfile: ' . $file ); 54 exit; 55 } 56 57 $wp_last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); 58 $wp_etag = '"' . md5( $wp_last_modified ) . '"'; 59 60 header( "Last-Modified: $wp_last_modified GMT" ); 61 header( 'ETag: ' . $wp_etag ); 62 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); 63 64 // Support for conditional GET - use stripslashes() to avoid formatting.php dependency. 65 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { 66 $client_etag = stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ); 67 } else { 68 $client_etag = ''; 69 } 70 71 if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { 72 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); 73 } else { 74 $client_last_modified = ''; 75 } 76 77 // If string is empty, return 0. If not, attempt to parse into a timestamp. 78 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; 79 80 // Make a timestamp for our most recent modification. 81 $wp_modified_timestamp = strtotime( $wp_last_modified ); 82 83 if ( ( $client_last_modified && $client_etag ) 84 ? ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) ) 85 : ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) 86 ) { 87 status_header( 304 ); 88 exit; 89 } 90 91 // If we made it this far, just serve the file. 92 readfile( $file ); 93 flush();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |