internalize uploaded media rewrite rule, see #11742
git-svn-id: http://svn.automattic.com/wordpress/trunk@12924 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ed24c3dd40
commit
44e511516d
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
define( 'SHORTINIT', true ); // this prevents most of WP from being loaded
|
||||
require_once( dirname( dirname( __FILE__) ) . '/wp-load.php' ); // absolute includes are faster
|
||||
if ( !defined( 'MEDIA_FILE' ) ) {
|
||||
define( 'SHORTINIT', true ); // this prevents most of WP from being loaded
|
||||
require_once( dirname( dirname( __FILE__) ) . '/wp-load.php' ); // absolute includes are faster
|
||||
}
|
||||
|
||||
if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
|
||||
status_header( 404 );
|
||||
|
@ -64,8 +66,10 @@ function wp_check_filetype($filename, $mimes = null) {
|
|||
}
|
||||
endif;
|
||||
|
||||
|
||||
$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
|
||||
if ( defined( 'MEDIA_FILE' ) )
|
||||
$file = BLOGUPLOADDIR . str_replace( '..', '', MEDIA_FILE );
|
||||
else
|
||||
$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
|
||||
if ( !is_file( $file ) ) {
|
||||
status_header( 404 );
|
||||
die('404 — File not found.');
|
||||
|
|
|
@ -82,6 +82,17 @@ require( ABSPATH . WPINC . '/plugin.php' );
|
|||
require( ABSPATH . WPINC . '/default-filters.php' );
|
||||
include_once( ABSPATH . WPINC . '/pomo/mo.php' );
|
||||
|
||||
// internalize virtual content rewrite rule
|
||||
if ( is_multisite() && !defined( 'SHORTINIT' ) ) {
|
||||
$media_base = $path . 'files/';
|
||||
$base_len = strlen( $media_base );
|
||||
if ( substr( $_SERVER[ 'REQUEST_URI' ], 0, $media_len ) == $media_base && $media_len < strlen( $_SERVER[ 'REQUEST_URI' ] ) ) {
|
||||
define( 'MEDIA_FILE', substr( $_SERVER[ 'REQUEST_URI' ], $media_len ) );
|
||||
require_once( WP_CONTENT_DIR . '/blogs.php' );
|
||||
exit();
|
||||
}
|
||||
unset( $media_base, $media_len );
|
||||
}
|
||||
// Stop most of WordPress from being loaded if we just want the basics.
|
||||
if ( SHORTINIT )
|
||||
return false;
|
||||
|
@ -272,4 +283,4 @@ $wp->init();
|
|||
// Everything is loaded and initialized.
|
||||
do_action( 'init' );
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue