Ticket #18180: 18180.2.diff
File 18180.2.diff, 17.2 KB (added by , 12 years ago) |
---|
-
wp-admin/css/install.dev.css
211 211 margin: 5px 0 15px; 212 212 background-color: #ffffe0; 213 213 } 214 .error { 215 background-color: #ffebe8; 216 border-color: #c00; 217 } 214 218 215 219 216 220 /* install-rtl */ -
wp-admin/setup-config.php
35 35 * the database class while being wp-content/db.php aware. 36 36 * @ignore 37 37 */ 38 define('ABSPATH', dirname(dirname(__FILE__)) .'/');38 define('ABSPATH', dirname(dirname(__FILE__)) . '/'); 39 39 define('WPINC', 'wp-includes'); 40 40 define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); 41 41 define('WP_DEBUG', false); 42 42 /**#@-*/ 43 43 44 44 require_once(ABSPATH . WPINC . '/load.php'); 45 45 46 require_once(ABSPATH . WPINC . '/version.php'); 46 47 wp_check_php_mysql_versions(); 47 48 48 49 require_once(ABSPATH . WPINC . '/compat.php'); 49 50 require_once(ABSPATH . WPINC . '/functions.php'); 51 require_once(ABSPATH . WPINC . '/plugin.php'); 52 require_once(ABSPATH . WPINC . '/formatting.php'); 50 53 require_once(ABSPATH . WPINC . '/class-wp-error.php'); 54 require_once(ABSPATH . WPINC . '/kses.php'); 51 55 52 if (!file_exists(ABSPATH . 'wp-config-sample.php')) 53 wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');56 wp_start_object_cache(); 57 wp_set_lang_dir(); 54 58 55 $configFile = file(ABSPATH . 'wp-config-sample.php'); 59 add_filter('wp_die_handler', '_installer_wp_die'); 60 function _installer_wp_die($handler) { 61 return '_installer_wp_die_handler'; 62 } 63 function _installer_wp_die_handler($error) { 64 display_header(); 65 echo '<p>'; 66 echo is_wp_error($error) ? $error->get_error_message() : $error; 67 echo '</p>'; 68 display_footer(); 69 die(); 70 } 56 71 72 73 /**#@+ 74 * A hacky way to set WPLANG to the installs default. 75 * @TODO This should be set somehow a little bit less hacky, $text_direction also needs to be set. 76 * @ignore 77 */ 78 if ( is_dir( WP_LANG_DIR ) && preg_match( '!define\(.+WPLANG.+[\'"]([A-z_]+)[\'"]!', file_get_contents( ABSPATH . 'wp-config-sample.php' ), $lang_match ) ) { 79 define('WPLANG', $lang_match[1]); 80 } 81 /**#@-*/ 82 83 require_once( ABSPATH . WPINC . '/pomo/mo.php' ); 84 require_once( ABSPATH . WPINC . '/l10n.php'); 85 load_default_textdomain(); 86 57 87 // Check if wp-config.php has been created 58 if ( file_exists(ABSPATH . 'wp-config.php'))59 wp_die( "<p>The file 'wp-config.php' already exists. 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>.</p>");88 if ( file_exists(ABSPATH . 'wp-config.php' )) 89 wp_die( __("<p>The file 'wp-config.php' already exists. 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>.</p>") ); 60 90 61 91 // Check if wp-config.php exists above the root directory but is not part of another install 62 if ( file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php'))63 wp_die( "<p>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>.</p>");92 if ( file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php') ) 93 wp_die( __("<p>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>.</p>") ); 64 94 65 if (isset($_GET['step'])) 95 // @TODO: Err, This string can't be translated this way, If the config file doesnt exist, we can't set the language. See TODO of setting the default language another way. 96 if ( ! file_exists(ABSPATH . 'wp-config-sample.php') ) 97 wp_die( __('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.') ); 98 99 if ( isset($_GET['step']) ) 66 100 $step = $_GET['step']; 67 101 else 68 102 $step = 0; 69 103 104 display_header(); 105 if ( 2 == $step ) 106 step_2(); 107 elseif ( 1 == $step ) 108 step_1(); 109 else 110 step_0(); 111 display_footer(); 112 70 113 /** 71 114 * Display setup wp-config.php file header. 72 115 * … … 82 125 <html xmlns="http://www.w3.org/1999/xhtml"> 83 126 <head> 84 127 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 85 <title> WordPress › Setup Configuration File</title>86 <link rel="stylesheet" href="css/install. css" type="text/css" />128 <title><?php _e('WordPress › Setup Configuration File'); ?></title> 129 <link rel="stylesheet" href="css/install.dev.css" type="text/css" /> 87 130 88 131 </head> 89 132 <body> … … 91 134 <?php 92 135 }//end function display_header(); 93 136 94 switch($step) { 95 case 0: 96 display_header(); 137 function step_0() { 97 138 ?> 98 139 99 <p> Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>140 <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> 100 141 <ol> 101 <li> Database name</li>102 <li> Database username</li>103 <li> Database password</li>104 <li> Database host</li>105 <li> Table prefix (if you want to run more than one WordPress in a single database)</li>142 <li><?php _e('Database name'); ?></li> 143 <li><?php _e('Database username'); ?></li> 144 <li><?php _e('Database password'); ?></li> 145 <li><?php _e('Database host'); ?></li> 146 <li><?php _e('Table prefix (if you want to run more than one WordPress in a single database)'); ?></li> 106 147 </ol> 107 <p>< strong>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>108 <p>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>148 <p><?php _e("<strong>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> 149 <p>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> 109 150 110 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button"> Let’s go!</a></p>151 <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button"><?php _e('Let’s go!'); ?></a></p> 111 152 <?php 112 break; 153 } 113 154 114 case 1: 115 display_header(); 155 function step_1( $details = array(), $errors = array() ) { 156 if ( empty($details) ) { 157 $details = array( 158 'dbname' => _x('wordpress', 'installer default database'), 159 'uname' => _x('username', 'installer default username'), 160 'pwd' => _x('password', 'installer default password'), 161 'dbhost' => _x('localhost', 'installer default host'), 162 'prefix' => _x('wp_', 'installer default table prefix'), 163 ); 164 } 165 166 foreach ( $errors as $error ) { 167 echo '<p class="error message">' . $error->get_error_message() . '</p>'; 168 } 169 116 170 ?> 117 171 <form method="post" action="setup-config.php?step=2"> 118 <p> Below you should enter your database connection details. If you're not sure about these, contact your host.</p>172 <p><?php _e("Below you should enter your database connection details. If you're not sure about these, contact your host."); ?></p> 119 173 <table class="form-table"> 120 174 <tr> 121 <th scope="row"><label for="dbname"> Database Name</label></th>122 <td><input name="dbname" id="dbname" type="text" size="25" value=" wordpress" /></td>123 <td> The name of the database you want to run WP in.</td>175 <th scope="row"><label for="dbname"><?php _e('Database Name'); ?></label></th> 176 <td><input name="dbname" id="dbname" type="text" size="25" value="<?php echo esc_attr($details['dbname']); ?>" /></td> 177 <td><?php _e('The name of the database you want to run WP in.'); ?></td> 124 178 </tr> 125 179 <tr> 126 <th scope="row"><label for="uname"> User Name</label></th>127 <td><input name="uname" id="uname" type="text" size="25" value=" username" /></td>128 <td> Your MySQL username</td>180 <th scope="row"><label for="uname"><?php _e('User Name'); ?></label></th> 181 <td><input name="uname" id="uname" type="text" size="25" value="<?php echo esc_attr($details['uname']); ?>" /></td> 182 <td><?php _e('Your MySQL username'); ?></td> 129 183 </tr> 130 184 <tr> 131 <th scope="row"><label for="pwd"> Password</label></th>132 <td><input name="pwd" id="pwd" type="text" size="25" value=" password" /></td>133 <td> ...and MySQL password.</td>185 <th scope="row"><label for="pwd"><?php _e('Password'); ?></label></th> 186 <td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo esc_attr($details['pwd']); ?>" /></td> 187 <td><?php _e('...and MySQL password.'); ?></td> 134 188 </tr> 135 189 <tr> 136 <th scope="row"><label for="dbhost"> Database Host</label></th>137 <td><input name="dbhost" id="dbhost" type="text" size="25" value=" localhost" /></td>138 <td> You should be able to get this info from your web host, if <code>localhost</code> does not work.</td>190 <th scope="row"><label for="dbhost"><?php _e('Database Host'); ?></label></th> 191 <td><input name="dbhost" id="dbhost" type="text" size="25" value="<?php echo esc_attr($details['dbhost']); ?>" /></td> 192 <td><?php _e('You should be able to get this info from your web host, if <code>localhost</code> does not work.'); ?></td> 139 193 </tr> 140 194 <tr> 141 <th scope="row"><label for="prefix"> Table Prefix</label></th>142 <td><input name="prefix" id="prefix" type="text" value=" wp_" size="25" /></td>143 <td> If you want to run multiple WordPress installations in a single database, change this.</td>195 <th scope="row"><label for="prefix"><?php _e('Table Prefix'); ?></label></th> 196 <td><input name="prefix" id="prefix" type="text" value="<?php echo esc_attr($details['prefix']); ?>" size="25" /></td> 197 <td><?php _e('If you want to run multiple WordPress installations in a single database, change this.'); ?></td> 144 198 </tr> 145 199 </table> 146 200 <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="true" /><?php } ?> 147 <p class="step"><input name="submit" type="submit" value=" Submit" class="button" /></p>201 <p class="step"><input name="submit" type="submit" value="<?php esc_attr_e('Submit'); ?>" class="button" /></p> 148 202 </form> 149 203 <?php 150 break; 204 } 151 205 152 case 2: 206 function step_2() { 207 global $wpdb; 208 153 209 $dbname = trim($_POST['dbname']); 154 210 $uname = trim($_POST['uname']); 155 $p asswrd= trim($_POST['pwd']);211 $pwd = trim($_POST['pwd']); 156 212 $dbhost = trim($_POST['dbhost']); 157 213 $prefix = trim($_POST['prefix']); 214 215 $errors = array(); 216 158 217 if ( empty($prefix) ) 159 $ prefix = 'wp_';218 $errors[] = new WP_Error('empty_prefix', __('"Table Prefix" must not be empty.') ); 160 219 161 220 // Validate $prefix: it can only contain letters, numbers and underscores 162 221 if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) 163 wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/);222 $errors[] = new WP_Error('invalid_prefix', __('"Table Prefix" can only contain numbers, letters, and underscores.') ); 164 223 165 224 // Test the db connection. 166 225 /**#@+ … … 168 227 */ 169 228 define('DB_NAME', $dbname); 170 229 define('DB_USER', $uname); 171 define('DB_PASSWORD', $p asswrd);230 define('DB_PASSWORD', $pwd); 172 231 define('DB_HOST', $dbhost); 173 232 /**#@-*/ 174 233 175 234 // We'll fail here if the values are no good. 176 235 require_wp_db(); 236 177 237 if ( ! empty( $wpdb->error ) ) { 178 $back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">Try Again</a></p>'; 179 wp_die( $wpdb->error->get_error_message() . $back ); 238 if ( is_string($wpdb->error) ) { 239 $errors[] = new WP_Error( 'unknown', $wpdb->error ); 240 } else if ( 'db_connect_fail' == $wpdb->error->get_error_code() ) { 241 // bad creds 242 $errors[] = new WP_Error( 'credentials', __('An error occured whilst connecting to the Database server listed, Please check the details below are correct.') ); 243 } else if ( 'db_select_fail' == $wpdb->error->get_error_code() ) { 244 // database doesn't exist. 245 $errors[] = new WP_Error( 'dbname', __("WordPress couldn't select te specified database, Please ensure it exists and the above user account can access it.") ); 246 } else { 247 $errors[] = $wpdb->error; 248 } 180 249 } 181 250 251 if ( ! empty($errors) ) 252 step_1( compact( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ), $errors); 253 else 254 write_config( $dbname, $uname, $pwd, $dbhost, $prefix ); 255 } 256 257 function write_config( $dbname, $uname, $pwd, $dbhost, $prefix ) { 258 global $wpdb; 259 182 260 // Fetch or generate keys and salts. 183 261 $no_api = isset( $_POST['noapi'] ); 184 require_once( ABSPATH . WPINC . '/plugin.php' );185 require_once( ABSPATH . WPINC . '/l10n.php' );186 require_once( ABSPATH . WPINC . '/pomo/translations.php' );187 262 if ( ! $no_api ) { 188 263 require_once( ABSPATH . WPINC . '/class-http.php' ); 189 264 require_once( ABSPATH . WPINC . '/http.php' ); … … 212 287 } 213 288 $key = 0; 214 289 215 foreach ($configFile as $line_num => $line) { 290 $config_file = file(ABSPATH . 'wp-config-sample.php'); 291 292 foreach ( $config_file as $line_num => $line ) { 216 293 switch (substr($line,0,16)) { 217 294 case "define('DB_NAME'": 218 $configFile[$line_num] = str_replace("database_name_here", $dbname, $line); 295 $dbname = addcslashes($dbname, "\\'"); 296 $config_file[$line_num] = str_replace("'database_name_here'", "'$dbname'", $line); 219 297 break; 220 298 case "define('DB_USER'": 221 $configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line); 299 $uname = addcslashes($uname, "\\'"); 300 $config_file[$line_num] = str_replace("'username_here'", "'$uname'", $line); 222 301 break; 223 302 case "define('DB_PASSW": 224 $configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line); 303 $pwd = addcslashes($pwd, "\\'"); 304 $config_file[$line_num] = str_replace("'password_here'", "'$pwd'", $line); 225 305 break; 226 306 case "define('DB_HOST'": 227 $configFile[$line_num] = str_replace("localhost", $dbhost, $line); 307 $dbhost = addcslashes($dbhost, "\\'"); 308 $config_file[$line_num] = str_replace("'localhost'", "'$dbhost'", $line); 228 309 break; 229 310 case '$table_prefix =': 230 $config File[$line_num] = str_replace('wp_', $prefix, $line);311 $config_file[$line_num] = str_replace("'wp_'", "'$prefix'", $line); 231 312 break; 232 313 case "define('AUTH_KEY": 233 314 case "define('SECURE_A": … … 237 318 case "define('SECURE_A": 238 319 case "define('LOGGED_I": 239 320 case "define('NONCE_SA": 240 $config File[$line_num] = str_replace('put your unique phrase here', $secret_keys[$key++], $line );321 $config_file[$line_num] = str_replace( _x('put your unique phrase here', 'MUST MATCH PLACE HOLDER IN SECRET KEYS IN wp-config-sample.php'), $secret_keys[$key++], $line ); 241 322 break; 242 323 } 243 324 } 244 325 if ( ! is_writable(ABSPATH) ) : 245 display_header();246 326 ?> 247 <p> Sorry, but I can't write the <code>wp-config.php</code> file.</p>248 <p> You can create the <code>wp-config.php</code> manually and paste the following text into it.</p>327 <p><?php _e("Sorry, but I can't write the <code>wp-config.php</code> file."); ?></p> 328 <p><?php _e('You can create the <code>wp-config.php</code> manually and paste the following text into it.'); ?></p> 249 329 <textarea cols="98" rows="15" class="code"><?php 250 foreach( $config File as $line ) {251 echo htmlentities($line, ENT_COMPAT, 'UTF-8');330 foreach( $config_file as $line ) { 331 echo esc_textarea($line); 252 332 } 253 333 ?></textarea> 254 <p> After you've done that, click "Run the install."</p>255 <p class="step"><a href="install.php" class="button"> Run the install</a></p>334 <p><?php _e('After you\'ve done that, click "Run the install."'); ?></p> 335 <p class="step"><a href="install.php" class="button"><?php _e('Run the install'); ?></a></p> 256 336 <?php 257 337 else : 258 $handle = fopen(ABSPATH . 'wp-config.php', 'w'); 259 foreach( $configFile as $line ) { 260 fwrite($handle, $line); 261 } 262 fclose($handle); 263 chmod(ABSPATH . 'wp-config.php', 0666); 264 display_header(); 338 file_put_contents( ABSPATH . 'wp-config.php', implode('', $config_file) ); 339 chmod(ABSPATH . 'wp-config.php', 0644); 265 340 ?> 266 <p> All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…</p>341 <p><?php _e("All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…"); ?></p> 267 342 268 <p class="step"><a href="install.php" class="button"> Run the install</a></p>343 <p class="step"><a href="install.php" class="button"><?php _e('Run the install'); ?></a></p> 269 344 <?php 270 345 endif; 271 break;272 346 } 347 348 function display_footer() { 273 349 ?> 274 350 </body> 275 351 </html> 352 <?php 353 }