wp/wp-admin/install.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 // Sanity check.
     9 // Confidence check.
    10 if ( false ) {
    10 if ( false ) {
    11 	?>
    11 	?>
    12 <!DOCTYPE html>
    12 <!DOCTYPE html>
    13 <html>
    13 <html>
    14 <head>
    14 <head>
    40 
    40 
    41 /** Load WordPress Translation Install API */
    41 /** Load WordPress Translation Install API */
    42 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    42 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    43 
    43 
    44 /** Load wpdb */
    44 /** Load wpdb */
    45 require_once ABSPATH . WPINC . '/wp-db.php';
    45 require_once ABSPATH . WPINC . '/class-wpdb.php';
    46 
    46 
    47 nocache_headers();
    47 nocache_headers();
    48 
    48 
    49 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
    49 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0;
    50 
    50 
    78 
    78 
    79 	<?php
    79 	<?php
    80 } // End display_header().
    80 } // End display_header().
    81 
    81 
    82 /**
    82 /**
    83  * Display installer setup form.
    83  * Displays installer setup form.
    84  *
    84  *
    85  * @since 2.8.0
    85  * @since 2.8.0
    86  *
    86  *
    87  * @global wpdb $wpdb WordPress database abstraction object.
    87  * @global wpdb $wpdb WordPress database abstraction object.
    88  *
    88  *
    94 	$user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null );
    94 	$user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null );
    95 
    95 
    96 	// Ensure that sites appear in search engines by default.
    96 	// Ensure that sites appear in search engines by default.
    97 	$blog_public = 1;
    97 	$blog_public = 1;
    98 	if ( isset( $_POST['weblog_title'] ) ) {
    98 	if ( isset( $_POST['weblog_title'] ) ) {
    99 		$blog_public = isset( $_POST['blog_public'] );
    99 		$blog_public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : $blog_public;
   100 	}
   100 	}
   101 
   101 
   102 	$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
   102 	$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
   103 	$user_name    = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
   103 	$user_name    = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
   104 	$admin_email  = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
   104 	$admin_email  = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
   121 			if ( $user_table ) {
   121 			if ( $user_table ) {
   122 				_e( 'User(s) already exists.' );
   122 				_e( 'User(s) already exists.' );
   123 				echo '<input name="user_name" type="hidden" value="admin" />';
   123 				echo '<input name="user_name" type="hidden" value="admin" />';
   124 			} else {
   124 			} else {
   125 				?>
   125 				?>
   126 				<input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
   126 				<input name="user_name" type="text" id="user_login" size="25" aria-describedby="user-name-desc" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
   127 				<p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p>
   127 				<p id="user-name-desc"><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p>
   128 				<?php
   128 				<?php
   129 			}
   129 			}
   130 			?>
   130 			?>
   131 			</td>
   131 			</td>
   132 		</tr>
   132 		</tr>
   138 				</label>
   138 				</label>
   139 			</th>
   139 			</th>
   140 			<td>
   140 			<td>
   141 				<div class="wp-pwd">
   141 				<div class="wp-pwd">
   142 					<?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?>
   142 					<?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?>
   143 					<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
   143 					<div class="password-input-wrapper">
       
   144 						<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result admin-password-desc" />
       
   145 						<div id="pass-strength-result" aria-live="polite"></div>
       
   146 					</div>
   144 					<button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
   147 					<button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
   145 						<span class="dashicons dashicons-hidden"></span>
   148 						<span class="dashicons dashicons-hidden"></span>
   146 						<span class="text"><?php _e( 'Hide' ); ?></span>
   149 						<span class="text"><?php _e( 'Hide' ); ?></span>
   147 					</button>
   150 					</button>
   148 					<div id="pass-strength-result" aria-live="polite"></div>
       
   149 				</div>
   151 				</div>
   150 				<p><span class="description important hide-if-no-js">
   152 				<p id="admin-password-desc"><span class="description important hide-if-no-js">
   151 				<strong><?php _e( 'Important:' ); ?></strong>
   153 				<strong><?php _e( 'Important:' ); ?></strong>
   152 				<?php /* translators: The non-breaking space prevents 1Password from thinking the text "log in" should trigger a password save prompt. */ ?>
   154 				<?php /* translators: The non-breaking space prevents 1Password from thinking the text "log in" should trigger a password save prompt. */ ?>
   153 				<?php _e( 'You will need this password to log&nbsp;in. Please store it in a secure location.' ); ?></span></p>
   155 				<?php _e( 'You will need this password to log&nbsp;in. Please store it in a secure location.' ); ?></span></p>
   154 			</td>
   156 			</td>
   155 		</tr>
   157 		</tr>
   158 				<label for="pass2"><?php _e( 'Repeat Password' ); ?>
   160 				<label for="pass2"><?php _e( 'Repeat Password' ); ?>
   159 					<span class="description"><?php _e( '(required)' ); ?></span>
   161 					<span class="description"><?php _e( '(required)' ); ?></span>
   160 				</label>
   162 				</label>
   161 			</th>
   163 			</th>
   162 			<td>
   164 			<td>
   163 				<input name="admin_password2" type="password" id="pass2" autocomplete="new-password" />
   165 				<input type="password" name="admin_password2" id="pass2" autocomplete="new-password" spellcheck="false" />
   164 			</td>
   166 			</td>
   165 		</tr>
   167 		</tr>
   166 		<tr class="pw-weak">
   168 		<tr class="pw-weak">
   167 			<th scope="row"><?php _e( 'Confirm Password' ); ?></th>
   169 			<th scope="row"><?php _e( 'Confirm Password' ); ?></th>
   168 			<td>
   170 			<td>
   173 			</td>
   175 			</td>
   174 		</tr>
   176 		</tr>
   175 		<?php endif; ?>
   177 		<?php endif; ?>
   176 		<tr>
   178 		<tr>
   177 			<th scope="row"><label for="admin_email"><?php _e( 'Your Email' ); ?></label></th>
   179 			<th scope="row"><label for="admin_email"><?php _e( 'Your Email' ); ?></label></th>
   178 			<td><input name="admin_email" type="email" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
   180 			<td><input name="admin_email" type="email" id="admin_email" size="25" aria-describedby="admin-email-desc" value="<?php echo esc_attr( $admin_email ); ?>" />
   179 			<p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
   181 			<p id="admin-email-desc"><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
   180 		</tr>
   182 		</tr>
   181 		<tr>
   183 		<tr>
   182 			<th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?></th>
   184 			<th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?></th>
   183 			<td>
   185 			<td>
   184 				<fieldset>
   186 				<fieldset>
   185 					<legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?> </span></legend>
   187 					<legend class="screen-reader-text"><span>
       
   188 						<?php
       
   189 						has_action( 'blog_privacy_selector' )
       
   190 							/* translators: Hidden accessibility text. */
       
   191 							? _e( 'Site visibility' )
       
   192 							/* translators: Hidden accessibility text. */
       
   193 							: _e( 'Search engine visibility' );
       
   194 						?>
       
   195 					</span></legend>
   186 					<?php
   196 					<?php
   187 					if ( has_action( 'blog_privacy_selector' ) ) {
   197 					if ( has_action( 'blog_privacy_selector' ) ) {
   188 						?>
   198 						?>
   189 						<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( 1, $blog_public ); ?> />
   199 						<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( 1, $blog_public ); ?> />
   190 						<label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br/>
   200 						<label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br />
   191 						<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( 0, $blog_public ); ?> />
   201 						<input id="blog-norobots" type="radio" name="blog_public"  aria-describedby="public-desc" value="0" <?php checked( 0, $blog_public ); ?> />
   192 						<label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   202 						<label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   193 						<p class="description"><?php _e( 'Note: Neither of these options blocks access to your site &mdash; it is up to search engines to honor your request.' ); ?></p>
   203 						<p id="public-desc" class="description"><?php _e( 'Note: Discouraging search engines does not block access to your site &mdash; it is up to search engines to honor your request.' ); ?></p>
   194 						<?php
   204 						<?php
   195 						/** This action is documented in wp-admin/options-reading.php */
   205 						/** This action is documented in wp-admin/options-reading.php */
   196 						do_action( 'blog_privacy_selector' );
   206 						do_action( 'blog_privacy_selector' );
   197 					} else {
   207 					} else {
   198 						?>
   208 						?>
   199 						<label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( 0, $blog_public ); ?> />
   209 						<label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" aria-describedby="privacy-desc" value="0" <?php checked( 0, $blog_public ); ?> />
   200 						<?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   210 						<?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   201 						<p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
   211 						<p id="privacy-desc" class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
   202 					<?php } ?>
   212 					<?php } ?>
   203 				</fieldset>
   213 				</fieldset>
   204 			</td>
   214 			</td>
   205 		</tr>
   215 		</tr>
   206 	</table>
   216 	</table>
   214 if ( is_blog_installed() ) {
   224 if ( is_blog_installed() ) {
   215 	display_header();
   225 	display_header();
   216 	die(
   226 	die(
   217 		'<h1>' . __( 'Already Installed' ) . '</h1>' .
   227 		'<h1>' . __( 'Already Installed' ) . '</h1>' .
   218 		'<p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p>' .
   228 		'<p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p>' .
   219 		'<p class="step"><a href="' . esc_url( wp_login_url() ) . '" class="button button-large">' . __( 'Log In' ) . '</a></p>' .
   229 		'<p class="step"><a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log In' ) . '</a></p>' .
   220 		'</body></html>'
   230 		'</body></html>'
   221 	);
   231 	);
   222 }
   232 }
   223 
   233 
   224 /**
   234 /**
   225  * @global string $wp_version             The WordPress version string.
   235  * @global string $wp_version             The WordPress version string.
   226  * @global string $required_php_version   The required PHP version string.
   236  * @global string $required_php_version   The required PHP version string.
   227  * @global string $required_mysql_version The required MySQL version string.
   237  * @global string $required_mysql_version The required MySQL version string.
   228  */
   238  * @global wpdb   $wpdb                   WordPress database abstraction object.
   229 global $wp_version, $required_php_version, $required_mysql_version;
   239  */
   230 
   240 global $wp_version, $required_php_version, $required_mysql_version, $wpdb;
   231 $php_version   = phpversion();
   241 
       
   242 $php_version   = PHP_VERSION;
   232 $mysql_version = $wpdb->db_version();
   243 $mysql_version = $wpdb->db_version();
   233 $php_compat    = version_compare( $php_version, $required_php_version, '>=' );
   244 $php_compat    = version_compare( $php_version, $required_php_version, '>=' );
   234 $mysql_compat  = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
   245 $mysql_compat  = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
   235 
   246 
   236 $version_url = sprintf(
   247 $version_url = sprintf(
   237 	/* translators: %s: WordPress version. */
   248 	/* translators: %s: WordPress version. */
   238 	esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
   249 	esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
   239 	sanitize_title( $wp_version )
   250 	sanitize_title( $wp_version )
   240 );
   251 );
   241 
   252 
   242 $php_update_message = '</p><p>' . sprintf(
   253 $php_update_message = '</p><p>' . sprintf(
   243 	/* translators: %s: URL to Update PHP page. */
   254 	/* translators: %s: URL to Update PHP page. */
   316  * @global string    $wp_local_package Locale code of the package.
   327  * @global string    $wp_local_package Locale code of the package.
   317  * @global WP_Locale $wp_locale        WordPress date and time locale object.
   328  * @global WP_Locale $wp_locale        WordPress date and time locale object.
   318  */
   329  */
   319 $language = '';
   330 $language = '';
   320 if ( ! empty( $_REQUEST['language'] ) ) {
   331 if ( ! empty( $_REQUEST['language'] ) ) {
   321 	$language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
   332 	$language = sanitize_locale_name( $_REQUEST['language'] );
   322 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
   333 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
   323 	$language = $GLOBALS['wp_local_package'];
   334 	$language = $GLOBALS['wp_local_package'];
   324 }
   335 }
   325 
   336 
   326 $scripts_to_print = array( 'jquery' );
   337 $scripts_to_print = array( 'jquery' );
   432 			<p><?php echo $result['password_message']; ?></p>
   443 			<p><?php echo $result['password_message']; ?></p>
   433 		</td>
   444 		</td>
   434 	</tr>
   445 	</tr>
   435 </table>
   446 </table>
   436 
   447 
   437 <p class="step"><a href="<?php echo esc_url( wp_login_url() ); ?>" class="button button-large"><?php _e( 'Log In' ); ?></a></p>
   448 <p class="step"><a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
   438 
   449 
   439 			<?php
   450 			<?php
   440 		}
   451 		}
   441 		break;
   452 		break;
   442 }
   453 }