Changeset 19701
- Timestamp:
- 01/06/2012 06:23:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/setup-config.php
r19297 r19701 53 53 wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); 54 54 55 $config File = file(ABSPATH . 'wp-config-sample.php');55 $config_file = file(ABSPATH . 'wp-config-sample.php'); 56 56 57 57 // Check if wp-config.php has been created … … 211 211 } 212 212 } 213 213 214 $key = 0; 214 215 foreach ($configFile as $line_num => $line) { 216 switch (substr($line,0,16)) { 217 case "define('DB_NAME'": 218 $configFile[$line_num] = str_replace("database_name_here", $dbname, $line); 215 foreach ( $config_file as &$line ) { 216 if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { 217 $line = '$table_prefix = \'' . $prefix . "';\r\n"; 218 continue; 219 } 220 221 if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) 222 continue; 223 224 $constant = $match[1]; 225 $padding = $match[2]; 226 227 switch ( $constant ) { 228 case 'DB_NAME' : 229 case 'DB_USER' : 230 case 'DB_PASSWORD' : 231 case 'DB_HOST' : 232 $line = "define('" . $constant . "'," . $padding . "'" . constant( $constant ) . "');\r\n"; 219 233 break; 220 case "define('DB_USER'": 221 $configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line); 234 case 'AUTH_KEY' : 235 case 'SECURE_AUTH_KEY' : 236 case 'LOGGED_IN_KEY' : 237 case 'NONCE_KEY' : 238 case 'AUTH_SALT' : 239 case 'SECURE_AUTH_SALT' : 240 case 'LOGGED_IN_SALT' : 241 case 'NONCE_SALT' : 242 $line = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n"; 222 243 break; 223 case "define('DB_PASSW": 224 $configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line); 225 break; 226 case "define('DB_HOST'": 227 $configFile[$line_num] = str_replace("localhost", $dbhost, $line); 228 break; 229 case '$table_prefix =': 230 $configFile[$line_num] = str_replace('wp_', $prefix, $line); 231 break; 232 case "define('AUTH_KEY": 233 case "define('SECURE_A": 234 case "define('LOGGED_I": 235 case "define('NONCE_KE": 236 case "define('AUTH_SAL": 237 case "define('SECURE_A": 238 case "define('LOGGED_I": 239 case "define('NONCE_SA": 240 $configFile[$line_num] = str_replace('put your unique phrase here', $secret_keys[$key++], $line ); 241 break; 242 } 243 } 244 } 245 } 246 unset( $line ); 247 244 248 if ( ! is_writable(ABSPATH) ) : 245 249 display_header(); … … 248 252 <p>You can create the <code>wp-config.php</code> manually and paste the following text into it.</p> 249 253 <textarea cols="98" rows="15" class="code"><?php 250 foreach( $config File as $line ) {254 foreach( $config_file as $line ) { 251 255 echo htmlentities($line, ENT_COMPAT, 'UTF-8'); 252 256 } … … 257 261 else : 258 262 $handle = fopen(ABSPATH . 'wp-config.php', 'w'); 259 foreach( $config File as $line ) {263 foreach( $config_file as $line ) { 260 264 fwrite($handle, $line); 261 265 }
Note: See TracChangeset
for help on using the changeset viewer.