From 4c1b9100306f1ae519f7cb80027423f206ff6f06 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 3 Mar 2010 07:43:32 +0000 Subject: [PATCH] First pass on network.php improvements. see #12094 git-svn-id: http://svn.automattic.com/wordpress/trunk@13571 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-footer.php | 2 +- wp-admin/comment.php | 1 - wp-admin/includes/network.php | 78 ++++++++ wp-admin/network.php | 367 ++++++++++++---------------------- 4 files changed, 211 insertions(+), 237 deletions(-) create mode 100644 wp-admin/includes/network.php diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index a43a4e459..05904ee82 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -29,7 +29,7 @@ echo apply_filters( 'admin_footer_text', '' . __('Tha

$msg

"; include('admin-footer.php'); die; diff --git a/wp-admin/includes/network.php b/wp-admin/includes/network.php new file mode 100644 index 000000000..24dee797e --- /dev/null +++ b/wp-admin/includes/network.php @@ -0,0 +1,78 @@ +get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) + return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" ); + + return false; +} + +/** + * Prints summary of server statistics in preparation for setting up a network. + * + * @since 3.0.0 + */ +function filestats( $err ) { +?> +

+

http://wordpress.org/support/ then copy and paste the following information into your message:' ); ?>

+
+

+ +

+
+
+
+
+
+ +

+
+"; +} diff --git a/wp-admin/network.php b/wp-admin/network.php index eaf0393dd..72be7cd2a 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -1,6 +1,6 @@ tables( 'ms_global' ) as $table => $prefixed_table ) $wpdb->$table = $prefixed_table; -$title = __( 'Network Settings' ); +$title = __( 'Create a Network of WordPress Sites' ); $parent_file = 'tools.php'; add_contextual_help( $current_screen, __( 'Network Settings') ); @@ -36,251 +41,142 @@ $dirs = array( substr( ABSPATH, 0, -1 ), ABSPATH . 'wp-content' );
Network + * should not be a sudden "Welcome to a new install process! Fill this out and click here." * * @since 3.0.0 */ -function filestats( $err ) { -?> -

-

http://wordpress.org/support/ then copy and paste the following information into your message:' ); ?>

-
-

- -

-
-
-
-
-
- -

-
-' . __( 'Please deactivate your plugins before enabling the Network feature. Once the network is created, you may reactivate your plugins.' ) . '

', admin_url( 'plugins.php' ) ); + include( './admin-footer.php' ); + die(); } - echo "
"; -} -/** - * Prints .htaccess component of step 2 for network settings. - * - * @since 3.0.0 - */ -function step2_htaccess() { - global $base; - - // remove ending slash from $base and $url - $htaccess = ''; - if ( substr( $base, -1 ) == '/' ) - $base = substr( $base, 0, -1 ); - - $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 ) ); - - $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 ) ); - } -?> -
  • %s.htaccess with the following:' ), ABSPATH ); ?>

    - -
  • - -

    -

    - -

    -
      -
    • -
    • -
    • README for further details." ); ?>
    • -
    - " . __( 'If the mod_rewrite module is disabled ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ) . '

    '; - - if ( function_exists( 'apache_get_modules' ) ) { - $modules = apache_get_modules(); - if ( ! in_array( 'mod_rewrite', $modules ) ) - echo '

    ' . __( 'Warning! It looks like mod_rewrite is not installed.' ) . '

    ' . $mod_rewrite_msg; - else - $rewrite_enabled = true; - } else { - echo '

    ' . __( 'Please make sure mod_rewrite is installed as it will be activated at the end of this install.' ) . '

    ' . $mod_rewrite_msg; - } - return $rewrite_enabled; -} - -/** - * Prints most of step 1 for network settings. - * - * @since 3.0.0 - * @param bool $rewrite_enabled Whether mod_rewrite is enabled. Default false. - */ -function printstep1form( $rewrite_enabled = false ) { - $weblog_title = sprintf( __( '%s Sites' ), ucfirst( get_option( 'blogname' ) ) ); - $email = get_option( 'admin_email' ); $hostname = get_clean_basedomain(); - $invalid_host = false; - if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname, $match ) ) - $invalid_host = true; - if ( substr( $hostname, 0, 4 ) == 'www.' ) - $nowww = substr( $hostname, 4 ); + if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) { + echo '

    ' . __('You cannot install a network of sites with your server address.' ) . '

    '; + echo '

    ' . __('You cannot use an IP address such as 127.0.0.1 or a single-word hostname like localhost.' ) . '

    '; + if ( 'localhost' == $hostname ) + echo '

    ' . __('Consider using localhost.localdomain.') . '

    '; + include( './admin-footer.php' ); + die(); + } + + ?> +

    +

    + ' . __( 'Please make sure the Apache mod_rewrite module is installed as it will be used at the end of this install.' ) . '

    '; + else + echo '

    ' . __( 'Warning! It looks like Apache mod_rewrite module is not installed.' ) . '

    '; + echo '

    ' . __( 'If mod_rewrite is disabled ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ) . '

    '; + } wp_nonce_field( 'install-network-1' ); if ( network_domain_check() ) { ?>

    -
    +

    - + -

    -

    +

    + +

    You cannot change this later.' ); ?>

    +

    +

    Note It looks like mod_rewrite is not installed.' ); ?>

    -

    -
    - -

    + + + + + + + + + +
    blog1.example.com and blog2.example.com'); ?>
    example.com/blog1 and example.com/blog2'); ?>
    -

    - -

    %1$s before enabling the network feature. It will still be possible to visit your site using the "www" prefix with an address like %2$s but any links will not have the "www" prefix.' ), $nowww, $hostname ); ?>

    - + +

    +

    %1$s before enabling the network feature. It will still be possible to visit your site using the "www" prefix with an address like %2$s but any links will not have the "www" prefix.' ), substr( $hostname, 4 ), $hostname ); ?>
    - - %s.' ), $hostname ); ?> + %s.' ), $hostname ); ?> - - localhost as your server address.' ); ?> -
    + -

    +

    + - + + + + + + - +
    - -
    + %s.' ), $hostname ); ?> +
    + ' /> +
    - + ' />
    - -

    ' />

    - - ' />

    + -

    -

    deactivate your plugins before enabling WordPress Sites. Once WordPress Sites are enabled, you may reactivate your plugins.' ), admin_url( 'plugins.php' ) ); ?>

    -get_var( "SHOW TABLES LIKE '$wpdb->site'" ) == $wpdb->site ) - return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" ); - - return false; -} - -/** - * Prints step 2 for network settings. - * - * @since 3.0.0 - */ -function step2() { -?> -

    +

    Note: We recommend you make a backup copy of your existing wp-config.php and .htaccess files.' ); ?>

    1. %s/blogs.dir directory. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?>
    2. - - -
    base_prefix; - $config_sample = ABSPATH . 'wp-admin/includes/wp-config.ms'; + $config_sample = ABSPATH . 'wp-admin/includes/ms-config-sample.php'; if ( ! file_exists( $config_sample ) ) wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) ); @@ -341,57 +237,58 @@ function step2_config() { +
  • %s.htaccess with the following:' ), ABSPATH ); ?>

    + +
  • + +