<!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>[13000] trunk/wp-admin/network.php: Allow network install to be restarted,
  see #11881</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13000">13000</a></dd>
<dt>Author</dt> <dd>wpmuguru</dd>
<dt>Date</dt> <dd>2010-02-07 02:13:20 +0000 (Sun, 07 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow network install to be restarted, see <a href="http://trac.wordpress.org/ticket/11881">#11881</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworkphp">trunk/wp-admin/network.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminnetworkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network.php (12999 => 13000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network.php        2010-02-07 01:59:30 UTC (rev 12999)
+++ trunk/wp-admin/network.php        2010-02-07 02:13:20 UTC (rev 13000)
</span><span class="lines">@@ -96,8 +96,6 @@
</span><span class="cx">         } else {
</span><span class="cx">                 wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) );
</span><span class="cx">         }
</span><del>-
-        //@todo: check for super-cache in use
</del><span class="cx"> ?&gt;
</span><span class="cx">                         &lt;li&gt;&lt;p&gt;&lt;?php _e( 'Replace the contents of your &lt;code&gt;.htaccess&lt;/code&gt; with the following:' ); ?&gt;&lt;/p&gt;
</span><span class="cx">                                 &lt;textarea name=&quot;htaccess&quot; cols=&quot;120&quot; rows=&quot;20&quot;&gt;
</span><span class="lines">@@ -157,7 +155,16 @@
</span><span class="cx">                 $nowww = substr( $hostname, 4 );
</span><span class="cx"> 
</span><span class="cx">         wp_nonce_field( 'install-network-1' );
</span><del>-        ?&gt;
</del><ins>+        if ( network_domain_check() ) { ?&gt;
+                &lt;h2&gt;&lt;?php esc_html_e( 'Existing Sites' ); ?&gt;&lt;/h2&gt;
+                &lt;p&gt;&lt;?php _e( 'An existing WordPress Network was detected.' ); ?&gt;&lt;/p&gt;
+                &lt;p class=&quot;existing-network&quot;&gt;
+                        &lt;label&gt;&lt;input type='checkbox' name='existing_network' value='yes' /&gt; &lt;?php _e( 'Yes, keep the existing network of sites.' ); ?&gt;&lt;/label&gt;&lt;br /&gt;
+                &lt;/p&gt;
+
+&lt;?php         } else { ?&gt;
+                &lt;input type='hidden' name='existing_network' value='none' /&gt;
+&lt;?php        } ?&gt;
</ins><span class="cx">                 &lt;input type='hidden' name='action' value='step2' /&gt;
</span><span class="cx">                 &lt;h2&gt;&lt;?php esc_html_e( 'Site Addresses' ); ?&gt;&lt;/h2&gt;
</span><span class="cx">                 &lt;p&gt;&lt;?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.' ); ?&gt;&lt;/p&gt;
</span><span class="lines">@@ -211,6 +218,37 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Checks for active plugins &amp; displays a notice to deactivate them.
+ *
+ * @since 3.0.0
+ */
+function step1_plugin_check() {
+        $active_plugins = get_option( 'active_plugins' );
+        if ( is_array( $active_plugins ) &amp;&amp; !empty( $active_plugins ) ) {
+?&gt;
+                &lt;h2&gt;&lt;?php esc_html_e( 'Enabling WordPress Sites' ); ?&gt;&lt;/h2&gt;
+                &lt;p&gt;&lt;?php printf( __( 'Please &lt;a href=&quot;%s&quot;&gt;deactivate&lt;/a&gt; your plugins before enabling WordPress Sites. Once WordPress Sites are enabled, you may reactivate your plugins.' ), admin_url( 'plugins.php' ) ); ?&gt;&lt;/p&gt;
+&lt;?php
+                return false;
+        }
+        return true;
+}
+
+/**
+ * Checks for existing network data/tables.
+ *
+ * @since 3.0.0
+ */
+function network_domain_check() {
+        global $wpdb;
+
+        if ( $wpdb-&gt;get_var( &quot;SHOW TABLES LIKE '$wpdb-&gt;site'&quot; ) == $wpdb-&gt;site )
+                return $wpdb-&gt;get_var( &quot;SELECT domain FROM $wpdb-&gt;site ORDER BY id ASC LIMIT 1&quot; );
+
+        return false;
+}
+
+/**
</ins><span class="cx">  * Prints step 2 for network settings.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="lines">@@ -308,6 +346,11 @@
</span><span class="cx">  */
</span><span class="cx"> function get_clean_basedomain() {
</span><span class="cx">         global $wpdb;
</span><ins>+
+        $existing_domain = network_domain_check();
+        if ( $existing_domain )
+                return $existing_domain;
+
</ins><span class="cx">         $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
</span><span class="cx">         if ( strpos( $domain, '/' ) )
</span><span class="cx">                 $domain = substr( $domain, 0, strpos( $domain, '/' ) );
</span><span class="lines">@@ -320,24 +363,27 @@
</span><span class="cx">         case 'step2':
</span><span class="cx">                 check_admin_referer( 'install-network-1' );
</span><span class="cx"> 
</span><del>-                // Install!
-                $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
-                if ( $base != '/' )
-                        $base .= '/';
</del><ins>+                if ( isset( $_POST[ 'existing_network' ] ) ) { 
+                        // Install!
+                        $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
+                        if ( $base != '/' )
+                                $base .= '/';
</ins><span class="cx"> 
</span><del>-                require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
-                // create network tables
-                $domain = get_clean_basedomain();
-                install_network();
-                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
+                        $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;
+                }
</ins><span class="cx">         default:
</span><span class="cx">                 //@todo: give an informative screen instead
</span><span class="cx">                 if ( is_multisite() ) {
</span><span class="cx">                         _e( 'Network already enabled.' );
</span><del>-                } else {
</del><ins>+                } elseif ( step1_plugin_check() ) {
</ins><span class="cx">                         $rewrite_enabled = step1();
</span><span class="cx">                         printstep1form( $rewrite_enabled );
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>

</body>
</html>