WordPress.org

Make WordPress Core

Changeset 13611


Ignore:
Timestamp:
03/06/10 20:01:32 (4 years ago)
Author:
nacin
Message:

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 #11816

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network.php

    r13572 r13611  
    9090            <label><input type='checkbox' name='existing_network' value='1' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br /> 
    9191        </p> 
    92  
    9392<?php   } else { ?> 
    9493        <input type='hidden' name='existing_network' value='0' /> 
     
    106105            <tr> 
    107106                <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th> 
    108                 <td><?php _e('like <code>blog1.example.com</code> and <code>blog2.example.com</code>'); ?></td> 
     107                <td><?php _e('like <code>site1.example.com</code> and <code>site2.example.com</code>'); ?></td> 
    109108            </tr> 
    110109            <tr> 
    111110                <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th> 
    112                 <td><?php _e('like <code>example.com/blog1</code> and <code>example.com/blog2</code>'); ?></td> 
     111                <td><?php _e('like <code>example.com/site1</code> and <code>example.com/site2</code>'); ?></td> 
    113112            </tr> 
    114113        </table> 
     
    169168?> 
    170169        <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> 
    171         <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> 
     170        <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p> 
     171        <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> 
    172172        <ol> 
    173             <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> 
    174 <?php 
    175     $vhost   = stripslashes( $_POST['vhost' ] ); 
    176     $prefix  = $wpdb->base_prefix; 
    177  
    178     $config_sample = ABSPATH . 'wp-admin/includes/wp-config.ms'; 
    179     if ( ! file_exists( $config_sample ) ) 
    180         wp_die( sprintf( __( 'Sorry, I need a <code>%s</code> to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) ); 
    181  
    182     $wp_config_file = file( $config_sample ); 
    183 ?> 
    184             <li><p><?php printf( __( 'Replace the contents of <code>%swp-config.php</code> with the following:' ), ABSPATH ); ?></p> 
    185                 <textarea name="wp-config" cols="120" rows="20"> 
    186 <?php 
    187     foreach ( $wp_config_file as $line ) { 
    188         switch ( trim( substr( $line, 0, 16 ) ) ) { 
    189             case "define('DB_NAME'": 
    190                 $output = str_replace( "wordpress", DB_NAME, $line ); 
    191                 break; 
    192             case "define('DB_USER'": 
    193                 $output = str_replace( "username", DB_USER, $line ); 
    194                 break; 
    195             case "define('DB_PASSW": 
    196                 $output = str_replace( "password", DB_PASSWORD, $line ); 
    197                 break; 
    198             case "define('DB_HOST'": 
    199                 $output = str_replace( "localhost", DB_HOST, $line ); 
    200                 break; 
    201             case "define('VHOST',": 
    202                 $output = str_replace( "VHOSTSETTING", $vhost, $line ); 
    203                 break; 
    204             case '$table_prefix  =': 
    205                 $output = str_replace( 'wp_', $prefix, $line ); 
    206                 break; 
    207             case '$base = \'BASE\';': 
    208                 $output = str_replace( 'BASE', $base, $line ); 
    209                 break; 
    210             case "define('DOMAIN_C": 
    211                 $domain = get_clean_basedomain(); 
    212                 $output = str_replace( "current_site_domain", $domain, $line ); 
    213                 break; 
    214             case "define('PATH_CUR": 
    215                 $output = str_replace( "current_site_path", $base, $line ); 
    216                 break; 
    217             case "define('AUTH_KEY": 
    218             case "define('AUTH_SAL": 
    219             case "define('LOGGED_I": 
    220             case "define('SECURE_A": 
    221             case "define('NONCE_KE": 
    222                 $constant = substr( $line, 8, strpos( $line, "'", 9 ) - 8 ); 
    223                 if ( defined( $constant ) ) 
    224                     $hash = constant( $constant ); 
    225                 else 
    226                     $hash = md5( mt_rand() ) . md5( mt_rand() ); 
    227                 $output = str_replace( 'put your unique phrase here', $hash, $line ); 
    228                 break; 
    229             default: 
    230                 $output = $line; 
    231                 break; 
    232         } 
    233         echo $output; 
    234     } 
    235 ?> 
    236                 </textarea> 
    237             </li> 
     173            <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> 
     174            <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code>:' ), ABSPATH ); ?></p> 
     175                <textarea class="code" readonly="readonly" cols="100" rows="7"> 
     176define( 'MULTISITE', true ); 
     177define( 'VHOST', '<?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?>' ); 
     178$base = '<?php echo $base; ?>'; 
     179define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' ); 
     180define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' ); 
     181define( 'SITE_ID_CURRENT_SITE', 1 ); 
     182define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea></li> 
    238183<?php 
    239184 
    240185    // remove ending slash from $base and $url 
    241186    $htaccess = ''; 
    242     if ( substr( $base, -1 ) == '/' ) 
    243         $base = substr( $base, 0, -1 ); 
    244  
    245     $htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms'; 
    246     if ( ! file_exists( $htaccess_sample ) ) 
    247         wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) ); 
    248  
    249     $htaccess_file = file( $htaccess_sample ); 
    250     $fp = @fopen( $htaccess_sample, "r" ); 
    251     if ( $fp ) { 
    252         while ( ! feof( $fp ) ) { 
    253             $htaccess .= fgets( $fp, 4096 ); 
    254         } 
    255         fclose( $fp ); 
    256         $htaccess_file = str_replace( "BASE", $base, $htaccess ); 
    257     } else { 
    258         wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) ); 
    259     } 
    260 ?> 
    261             <li><p><?php printf( __( 'Replace the contents of your <code>%s.htaccess</code> with the following:' ), ABSPATH ); ?></p> 
    262                 <textarea name="htaccess" cols="120" rows="20"> 
     187    $base = rtrim( $base, '/' ); 
     188 
     189    $htaccess_file = 'RewriteEngine On 
     190RewriteBase ' . $base . '/ 
     191 
     192#uploaded files 
     193RewriteRule ^(.*/)?files/$ index.php [L] 
     194RewriteCond %{REQUEST_URI} !.*wp-content/plugins.* 
     195RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L] 
     196 
     197# add a trailing slash to /wp-admin 
     198RewriteCond %{REQUEST_URI} ^.*/wp-admin$ 
     199RewriteRule ^(.+)$ $1/ [R=301,L] 
     200 
     201RewriteCond %{REQUEST_FILENAME} -f [OR] 
     202RewriteCond %{REQUEST_FILENAME} -d 
     203RewriteRule . - [L] 
     204RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] 
     205RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] 
     206RewriteRule . index.php [L]'; 
     207?> 
     208            <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 
     209                <textarea class="code" readonly="readonly" cols="100" rows="18"> 
    263210<?php echo wp_htmledit_pre( $htaccess_file ); ?> 
    264 </textarea> 
    265             </li> 
     211</textarea></li> 
    266212        </ol> 
    267213<?php 
     
    280226        // create network tables 
    281227        install_network(); 
    282         if ( !network_domain_check() || $_POST['existing_network'] == '0' ) 
     228        if ( !network_domain_check() || isset( $_POST['existing_network'] ) && $_POST['existing_network'] == '0' ) 
    283229            populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] ); 
    284230        // create wp-config.php / htaccess 
  • trunk/wp-includes/ms-load.php

    r13575 r13611  
    102102        $current_site->domain = DOMAIN_CURRENT_SITE; 
    103103        $current_site->path   = $path = PATH_CURRENT_SITE; 
    104         if ( defined( 'BLOGID_CURRENT_SITE' ) ) 
     104        if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) 
     105            $current_site->blog_id = BLOG_ID_CURRENT_SITE; 
     106        elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated. 
    105107            $current_site->blog_id = BLOGID_CURRENT_SITE; 
    106108        if ( DOMAIN_CURRENT_SITE == $domain ) 
Note: See TracChangeset for help on using the changeset viewer.