<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13571] trunk/wp-admin: First pass on network.php improvements.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13571">13571</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-03 07:43:32 +0000 (Wed, 03 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>First pass on network.php improvements. see <a href="http://trac.wordpress.org/ticket/12094">#12094</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminfooterphp">trunk/wp-admin/admin-footer.php</a></li>
<li><a href="#trunkwpadmincommentphp">trunk/wp-admin/comment.php</a></li>
<li><a href="#trunkwpadminnetworkphp">trunk/wp-admin/network.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesnetworkphp">trunk/wp-admin/includes/network.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminfooterphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin-footer.php (13570 => 13571)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin-footer.php        2010-03-03 07:34:20 UTC (rev 13570)
+++ trunk/wp-admin/admin-footer.php        2010-03-03 07:43:32 UTC (rev 13571)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> <?php
</span><span class="cx"> do_action('admin_footer', '');
</span><span class="cx"> do_action('admin_print_footer_scripts');
</span><del>-do_action("admin_footer-$hook_suffix");
</del><ins>+do_action("admin_footer-" . $GLOBALS['hook_suffix']);
</ins><span class="cx">
</span><span class="cx"> // get_site_option() won't exist when auto upgrading from <= 2.7
</span><span class="cx"> if ( function_exists('get_site_option') ) {
</span></span></pre></div>
<a id="trunkwpadmincommentphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/comment.php (13570 => 13571)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/comment.php        2010-03-03 07:34:20 UTC (rev 13570)
+++ trunk/wp-admin/comment.php        2010-03-03 07:43:32 UTC (rev 13571)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
</span><span class="cx"> */
</span><span class="cx"> function comment_footer_die( $msg ) {
</span><del>-        global $hook_suffix;
</del><span class="cx">         echo "<div class='wrap'><p>$msg</p></div>";
</span><span class="cx">         include('admin-footer.php');
</span><span class="cx">         die;
</span></span></pre></div>
<a id="trunkwpadminincludesnetworkphp"></a>
<div class="addfile"><h4>Added: trunk/wp-admin/includes/network.php (0 => 13571)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/network.php         (rev 0)
+++ trunk/wp-admin/includes/network.php        2010-03-03 07:43:32 UTC (rev 13571)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+<?php
+/**
+ * Network installation functions.
+ *
+ * @since 3.0.0
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ */
+
+/**
+ * Gets base domain of network.
+ *
+ * @since 3.0.0
+ */
+function get_clean_basedomain() {
+        global $wpdb;
+
+        $existing_domain = network_domain_check();
+        if ( $existing_domain )
+                return $existing_domain;
+
+        $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
+        if ( strpos( $domain, '/' ) )
+                $domain = substr( $domain, 0, strpos( $domain, '/' ) );
+        return $domain;
+}
+
+/**
+ * Checks for existing network data/tables.
+ *
+ * @since 3.0.0
+ */
+function network_domain_check() {
+        global $wpdb;
+
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
+                return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
+
+        return false;
+}
+
+/**
+ * Prints summary of server statistics in preparation for setting up a network.
+ *
+ * @since 3.0.0
+ */
+function filestats( $err ) {
+?>
+        <h2><?php esc_html_e( 'Server Summary' ); ?></h2>
+        <p><?php _e( 'If you post a message to the WordPress support forum at <a target="_blank" href="http://wordpress.org/support/">http://wordpress.org/support/</a> then copy and paste the following information into your message:' ); ?></p>
+        <blockquote style="background: #eee; border: 1px solid #333; padding: 5px;">
+        <br /><strong><?php printf( __( 'ERROR: %s' ), $err ); ?></strong><br />
+<?php
+        clearstatcache();
+        $files = array( 'htaccess.dist', '.htaccess' );
+
+        $indent = '&nbsp;&nbsp;&nbsp;&nbsp;';
+        foreach ( (array) $files as $val ) {
+                $stats = @stat( $val );
+                if ( $stats ) {
+?>
+                        <h2><?php echo esc_html( $val ); ?></h2>
+                        <?php echo $indent . sprintf( __( 'uid/gid: %1$s/%2$s' ), $stats['uid'], $stats['gid'] ); ?><br />
+                        <?php echo $indent . sprintf( __( 'size: %s' ), $stats['size'] ); ?><br/>
+                        <?php echo $indent . sprintf( __( 'perms: %s' ), substr( sprintf( '%o', fileperms( $val ) ), -4 ) ); ?><br/>
+                        <?php echo $indent . sprintf( __( 'readable: %s' ), is_readable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/>
+                        <?php echo $indent . sprintf( __( 'writeable: %s' ), is_writeable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/>
+<?php
+                } elseif ( ! file_exists( $val ) ) {
+?>
+                        <h2><?php echo esc_html( $val ); ?></h2>
+                        <?php echo $indent . sprintf( __( 'FILE NOT FOUND: %s' ), $val ); ?><br/>
+<?php
+                }
+        }
+        echo "</blockquote>";
+}
</ins></span></pre></div>
<a id="trunkwpadminnetworkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network.php (13570 => 13571)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network.php        2010-03-03 07:34:20 UTC (rev 13570)
+++ trunk/wp-admin/network.php        2010-03-03 07:43:32 UTC (rev 13571)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><del>- * Network settings administration panel.
</del><ins>+ * Network installation administration panel.
</ins><span class="cx"> *
</span><span class="cx"> * A multi-step process allowing the user to enable a network of WordPress sites.
</span><span class="cx"> *
</span><span class="lines">@@ -14,13 +14,18 @@
</span><span class="cx"> require_once( './admin.php' );
</span><span class="cx">
</span><span class="cx"> if ( ! is_super_admin() )
</span><del>-        wp_die( __( 'You do not have sufficient permissions to manage options for this blog.' ) );
</del><ins>+        wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
</ins><span class="cx">
</span><ins>+if ( is_multisite() )
+        wp_die( __( 'The Network feature is already enabled.' ) );
+
+include( ABSPATH . 'wp-admin/includes/network.php' );
+
</ins><span class="cx"> // We need to create references to ms global tables to enable Network.
</span><span class="cx"> foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
</span><span class="cx">         $wpdb->$table = $prefixed_table;
</span><span class="cx">
</span><del>-$title = __( 'Network Settings' );
</del><ins>+$title = __( 'Create a Network of WordPress Sites' );
</ins><span class="cx"> $parent_file = 'tools.php';
</span><span class="cx">
</span><span class="cx"> add_contextual_help( $current_screen, __( '<a href="http://codex.wordpress.org/Settings_Network_SubPanel" target="_blank">Network Settings</a>') );
</span><span class="lines">@@ -36,251 +41,142 @@
</span><span class="cx"> <form method="post" action="network.php">
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><del>- * Prints summary of server statistics in preparation for setting up a network.
</del><ins>+ * Prints step 1 for Network installation process.
</ins><span class="cx"> *
</span><ins>+ * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
+ *         should not be a sudden "Welcome to a new install process! Fill this out and click here."
+ *
</ins><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><del>-function filestats( $err ) {
-?>
-        <h2><?php esc_html_e( 'Server Summary' ); ?></h2>
-        <p><?php _e( 'If you post a message to the WordPress support forum at <a target="_blank" href="http://wordpress.org/support/">http://wordpress.org/support/</a> then copy and paste the following information into your message:' ); ?></p>
-        <blockquote style="background: #eee; border: 1px solid #333; padding: 5px;">
-        <br /><strong><?php printf( __( 'ERROR: %s' ), $err ); ?></strong><br />
-<?php
-        clearstatcache();
-        $files = array( 'htaccess.dist', '.htaccess' );
</del><ins>+function ms_network_step1() {
</ins><span class="cx">
</span><del>-        $indent = '&nbsp;&nbsp;&nbsp;&nbsp;';
-        foreach ( (array) $files as $val ) {
-                $stats = @stat( $val );
-                if ( $stats ) {
-?>
-                        <h2><?php echo esc_html( $val ); ?></h2>
-                        <?php echo $indent . sprintf( __( 'uid/gid: %1$s/%2$s' ), $stats['uid'], $stats['gid'] ); ?><br />
-                        <?php echo $indent . sprintf( __( 'size: %s' ), $stats['size'] ); ?><br/>
-                        <?php echo $indent . sprintf( __( 'perms: %s' ), substr( sprintf( '%o', fileperms( $val ) ), -4 ) ); ?><br/>
-                        <?php echo $indent . sprintf( __( 'readable: %s' ), is_readable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/>
-                        <?php echo $indent . sprintf( __( 'writeable: %s' ), is_writeable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/>
-<?php
-                } elseif ( ! file_exists( $val ) ) {
-?>
-                        <h2><?php echo esc_html( $val ); ?></h2>
-                        <?php echo $indent . sprintf( __( 'FILE NOT FOUND: %s' ), $val ); ?><br/>
-<?php
-                }
</del><ins>+        $active_plugins = get_option( 'active_plugins' );
+        if ( ! empty( $active_plugins ) ) {
+                printf( '<p>' . __( 'Please <a href="%s">deactivate</a> your plugins before enabling the Network feature. Once the network is created, you may reactivate your plugins.' ) . '</p>', admin_url( 'plugins.php' ) );
+                include( './admin-footer.php' );
+                die();
</ins><span class="cx">         }
</span><del>-        echo "</blockquote>";
-}
</del><span class="cx">
</span><del>-/**
- * Prints .htaccess component of step 2 for network settings.
- *
- * @since 3.0.0
- */
-function step2_htaccess() {
-        global $base;
-
-        // remove ending slash from $base and $url
-        $htaccess = '';
-        if ( substr( $base, -1 ) == '/' )
-                $base = substr( $base, 0, -1 );
-
-        $htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms';
-        if ( ! file_exists( $htaccess_sample ) )
-                wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) );
-
-        $htaccess_file = file( $htaccess_sample );
-        $fp = @fopen( $htaccess_sample, "r" );
-        if ( $fp ) {
-                while ( ! feof( $fp ) ) {
-                        $htaccess .= fgets( $fp, 4096 );
-                }
-                fclose( $fp );
-                $htaccess_file = str_replace( "BASE", $base, $htaccess );
-        } else {
-                wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) );
</del><ins>+        $hostname = get_clean_basedomain();
+        if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
+                echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>';
+                echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code> or a single-word hostname like <code>localhost</code>.' ) . '</p>';
+                if ( 'localhost' == $hostname )
+                        echo '<p>' . __('Consider using <code>localhost.localdomain</code>.') . '</p>';
+                include( './admin-footer.php' );
+                die();
</ins><span class="cx">         }
</span><del>-?>
-                        <li><p><?php printf( __( 'Replace the contents of your <code>%s.htaccess</code> with the following:' ), ABSPATH ); ?></p>
-                                <textarea name="htaccess" cols="120" rows="20">
-<?php echo wp_htmledit_pre( $htaccess_file ); ?>
-                                </textarea>
-                        </li>
-<?php
-}
</del><span class="cx">
</span><del>-/**
- * Prints part of step 1 for network settings and checks for mod_rewrite.
- *
- * @since 3.0.0
- * @return bool Whether mod_rewrite is enabled.
- */
-function step1() {
-        $rewrite_enabled = false;
</del><span class="cx">         ?>
</span><del>-        <h2><?php esc_html_e( 'Installing Network of WordPress Sites' ); ?></h2>
-        <p><?php _e( 'I will help you enable the features for creating a network of sites by asking you a few questions so that you can create configuration files and make a directory to store all your uploaded files.' ); ?></p>
-
-        <h2><?php esc_html_e( 'What do I need?' ); ?></h2>
-        <ul>
-                <li><?php _e( 'Access to your server to change directory permissions. This can be done through ssh or ftp for example.' ); ?></li>
-                <li><?php _e( 'A valid email where your password and administrative emails will be sent.' ); ?></li>
-                <li><?php _e( "Wildcard dns records if you're going to use the virtual host (sub-domain) functionality. Check the <a href='http://trac.mu.wordpress.org/browser/trunk/README.txt'>README</a> for further details." ); ?></li>
-        </ul>
</del><ins>+        <p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
+        <p><?php _e( "Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We'll create configuration files in the next step." ); ?></p>
</ins><span class="cx">         <?php
</span><del>-        $mod_rewrite_msg = "\n<p>" . __( 'If the <code>mod_rewrite</code> module is disabled ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p>';
</del><span class="cx">
</span><del>-        if ( function_exists( 'apache_get_modules' ) ) {
-                $modules = apache_get_modules();
-                if ( ! in_array( 'mod_rewrite', $modules ) )
-                        echo '<p>' . __( '<strong>Warning!</strong> It looks like mod_rewrite is not installed.' ) . '</p>' . $mod_rewrite_msg;
-                else
-                        $rewrite_enabled = true;
</del><ins>+        if ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
+                $rewrite_enabled = true;
</ins><span class="cx">         } else {
</span><del>-                echo '<p>' . __( 'Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.' ) . '</p>' . $mod_rewrite_msg;
</del><ins>+                $rewrite_enabled = false;
+                if ( got_mod_rewrite() ) // dangerous assumptions
+                        echo '<p>' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this install.' ) . '</p>';
+                else
+                        echo '<p>' . __( '<strong>Warning!</strong> It looks like Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
+                echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p>';
</ins><span class="cx">         }
</span><del>-        return $rewrite_enabled;
-}
</del><span class="cx">
</span><del>-/**
- * Prints most of step 1 for network settings.
- *
- * @since 3.0.0
- * @param bool $rewrite_enabled Whether mod_rewrite is enabled. Default false.
- */
-function printstep1form( $rewrite_enabled = false ) {
-        $weblog_title = sprintf( __( '%s Sites' ), ucfirst( get_option( 'blogname' ) ) );
-        $email = get_option( 'admin_email' );
-        $hostname = get_clean_basedomain();
-        $invalid_host = false;
-        if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname, $match ) )
-                $invalid_host = true;
-        if ( substr( $hostname, 0, 4 ) == 'www.' )
-                $nowww = substr( $hostname, 4 );
-
</del><span class="cx">         wp_nonce_field( 'install-network-1' );
</span><span class="cx">         if ( network_domain_check() ) { ?>
</span><span class="cx">                 <h2><?php esc_html_e( 'Existing Sites' ); ?></h2>
</span><span class="cx">                 <p><?php _e( 'An existing WordPress Network was detected.' ); ?></p>
</span><span class="cx">                 <p class="existing-network">
</span><del>-                        <label><input type='checkbox' name='existing_network' value='yes' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br />
</del><ins>+                        <label><input type='checkbox' name='existing_network' value='1' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br />
</ins><span class="cx">                 </p>
</span><span class="cx">
</span><span class="cx"> <?php         } else { ?>
</span><del>-                <input type='hidden' name='existing_network' value='none' />
</del><ins>+                <input type='hidden' name='existing_network' value='0' />
</ins><span class="cx"> <?php        } ?>
</span><span class="cx">                 <input type='hidden' name='action' value='step2' />
</span><del>-                <h2><?php esc_html_e( 'Site Addresses' ); ?></h2>
-                <p><?php _e( 'Please choose whether you would like sites in your WordPress install to use sub-domains or sub-directories. You cannot change this later.' ); ?></p>
</del><ins>+                <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
+        
+                <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
+                <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
+                <?php /* @todo: Link to an MS readme? */ ?>
</ins><span class="cx">                 <?php if ( ! $rewrite_enabled ) { ?>
</span><span class="cx">                 <p><?php _e( '<strong>Note</strong> It looks like <code>mod_rewrite</code> is not installed.' ); ?></p>
</span><span class="cx">                 <?php } ?>
</span><del>-                <p class="blog-address">
-                        <label><input type='radio' name='vhost' value='yes'<?php if ( $rewrite_enabled ) echo ' checked="checked"'; ?> /> <?php _e( 'Sub-domains (like <code>blog1.example.com</code>)' ); ?></label><br />
-                        <label><input type='radio' name='vhost' value='no'<?php if ( ! $rewrite_enabled ) echo ' checked="checked"'; ?> /> <?php _e( 'Sub-directories (like <code>example.com/blog1</code>)' ); ?></label>
-                </p>
</del><ins>+                <table class="form-table">
+                        <tr>
+                                <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th>
+                                <td><?php _e('like <code>blog1.example.com</code> and <code>blog2.example.com</code>'); ?></td>
+                        </tr>
+                        <tr>
+                                <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th>
+                                <td><?php _e('like <code>example.com/blog1</code> and <code>example.com/blog2</code>'); ?></td>
+                        </tr>
+                </table>
</ins><span class="cx">
</span><del>-                <h2><?php esc_html_e( 'Server Address' ); ?></h2>
-                <?php if ( isset( $nowww ) ) { ?>
-                <h3><?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 "www" prefix with an address like <code>%2$s</code> but any links will not have the "www" prefix.' ), $nowww, $hostname ); ?></h3>
-                <?php } ?>
</del><ins>+                <?php
+                $is_www = ( substr( $hostname, 0, 4 ) == 'www.' );
+                if ( $is_www ) :
+                ?>
+                <h3><?php esc_html_e( 'Server Address' ); ?></h3>
+                <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 "www" prefix with an address like <code>%2$s</code> but any links will not have the "www" prefix.' ), substr( $hostname, 4 ), $hostname ); ?></h3>
</ins><span class="cx">                 <table class="form-table">
</span><span class="cx">                         <tr>
</span><span class="cx">                                 <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
</span><span class="cx">                                 <td>
</span><del>-                <?php if ( !$invalid_host ) { ?>
-                                        <?php printf( __( 'This will be the Internet address of your site: <strong><em>%s</em></strong>.' ), $hostname ); ?>
</del><ins>+                                        <?php printf( __( 'The Internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
</ins><span class="cx">                                         <input type='hidden' name='basedomain' value='<?php echo esc_attr( $hostname ); ?>' />
</span><del>-                <?php } else { ?>
-                                        <?php _e( 'Do not use an IP address (like 127.0.0.1) or a single word hostname like <q>localhost</q> as your server address.' ); ?>
-                <?php } ?>
</del><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="cx">                 </table>
</span><ins>+                <?php endif; ?>
</ins><span class="cx">
</span><del>-                <h2><?php esc_html_e( 'Site Details' ); ?></h2>
</del><ins>+                <h3><?php esc_html_e( 'Network Details' ); ?></h3>
</ins><span class="cx">                 <table class="form-table">
</span><ins>+                <?php if ( ! $is_www ) : ?>
</ins><span class="cx">                         <tr>
</span><del>-                                <th scope='row'><?php esc_html_e( 'Site&nbsp;Title' ); ?></th>
</del><ins>+                                <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
</ins><span class="cx">                                 <td>
</span><del>-                                        <input name='weblog_title' type='text' size='45' value='<?php echo esc_attr( $weblog_title ); ?>' />
-                                        <br /><?php _e( 'What would you like to call your site?' ); ?>
</del><ins>+                                        <?php printf( __( 'The Internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
</ins><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><ins>+                <?php endif; ?>
</ins><span class="cx">                         <tr>
</span><del>-                                <th scope='row'><?php esc_html_e( 'Email' ); ?></th>
</del><ins>+                                <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
</ins><span class="cx">                                 <td>
</span><del>-                                        <input name='email' type='text' size='45' value='<?php echo esc_attr( $email ); ?>' />
</del><ins>+                                        <input name='weblog_title' type='text' size='45' value='<?php echo esc_attr( sprintf( __('%s Sites'), get_option( 'blogname' ) ) ); ?>' />
+                                        <br /><?php _e( 'What would you like to call your network?' ); ?>
+                                </td>
+                        </tr>
+                        <tr>
+                                <th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th>
+                                <td>
+                                        <input name='email' type='text' size='45' value='<?php echo esc_attr( get_option( 'admin_email' ) ); ?>' />
</ins><span class="cx">                                         <br /><?php _e( 'Your email address.' ); ?>
</span><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="cx">                 </table>
</span><del>-                <?php if ( !$invalid_host ) { ?>
-                <p class='submit'><input class="button" name='submit' type='submit' value='<?php esc_attr_e( 'Proceed' ); ?>' /></p>
-                <?php } ?>
-        <?php
</del><ins>+                <p class='submit'><input class="button-primary" name='submit' type='submit' value='<?php esc_attr_e( 'Install' ); ?>' /></p>
+                <?php
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Checks for active plugins & displays a notice to deactivate them.
</del><ins>+ * Prints step 2 for Network installation process.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><del>-function step1_plugin_check() {
-        $active_plugins = get_option( 'active_plugins' );
-        if ( is_array( $active_plugins ) && !empty( $active_plugins ) ) {
</del><ins>+function ms_network_step2() {
+        global $base, $wpdb;
</ins><span class="cx"> ?>
</span><del>-                <h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2>
-                <p><?php printf( __( 'Please <a href="%s">deactivate</a> your plugins before enabling WordPress Sites. Once WordPress Sites are enabled, you may reactivate your plugins.' ), admin_url( 'plugins.php' ) ); ?></p>
-<?php
-                return false;
-        }
-        return true;
-}
-
-/**
- * Checks for existing network data/tables.
- *
- * @since 3.0.0
- */
-function network_domain_check() {
-        global $wpdb;
-
-        if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) == $wpdb->site )
-                return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
-
-        return false;
-}
-
-/**
- * Prints step 2 for network settings.
- *
- * @since 3.0.0
- */
-function step2() {
-?>
-                <h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2>
</del><ins>+                <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
</ins><span class="cx">                 <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites. <strong>Note:</strong> We recommend you make a backup copy of your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' ); ?></p>
</span><span class="cx">                 <ol>
</span><span class="cx">                         <li><?php printf( __( 'Create a <code>%s/blogs.dir</code> directory. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?></li>
</span><del>-<?php step2_config(); ?>
-<?php step2_htaccess(); ?>
-                </ol>
</del><span class="cx"> <?php
</span><del>-}
-
-/**
- * Prints configuration file component of step 2 for network settings.
- *
- * @since 3.0.0
- */
-function step2_config() {
-        global $base, $wpdb, $vhost;
-
</del><span class="cx">         $vhost = stripslashes( $_POST['vhost' ] );
</span><span class="cx">         $prefix = $wpdb->base_prefix;
</span><span class="cx">
</span><del>-        $config_sample = ABSPATH . 'wp-admin/includes/wp-config.ms';
</del><ins>+        $config_sample = ABSPATH . 'wp-admin/includes/ms-config-sample.php';
</ins><span class="cx">         if ( ! file_exists( $config_sample ) )
</span><span class="cx">                 wp_die( sprintf( __( 'Sorry, I need a <code>%s</code> to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) );
</span><span class="cx">
</span><span class="lines">@@ -341,57 +237,58 @@
</span><span class="cx">                                 </textarea>
</span><span class="cx">                         </li>
</span><span class="cx"> <?php
</span><del>-}
</del><span class="cx">
</span><del>-/**
- * Gets base domain of network.
- *
- * @since 3.0.0
- */
-function get_clean_basedomain() {
-        global $wpdb;
</del><ins>+        // remove ending slash from $base and $url
+        $htaccess = '';
+        if ( substr( $base, -1 ) == '/' )
+                $base = substr( $base, 0, -1 );
</ins><span class="cx">
</span><del>-        $existing_domain = network_domain_check();
-        if ( $existing_domain )
-                return $existing_domain;
</del><ins>+        $htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms';
+        if ( ! file_exists( $htaccess_sample ) )
+                wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) );
</ins><span class="cx">
</span><del>-        $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
-        if ( strpos( $domain, '/' ) )
-                $domain = substr( $domain, 0, strpos( $domain, '/' ) );
-        return $domain;
</del><ins>+        $htaccess_file = file( $htaccess_sample );
+        $fp = @fopen( $htaccess_sample, "r" );
+        if ( $fp ) {
+                while ( ! feof( $fp ) ) {
+                        $htaccess .= fgets( $fp, 4096 );
+                }
+                fclose( $fp );
+                $htaccess_file = str_replace( "BASE", $base, $htaccess );
+        } else {
+                wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) );
+        }
+?>
+                        <li><p><?php printf( __( 'Replace the contents of your <code>%s.htaccess</code> with the following:' ), ABSPATH ); ?></p>
+                                <textarea name="htaccess" cols="120" rows="20">
+<?php echo wp_htmledit_pre( $htaccess_file ); ?>
+                                </textarea>
+                        </li>
+                </ol>
+<?php
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-$action = isset( $_POST[ 'action' ] ) ? $_POST[ 'action' ] : null;
</del><ins>+$action = isset( $_POST['action'] ) ? $_POST['action'] : null;
</ins><span class="cx">
</span><del>-switch( $action ) {
</del><ins>+switch ( $action ) {
</ins><span class="cx">         case 'step2':
</span><span class="cx">                 check_admin_referer( 'install-network-1' );
</span><span class="cx">
</span><del>-                if ( isset( $_POST[ 'existing_network' ] ) ) {
-                        // Install!
-                        $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
-                        if ( $base != '/' )
-                                $base .= '/';
</del><ins>+                // Install!
+                $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
</ins><span class="cx">
</span><del>-                        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
-                        // create network tables
-                        $domain = get_clean_basedomain();
-                        install_network();
-                        if ( !network_domain_check() || $_POST[ 'existing_network' ] == 'none' )
-                                populate_network( 1, $domain, sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
-                        // create wp-config.php / htaccess
-                        step2();
-                        break;
-                }
</del><ins>+                require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+                // create network tables
+                install_network();
+                if ( !network_domain_check() || $_POST['existing_network'] == '0' )
+                        populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
+                // create wp-config.php / htaccess
+                ms_network_step2();
+                break;
+
</ins><span class="cx">         default:
</span><del>-                //@todo: give an informative screen instead
-                if ( is_multisite() ) {
-                        _e( 'Network already enabled.' );
-                } elseif ( step1_plugin_check() ) {
-                        $rewrite_enabled = step1();
-                        printstep1form( $rewrite_enabled );
-                }
-        break;
</del><ins>+                ms_network_step1();
+                break;
</ins><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="cx"> </form>
</span></span></pre>
</div>
</div>
</body>
</html>