36 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
36 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
37 |
37 |
38 /** Load WordPress Administration Upgrade API */ |
38 /** Load WordPress Administration Upgrade API */ |
39 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
39 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
40 |
40 |
|
41 /** Load WordPress Translation Install API */ |
|
42 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
43 |
41 /** Load wpdb */ |
44 /** Load wpdb */ |
42 require_once( ABSPATH . 'wp-includes/wp-db.php' ); |
45 require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
46 |
|
47 nocache_headers(); |
43 |
48 |
44 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; |
49 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; |
45 |
50 |
46 /** |
51 /** |
47 * Display install header. |
52 * Display install header. |
48 * |
53 * |
49 * @since 2.5.0 |
54 * @since 2.5.0 |
50 * @package WordPress |
|
51 * @subpackage Installer |
|
52 */ |
55 */ |
53 function display_header() { |
56 function display_header( $body_classes = '' ) { |
54 header( 'Content-Type: text/html; charset=utf-8' ); |
57 header( 'Content-Type: text/html; charset=utf-8' ); |
|
58 if ( is_rtl() ) { |
|
59 $body_classes .= 'rtl'; |
|
60 } |
|
61 if ( $body_classes ) { |
|
62 $body_classes = ' ' . $body_classes; |
|
63 } |
55 ?> |
64 ?> |
56 <!DOCTYPE html> |
65 <!DOCTYPE html> |
57 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> |
66 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> |
58 <head> |
67 <head> |
|
68 <meta name="viewport" content="width=device-width" /> |
59 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
69 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
60 <title><?php _e( 'WordPress › Installation' ); ?></title> |
70 <title><?php _e( 'WordPress › Installation' ); ?></title> |
61 <?php |
71 <?php |
62 wp_admin_css( 'install', true ); |
72 wp_admin_css( 'install', true ); |
63 ?> |
73 ?> |
64 </head> |
74 </head> |
65 <body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>"> |
75 <body class="wp-core-ui<?php echo $body_classes ?>"> |
66 <h1 id="logo"><a href="<?php echo esc_url( __( 'http://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></h1> |
76 <h1 id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1> |
67 |
77 |
68 <?php |
78 <?php |
69 } // end display_header() |
79 } // end display_header() |
70 |
80 |
71 /** |
81 /** |
72 * Display installer setup form. |
82 * Display installer setup form. |
73 * |
83 * |
74 * @since 2.8.0 |
84 * @since 2.8.0 |
75 * @package WordPress |
|
76 * @subpackage Installer |
|
77 */ |
85 */ |
78 function display_setup_form( $error = null ) { |
86 function display_setup_form( $error = null ) { |
79 global $wpdb; |
87 global $wpdb; |
80 $user_table = ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->users'") != null ); |
88 |
81 |
89 $sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) ); |
82 // Ensure that Blogs appear in search engines by default |
90 $user_table = ( $wpdb->get_var( $sql ) != null ); |
|
91 |
|
92 // Ensure that Blogs appear in search engines by default. |
83 $blog_public = 1; |
93 $blog_public = 1; |
84 if ( ! empty( $_POST ) ) |
94 if ( isset( $_POST['weblog_title'] ) ) { |
85 $blog_public = isset( $_POST['blog_public'] ); |
95 $blog_public = isset( $_POST['blog_public'] ); |
|
96 } |
86 |
97 |
87 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; |
98 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; |
88 $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; |
99 $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; |
89 $admin_password = isset($_POST['admin_password']) ? trim( wp_unslash( $_POST['admin_password'] ) ) : ''; |
|
90 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; |
100 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; |
91 |
101 |
92 if ( ! is_null( $error ) ) { |
102 if ( ! is_null( $error ) ) { |
93 ?> |
103 ?> |
94 <p class="message"><?php echo $error; ?></p> |
104 <p class="message"><?php echo $error; ?></p> |
95 <?php } ?> |
105 <?php } ?> |
96 <form id="setup" method="post" action="install.php?step=2"> |
106 <form id="setup" method="post" action="install.php?step=2" novalidate="novalidate"> |
97 <table class="form-table"> |
107 <table class="form-table"> |
98 <tr> |
108 <tr> |
99 <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th> |
109 <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th> |
100 <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td> |
110 <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td> |
101 </tr> |
111 </tr> |
103 <th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th> |
113 <th scope="row"><label for="user_login"><?php _e('Username'); ?></label></th> |
104 <td> |
114 <td> |
105 <?php |
115 <?php |
106 if ( $user_table ) { |
116 if ( $user_table ) { |
107 _e('User(s) already exists.'); |
117 _e('User(s) already exists.'); |
|
118 echo '<input name="user_name" type="hidden" value="admin" />'; |
108 } else { |
119 } else { |
109 ?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" /> |
120 ?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" /> |
110 <p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol.' ); ?></p> |
121 <p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p> |
111 <?php |
122 <?php |
112 } ?> |
123 } ?> |
113 </td> |
124 </td> |
114 </tr> |
125 </tr> |
115 <?php if ( ! $user_table ) : ?> |
126 <?php if ( ! $user_table ) : ?> |
116 <tr> |
127 <tr> |
117 <th scope="row"> |
128 <th scope="row"> |
118 <label for="admin_password"><?php _e('Password, twice'); ?></label> |
129 <label for="pass1"><?php _e('Password, twice'); ?></label> |
119 <p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p> |
130 <p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p> |
120 </th> |
131 </th> |
121 <td> |
132 <td> |
122 <input name="admin_password" type="password" id="pass1" size="25" value="" /> |
133 <input name="admin_password" type="password" id="pass1" size="25" value="" /> |
123 <p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p> |
134 <p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p> |
124 <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div> |
135 <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div> |
125 <p><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).'); ?></p> |
136 <p><?php echo wp_get_password_hint(); ?></p> |
126 </td> |
137 </td> |
127 </tr> |
138 </tr> |
128 <?php endif; ?> |
139 <?php endif; ?> |
129 <tr> |
140 <tr> |
130 <th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th> |
141 <th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th> |
131 <td><input name="admin_email" type="text" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" /> |
142 <td><input name="admin_email" type="email" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" /> |
132 <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> |
143 <p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> |
133 </tr> |
144 </tr> |
134 <tr> |
145 <tr> |
135 <th scope="row"><label for="blog_public"><?php _e( 'Privacy' ); ?></label></th> |
146 <th scope="row"><?php _e( 'Privacy' ); ?></th> |
136 <td colspan="2"><label><input type="checkbox" name="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site.' ); ?></label></td> |
147 <td colspan="2"><label><input type="checkbox" name="blog_public" id="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow search engines to index this site.' ); ?></label></td> |
137 </tr> |
148 </tr> |
138 </table> |
149 </table> |
139 <p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p> |
150 <p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button button-large" /></p> |
|
151 <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" /> |
140 </form> |
152 </form> |
141 <?php |
153 <?php |
142 } // end display_setup_form() |
154 } // end display_setup_form() |
143 |
155 |
144 // Let's check to make sure WP isn't already installed. |
156 // Let's check to make sure WP isn't already installed. |
145 if ( is_blog_installed() ) { |
157 if ( is_blog_installed() ) { |
146 display_header(); |
158 display_header(); |
147 die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' ); |
159 die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button button-large">' . __( 'Log In' ) . '</a></p></body></html>' ); |
148 } |
160 } |
149 |
161 |
|
162 global $wp_version, $required_php_version, $required_mysql_version; |
|
163 |
150 $php_version = phpversion(); |
164 $php_version = phpversion(); |
151 $mysql_version = $wpdb->db_version(); |
165 $mysql_version = $wpdb->db_version(); |
152 $php_compat = version_compare( $php_version, $required_php_version, '>=' ); |
166 $php_compat = version_compare( $php_version, $required_php_version, '>=' ); |
153 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); |
167 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); |
154 |
168 |
155 if ( !$mysql_compat && !$php_compat ) |
169 if ( !$mysql_compat && !$php_compat ) |
156 $compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ); |
170 $compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ); |
157 elseif ( !$php_compat ) |
171 elseif ( !$php_compat ) |
158 $compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ); |
172 $compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ); |
159 elseif ( !$mysql_compat ) |
173 elseif ( !$mysql_compat ) |
160 $compat = sprintf( __( 'You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ); |
174 $compat = sprintf( __( 'You cannot install because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ); |
161 |
175 |
162 if ( !$mysql_compat || !$php_compat ) { |
176 if ( !$mysql_compat || !$php_compat ) { |
163 display_header(); |
177 display_header(); |
164 die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' ); |
178 die( '<h1>' . __( 'Insufficient Requirements' ) . '</h1><p>' . $compat . '</p></body></html>' ); |
165 } |
179 } |
167 if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { |
181 if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { |
168 display_header(); |
182 display_header(); |
169 die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' ); |
183 die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' ); |
170 } |
184 } |
171 |
185 |
|
186 $language = ''; |
|
187 if ( ! empty( $_REQUEST['language'] ) ) { |
|
188 $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); |
|
189 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { |
|
190 $language = $GLOBALS['wp_local_package']; |
|
191 } |
|
192 |
172 switch($step) { |
193 switch($step) { |
173 case 0: // Step 1 |
194 case 0: // Step 0 |
174 case 1: // Step 1, direct link. |
195 |
175 display_header(); |
196 if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { |
|
197 display_header( 'language-chooser' ); |
|
198 echo '<form id="setup" method="post" action="?step=1">'; |
|
199 wp_install_language_form( $languages ); |
|
200 echo '</form>'; |
|
201 break; |
|
202 } |
|
203 |
|
204 // Deliberately fall through if we can't reach the translations API. |
|
205 |
|
206 case 1: // Step 1, direct link or from language chooser. |
|
207 if ( ! empty( $language ) ) { |
|
208 $loaded_language = wp_download_language_pack( $language ); |
|
209 if ( $loaded_language ) { |
|
210 load_default_textdomain( $loaded_language ); |
|
211 $GLOBALS['wp_locale'] = new WP_Locale(); |
|
212 } |
|
213 } |
|
214 |
|
215 display_header(); |
176 ?> |
216 ?> |
177 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> |
217 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> |
178 <p><?php printf( __( 'Welcome to the famous five minute WordPress installation process! You may want to browse the <a href="%s">ReadMe documentation</a> at your leisure. Otherwise, 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.' ), '../readme.html' ); ?></p> |
218 <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> |
179 |
219 |
180 <h1><?php _e( 'Information needed' ); ?></h1> |
220 <h1><?php _e( 'Information needed' ); ?></h1> |
181 <p><?php _e( 'Please provide the following information. Don’t worry, you can always change these settings later.' ); ?></p> |
221 <p><?php _e( 'Please provide the following information. Don’t worry, you can always change these settings later.' ); ?></p> |
182 |
222 |
183 <?php |
223 <?php |
184 display_setup_form(); |
224 display_setup_form(); |
185 break; |
225 break; |
186 case 2: |
226 case 2: |
|
227 if ( ! empty( $language ) && load_default_textdomain( $language ) ) { |
|
228 $loaded_language = $language; |
|
229 $GLOBALS['wp_locale'] = new WP_Locale(); |
|
230 } else { |
|
231 $loaded_language = 'en_US'; |
|
232 } |
|
233 |
187 if ( ! empty( $wpdb->error ) ) |
234 if ( ! empty( $wpdb->error ) ) |
188 wp_die( $wpdb->error->get_error_message() ); |
235 wp_die( $wpdb->error->get_error_message() ); |
189 |
236 |
190 display_header(); |
237 display_header(); |
191 // Fill in the data we gathered |
238 // Fill in the data we gathered |
192 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; |
239 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; |
193 $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; |
240 $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; |
194 $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : ''; |
241 $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : ''; |
195 $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : ''; |
242 $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : ''; |
196 $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : ''; |
243 $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : ''; |
197 $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0; |
244 $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0; |
198 // check e-mail address |
245 |
|
246 // Check e-mail address. |
199 $error = false; |
247 $error = false; |
200 if ( empty( $user_name ) ) { |
248 if ( empty( $user_name ) ) { |
201 // TODO: poka-yoke |
249 // TODO: poka-yoke |
202 display_setup_form( __( 'Please provide a valid username.' ) ); |
250 display_setup_form( __( 'Please provide a valid username.' ) ); |
203 $error = true; |
251 $error = true; |