24 define('WP_SETUP_CONFIG', true); |
22 define('WP_SETUP_CONFIG', true); |
25 |
23 |
26 /** |
24 /** |
27 * Disable error reporting |
25 * Disable error reporting |
28 * |
26 * |
29 * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging |
27 * Set this to error_reporting( -1 ) for debugging |
30 */ |
28 */ |
31 error_reporting(0); |
29 error_reporting(0); |
32 |
30 |
33 /**#@+ |
31 define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
34 * These three defines are required to allow us to use require_wp_db() to load |
32 |
35 * the database class while being wp-content/db.php aware. |
33 require( ABSPATH . 'wp-settings.php' ); |
36 * @ignore |
34 |
37 */ |
35 /** Load WordPress Administration Upgrade API */ |
38 define('ABSPATH', dirname(dirname(__FILE__)).'/'); |
36 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
39 define('WPINC', 'wp-includes'); |
37 |
40 define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); |
38 /** Load WordPress Translation Install API */ |
41 define('WP_DEBUG', false); |
39 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
42 /**#@-*/ |
40 |
43 |
41 nocache_headers(); |
44 require(ABSPATH . WPINC . '/load.php'); |
|
45 require(ABSPATH . WPINC . '/version.php'); |
|
46 |
|
47 // Check for the required PHP version and for the MySQL extension or a database drop-in. |
|
48 wp_check_php_mysql_versions(); |
|
49 |
|
50 require_once(ABSPATH . WPINC . '/functions.php'); |
|
51 |
|
52 // Also loads plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php) |
|
53 wp_load_translations_early(); |
|
54 |
|
55 // Turn register_globals off. |
|
56 wp_unregister_GLOBALS(); |
|
57 |
|
58 // Standardize $_SERVER variables across setups. |
|
59 wp_fix_server_vars(); |
|
60 |
|
61 require_once(ABSPATH . WPINC . '/compat.php'); |
|
62 require_once(ABSPATH . WPINC . '/class-wp-error.php'); |
|
63 require_once(ABSPATH . WPINC . '/formatting.php'); |
|
64 |
|
65 // Add magic quotes and set up $_REQUEST ( $_GET + $_POST ) |
|
66 wp_magic_quotes(); |
|
67 |
42 |
68 // Support wp-config-sample.php one level up, for the develop repo. |
43 // Support wp-config-sample.php one level up, for the develop repo. |
69 if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
44 if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
70 $config_file = file( ABSPATH . 'wp-config-sample.php' ); |
45 $config_file = file( ABSPATH . 'wp-config-sample.php' ); |
71 elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) |
46 elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) |
79 |
54 |
80 // Check if wp-config.php exists above the root directory but is not part of another install |
55 // Check if wp-config.php exists above the root directory but is not part of another install |
81 if ( file_exists(ABSPATH . '../wp-config.php' ) && ! file_exists( ABSPATH . '../wp-settings.php' ) ) |
56 if ( file_exists(ABSPATH . '../wp-config.php' ) && ! file_exists( ABSPATH . '../wp-settings.php' ) ) |
82 wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>."), 'install.php' ) . '</p>' ); |
57 wp_die( '<p>' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>."), 'install.php' ) . '</p>' ); |
83 |
58 |
84 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; |
59 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : -1; |
85 |
60 |
86 /** |
61 /** |
87 * Display setup wp-config.php file header. |
62 * Display setup wp-config.php file header. |
88 * |
63 * |
89 * @ignore |
64 * @ignore |
90 * @since 2.3.0 |
65 * @since 2.3.0 |
91 * @package WordPress |
66 */ |
92 * @subpackage Installer_WP_Config |
67 function setup_config_display_header( $body_classes = array() ) { |
93 */ |
|
94 function setup_config_display_header() { |
|
95 global $wp_version; |
68 global $wp_version; |
|
69 $body_classes = (array) $body_classes; |
|
70 $body_classes[] = 'wp-core-ui'; |
|
71 if ( is_rtl() ) { |
|
72 $body_classes[] = 'rtl'; |
|
73 } |
96 |
74 |
97 header( 'Content-Type: text/html; charset=utf-8' ); |
75 header( 'Content-Type: text/html; charset=utf-8' ); |
98 ?> |
76 ?> |
99 <!DOCTYPE html> |
77 <!DOCTYPE html> |
100 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
78 <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
101 <head> |
79 <head> |
102 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
80 <meta name="viewport" content="width=device-width" /> |
103 <title><?php _e( 'WordPress › Setup Configuration File' ); ?></title> |
81 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
104 <link rel="stylesheet" href="css/install.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" /> |
82 <title><?php _e( 'WordPress › Setup Configuration File' ); ?></title> |
105 <link rel="stylesheet" href="../wp-includes/css/buttons.css?ver=<?php echo preg_replace( '/[^0-9a-z\.-]/i', '', $wp_version ); ?>" type="text/css" /> |
83 <?php wp_admin_css( 'install', true ); ?> |
106 |
|
107 </head> |
84 </head> |
108 <body class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>"> |
85 <body class="<?php echo implode( ' ', $body_classes ); ?>"> |
109 <h1 id="logo"><a href="<?php esc_attr_e( 'http://wordpress.org/' ); ?>"><?php _e( 'WordPress' ); ?></a></h1> |
86 <h1 id="logo"><a href="<?php esc_attr_e( 'https://wordpress.org/' ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></h1> |
110 <?php |
87 <?php |
111 } // end function setup_config_display_header(); |
88 } // end function setup_config_display_header(); |
112 |
89 |
|
90 $language = ''; |
|
91 if ( ! empty( $_REQUEST['language'] ) ) { |
|
92 $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); |
|
93 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { |
|
94 $language = $GLOBALS['wp_local_package']; |
|
95 } |
|
96 |
113 switch($step) { |
97 switch($step) { |
|
98 case -1: |
|
99 if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { |
|
100 setup_config_display_header( 'language-chooser' ); |
|
101 echo '<form id="setup" method="post" action="?step=0">'; |
|
102 wp_install_language_form( $languages ); |
|
103 echo '</form>'; |
|
104 break; |
|
105 } |
|
106 |
|
107 // Deliberately fall through if we can't reach the translations API. |
|
108 |
114 case 0: |
109 case 0: |
|
110 if ( ! empty( $language ) ) { |
|
111 $loaded_language = wp_download_language_pack( $language ); |
|
112 if ( $loaded_language ) { |
|
113 load_default_textdomain( $loaded_language ); |
|
114 $GLOBALS['wp_locale'] = new WP_Locale(); |
|
115 } |
|
116 } |
|
117 |
115 setup_config_display_header(); |
118 setup_config_display_header(); |
|
119 $step_1 = 'setup-config.php?step=1'; |
|
120 if ( isset( $_REQUEST['noapi'] ) ) { |
|
121 $step_1 .= '&noapi'; |
|
122 } |
|
123 if ( ! empty( $loaded_language ) ) { |
|
124 $step_1 .= '&language=' . $loaded_language; |
|
125 } |
116 ?> |
126 ?> |
117 |
127 |
118 <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> |
128 <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> |
119 <ol> |
129 <ol> |
120 <li><?php _e( 'Database name' ); ?></li> |
130 <li><?php _e( 'Database name' ); ?></li> |
121 <li><?php _e( 'Database username' ); ?></li> |
131 <li><?php _e( 'Database username' ); ?></li> |
122 <li><?php _e( 'Database password' ); ?></li> |
132 <li><?php _e( 'Database password' ); ?></li> |
123 <li><?php _e( 'Database host' ); ?></li> |
133 <li><?php _e( 'Database host' ); ?></li> |
124 <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li> |
134 <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li> |
125 </ol> |
135 </ol> |
126 <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> |
136 <p> |
|
137 <?php _e( 'We’re going to use this information to create a <code>wp-config.php</code> file.' ); ?> |
|
138 <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> |
|
139 <?php _e( "Need more help? <a href='https://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ); ?> |
|
140 </p> |
127 <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’re all ready…" ); ?></p> |
141 <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’re all ready…" ); ?></p> |
128 |
142 |
129 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p> |
143 <p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p> |
130 <?php |
144 <?php |
131 break; |
145 break; |
132 |
146 |
133 case 1: |
147 case 1: |
|
148 load_default_textdomain( $language ); |
|
149 $GLOBALS['wp_locale'] = new WP_Locale(); |
|
150 |
134 setup_config_display_header(); |
151 setup_config_display_header(); |
135 ?> |
152 ?> |
136 <form method="post" action="setup-config.php?step=2"> |
153 <form method="post" action="setup-config.php?step=2"> |
137 <p><?php _e( "Below you should enter your database connection details. If you’re not sure about these, contact your host." ); ?></p> |
154 <p><?php _e( "Below you should enter your database connection details. If you’re not sure about these, contact your host." ); ?></p> |
138 <table class="form-table"> |
155 <table class="form-table"> |
161 <td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td> |
178 <td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td> |
162 <td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td> |
179 <td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td> |
163 </tr> |
180 </tr> |
164 </table> |
181 </table> |
165 <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> |
182 <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> |
|
183 <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" /> |
166 <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p> |
184 <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p> |
167 </form> |
185 </form> |
168 <?php |
186 <?php |
169 break; |
187 break; |
170 |
188 |
171 case 2: |
189 case 2: |
172 foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key ) |
190 load_default_textdomain( $language ); |
173 $$key = trim( wp_unslash( $_POST[ $key ] ) ); |
191 $GLOBALS['wp_locale'] = new WP_Locale(); |
174 |
192 |
175 $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>'; |
193 $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) ); |
|
194 $uname = trim( wp_unslash( $_POST[ 'uname' ] ) ); |
|
195 $pwd = trim( wp_unslash( $_POST[ 'pwd' ] ) ); |
|
196 $dbhost = trim( wp_unslash( $_POST[ 'dbhost' ] ) ); |
|
197 $prefix = trim( wp_unslash( $_POST[ 'prefix' ] ) ); |
|
198 |
|
199 $step_1 = 'setup-config.php?step=1'; |
|
200 $install = 'install.php'; |
|
201 if ( isset( $_REQUEST['noapi'] ) ) { |
|
202 $step_1 .= '&noapi'; |
|
203 } |
|
204 |
|
205 if ( ! empty( $language ) ) { |
|
206 $step_1 .= '&language=' . $language; |
|
207 $install .= '?language=' . $language; |
|
208 } else { |
|
209 $install .= '?language=en_US'; |
|
210 } |
|
211 |
|
212 $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>'; |
176 |
213 |
177 if ( empty( $prefix ) ) |
214 if ( empty( $prefix ) ) |
178 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
215 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
179 |
216 |
180 // Validate $prefix: it can only contain letters, numbers and underscores. |
217 // Validate $prefix: it can only contain letters, numbers and underscores. |
189 define('DB_USER', $uname); |
226 define('DB_USER', $uname); |
190 define('DB_PASSWORD', $pwd); |
227 define('DB_PASSWORD', $pwd); |
191 define('DB_HOST', $dbhost); |
228 define('DB_HOST', $dbhost); |
192 /**#@-*/ |
229 /**#@-*/ |
193 |
230 |
194 // We'll fail here if the values are no good. |
231 // Re-construct $wpdb with these new values. |
|
232 unset( $wpdb ); |
195 require_wp_db(); |
233 require_wp_db(); |
|
234 |
|
235 /* |
|
236 * The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must |
|
237 * fire this manually. We'll fail here if the values are no good. |
|
238 */ |
|
239 $wpdb->db_connect(); |
|
240 |
196 if ( ! empty( $wpdb->error ) ) |
241 if ( ! empty( $wpdb->error ) ) |
197 wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
242 wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
198 |
243 |
199 // Fetch or generate keys and salts. |
244 // Fetch or generate keys and salts. |
200 $no_api = isset( $_POST['noapi'] ); |
245 $no_api = isset( $_POST['noapi'] ); |
201 if ( ! $no_api ) { |
246 if ( ! $no_api ) { |
202 require_once( ABSPATH . WPINC . '/class-http.php' ); |
|
203 require_once( ABSPATH . WPINC . '/http.php' ); |
|
204 /**#@+ |
|
205 * @ignore |
|
206 */ |
|
207 function get_bloginfo() { |
|
208 return wp_guess_url(); |
|
209 } |
|
210 /**#@-*/ |
|
211 $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
247 $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
212 } |
248 } |
213 |
249 |
214 if ( $no_api || is_wp_error( $secret_keys ) ) { |
250 if ( $no_api || is_wp_error( $secret_keys ) ) { |
215 $secret_keys = array(); |
251 $secret_keys = array(); |
216 require_once( ABSPATH . WPINC . '/pluggable.php' ); |
|
217 for ( $i = 0; $i < 8; $i++ ) { |
252 for ( $i = 0; $i < 8; $i++ ) { |
218 $secret_keys[] = wp_generate_password( 64, true, true ); |
253 $secret_keys[] = wp_generate_password( 64, true, true ); |
219 } |
254 } |
220 } else { |
255 } else { |
221 $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); |
256 $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); |
268 foreach( $config_file as $line ) { |
308 foreach( $config_file as $line ) { |
269 echo htmlentities($line, ENT_COMPAT, 'UTF-8'); |
309 echo htmlentities($line, ENT_COMPAT, 'UTF-8'); |
270 } |
310 } |
271 ?></textarea> |
311 ?></textarea> |
272 <p><?php _e( 'After you’ve done that, click “Run the install.”' ); ?></p> |
312 <p><?php _e( 'After you’ve done that, click “Run the install.”' ); ?></p> |
273 <p class="step"><a href="install.php" class="button button-large"><?php _e( 'Run the install' ); ?></a></p> |
313 <p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the install' ); ?></a></p> |
274 <script> |
314 <script> |
275 (function(){ |
315 (function(){ |
276 var el=document.getElementById('wp-config'); |
316 if ( ! /iPad|iPod|iPhone/.test( navigator.userAgent ) ) { |
277 el.focus(); |
317 var el = document.getElementById('wp-config'); |
278 el.select(); |
318 el.focus(); |
|
319 el.select(); |
|
320 } |
279 })(); |
321 })(); |
280 </script> |
322 </script> |
281 <?php |
323 <?php |
282 else : |
324 else : |
283 // If this file doesn't exist, then we are using the wp-config-sample.php |
325 /* |
284 // file one level up, which is for the develop repo. |
326 * If this file doesn't exist, then we are using the wp-config-sample.php |
|
327 * file one level up, which is for the develop repo. |
|
328 */ |
285 if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
329 if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
286 $path_to_wp_config = ABSPATH . 'wp-config.php'; |
330 $path_to_wp_config = ABSPATH . 'wp-config.php'; |
287 else |
331 else |
288 $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; |
332 $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; |
289 |
333 |