web/wp-admin/network.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    49  *
    49  *
    50  * @since 3.0.0
    50  * @since 3.0.0
    51  * @return bool Whether subdomain install is allowed
    51  * @return bool Whether subdomain install is allowed
    52  */
    52  */
    53 function allow_subdomain_install() {
    53 function allow_subdomain_install() {
    54 	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'siteurl' ) );
    54 	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
    55 	if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) )
    55 	if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
    56 		return false;
    56 		return false;
    57 
    57 
    58 	return true;
    58 	return true;
    59 }
    59 }
    60 /**
    60 /**
   104 }
   104 }
   105 
   105 
   106 $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>' .
   106 $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>' .
   107 	'<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>' .
   107 	'<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>' .
   108 	'<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>' .
   108 	'<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>' .
   109 	'<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>' .
   109 	'<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>' .
   110 	'<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>' .
   110 	'<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>' .
   111 	'<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>' .
   111 	'<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>' .
   112 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   112 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   113 	'<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
   113 	'<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
   114 	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>';
   114 	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>';
   141  *
   141  *
   142  * @since 3.0.0
   142  * @since 3.0.0
   143  */
   143  */
   144 function network_step1( $errors = false ) {
   144 function network_step1( $errors = false ) {
   145 	global $is_apache;
   145 	global $is_apache;
   146 
       
   147 	if ( get_option( 'siteurl' ) != get_option( 'home' ) ) {
       
   148 		echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . sprintf( __( 'Your <strong>WordPress address</strong> must match your <strong>Site address</strong> before creating a Network. See <a href="%s">General Settings</a>.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '</p></div>';
       
   149 		echo '</div>';
       
   150 		include ( ABSPATH . 'wp-admin/admin-footer.php' );
       
   151 		die();
       
   152 	}
       
   153 
   146 
   154 	if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
   147 	if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
   155 		echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
   148 		echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
   156 		echo '</div>';
   149 		echo '</div>';
   157 		include ( ABSPATH . 'wp-admin/admin-footer.php' );
   150 		include ( ABSPATH . 'wp-admin/admin-footer.php' );
   187 		foreach ( $errors->get_error_messages() as $error )
   180 		foreach ( $errors->get_error_messages() as $error )
   188 			echo "<p>$error</p>";
   181 			echo "<p>$error</p>";
   189 		echo '</div>';
   182 		echo '</div>';
   190 		$error_codes = $errors->get_error_codes();
   183 		$error_codes = $errors->get_error_codes();
   191 	}
   184 	}
   192 
       
   193 	if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
       
   194 		echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
       
   195 
   185 
   196 	$site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
   186 	$site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
   197 	$admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
   187 	$admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
   198 	?>
   188 	?>
   199 	<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
   189 	<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
   233 		</table>
   223 		</table>
   234 
   224 
   235 <?php
   225 <?php
   236 	endif;
   226 	endif;
   237 
   227 
       
   228 		if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
       
   229 			echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
       
   230 
   238 		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
   231 		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
   239 		if ( $is_www ) :
   232 		if ( $is_www ) :
   240 		?>
   233 		?>
   241 		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
   234 		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
   242 		<p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></p>
   235 		<p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></p>
   312  * Prints step 2 for Network installation process.
   305  * Prints step 2 for Network installation process.
   313  *
   306  *
   314  * @since 3.0.0
   307  * @since 3.0.0
   315  */
   308  */
   316 function network_step2( $errors = false ) {
   309 function network_step2( $errors = false ) {
   317 	global $base, $wpdb;
   310 	global $wpdb;
   318 	$hostname = get_clean_basedomain();
   311 
   319 
   312 	$hostname          = get_clean_basedomain();
   320 	if ( ! isset( $base ) )
   313 	$slashed_home      = trailingslashit( get_option( 'home' ) );
   321 		$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
   314 	$base              = parse_url( $slashed_home, PHP_URL_PATH );
       
   315 	$wp_dir_from_root  = preg_replace( '#^' . preg_quote( $_SERVER['DOCUMENT_ROOT'], '#' ) . '#', '', ABSPATH );
       
   316 	$wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) );
       
   317 	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
       
   318 
       
   319 	$home_path         = get_home_path();
       
   320 
       
   321 	$location_of_wp_config = ABSPATH;
       
   322 	if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) )
       
   323 		$location_of_wp_config = trailingslashit( dirname( ABSPATH ) );
   322 
   324 
   323 	// Wildcard DNS message.
   325 	// Wildcard DNS message.
   324 	if ( is_wp_error( $errors ) )
   326 	if ( is_wp_error( $errors ) )
   325 		echo '<div class="error">' . $errors->get_error_message() . '</div>';
   327 		echo '<div class="error">' . $errors->get_error_message() . '</div>';
   326 
   328 
   342 	<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
   344 	<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
   343 <?php
   345 <?php
   344 		}
   346 		}
   345 	}
   347 	}
   346 
   348 
       
   349 	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
       
   350 	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
       
   351 	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
       
   352 
   347 	if ( $_POST || ! is_multisite() ) {
   353 	if ( $_POST || ! is_multisite() ) {
   348 ?>
   354 ?>
   349 		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
   355 		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
   350 		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
   356 		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
   351 		<div class="updated inline"><p><?php
   357 		<div class="updated inline"><p><?php
   352 			if ( file_exists( ABSPATH . '.htaccess' ) )
   358 			if ( file_exists( $home_path . '.htaccess' ) )
   353 				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' );
   359 				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' );
   354 			elseif ( file_exists( ABSPATH . 'web.config' ) )
   360 			elseif ( file_exists( $home_path . 'web.config' ) )
   355 				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' );
   361 				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' );
   356 			else
   362 			else
   357 				_e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
   363 				_e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
   358 		?></p></div>
   364 		?></p></div>
   359 <?php
   365 <?php
   360 	}
   366 	}
   361 ?>
   367 ?>
   362 		<ol>
   368 		<ol>
   363 			<li><p><?php
   369 			<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>:' ), $location_of_wp_config ); ?></p>
   364 				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 );
   370 				<textarea class="code" readonly="readonly" cols="100" rows="6">
   365 				if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
       
   366 					echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
       
   367 			?></p></li>
       
   368 			<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>
       
   369 				<textarea class="code" readonly="readonly" cols="100" rows="7">
       
   370 define('MULTISITE', true);
   371 define('MULTISITE', true);
   371 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
   372 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
   372 $base = '<?php echo $base; ?>';
       
   373 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
   373 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
   374 define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
   374 define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
   375 define('SITE_ID_CURRENT_SITE', 1);
   375 define('SITE_ID_CURRENT_SITE', 1);
   376 define('BLOG_ID_CURRENT_SITE', 1);</textarea>
   376 define('BLOG_ID_CURRENT_SITE', 1);
       
   377 </textarea>
   377 <?php
   378 <?php
   378 	$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
   379 	$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
   379 	foreach ( $keys_salts as $c => $v ) {
   380 	foreach ( $keys_salts as $c => $v ) {
   380 		if ( defined( $c ) )
   381 		if ( defined( $c ) )
   381 			unset( $keys_salts[ $c ] );
   382 			unset( $keys_salts[ $c ] );
   382 	}
   383 	}
       
   384 
   383 	if ( ! empty( $keys_salts ) ) {
   385 	if ( ! empty( $keys_salts ) ) {
   384 		$keys_salts_str = '';
   386 		$keys_salts_str = '';
   385 		$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
   387 		$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
   386 		if ( is_wp_error( $from_api ) ) {
   388 		if ( is_wp_error( $from_api ) ) {
   387 			foreach ( $keys_salts as $c => $v ) {
   389 			foreach ( $keys_salts as $c => $v ) {
   402 	}
   404 	}
   403 ?>
   405 ?>
   404 </li>
   406 </li>
   405 <?php
   407 <?php
   406 	if ( iis7_supports_permalinks() ) :
   408 	if ( iis7_supports_permalinks() ) :
   407 
   409 		// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
   408 			if ( $subdomain_install ) {
   410 		$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
   409 				$web_config_file =
   411 		$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
   410 '<?xml version="1.0" encoding="UTF-8"?>
   412 		$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
       
   413 
       
   414 		$web_config_file = <<<EOF
       
   415 <?xml version="1.0" encoding="UTF-8"?>
   411 <configuration>
   416 <configuration>
   412     <system.webServer>
   417     <system.webServer>
   413         <rewrite>
   418         <rewrite>
   414             <rules>
   419             <rules>
   415                 <rule name="WordPress Rule 1" stopProcessing="true">
   420                 <rule name="WordPress Rule 1" stopProcessing="true">
   416                     <match url="^index\.php$" ignoreCase="false" />
   421                     <match url="^index\.php$" ignoreCase="false" />
   417                     <action type="None" />
   422                     <action type="None" />
   418                 </rule>
   423                 </rule>';
       
   424 				if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
       
   425 					$web_config_file .= '
       
   426                 <rule name="WordPress Rule for Files" stopProcessing="true">
       
   427                     <match url="^{$iis_subdir_match}files/(.+)" ignoreCase="false" />
       
   428                     <action type="Rewrite" url="{$iis_rewrite_base}wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
       
   429                 </rule>';
       
   430                 }
       
   431                 $web_config_file .= '
   419                 <rule name="WordPress Rule 2" stopProcessing="true">
   432                 <rule name="WordPress Rule 2" stopProcessing="true">
   420                     <match url="^files/(.+)" ignoreCase="false" />
   433                     <match url="^{$iis_subdir_match}wp-admin$" ignoreCase="false" />
   421                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
   434                     <action type="Redirect" url="{$iis_subdir_replacement}wp-admin/" redirectType="Permanent" />
   422                 </rule>
   435                 </rule>
   423                 <rule name="WordPress Rule 3" stopProcessing="true">
   436                 <rule name="WordPress Rule 3" stopProcessing="true">
   424                     <match url="^" ignoreCase="false" />
   437                     <match url="^" ignoreCase="false" />
   425                     <conditions logicalGrouping="MatchAny">
   438                     <conditions logicalGrouping="MatchAny">
   426                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
   439                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
   427                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
   440                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
   428                     </conditions>
   441                     </conditions>
   429                     <action type="None" />
   442                     <action type="None" />
   430                 </rule>
   443                 </rule>
   431                 <rule name="WordPress Rule 4" stopProcessing="true">
   444                 <rule name="WordPress Rule 4" stopProcessing="true">
       
   445                     <match url="^{$iis_subdir_match}(wp-(content|admin|includes).*)" ignoreCase="false" />
       
   446                     <action type="Rewrite" url="{$iis_rewrite_base}{R:1}" />
       
   447                 </rule>
       
   448                 <rule name="WordPress Rule 5" stopProcessing="true">
       
   449                     <match url="^{$iis_subdir_match}([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
       
   450                     <action type="Rewrite" url="{$iis_rewrite_base}{R:2}" />
       
   451                 </rule>
       
   452                 <rule name="WordPress Rule 6" stopProcessing="true">
   432                     <match url="." ignoreCase="false" />
   453                     <match url="." ignoreCase="false" />
   433                     <action type="Rewrite" url="index.php" />
   454                     <action type="Rewrite" url="index.php" />
   434                 </rule>
   455                 </rule>
   435             </rules>
   456             </rules>
   436         </rewrite>
   457         </rewrite>
   437     </system.webServer>
   458     </system.webServer>
   438 </configuration>';
   459 </configuration>
   439 			} else {
   460 EOF;
   440 				$web_config_file =
   461 
   441 '<?xml version="1.0" encoding="UTF-8"?>
       
   442 <configuration>
       
   443     <system.webServer>
       
   444         <rewrite>
       
   445             <rules>
       
   446                 <rule name="WordPress Rule 1" stopProcessing="true">
       
   447                     <match url="^index\.php$" ignoreCase="false" />
       
   448                     <action type="None" />
       
   449                 </rule>
       
   450                 <rule name="WordPress Rule 2" stopProcessing="true">
       
   451                     <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
       
   452                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
       
   453                 </rule>
       
   454                 <rule name="WordPress Rule 3" stopProcessing="true">
       
   455                     <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
       
   456                     <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
       
   457                 </rule>
       
   458                 <rule name="WordPress Rule 4" stopProcessing="true">
       
   459                     <match url="^" ignoreCase="false" />
       
   460                     <conditions logicalGrouping="MatchAny">
       
   461                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
       
   462                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
       
   463                     </conditions>
       
   464                     <action type="None" />
       
   465                 </rule>
       
   466                 <rule name="WordPress Rule 5" stopProcessing="true">
       
   467                     <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
       
   468                     <action type="Rewrite" url="{R:1}" />
       
   469                 </rule>
       
   470                 <rule name="WordPress Rule 6" stopProcessing="true">
       
   471                     <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
       
   472                     <action type="Rewrite" url="{R:2}" />
       
   473                 </rule>
       
   474                 <rule name="WordPress Rule 7" stopProcessing="true">
       
   475                     <match url="." ignoreCase="false" />
       
   476                     <action type="Rewrite" url="index.php" />
       
   477                 </rule>
       
   478             </rules>
       
   479         </rewrite>
       
   480     </system.webServer>
       
   481 </configuration>';
       
   482 			}
       
   483 	?>
   462 	?>
   484 		<li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
   463 		<li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p>
   485 		<textarea class="code" readonly="readonly" cols="100" rows="20">
   464 		<?php
   486 		<?php echo esc_textarea( $web_config_file ); ?>
   465 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
       
   466 			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
       
   467 		?>
       
   468 		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
   487 		</textarea></li>
   469 		</textarea></li>
   488 		</ol>
   470 		</ol>
   489 
   471 
   490 	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
   472 	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
   491 
   473 
   492 		$htaccess_file = 'RewriteEngine On
   474 		$ms_files_rewriting = '';
   493 RewriteBase ' . $base . '
   475 		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
       
   476 			$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
       
   477 			$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}wp-includes/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
       
   478 		}
       
   479 
       
   480 		$htaccess_file = <<<EOF
       
   481 RewriteEngine On
       
   482 RewriteBase {$base}
   494 RewriteRule ^index\.php$ - [L]
   483 RewriteRule ^index\.php$ - [L]
   495 
   484 {$ms_files_rewriting}
   496 # uploaded files
   485 # add a trailing slash to /wp-admin
   497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
   486 RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L]
   498 
   487 
   499 		if ( ! $subdomain_install )
   488 RewriteCond %{REQUEST_FILENAME} -f [OR]
   500 			$htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
       
   501 
       
   502 		$htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
       
   503 RewriteCond %{REQUEST_FILENAME} -d
   489 RewriteCond %{REQUEST_FILENAME} -d
   504 RewriteRule ^ - [L]';
   490 RewriteRule ^ - [L]
   505 
   491 RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
   506 		// @todo custom content dir.
   492 RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L]
   507 		if ( ! $subdomain_install )
   493 RewriteRule . index.php [L]
   508 			$htaccess_file .= "\nRewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]";
   494 EOF;
   509 
       
   510 		$htaccess_file .= "\nRewriteRule . index.php [L]";
       
   511 
   495 
   512 		?>
   496 		?>
   513 		<li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
   497 		<li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p>
   514 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
   498 		<?php
       
   499 		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
       
   500 			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
       
   501 		?>
       
   502 		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
   515 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
   503 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
   516 		</ol>
   504 		</ol>
   517 
   505 
   518 	<?php endif; // end IIS/Apache code branches.
   506 	<?php endif; // end IIS/Apache code branches.
   519 
   507 
   522 <?php
   510 <?php
   523 	}
   511 	}
   524 }
   512 }
   525 
   513 
   526 if ( $_POST ) {
   514 if ( $_POST ) {
   527 
       
   528 	$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
       
   529 
   515 
   530 	check_admin_referer( 'install-network-1' );
   516 	check_admin_referer( 'install-network-1' );
   531 
   517 
   532 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   518 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   533 	// create network tables
   519 	// create network tables
   534 	install_network();
   520 	install_network();
   535 	$hostname = get_clean_basedomain();
   521 	$base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
   536 	$subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
   522 	$subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
   537 	if ( ! network_domain_check() ) {
   523 	if ( ! network_domain_check() ) {
   538 		$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
   524 		$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
   539 		if ( is_wp_error( $result ) ) {
   525 		if ( is_wp_error( $result ) ) {
   540 			if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
   526 			if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )