<!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">                 <p class="existing-network">
</span><span class="cx">                         <label><input type='checkbox' name='existing_network' value='1' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br />
</span><span class="cx">                 </p>
</span><del>-
</del><span class="cx"> <?php         } else { ?>
</span><span class="cx">                 <input type='hidden' name='existing_network' value='0' />
</span><span class="cx"> <?php        } ?>
</span><span class="lines">@@ -105,11 +104,11 @@
</span><span class="cx">                 <table class="form-table">
</span><span class="cx">                         <tr>
</span><span class="cx">                                 <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th>
</span><del>-                                <td><?php _e('like <code>blog1.example.com</code> and <code>blog2.example.com</code>'); ?></td>
</del><ins>+                                <td><?php _e('like <code>site1.example.com</code> and <code>site2.example.com</code>'); ?></td>
</ins><span class="cx">                         </tr>
</span><span class="cx">                         <tr>
</span><span class="cx">                                 <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th>
</span><del>-                                <td><?php _e('like <code>example.com/blog1</code> and <code>example.com/blog2</code>'); ?></td>
</del><ins>+                                <td><?php _e('like <code>example.com/site1</code> and <code>example.com/site2</code>'); ?></td>
</ins><span class="cx">                         </tr>
</span><span class="cx">                 </table>
</span><span class="cx">
</span><span class="lines">@@ -168,101 +167,48 @@
</span><span class="cx">         global $base, $wpdb;
</span><span class="cx"> ?>
</span><span class="cx">                 <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
</span><del>-                <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>
</del><ins>+                <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
+                <div class="updated inline"><p><?php _e( '<strong>Caution:</strong> We recommend you backup your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' ); ?></p></div>
</ins><span class="cx">                 <ol>
</span><del>-                        <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>
</del><ins>+                        <li><p><?php printf( __( 'Create a <code>blogs.dir</code> directory in <code>%s</code>. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?></p></li>
+                        <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code>:' ), ABSPATH ); ?></p>
+                                <textarea class="code" readonly="readonly" cols="100" rows="7">
+define( 'MULTISITE', true );
+define( 'VHOST', '<?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?>' );
+$base = '<?php echo $base; ?>';
+define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' );
+define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
+define( 'SITE_ID_CURRENT_SITE', 1 );
+define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea></li>
</ins><span class="cx"> <?php
</span><del>-        $vhost = stripslashes( $_POST['vhost' ] );
-        $prefix = $wpdb->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 <code>%s</code> to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) );
-
-        $wp_config_file = file( $config_sample );
-?>
-                        <li><p><?php printf( __( 'Replace the contents of <code>%swp-config.php</code> with the following:' ), ABSPATH ); ?></p>
-                                <textarea name="wp-config" cols="120" rows="20">
-<?php
-        foreach ( $wp_config_file as $line ) {
-                switch ( trim( substr( $line, 0, 16 ) ) ) {
-                        case "define('DB_NAME'":
-                                $output = str_replace( "wordpress", DB_NAME, $line );
-                                break;
-                        case "define('DB_USER'":
-                                $output = str_replace( "username", DB_USER, $line );
-                                break;
-                        case "define('DB_PASSW":
-                                $output = str_replace( "password", DB_PASSWORD, $line );
-                                break;
-                        case "define('DB_HOST'":
-                                $output = str_replace( "localhost", DB_HOST, $line );
-                                break;
-                        case "define('VHOST',":
-                                $output = str_replace( "VHOSTSETTING", $vhost, $line );
-                                break;
-                        case '$table_prefix =':
-                                $output = str_replace( 'wp_', $prefix, $line );
-                                break;
-                        case '$base = \'BASE\';':
-                                $output = str_replace( 'BASE', $base, $line );
-                                break;
-                        case "define('DOMAIN_C":
-                                $domain = get_clean_basedomain();
-                                $output = str_replace( "current_site_domain", $domain, $line );
-                                break;
-                        case "define('PATH_CUR":
-                                $output = str_replace( "current_site_path", $base, $line );
-                                break;
-                        case "define('AUTH_KEY":
-                        case "define('AUTH_SAL":
-                        case "define('LOGGED_I":
-                        case "define('SECURE_A":
-                        case "define('NONCE_KE":
-                                $constant = substr( $line, 8, strpos( $line, "'", 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;
-        }
-?>
-                                </textarea>
-                        </li>
-<?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, "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>+#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"> ?>
</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">
</del><ins>+                        <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
+                                <textarea class="code" readonly="readonly" cols="100" rows="18">
</ins><span class="cx"> <?php echo wp_htmledit_pre( $htaccess_file ); ?>
</span><del>-</textarea>
-                        </li>
</del><ins>+</textarea></li>
</ins><span class="cx">                 </ol>
</span><span class="cx"> <?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'] ) && $_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->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
</span><span class="cx">                 $current_site->domain = DOMAIN_CURRENT_SITE;
</span><span class="cx">                 $current_site->path = $path = PATH_CURRENT_SITE;
</span><del>-                if ( defined( 'BLOGID_CURRENT_SITE' ) )
</del><ins>+                if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
+                        $current_site->blog_id = BLOG_ID_CURRENT_SITE;
+                elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
</ins><span class="cx">                         $current_site->blog_id = BLOGID_CURRENT_SITE;
</span><span class="cx">                 if ( DOMAIN_CURRENT_SITE == $domain )
</span><span class="cx">                         $current_site->cookie_domain = $cookie_domain;
</span></span></pre>
</div>
</div>
</body>
</html>