X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/596d585e1dc1eb25bccd3781e37210a4e2504179..6c8f14c09105d0afa4c1574215c59b5021040e76:/wp-admin/network.php diff --git a/wp-admin/network.php b/wp-admin/network.php index 2931cbbc..f9a2f1d3 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -51,8 +51,8 @@ function network_domain_check() { * @return bool Whether subdomain install is allowed */ function allow_subdomain_install() { - $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'siteurl' ) ); - if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) ) + $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) ); + if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) return false; return true; @@ -106,7 +106,7 @@ if ( is_network_admin() ) { $network_help = '

' . __('This screen allows you to configure a network as having subdomains (site1.example.com) or subdirectories (example.com/site1). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '

' . '

' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '

' . '

' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '

' . - '

' . __('Add a blogs.dir directory under /wp-content and add the designated lines of code to wp-config.php (just before /*...stop editing...*/) and .htaccess (replacing the existing WordPress rules).') . '

' . + '

' . __('Add the designated lines of code to wp-config.php (just before /*...stop editing...*/) and .htaccess (replacing the existing WordPress rules).') . '

' . '

' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '

' . '

' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed in a future version.') . '

' . '

' . __('For more information:') . '

' . @@ -144,13 +144,6 @@ include( ABSPATH . 'wp-admin/admin-header.php' ); function network_step1( $errors = false ) { global $is_apache; - if ( get_option( 'siteurl' ) != get_option( 'home' ) ) { - echo '

' . __('ERROR:') . ' ' . sprintf( __( 'Your WordPress address must match your Site address before creating a Network. See General Settings.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '

'; - echo ''; - include ( ABSPATH . 'wp-admin/admin-footer.php' ); - die(); - } - if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { echo '

' . __('ERROR:') . ' ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '

'; echo ''; @@ -190,9 +183,6 @@ function network_step1( $errors = false ) { $error_codes = $errors->get_error_codes(); } - if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) - echo '

' . __('Warning!') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '

'; - $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) ); $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' ); ?> @@ -235,6 +225,9 @@ function network_step1( $errors = false ) {

' . __('Warning!') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

'; + $is_www = ( 0 === strpos( $hostname, 'www.' ) ); if ( $is_www ) : ?> @@ -314,11 +307,20 @@ function network_step1( $errors = false ) { * @since 3.0.0 */ function network_step2( $errors = false ) { - global $base, $wpdb; - $hostname = get_clean_basedomain(); + global $wpdb; + + $hostname = get_clean_basedomain(); + $slashed_home = trailingslashit( get_option( 'home' ) ); + $base = parse_url( $slashed_home, PHP_URL_PATH ); + $wp_dir_from_root = preg_replace( '#^' . preg_quote( $_SERVER['DOCUMENT_ROOT'], '#' ) . '#', '', ABSPATH ); + $wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) ); + $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : ''; - if ( ! isset( $base ) ) - $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); + $home_path = get_home_path(); + + $location_of_wp_config = ABSPATH; + if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) + $location_of_wp_config = trailingslashit( dirname( ABSPATH ) ); // Wildcard DNS message. if ( is_wp_error( $errors ) ) @@ -344,14 +346,18 @@ function network_step2( $errors = false ) { } } + $subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?'; + $subdir_replacement_01 = $subdomain_install ? '' : '$1'; + $subdir_replacement_12 = $subdomain_install ? '$1' : '$2'; + if ( $_POST || ! is_multisite() ) { ?>

Caution: We recommend you back up your existing wp-config.php and %s files.' ), '.htaccess' ); - elseif ( file_exists( ABSPATH . 'web.config' ) ) + elseif ( file_exists( $home_path . 'web.config' ) ) printf( __( 'Caution: We recommend you back up your existing wp-config.php and %s files.' ), 'web.config' ); else _e( 'Caution: We recommend you back up your existing wp-config.php file.' ); @@ -360,26 +366,22 @@ function network_step2( $errors = false ) { } ?>

    -
  1. blogs.dir directory at %s/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); - if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) - echo ' ' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . ''; - ?>

  2. -
  3. wp-config.php file in %s above the line reading /* That’s all, stop editing! Happy blogging. */:' ), ABSPATH ); ?>

    - +define('BLOG_ID_CURRENT_SITE', 1); + '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' ); foreach ( $keys_salts as $c => $v ) { if ( defined( $c ) ) unset( $keys_salts[ $c ] ); } + if ( ! empty( $keys_salts ) ) { $keys_salts_str = ''; $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); @@ -404,10 +406,13 @@ define('BLOG_ID_CURRENT_SITE', 1);
  4. + $web_config_file = << @@ -415,10 +420,18 @@ define('BLOG_ID_CURRENT_SITE', 1); - + '; + if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { + $web_config_file .= ' + + + + '; + } + $web_config_file .= ' - - + + @@ -429,89 +442,64 @@ define('BLOG_ID_CURRENT_SITE', 1); - - - - - - -'; - } else { - $web_config_file = -' - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - -'; - } + +EOF; + ?> -
  5. web.config file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

    -
-
  • .htaccess file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

    -
  • @@ -525,14 +513,12 @@ RewriteRule ^ - [L]'; if ( $_POST ) { - $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); - check_admin_referer( 'install-network-1' ); require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); // create network tables install_network(); - $hostname = get_clean_basedomain(); + $base = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH ); $subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false; if ( ! network_domain_check() ) { $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );