Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 21466)
+++ wp-includes/post.php	(working copy)
@@ -204,7 +204,7 @@
 		return false;
 
 	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
-	$file = _wp_relative_upload_path($file);
+	$file = _wp_relative_upload_path( $file );
 
 	return update_post_meta( $attachment_id, '_wp_attached_file', $file );
 }
@@ -223,11 +223,10 @@
 function _wp_relative_upload_path( $path ) {
 	$new_path = $path;
 
-	if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
-		if ( 0 === strpos($new_path, $uploads['basedir']) ) {
-				$new_path = str_replace($uploads['basedir'], '', $new_path);
-				$new_path = ltrim($new_path, '/');
-		}
+	$uploads = wp_upload_dir();
+	if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
+		$new_path = str_replace( $uploads['basedir'], '', $new_path );
+		$new_path = ltrim( $new_path, '/' );
 	}
 
 	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 21466)
+++ wp-includes/functions.php	(working copy)
@@ -1432,21 +1432,16 @@
  * @return array See above for description.
  */
 function wp_upload_dir( $time = null ) {
-	global $switched;
 	$siteurl = get_option( 'siteurl' );
-	$upload_path = get_option( 'upload_path' );
-	$upload_path = trim($upload_path);
-	$main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
-	if ( empty($upload_path) ) {
+	$upload_path = trim( get_option( 'upload_path' ) );
+
+	if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
 		$dir = WP_CONTENT_DIR . '/uploads';
+	} elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
+		// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
+		$dir = path_join( ABSPATH, $upload_path );
 	} else {
 		$dir = $upload_path;
-		if ( 'wp-content/uploads' == $upload_path ) {
-			$dir = WP_CONTENT_DIR . '/uploads';
-		} elseif ( 0 !== strpos($dir, ABSPATH) ) {
-			// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
-			$dir = path_join( ABSPATH, $dir );
-		}
 	}
 
 	if ( !$url = get_option( 'upload_url_path' ) ) {
@@ -1456,19 +1451,28 @@
 			$url = trailingslashit( $siteurl ) . $upload_path;
 	}
 
-	if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
+	if ( defined( 'UPLOADS' ) ) {
 		$dir = ABSPATH . UPLOADS;
 		$url = trailingslashit( $siteurl ) . UPLOADS;
 	}
 
-	if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
-		if ( defined( 'BLOGUPLOADDIR' ) )
-			$dir = untrailingslashit(BLOGUPLOADDIR);
-		$url = str_replace( UPLOADS, 'files', $url );
+	// Multisite (if not the main site in a post-MU network)
+	if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
+		if ( ! get_site_option( 'ms_files_rewriting' ) ) {
+			// Append sites/%d if we're not on the main site (for post-MU networks).
+			$ms_dir = '/sites/' . get_current_blog_id();
+			$dir .= $ms_dir;
+			$url .= $ms_dir;
+		} elseif ( empty( $GLOBALS['switched'] ) ) {
+			// Handle the old-form ms-files.php rewriting if the network still has that enabled.
+			if ( defined( 'BLOGUPLOADDIR' ) )
+				$dir = untrailingslashit( BLOGUPLOADDIR );
+			$url = str_replace( UPLOADS, 'files', $url );
+		}
 	}
 
-	$bdir = $dir;
-	$burl = $url;
+	$basedir = $dir;
+	$baseurl = $url;
 
 	$subdir = '';
 	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
@@ -1483,12 +1487,22 @@
 	$dir .= $subdir;
 	$url .= $subdir;
 
-	$uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) );
+	$uploads = apply_filters( 'upload_dir',
+		array(
+			'path'    => $dir,
+			'url'     => $url,
+			'subdir'  => $subdir,
+			'basedir' => $basedir,
+			'baseurl' => $baseurl,
+			'error'   => false,
+		)
+	);
 
 	// Make sure we have an uploads dir
 	if ( ! wp_mkdir_p( $uploads['path'] ) ) {
 		$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] );
-		return array( 'error' => $message );
+		$uploads['error'] = $message;
+		return $uploads;
 	}
 
 	return $uploads;
Index: wp-includes/option.php
===================================================================
--- wp-includes/option.php	(revision 21466)
+++ wp-includes/option.php	(working copy)
@@ -174,7 +174,7 @@
 	if ( empty($site_id) )
 		$site_id = $wpdb->siteid;
 
-	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' );
+	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
 
 	$core_options_in = "'" . implode("', '", $core_options) . "'";
 	$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
Index: wp-includes/ms-default-constants.php
===================================================================
--- wp-includes/ms-default-constants.php	(revision 21466)
+++ wp-includes/ms-default-constants.php	(working copy)
@@ -12,9 +12,12 @@
  *
  * @since 3.0.0
  */
-function ms_upload_constants(  ) {
-	global $wpdb;
+function ms_upload_constants() {
+	global $blog_id;
 
+	if ( ! get_site_option( 'ms_files_rewriting' ) )
+		return;
+
 	/** @since 3.0.0 */
 	// Base uploads dir relative to ABSPATH
 	if ( !defined( 'UPLOADBLOGSDIR' ) )
@@ -23,9 +26,9 @@
 	/** @since 3.0.0 */
 	if ( !defined( 'UPLOADS' ) ) {
 		// Uploads dir relative to ABSPATH
-		define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
-		if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
-			define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
+		define( 'UPLOADS', UPLOADBLOGSDIR . "/$blog_id/files/" );
+		if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
+			define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/$blog_id/files/" );
 	}
 }
 
Index: wp-includes/ms-functions.php
===================================================================
--- wp-includes/ms-functions.php	(revision 21466)
+++ wp-includes/ms-functions.php	(working copy)
@@ -1129,8 +1129,7 @@
  * @param string $blog_title The title of the new site.
  */
 function install_blog($blog_id, $blog_title = '') {
-	global $wpdb, $table_prefix, $wp_roles;
-	$wpdb->suppress_errors();
+	global $wpdb, $wp_roles, $current_site;
 
 	// Cast for security
 	$blog_id = (int) $blog_id;
@@ -1138,12 +1137,10 @@
 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 
 	if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
-		die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+		die( __( '<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>' ) . '</body></html>' );
 
-	$wpdb->suppress_errors(false);
+	$url = get_blogaddress_by_id( $blog_id );
 
-	$url = get_blogaddress_by_id($blog_id);
-
 	// Set everything up
 	make_db_current_silent( 'blog' );
 	populate_options();
@@ -1151,21 +1148,22 @@
 	$wp_roles->_init();
 
 	$url = untrailingslashit( $url );
-	// fix url.
-	update_option('siteurl', $url);
-	update_option('home', $url);
-	update_option('fileupload_url', $url . "/files" );
-	update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
-	update_option('blogname', stripslashes( $blog_title ) );
-	update_option('admin_email', '');
-	$wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
 
-	// remove all perms
-	$wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) );
+	update_option( 'siteurl', $url );
+	update_option( 'home', $url );
 
-	$wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );
+	if ( get_site_option( 'ms_files_rewriting' ) )
+		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
+	else
+		update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
 
-	$wpdb->suppress_errors( false );
+	update_option( 'blogname', stripslashes( $blog_title ) );
+	update_option( 'admin_email', '' );
+
+	// remove all perms
+	$table_prefix = $wpdb->get_blog_prefix();
+	delete_metadata( 'user', 0, $table_prefix . 'user_level',   null, true ); // delete all
+	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
 }
 
 /**
Index: wp-admin/network.php
===================================================================
--- wp-admin/network.php	(revision 21466)
+++ wp-admin/network.php	(working copy)
@@ -106,7 +106,7 @@
 $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
 	'<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
 	'<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
-	'<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
+	'<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
 	'<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' .
 	'<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed in a future version.') . '</p>' .
 	'<p><strong>' . __('For more information:') . '</strong></p>' .
@@ -190,9 +190,6 @@
 		$error_codes = $errors->get_error_codes();
 	}
 
-	if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
-		echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
-
 	$site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
 	$admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
 	?>
@@ -235,6 +232,9 @@
 <?php
 	endif;
 
+		if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
+			echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
+
 		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
 		if ( $is_www ) :
 		?>
@@ -360,11 +360,6 @@
 	}
 ?>
 		<ol>
-			<li><p><?php
-				printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
-				if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
-					echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
-			?></p></li>
 			<li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
 				<textarea class="code" readonly="readonly" cols="100" rows="7">
 define('MULTISITE', true);
@@ -415,12 +410,16 @@
                 <rule name="WordPress Rule 1" stopProcessing="true">
                     <match url="^index\.php$" ignoreCase="false" />
                     <action type="None" />
-                </rule>
-                <rule name="WordPress Rule 2" stopProcessing="true">
+                </rule>';
+				if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+					$web_config_file .= '
+                <rule name="WordPress Rule for Files" stopProcessing="true">
                     <match url="^files/(.+)" ignoreCase="false" />
                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
-                </rule>
-                <rule name="WordPress Rule 3" stopProcessing="true">
+                </rule>';
+                }
+                $web_config_file .= '
+                <rule name="WordPress Rule 2" stopProcessing="true">
                     <match url="^" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
@@ -428,7 +427,7 @@
                     </conditions>
                     <action type="None" />
                 </rule>
-                <rule name="WordPress Rule 4" stopProcessing="true">
+                <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="." ignoreCase="false" />
                     <action type="Rewrite" url="index.php" />
                 </rule>
@@ -446,16 +445,20 @@
                 <rule name="WordPress Rule 1" stopProcessing="true">
                     <match url="^index\.php$" ignoreCase="false" />
                     <action type="None" />
-                </rule>
+                </rule>';
+				if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+					$web_config_file .= '
+                <rule name="WordPress Rule for Files" stopProcessing="true">
+                    <match url="^files/(.+)" ignoreCase="false" />
+                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
+                </rule>';
+                }
+                $web_config_file .= '
                 <rule name="WordPress Rule 2" stopProcessing="true">
-                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
-                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
-                </rule>
-                <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                     <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
                 </rule>
-                <rule name="WordPress Rule 4" stopProcessing="true">
+                <rule name="WordPress Rule 3" stopProcessing="true">
                     <match url="^" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
@@ -463,15 +466,15 @@
                     </conditions>
                     <action type="None" />
                 </rule>
-                <rule name="WordPress Rule 5" stopProcessing="true">
+                <rule name="WordPress Rule 4" stopProcessing="true">
                     <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
                     <action type="Rewrite" url="{R:1}" />
                 </rule>
-                <rule name="WordPress Rule 6" stopProcessing="true">
+                <rule name="WordPress Rule 5" stopProcessing="true">
                     <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                     <action type="Rewrite" url="{R:2}" />
                 </rule>
-                <rule name="WordPress Rule 7" stopProcessing="true">
+                <rule name="WordPress Rule 6" stopProcessing="true">
                     <match url="." ignoreCase="false" />
                     <action type="Rewrite" url="index.php" />
                 </rule>
@@ -482,8 +485,11 @@
 			}
 	?>
 		<li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
-		<textarea class="code" readonly="readonly" cols="100" rows="20">
-		<?php echo esc_textarea( $web_config_file ); ?>
+		<?php
+		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
+		?>
+		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
 		</textarea></li>
 		</ol>
 
@@ -491,10 +497,12 @@
 
 		$htaccess_file = 'RewriteEngine On
 RewriteBase ' . $base . '
-RewriteRule ^index\.php$ - [L]
+RewriteRule ^index\.php$ - [L]' . "\n";
 
-# uploaded files
-RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
+		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
+			$htaccess_file .= "\n\n# uploaded files\nRewriteRule ^";
+			$htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
+		}
 
 		if ( ! $subdomain_install )
 			$htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
@@ -511,7 +519,11 @@
 
 		?>
 		<li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
-		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
+		<?php
+		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
+		?>
+		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
 		</ol>
 
Index: wp-admin/includes/ms-deprecated.php
===================================================================
--- wp-admin/includes/ms-deprecated.php	(revision 21466)
+++ wp-admin/includes/ms-deprecated.php	(working copy)
@@ -73,4 +73,6 @@
 function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
 	_deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()' );
 	return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) );
-}
\ No newline at end of file
+}
+
+function ms_deprecated_blogs_file() {}
\ No newline at end of file
Index: wp-admin/includes/upgrade.php
===================================================================
--- wp-admin/includes/upgrade.php	(revision 21466)
+++ wp-admin/includes/upgrade.php	(working copy)
@@ -1308,6 +1308,9 @@
 			delete_site_option( 'allowed_themes' );
 		}
 	}
+
+	if ( $wp_current_db_version < 20600 )
+		update_site_option( 'ms_files_rewriting', '1' );
 }
 
 // The functions we use to actually do stuff
Index: wp-admin/includes/schema.php
===================================================================
--- wp-admin/includes/schema.php	(revision 21466)
+++ wp-admin/includes/schema.php	(working copy)
@@ -901,6 +901,7 @@
 		'upload_space_check_disabled' => '0',
 		'subdomain_install' => intval( $subdomain_install ),
 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
+		'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
 		'initial_db_version' => get_option( 'initial_db_version' ),
 		'active_sitewide_plugins' => array(),
 	);
@@ -928,11 +929,6 @@
 		$blog_id = $wpdb->insert_id;
 		update_user_meta( $site_user->ID, 'source_domain', $domain );
 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
-		if ( !$upload_path = get_option( 'upload_path' ) ) {
-			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
-			update_option( 'upload_path', $upload_path );
-		}
-		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
 	}
 
 	if ( $subdomain_install )
Index: wp-admin/includes/ms.php
===================================================================
--- wp-admin/includes/ms.php	(revision 21466)
+++ wp-admin/includes/ms.php	(working copy)
@@ -90,7 +90,8 @@
 
 		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
 
-		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
+		$uploads = wp_upload_dir();
+		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
 		$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
 		$top_dir = $dir;
 		$stack = array($dir);
@@ -347,8 +348,10 @@
 function get_space_used() {
 	// Allow for an alternative way of tracking storage space used
 	$space_used = apply_filters( 'pre_get_space_used', false );
-	if ( false === $space_used )
-		$space_used = get_dirsize( BLOGUPLOADDIR );
+	if ( false === $space_used ) {
+		$upload_dir = wp_upload_dir();
+		$space_used = get_dirsize( $upload_dir['basedir'] );
+	}
 
 	return $space_used;
 }
@@ -665,15 +668,6 @@
 	<?php
 }
 
-function ms_deprecated_blogs_file() {
-	if ( ! is_super_admin() )
-		return;
-	if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
-		return;
-	echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
-}
-add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
-
 /**
  * Grants super admin privileges.
  *
