From 44e511516dd475fb1ddd4d39ad92be8eda70f090 Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Tue, 2 Feb 2010 02:17:33 +0000 Subject: [PATCH] internalize uploaded media rewrite rule, see #11742 git-svn-id: http://svn.automattic.com/wordpress/trunk@12924 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/blogs.php | 12 ++++++++---- wp-settings.php | 13 ++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/wp-content/blogs.php b/wp-content/blogs.php index 4e16b9afe..d92920443 100755 --- a/wp-content/blogs.php +++ b/wp-content/blogs.php @@ -1,6 +1,8 @@ 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.'); diff --git a/wp-settings.php b/wp-settings.php index 0a5db913e..ae1c199ef 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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' ); -?> \ No newline at end of file +?>