WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[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( 'SHORTINIT', true ); 12 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); 13 14 ms_file_constants(); 15 16 error_reporting( 0 ); 17 18 if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) { 19 status_header( 404 ); 20 die( '404 — File not found.' ); 21 } 22 23 $file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] ); 24 if ( !is_file( $file ) ) { 25 status_header( 404 ); 26 die( '404 — File not found.' ); 27 } 28 29 $mime = wp_check_filetype( $_SERVER[ 'REQUEST_URI' ] ); 30 if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) ) 31 $mime[ 'type' ] = mime_content_type( $file ); 32 33 if( $mime[ 'type' ] ) 34 $mimetype = $mime[ 'type' ]; 35 else 36 $mimetype = 'image/' . substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); 37 38 header( 'Content-type: ' . $mimetype ); // always send this 39 if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) 40 header( 'Content-Length: ' . filesize( $file ) ); 41 42 // Optional support for X-Sendfile and X-Accel-Redirect 43 if ( WPMU_ACCEL_REDIRECT ) { 44 header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); 45 exit; 46 } elseif ( WPMU_SENDFILE ) { 47 header( 'X-Sendfile: ' . $file ); 48 exit; 49 } 50 51 $last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) ); 52 $etag = '"' . md5( $last_modified ) . '"'; 53 header( "Last-Modified: $last_modified GMT" ); 54 header( 'ETag: ' . $etag ); 55 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); 56 57 // Support for Conditional GET 58 $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; 59 60 if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) 61 $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false; 62 63 $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); 64 // If string is empty, return 0. If not, attempt to parse into a timestamp 65 $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; 66 67 // Make a timestamp for our most recent modification... 68 $modified_timestamp = strtotime($last_modified); 69 70 if ( ( $client_last_modified && $client_etag ) 71 ? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) ) 72 : ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) ) 73 ) { 74 status_header( 304 ); 75 exit; 76 } 77 78 // If we made it this far, just serve the file 79 readfile( $file ); 80 81 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |