<!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>[13611] trunk: More network.php refinements.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13611">13611</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-06 20:01:32 +0000 (Sat, 06 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>More network.php refinements. Bring wp-config and htaccess inline. Rename BLOGID_CURRENT_SITE to BLOG_ID_CURRENT_SITE for consistency with SITE_ID_CURRENT_SITE. see <a href="http://trac.wordpress.org/ticket/11816">#11816</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworkphp">trunk/wp-admin/network.php</a></li>
<li><a href="#trunkwpincludesmsloadphp">trunk/wp-includes/ms-load.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 (13610 => 13611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network.php        2010-03-06 19:36:35 UTC (rev 13610)
+++ trunk/wp-admin/network.php        2010-03-06 20:01:32 UTC (rev 13611)
</span><span class="lines">@@ -89,7 +89,6 @@
</span><span class="cx">                 &lt;p class=&quot;existing-network&quot;&gt;
</span><span class="cx">                         &lt;label&gt;&lt;input type='checkbox' name='existing_network' value='1' /&gt; &lt;?php _e( 'Yes, keep the existing network of sites.' ); ?&gt;&lt;/label&gt;&lt;br /&gt;
</span><span class="cx">                 &lt;/p&gt;
</span><del>-
</del><span class="cx"> &lt;?php         } else { ?&gt;
</span><span class="cx">                 &lt;input type='hidden' name='existing_network' value='0' /&gt;
</span><span class="cx"> &lt;?php        } ?&gt;
</span><span class="lines">@@ -105,11 +104,11 @@
</span><span class="cx">                 &lt;table class=&quot;form-table&quot;&gt;
</span><span class="cx">                         &lt;tr&gt;
</span><span class="cx">                                 &lt;th&gt;&lt;label&gt;&lt;input type='radio' name='vhost' value='yes'&lt;?php checked( $rewrite_enabled ); ?&gt; /&gt; Sub-domains&lt;/label&gt;&lt;/th&gt;
</span><del>-                                &lt;td&gt;&lt;?php _e('like &lt;code&gt;blog1.example.com&lt;/code&gt; and &lt;code&gt;blog2.example.com&lt;/code&gt;'); ?&gt;&lt;/td&gt;
</del><ins>+                                &lt;td&gt;&lt;?php _e('like &lt;code&gt;site1.example.com&lt;/code&gt; and &lt;code&gt;site2.example.com&lt;/code&gt;'); ?&gt;&lt;/td&gt;
</ins><span class="cx">                         &lt;/tr&gt;
</span><span class="cx">                         &lt;tr&gt;
</span><span class="cx">                                 &lt;th&gt;&lt;label&gt;&lt;input type='radio' name='vhost' value='no'&lt;?php checked( ! $rewrite_enabled ); ?&gt; /&gt; Sub-directories&lt;/label&gt;&lt;/th&gt;
</span><del>-                                &lt;td&gt;&lt;?php _e('like &lt;code&gt;example.com/blog1&lt;/code&gt; and &lt;code&gt;example.com/blog2&lt;/code&gt;'); ?&gt;&lt;/td&gt;
</del><ins>+                                &lt;td&gt;&lt;?php _e('like &lt;code&gt;example.com/site1&lt;/code&gt; and &lt;code&gt;example.com/site2&lt;/code&gt;'); ?&gt;&lt;/td&gt;
</ins><span class="cx">                         &lt;/tr&gt;
</span><span class="cx">                 &lt;/table&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -168,101 +167,48 @@
</span><span class="cx">         global $base, $wpdb;
</span><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;h3&gt;&lt;?php esc_html_e( 'Enabling the Network' ); ?&gt;&lt;/h3&gt;
</span><del>-                &lt;p&gt;&lt;?php _e( 'Complete the following steps to enable the features for creating a network of sites. &lt;strong&gt;Note:&lt;/strong&gt; We recommend you make a backup copy of your existing &lt;code&gt;wp-config.php&lt;/code&gt; and &lt;code&gt;.htaccess&lt;/code&gt; files.' ); ?&gt;&lt;/p&gt;
</del><ins>+                &lt;p&gt;&lt;?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?&gt;&lt;/p&gt;
+                &lt;div class=&quot;updated inline&quot;&gt;&lt;p&gt;&lt;?php _e( '&lt;strong&gt;Caution:&lt;/strong&gt; We recommend you backup your existing &lt;code&gt;wp-config.php&lt;/code&gt; and &lt;code&gt;.htaccess&lt;/code&gt; files.' ); ?&gt;&lt;/p&gt;&lt;/div&gt;
</ins><span class="cx">                 &lt;ol&gt;
</span><del>-                        &lt;li&gt;&lt;?php printf( __( 'Create a &lt;code&gt;%s/blogs.dir&lt;/code&gt; directory. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?&gt;&lt;/li&gt;
</del><ins>+                        &lt;li&gt;&lt;p&gt;&lt;?php printf( __( 'Create a &lt;code&gt;blogs.dir&lt;/code&gt; directory in &lt;code&gt;%s&lt;/code&gt;. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                        &lt;li&gt;&lt;p&gt;&lt;?php printf( __( 'Add the following to your &lt;code&gt;wp-config.php&lt;/code&gt; file in &lt;code&gt;%s&lt;/code&gt;:' ), ABSPATH ); ?&gt;&lt;/p&gt;
+                                &lt;textarea class=&quot;code&quot; readonly=&quot;readonly&quot; cols=&quot;100&quot; rows=&quot;7&quot;&gt;
+define( 'MULTISITE', true );
+define( 'VHOST', '&lt;?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?&gt;' );
+$base = '&lt;?php echo $base; ?&gt;';
+define( 'DOMAIN_CURRENT_SITE', '&lt;?php echo get_clean_basedomain(); ?&gt;' );
+define( 'PATH_CURRENT_SITE', '&lt;?php echo $base; ?&gt;' );
+define( 'SITE_ID_CURRENT_SITE', 1 );
+define( 'BLOG_ID_CURRENT_SITE', 1 );&lt;/textarea&gt;&lt;/li&gt;
</ins><span class="cx"> &lt;?php
</span><del>-        $vhost   = stripslashes( $_POST['vhost' ] );
-        $prefix  = $wpdb-&gt;base_prefix;
</del><span class="cx"> 
</span><del>-        $config_sample = ABSPATH . 'wp-admin/includes/wp-config.ms';
-        if ( ! file_exists( $config_sample ) )
-                wp_die( sprintf( __( 'Sorry, I need a &lt;code&gt;%s&lt;/code&gt; to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) );
-
-        $wp_config_file = file( $config_sample );
-?&gt;
-                        &lt;li&gt;&lt;p&gt;&lt;?php printf( __( 'Replace the contents of &lt;code&gt;%swp-config.php&lt;/code&gt; with the following:' ), ABSPATH ); ?&gt;&lt;/p&gt;
-                                &lt;textarea name=&quot;wp-config&quot; cols=&quot;120&quot; rows=&quot;20&quot;&gt;
-&lt;?php
-        foreach ( $wp_config_file as $line ) {
-                switch ( trim( substr( $line, 0, 16 ) ) ) {
-                        case &quot;define('DB_NAME'&quot;:
-                                $output = str_replace( &quot;wordpress&quot;, DB_NAME, $line );
-                                break;
-                        case &quot;define('DB_USER'&quot;:
-                                $output = str_replace( &quot;username&quot;, DB_USER, $line );
-                                break;
-                        case &quot;define('DB_PASSW&quot;:
-                                $output = str_replace( &quot;password&quot;, DB_PASSWORD, $line );
-                                break;
-                        case &quot;define('DB_HOST'&quot;:
-                                $output = str_replace( &quot;localhost&quot;, DB_HOST, $line );
-                                break;
-                        case &quot;define('VHOST',&quot;:
-                                $output = str_replace( &quot;VHOSTSETTING&quot;, $vhost, $line );
-                                break;
-                        case '$table_prefix  =':
-                                $output = str_replace( 'wp_', $prefix, $line );
-                                break;
-                        case '$base = \'BASE\';':
-                                $output = str_replace( 'BASE', $base, $line );
-                                break;
-                        case &quot;define('DOMAIN_C&quot;:
-                                $domain = get_clean_basedomain();
-                                $output = str_replace( &quot;current_site_domain&quot;, $domain, $line );
-                                break;
-                        case &quot;define('PATH_CUR&quot;:
-                                $output = str_replace( &quot;current_site_path&quot;, $base, $line );
-                                break;
-                        case &quot;define('AUTH_KEY&quot;:
-                        case &quot;define('AUTH_SAL&quot;:
-                        case &quot;define('LOGGED_I&quot;:
-                        case &quot;define('SECURE_A&quot;:
-                        case &quot;define('NONCE_KE&quot;:
-                                $constant = substr( $line, 8, strpos( $line, &quot;'&quot;, 9 ) - 8 );
-                                if ( defined( $constant ) )
-                                        $hash = constant( $constant );
-                                else
-                                        $hash = md5( mt_rand() ) . md5( mt_rand() );
-                                $output = str_replace( 'put your unique phrase here', $hash, $line );
-                                break;
-                        default:
-                                $output = $line;
-                                break;
-                }
-                echo $output;
-        }
-?&gt;
-                                &lt;/textarea&gt;
-                        &lt;/li&gt;
-&lt;?php
-
</del><span class="cx">         // remove ending slash from $base and $url
</span><span class="cx">         $htaccess = '';
</span><del>-        if ( substr( $base, -1 ) == '/' )
-                $base = substr( $base, 0, -1 );
</del><ins>+        $base = rtrim( $base, '/' );
</ins><span class="cx"> 
</span><del>-        $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 ) );
</del><ins>+        $htaccess_file = 'RewriteEngine On
+RewriteBase ' . $base . '/
</ins><span class="cx"> 
</span><del>-        $htaccess_file = file( $htaccess_sample );
-        $fp = @fopen( $htaccess_sample, &quot;r&quot; );
-        if ( $fp ) {
-                while ( ! feof( $fp ) ) {
-                        $htaccess .= fgets( $fp, 4096 );
-                }
-                fclose( $fp );
-                $htaccess_file = str_replace( &quot;BASE&quot;, $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>+#uploaded files
+RewriteRule ^(.*/)?files/$ index.php [L]
+RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
+RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
+
+# add a trailing slash to /wp-admin
+RewriteCond %{REQUEST_URI} ^.*/wp-admin$
+RewriteRule ^(.+)$ $1/ [R=301,L]
+
+RewriteCond %{REQUEST_FILENAME} -f [OR]
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteRule . - [L]
+RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
+RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
+RewriteRule . index.php [L]';
</ins><span class="cx"> ?&gt;
</span><del>-                        &lt;li&gt;&lt;p&gt;&lt;?php printf( __( 'Replace the contents of your &lt;code&gt;%s.htaccess&lt;/code&gt; with the following:' ), ABSPATH ); ?&gt;&lt;/p&gt;
-                                &lt;textarea name=&quot;htaccess&quot; cols=&quot;120&quot; rows=&quot;20&quot;&gt;
</del><ins>+                        &lt;li&gt;&lt;p&gt;&lt;?php printf( __( 'Add the following to your &lt;code&gt;.htaccess&lt;/code&gt; file in &lt;code&gt;%s&lt;/code&gt;, replacing other WordPress rules:' ), ABSPATH ); ?&gt;&lt;/p&gt;
+                                &lt;textarea class=&quot;code&quot; readonly=&quot;readonly&quot; cols=&quot;100&quot; rows=&quot;18&quot;&gt;
</ins><span class="cx"> &lt;?php echo wp_htmledit_pre( $htaccess_file ); ?&gt;
</span><del>-&lt;/textarea&gt;
-                        &lt;/li&gt;
</del><ins>+&lt;/textarea&gt;&lt;/li&gt;
</ins><span class="cx">                 &lt;/ol&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><span class="lines">@@ -279,7 +225,7 @@
</span><span class="cx">                 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
</span><span class="cx">                 // create network tables
</span><span class="cx">                 install_network();
</span><del>-                if ( !network_domain_check() || $_POST['existing_network'] == '0' )
</del><ins>+                if ( !network_domain_check() || isset( $_POST['existing_network'] ) &amp;&amp; $_POST['existing_network'] == '0' )
</ins><span class="cx">                         populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
</span><span class="cx">                 // create wp-config.php / htaccess
</span><span class="cx">                 network_step2();
</span></span></pre></div>
<a id="trunkwpincludesmsloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-load.php (13610 => 13611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php        2010-03-06 19:36:35 UTC (rev 13610)
+++ trunk/wp-includes/ms-load.php        2010-03-06 20:01:32 UTC (rev 13611)
</span><span class="lines">@@ -101,7 +101,9 @@
</span><span class="cx">                 $current_site-&gt;id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
</span><span class="cx">                 $current_site-&gt;domain = DOMAIN_CURRENT_SITE;
</span><span class="cx">                 $current_site-&gt;path   = $path = PATH_CURRENT_SITE;
</span><del>-                if ( defined( 'BLOGID_CURRENT_SITE' ) )
</del><ins>+                if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
+                        $current_site-&gt;blog_id = BLOG_ID_CURRENT_SITE;
+                elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
</ins><span class="cx">                         $current_site-&gt;blog_id = BLOGID_CURRENT_SITE;
</span><span class="cx">                 if ( DOMAIN_CURRENT_SITE == $domain )
</span><span class="cx">                         $current_site-&gt;cookie_domain = $cookie_domain;
</span></span></pre>
</div>
</div>

</body>
</html>