pass #2 change uploaded media rewrite rule, props nacin, see #11742

git-svn-id: http://svn.automattic.com/wordpress/trunk@12926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-02-02 16:32:19 +00:00
parent 3e0f3f54d6
commit 998704b8d7
4 changed files with 17 additions and 17 deletions

View File

@ -4,7 +4,7 @@ RewriteBase BASE/
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteRule ^(.*/)?files/(.*) wp-includes/blogs.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$

View File

@ -1,5 +1,5 @@
<?php
if ( !defined( 'MEDIA_FILE' ) ) {
if ( !defined( 'SHORTINIT' ) ) {
define( 'SHORTINIT', true ); // this prevents most of WP from being loaded
require_once( dirname( dirname( __FILE__) ) . '/wp-load.php' ); // absolute includes are faster
}
@ -66,10 +66,7 @@ function wp_check_filetype($filename, $mimes = null) {
}
endif;
if ( defined( 'MEDIA_FILE' ) )
$file = BLOGUPLOADDIR . str_replace( '..', '', MEDIA_FILE );
else
$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
if ( !is_file( $file ) ) {
status_header( 404 );
die('404 &#8212; File not found.');

14
wp-includes/blogs.php Normal file
View File

@ -0,0 +1,14 @@
<?php
/**
* Load mulitsite uploaded media
*
* @since 3.0.0
*
* @package WordPress
* @subpackage Multisite
*/
define( 'SHORTINIT', true );
require_once( dirname( dirname( __FILE__) ) . '/wp-load.php' ); // absolute includes are faster
require_once( WP_CONTENT_DIR . '/blogs.php' );
exit();

View File

@ -82,17 +82,6 @@ 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;