2010-01-06 05:02:57 +01:00
|
|
|
<?php
|
2010-02-03 19:19:56 +01:00
|
|
|
/**
|
2010-02-05 22:40:22 +01:00
|
|
|
* Multisite upload handler.
|
2010-02-03 19:19:56 +01:00
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Multisite
|
|
|
|
*/
|
|
|
|
|
2010-02-28 21:29:24 +01:00
|
|
|
define( 'SHORTINIT', true );
|
|
|
|
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
|
2010-02-05 22:40:22 +01:00
|
|
|
|
2010-05-13 23:40:42 +02:00
|
|
|
if( !is_multisite() )
|
|
|
|
die( 'Multisite support not enabled' );
|
|
|
|
|
2010-02-28 21:29:24 +01:00
|
|
|
ms_file_constants();
|
2010-02-03 19:19:56 +01:00
|
|
|
|
2010-02-09 19:22:21 +01:00
|
|
|
error_reporting( 0 );
|
|
|
|
|
2010-01-06 05:02:57 +01:00
|
|
|
if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
|
|
|
|
status_header( 404 );
|
2010-02-03 19:19:56 +01:00
|
|
|
die( '404 — File not found.' );
|
2010-01-06 05:02:57 +01:00
|
|
|
}
|
|
|
|
|
2011-09-06 17:41:57 +02:00
|
|
|
$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET[ 'file' ] );
|
2010-01-06 05:02:57 +01:00
|
|
|
if ( !is_file( $file ) ) {
|
|
|
|
status_header( 404 );
|
2010-02-03 19:19:56 +01:00
|
|
|
die( '404 — File not found.' );
|
2010-01-06 05:02:57 +01:00
|
|
|
}
|
|
|
|
|
2010-10-07 23:00:45 +02:00
|
|
|
$mime = wp_check_filetype( $file );
|
2010-02-03 19:19:56 +01:00
|
|
|
if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
|
|
|
|
$mime[ 'type' ] = mime_content_type( $file );
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2010-02-03 19:19:56 +01:00
|
|
|
if( $mime[ 'type' ] )
|
2010-01-06 05:02:57 +01:00
|
|
|
$mimetype = $mime[ 'type' ];
|
2010-02-03 19:19:56 +01:00
|
|
|
else
|
2010-10-07 23:00:45 +02:00
|
|
|
$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
|
2010-02-03 19:19:56 +01:00
|
|
|
|
2011-05-13 21:31:36 +02:00
|
|
|
header( 'Content-Type: ' . $mimetype ); // always send this
|
2010-01-06 05:02:57 +01:00
|
|
|
if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
|
2010-02-03 19:19:56 +01:00
|
|
|
header( 'Content-Length: ' . filesize( $file ) );
|
2010-01-06 05:02:57 +01:00
|
|
|
|
|
|
|
// Optional support for X-Sendfile and X-Accel-Redirect
|
2010-02-03 19:19:56 +01:00
|
|
|
if ( WPMU_ACCEL_REDIRECT ) {
|
|
|
|
header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
|
2010-01-06 05:02:57 +01:00
|
|
|
exit;
|
2010-02-03 19:19:56 +01:00
|
|
|
} elseif ( WPMU_SENDFILE ) {
|
|
|
|
header( 'X-Sendfile: ' . $file );
|
2010-01-06 05:02:57 +01:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2010-02-03 19:19:56 +01:00
|
|
|
$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
|
|
|
|
$etag = '"' . md5( $last_modified ) . '"';
|
|
|
|
header( "Last-Modified: $last_modified GMT" );
|
|
|
|
header( 'ETag: ' . $etag );
|
|
|
|
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2013-05-20 22:20:22 +02:00
|
|
|
// Support for Conditional GET - use stripslashes to avoid formatting.php dependency
|
|
|
|
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2010-02-03 19:19:56 +01:00
|
|
|
if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
|
2010-01-06 05:02:57 +01:00
|
|
|
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
|
2010-02-03 19:19:56 +01:00
|
|
|
|
|
|
|
$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
|
2010-01-06 05:02:57 +01:00
|
|
|
// If string is empty, return 0. If not, attempt to parse into a timestamp
|
2010-02-03 19:19:56 +01:00
|
|
|
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
|
2010-01-06 05:02:57 +01:00
|
|
|
|
2010-01-26 23:49:05 +01:00
|
|
|
// Make a timestamp for our most recent modification...
|
2010-01-06 05:02:57 +01:00
|
|
|
$modified_timestamp = strtotime($last_modified);
|
|
|
|
|
2010-02-03 19:19:56 +01:00
|
|
|
if ( ( $client_last_modified && $client_etag )
|
|
|
|
? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
|
|
|
|
: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
|
|
|
|
) {
|
2010-01-06 05:02:57 +01:00
|
|
|
status_header( 304 );
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we made it this far, just serve the file
|
|
|
|
readfile( $file );
|