[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * WordPress Installer 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 // Sanity check. 10 if ( false ) { 11 ?> 12 <!DOCTYPE html> 13 <html> 14 <head> 15 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 16 <title>Error: PHP is not running</title> 17 </head> 18 <body class="wp-core-ui"> 19 <p id="logo"><a href="https://wordpress.org/">WordPress</a></p> 20 <h1>Error: PHP is not running</h1> 21 <p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p> 22 </body> 23 </html> 24 <?php 25 } 26 27 /** 28 * We are installing WordPress. 29 * 30 * @since 1.5.1 31 * @var bool 32 */ 33 define( 'WP_INSTALLING', true ); 34 35 /** Load WordPress Bootstrap */ 36 require_once dirname( __DIR__ ) . '/wp-load.php'; 37 38 /** Load WordPress Administration Upgrade API */ 39 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 40 41 /** Load WordPress Translation Install API */ 42 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; 43 44 /** Load wpdb */ 45 require_once ABSPATH . WPINC . '/wp-db.php'; 46 47 nocache_headers(); 48 49 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; 50 51 /** 52 * Display installation header. 53 * 54 * @since 2.5.0 55 * 56 * @param string $body_classes 57 */ 58 function display_header( $body_classes = '' ) { 59 header( 'Content-Type: text/html; charset=utf-8' ); 60 if ( is_rtl() ) { 61 $body_classes .= 'rtl'; 62 } 63 if ( $body_classes ) { 64 $body_classes = ' ' . $body_classes; 65 } 66 ?> 67 <!DOCTYPE html> 68 <html <?php language_attributes(); ?>> 69 <head> 70 <meta name="viewport" content="width=device-width" /> 71 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 72 <meta name="robots" content="noindex,nofollow" /> 73 <title><?php _e( 'WordPress › Installation' ); ?></title> 74 <?php wp_admin_css( 'install', true ); ?> 75 </head> 76 <body class="wp-core-ui<?php echo $body_classes; ?>"> 77 <p id="logo"><?php _e( 'WordPress' ); ?></p> 78 79 <?php 80 } // End display_header(). 81 82 /** 83 * Display installer setup form. 84 * 85 * @since 2.8.0 86 * 87 * @global wpdb $wpdb WordPress database abstraction object. 88 * 89 * @param string|null $error 90 */ 91 function display_setup_form( $error = null ) { 92 global $wpdb; 93 94 $user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null ); 95 96 // Ensure that sites appear in search engines by default. 97 $blog_public = 1; 98 if ( isset( $_POST['weblog_title'] ) ) { 99 $blog_public = isset( $_POST['blog_public'] ); 100 } 101 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'] ) ) : ''; 104 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; 105 106 if ( ! is_null( $error ) ) { 107 ?> 108 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> 109 <p class="message"><?php echo $error; ?></p> 110 <?php } ?> 111 <form id="setup" method="post" action="install.php?step=2" novalidate="novalidate"> 112 <table class="form-table" role="presentation"> 113 <tr> 114 <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th> 115 <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td> 116 </tr> 117 <tr> 118 <th scope="row"><label for="user_login"><?php _e( 'Username' ); ?></label></th> 119 <td> 120 <?php 121 if ( $user_table ) { 122 _e( 'User(s) already exists.' ); 123 echo '<input name="user_name" type="hidden" value="admin" />'; 124 } else { 125 ?> 126 <input name="user_name" type="text" id="user_login" size="25" 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> 128 <?php 129 } 130 ?> 131 </td> 132 </tr> 133 <?php if ( ! $user_table ) : ?> 134 <tr class="form-field form-required user-pass1-wrap"> 135 <th scope="row"> 136 <label for="pass1"> 137 <?php _e( 'Password' ); ?> 138 </label> 139 </th> 140 <td> 141 <div class="wp-pwd"> 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" /> 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' ); ?>"> 145 <span class="dashicons dashicons-hidden"></span> 146 <span class="text"><?php _e( 'Hide' ); ?></span> 147 </button> 148 <div id="pass-strength-result" aria-live="polite"></div> 149 </div> 150 <p><span class="description important hide-if-no-js"> 151 <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. */ ?> 153 <?php _e( 'You will need this password to log in. Please store it in a secure location.' ); ?></span></p> 154 </td> 155 </tr> 156 <tr class="form-field form-required user-pass2-wrap hide-if-js"> 157 <th scope="row"> 158 <label for="pass2"><?php _e( 'Repeat Password' ); ?> 159 <span class="description"><?php _e( '(required)' ); ?></span> 160 </label> 161 </th> 162 <td> 163 <input name="admin_password2" type="password" id="pass2" autocomplete="new-password" /> 164 </td> 165 </tr> 166 <tr class="pw-weak"> 167 <th scope="row"><?php _e( 'Confirm Password' ); ?></th> 168 <td> 169 <label> 170 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 171 <?php _e( 'Confirm use of weak password' ); ?> 172 </label> 173 </td> 174 </tr> 175 <?php endif; ?> 176 <tr> 177 <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 ); ?>" /> 179 <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> 180 </tr> 181 <tr> 182 <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?></th> 183 <td> 184 <fieldset> 185 <legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?> </span></legend> 186 <?php 187 if ( has_action( 'blog_privacy_selector' ) ) { 188 ?> 189 <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/> 191 <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( 0, $blog_public ); ?> /> 192 <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 — it is up to search engines to honor your request.' ); ?></p> 194 <?php 195 /** This action is documented in wp-admin/options-reading.php */ 196 do_action( 'blog_privacy_selector' ); 197 } else { 198 ?> 199 <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( 0, $blog_public ); ?> /> 200 <?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> 202 <?php } ?> 203 </fieldset> 204 </td> 205 </tr> 206 </table> 207 <p class="step"><?php submit_button( __( 'Install WordPress' ), 'large', 'Submit', false, array( 'id' => 'submit' ) ); ?></p> 208 <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" /> 209 </form> 210 <?php 211 } // End display_setup_form(). 212 213 // Let's check to make sure WP isn't already installed. 214 if ( is_blog_installed() ) { 215 display_header(); 216 die( 217 '<h1>' . __( 'Already Installed' ) . '</h1>' . 218 '<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>' . 220 '</body></html>' 221 ); 222 } 223 224 /** 225 * @global string $wp_version The WordPress version string. 226 * @global string $required_php_version The required PHP version string. 227 * @global string $required_mysql_version The required MySQL version string. 228 */ 229 global $wp_version, $required_php_version, $required_mysql_version; 230 231 $php_version = phpversion(); 232 $mysql_version = $wpdb->db_version(); 233 $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' ); 235 236 $version_url = sprintf( 237 /* translators: %s: WordPress version. */ 238 esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ), 239 sanitize_title( $wp_version ) 240 ); 241 242 $php_update_message = '</p><p>' . sprintf( 243 /* translators: %s: URL to Update PHP page. */ 244 __( '<a href="%s">Learn more about updating PHP</a>.' ), 245 esc_url( wp_get_update_php_url() ) 246 ); 247 248 $annotation = wp_get_update_php_annotation(); 249 250 if ( $annotation ) { 251 $php_update_message .= '</p><p><em>' . $annotation . '</em>'; 252 } 253 254 if ( ! $mysql_compat && ! $php_compat ) { 255 $compat = sprintf( 256 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */ 257 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), 258 $version_url, 259 $wp_version, 260 $required_php_version, 261 $required_mysql_version, 262 $php_version, 263 $mysql_version 264 ) . $php_update_message; 265 } elseif ( ! $php_compat ) { 266 $compat = sprintf( 267 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ 268 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), 269 $version_url, 270 $wp_version, 271 $required_php_version, 272 $php_version 273 ) . $php_update_message; 274 } elseif ( ! $mysql_compat ) { 275 $compat = sprintf( 276 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ 277 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), 278 $version_url, 279 $wp_version, 280 $required_mysql_version, 281 $mysql_version 282 ); 283 } 284 285 if ( ! $mysql_compat || ! $php_compat ) { 286 display_header(); 287 die( '<h1>' . __( 'Requirements Not Met' ) . '</h1><p>' . $compat . '</p></body></html>' ); 288 } 289 290 if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { 291 display_header(); 292 die( 293 '<h1>' . __( 'Configuration Error' ) . '</h1>' . 294 '<p>' . sprintf( 295 /* translators: %s: wp-config.php */ 296 __( 'Your %s file has an empty database table prefix, which is not supported.' ), 297 '<code>wp-config.php</code>' 298 ) . '</p></body></html>' 299 ); 300 } 301 302 // Set error message if DO_NOT_UPGRADE_GLOBAL_TABLES isn't set as it will break install. 303 if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { 304 display_header(); 305 die( 306 '<h1>' . __( 'Configuration Error' ) . '</h1>' . 307 '<p>' . sprintf( 308 /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */ 309 __( 'The constant %s cannot be defined when installing WordPress.' ), 310 '<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>' 311 ) . '</p></body></html>' 312 ); 313 } 314 315 /** 316 * @global string $wp_local_package Locale code of the package. 317 * @global WP_Locale $wp_locale WordPress date and time locale object. 318 */ 319 $language = ''; 320 if ( ! empty( $_REQUEST['language'] ) ) { 321 $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] ); 322 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { 323 $language = $GLOBALS['wp_local_package']; 324 } 325 326 $scripts_to_print = array( 'jquery' ); 327 328 switch ( $step ) { 329 case 0: // Step 0. 330 if ( wp_can_install_language_pack() && empty( $language ) ) { 331 $languages = wp_get_available_translations(); 332 if ( $languages ) { 333 $scripts_to_print[] = 'language-chooser'; 334 display_header( 'language-chooser' ); 335 echo '<form id="setup" method="post" action="?step=1">'; 336 wp_install_language_form( $languages ); 337 echo '</form>'; 338 break; 339 } 340 } 341 342 // Deliberately fall through if we can't reach the translations API. 343 344 case 1: // Step 1, direct link or from language chooser. 345 if ( ! empty( $language ) ) { 346 $loaded_language = wp_download_language_pack( $language ); 347 if ( $loaded_language ) { 348 load_default_textdomain( $loaded_language ); 349 $GLOBALS['wp_locale'] = new WP_Locale(); 350 } 351 } 352 353 $scripts_to_print[] = 'user-profile'; 354 355 display_header(); 356 ?> 357 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> 358 <p><?php _e( 'Welcome to the famous five-minute WordPress installation process! Just fill in the information below and you’ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ); ?></p> 359 360 <h2><?php _e( 'Information needed' ); ?></h2> 361 <p><?php _e( 'Please provide the following information. Do not worry, you can always change these settings later.' ); ?></p> 362 363 <?php 364 display_setup_form(); 365 break; 366 case 2: 367 if ( ! empty( $language ) && load_default_textdomain( $language ) ) { 368 $loaded_language = $language; 369 $GLOBALS['wp_locale'] = new WP_Locale(); 370 } else { 371 $loaded_language = 'en_US'; 372 } 373 374 if ( ! empty( $wpdb->error ) ) { 375 wp_die( $wpdb->error->get_error_message() ); 376 } 377 378 $scripts_to_print[] = 'user-profile'; 379 380 display_header(); 381 // Fill in the data we gathered. 382 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; 383 $user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; 384 $admin_password = isset( $_POST['admin_password'] ) ? wp_unslash( $_POST['admin_password'] ) : ''; 385 $admin_password_check = isset( $_POST['admin_password2'] ) ? wp_unslash( $_POST['admin_password2'] ) : ''; 386 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; 387 $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 1; 388 389 // Check email address. 390 $error = false; 391 if ( empty( $user_name ) ) { 392 // TODO: Poka-yoke. 393 display_setup_form( __( 'Please provide a valid username.' ) ); 394 $error = true; 395 } elseif ( sanitize_user( $user_name, true ) !== $user_name ) { 396 display_setup_form( __( 'The username you provided has invalid characters.' ) ); 397 $error = true; 398 } elseif ( $admin_password !== $admin_password_check ) { 399 // TODO: Poka-yoke. 400 display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); 401 $error = true; 402 } elseif ( empty( $admin_email ) ) { 403 // TODO: Poka-yoke. 404 display_setup_form( __( 'You must provide an email address.' ) ); 405 $error = true; 406 } elseif ( ! is_email( $admin_email ) ) { 407 // TODO: Poka-yoke. 408 display_setup_form( __( 'Sorry, that is not a valid email address. Email addresses look like <code>username@example.com</code>.' ) ); 409 $error = true; 410 } 411 412 if ( false === $error ) { 413 $wpdb->show_errors(); 414 $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language ); 415 ?> 416 417 <h1><?php _e( 'Success!' ); ?></h1> 418 419 <p><?php _e( 'WordPress has been installed. Thank you, and enjoy!' ); ?></p> 420 421 <table class="form-table install-success"> 422 <tr> 423 <th><?php _e( 'Username' ); ?></th> 424 <td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td> 425 </tr> 426 <tr> 427 <th><?php _e( 'Password' ); ?></th> 428 <td> 429 <?php if ( ! empty( $result['password'] ) && empty( $admin_password_check ) ) : ?> 430 <code><?php echo esc_html( $result['password'] ); ?></code><br /> 431 <?php endif; ?> 432 <p><?php echo $result['password_message']; ?></p> 433 </td> 434 </tr> 435 </table> 436 437 <p class="step"><a href="<?php echo esc_url( wp_login_url() ); ?>" class="button button-large"><?php _e( 'Log In' ); ?></a></p> 438 439 <?php 440 } 441 break; 442 } 443 444 if ( ! wp_is_mobile() ) { 445 ?> 446 <script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script> 447 <?php 448 } 449 450 wp_print_scripts( $scripts_to_print ); 451 ?> 452 <script type="text/javascript"> 453 jQuery( function( $ ) { 454 $( '.hide-if-no-js' ).removeClass( 'hide-if-no-js' ); 455 } ); 456 </script> 457 </body> 458 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |