]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/setup-config.php
WordPress 3.9-scripts
[autoinstalls/wordpress.git] / wp-admin / setup-config.php
index 6201b00451c1d8b447973809cd9b8ad5a1f25a39..2b5b7f89fb6bb2f14ed4dbc9123b8fa8f02c4b28 100644 (file)
@@ -13,8 +13,6 @@
 
 /**
  * We are installing.
 
 /**
  * We are installing.
- *
- * @package WordPress
  */
 define('WP_INSTALLING', true);
 
  */
 define('WP_INSTALLING', true);
 
@@ -44,15 +42,20 @@ define('WP_DEBUG', false);
 require(ABSPATH . WPINC . '/load.php');
 require(ABSPATH . WPINC . '/version.php');
 
 require(ABSPATH . WPINC . '/load.php');
 require(ABSPATH . WPINC . '/version.php');
 
-// Also loads functions.php, plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php)
-wp_load_translations_early();
-
 // Check for the required PHP version and for the MySQL extension or a database drop-in.
 wp_check_php_mysql_versions();
 
 // Check for the required PHP version and for the MySQL extension or a database drop-in.
 wp_check_php_mysql_versions();
 
+require_once(ABSPATH . WPINC . '/functions.php');
+
+// Also loads plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php)
+wp_load_translations_early();
+
 // Turn register_globals off.
 wp_unregister_GLOBALS();
 
 // Turn register_globals off.
 wp_unregister_GLOBALS();
 
+// Standardize $_SERVER variables across setups.
+wp_fix_server_vars();
+
 require_once(ABSPATH . WPINC . '/compat.php');
 require_once(ABSPATH . WPINC . '/class-wp-error.php');
 require_once(ABSPATH . WPINC . '/formatting.php');
 require_once(ABSPATH . WPINC . '/compat.php');
 require_once(ABSPATH . WPINC . '/class-wp-error.php');
 require_once(ABSPATH . WPINC . '/formatting.php');
@@ -60,11 +63,14 @@ require_once(ABSPATH . WPINC . '/formatting.php');
 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
 wp_magic_quotes();
 
 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
 wp_magic_quotes();
 
-if ( ! file_exists( ABSPATH . 'wp-config-sample.php' ) )
+// Support wp-config-sample.php one level up, for the develop repo.
+if ( file_exists( ABSPATH . 'wp-config-sample.php' ) )
+       $config_file = file( ABSPATH . 'wp-config-sample.php' );
+elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) )
+       $config_file = file( dirname( ABSPATH ) . '/wp-config-sample.php' );
+else
        wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) );
 
        wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) );
 
-$config_file = file(ABSPATH . 'wp-config-sample.php');
-
 // Check if wp-config.php has been created
 if ( file_exists( ABSPATH . 'wp-config.php' ) )
        wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), 'install.php' ) . '</p>' );
 // Check if wp-config.php has been created
 if ( file_exists( ABSPATH . 'wp-config.php' ) )
        wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), 'install.php' ) . '</p>' );
@@ -80,10 +86,8 @@ $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
  *
  * @ignore
  * @since 2.3.0
  *
  * @ignore
  * @since 2.3.0
- * @package WordPress
- * @subpackage Installer_WP_Config
  */
  */
-function display_header() {
+function setup_config_display_header() {
        global $wp_version;
 
        header( 'Content-Type: text/html; charset=utf-8' );
        global $wp_version;
 
        header( 'Content-Type: text/html; charset=utf-8' );
@@ -91,19 +95,21 @@ function display_header() {
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
 <head>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
 <head>
+<meta name="viewport" content="width=device-width" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title><?php _e( 'WordPress &rsaquo; Setup Configuration File' ); ?></title>
 <link rel="stylesheet" href="css/install.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title><?php _e( 'WordPress &rsaquo; Setup Configuration File' ); ?></title>
 <link rel="stylesheet" href="css/install.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
+<link rel="stylesheet" href="../wp-includes/css/buttons.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" />
 
 </head>
 
 </head>
-<body<?php if ( is_rtl() ) echo ' class="rtl"'; ?>>
-<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png?ver=20120216" /></h1>
+<body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>">
+<h1 id="logo"><a href="<?php esc_attr_e( 'https://wordpress.org/' ); ?>"><?php _e( 'WordPress' ); ?></a></h1>
 <?php
 <?php
-}//end function display_header();
+} // end function setup_config_display_header();
 
 switch($step) {
        case 0:
 
 switch($step) {
        case 0:
-               display_header();
+               setup_config_display_header();
 ?>
 
 <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
 ?>
 
 <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
@@ -114,18 +120,18 @@ switch($step) {
        <li><?php _e( 'Database host' ); ?></li>
        <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
 </ol>
        <li><?php _e( 'Database host' ); ?></li>
        <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
 </ol>
-<p><strong><?php _e( "If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
+<p><strong><?php _e( "If for any reason this automatic file creation doesn&#8217;t work, don&#8217;t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
 <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
 
 <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
 
-<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
+<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
 <?php
        break;
 
        case 1:
 <?php
        break;
 
        case 1:
-               display_header();
+               setup_config_display_header();
        ?>
 <form method="post" action="setup-config.php?step=2">
        ?>
 <form method="post" action="setup-config.php?step=2">
-       <p><?php _e( "Below you should enter your database connection details. If you're not sure about these, contact your host." ); ?></p>
+       <p><?php _e( "Below you should enter your database connection details. If you&#8217;re not sure about these, contact your host." ); ?></p>
        <table class="form-table">
                <tr>
                        <th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
        <table class="form-table">
                <tr>
                        <th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
@@ -154,16 +160,16 @@ switch($step) {
                </tr>
        </table>
        <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
                </tr>
        </table>
        <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
-       <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button" /></p>
+       <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p>
 </form>
 <?php
        break;
 
        case 2:
        foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
 </form>
 <?php
        break;
 
        case 2:
        foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
-               $$key = trim( stripslashes( $_POST[ $key ] ) );
+               $$key = trim( wp_unslash( $_POST[ $key ] ) );
 
 
-       $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a>';
+       $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
 
        if ( empty( $prefix ) )
                wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
 
        if ( empty( $prefix ) )
                wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
@@ -192,12 +198,11 @@ switch($step) {
        if ( ! $no_api ) {
                require_once( ABSPATH . WPINC . '/class-http.php' );
                require_once( ABSPATH . WPINC . '/http.php' );
        if ( ! $no_api ) {
                require_once( ABSPATH . WPINC . '/class-http.php' );
                require_once( ABSPATH . WPINC . '/http.php' );
-               wp_fix_server_vars();
                /**#@+
                 * @ignore
                 */
                function get_bloginfo() {
                /**#@+
                 * @ignore
                 */
                function get_bloginfo() {
-                       return ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . str_replace( $_SERVER['PHP_SELF'], '/wp-admin/setup-config.php', '' ) );
+                       return wp_guess_url();
                }
                /**#@-*/
                $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
                }
                /**#@-*/
                $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
@@ -217,9 +222,10 @@ switch($step) {
        }
 
        $key = 0;
        }
 
        $key = 0;
-       foreach ( $config_file as &$line ) {
+       // Not a PHP5-style by-reference foreach, as this file must be parseable by PHP4.
+       foreach ( $config_file as $line_num => $line ) {
                if ( '$table_prefix  =' == substr( $line, 0, 16 ) ) {
                if ( '$table_prefix  =' == substr( $line, 0, 16 ) ) {
-                       $line = '$table_prefix  = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n";
+                       $config_file[ $line_num ] = '$table_prefix  = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n";
                        continue;
                }
 
                        continue;
                }
 
@@ -234,7 +240,7 @@ switch($step) {
                        case 'DB_USER'     :
                        case 'DB_PASSWORD' :
                        case 'DB_HOST'     :
                        case 'DB_USER'     :
                        case 'DB_PASSWORD' :
                        case 'DB_HOST'     :
-                               $line = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n";
+                               $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n";
                                break;
                        case 'AUTH_KEY'         :
                        case 'SECURE_AUTH_KEY'  :
                                break;
                        case 'AUTH_KEY'         :
                        case 'SECURE_AUTH_KEY'  :
@@ -244,37 +250,51 @@ switch($step) {
                        case 'SECURE_AUTH_SALT' :
                        case 'LOGGED_IN_SALT'   :
                        case 'NONCE_SALT'       :
                        case 'SECURE_AUTH_SALT' :
                        case 'LOGGED_IN_SALT'   :
                        case 'NONCE_SALT'       :
-                               $line = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n";
+                               $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n";
                                break;
                }
        }
        unset( $line );
 
        if ( ! is_writable(ABSPATH) ) :
                                break;
                }
        }
        unset( $line );
 
        if ( ! is_writable(ABSPATH) ) :
-               display_header();
+               setup_config_display_header();
 ?>
 ?>
-<p><?php _e( "Sorry, but I can't write the <code>wp-config.php</code> file." ); ?></p>
+<p><?php _e( "Sorry, but I can&#8217;t write the <code>wp-config.php</code> file." ); ?></p>
 <p><?php _e( 'You can create the <code>wp-config.php</code> manually and paste the following text into it.' ); ?></p>
 <p><?php _e( 'You can create the <code>wp-config.php</code> manually and paste the following text into it.' ); ?></p>
-<textarea cols="98" rows="15" class="code"><?php
+<textarea id="wp-config" cols="98" rows="15" class="code" readonly="readonly"><?php
                foreach( $config_file as $line ) {
                        echo htmlentities($line, ENT_COMPAT, 'UTF-8');
                }
 ?></textarea>
                foreach( $config_file as $line ) {
                        echo htmlentities($line, ENT_COMPAT, 'UTF-8');
                }
 ?></textarea>
-<p><?php _e( 'After you\'ve done that, click "Run the install."' ); ?></p>
-<p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
+<p><?php _e( 'After you&#8217;ve done that, click &#8220;Run the install.&#8221;' ); ?></p>
+<p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
+<script>
+(function(){
+var el=document.getElementById('wp-config');
+el.focus();
+el.select();
+})();
+</script>
 <?php
        else :
 <?php
        else :
-               $handle = fopen(ABSPATH . 'wp-config.php', 'w');
+               // If this file doesn't exist, then we are using the wp-config-sample.php
+               // file one level up, which is for the develop repo.
+               if ( file_exists( ABSPATH . 'wp-config-sample.php' ) )
+                       $path_to_wp_config = ABSPATH . 'wp-config.php';
+               else
+                       $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php';
+
+               $handle = fopen( $path_to_wp_config, 'w' );
                foreach( $config_file as $line ) {
                foreach( $config_file as $line ) {
-                       fwrite($handle, $line);
+                       fwrite( $handle, $line );
                }
                }
-               fclose($handle);
-               chmod(ABSPATH . 'wp-config.php', 0666);
-               display_header();
+               fclose( $handle );
+               chmod( $path_to_wp_config, 0666 );
+               setup_config_display_header();
 ?>
 ?>
-<p><?php _e( "All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
+<p><?php _e( "All right, sparky! You&#8217;ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;" ); ?></p>
 
 
-<p class="step"><a href="install.php" class="button"><?php _e( 'Run the install' ); ?></a></p>
+<p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p>
 <?php
        endif;
        break;
 <?php
        endif;
        break;