Ticket #18180: 18180.4.diff
File 18180.4.diff, 17.9 KB (added by , 13 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
29 29 * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging 30 30 */ 31 31 error_reporting(0); 32 error_reporting( E_ALL & ~E_STRICT & ~E_DEPRECATED ); // DEBUG Dev edition 32 33 33 34 /**#@+ 34 35 * These three defines are required to allow us to use require_wp_db() to load 35 36 * the database class while being wp-content/db.php aware. 36 37 * @ignore 37 38 */ 38 define('ABSPATH', dirname(dirname(__FILE__)) .'/');39 define('ABSPATH', dirname(dirname(__FILE__)) . '/'); 39 40 define('WPINC', 'wp-includes'); 40 41 define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); 41 42 define('WP_DEBUG', false); 42 43 /**#@-*/ 43 44 44 45 require_once(ABSPATH . WPINC . '/load.php'); 46 45 47 require_once(ABSPATH . WPINC . '/version.php'); 46 48 wp_check_php_mysql_versions(); 47 49 48 50 require_once(ABSPATH . WPINC . '/compat.php'); 49 51 require_once(ABSPATH . WPINC . '/functions.php'); 52 require_once(ABSPATH . WPINC . '/plugin.php'); 53 require_once(ABSPATH . WPINC . '/formatting.php'); 50 54 require_once(ABSPATH . WPINC . '/class-wp-error.php'); 55 require_once(ABSPATH . WPINC . '/kses.php'); 56 require_once( ABSPATH . WPINC . '/pomo/mo.php' ); 57 require_once( ABSPATH . WPINC . '/l10n.php'); 51 58 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.');59 wp_start_object_cache(); 60 wp_set_lang_dir(); 54 61 55 $configFile = file(ABSPATH . 'wp-config-sample.php'); 62 /**#@+ 63 * Set the Language to this installs default language 64 * @ignore 65 */ 66 if ( !empty($wp_local_package) ) 67 define('WPLANG', $wp_local_package); 68 /**#@-*/ 56 69 70 // Load the default text localization domain. 71 load_default_textdomain(); 72 73 // Find the blog locale. 74 $locale = get_locale(); 75 $locale_file = WP_LANG_DIR . "/$locale.php"; 76 if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) 77 require( $locale_file ); 78 unset($locale_file); 79 80 add_filter('wp_die_handler', '_installer_wp_die'); 81 function _installer_wp_die($handler) { 82 return '_installer_wp_die_handler'; 83 } 84 function _installer_wp_die_handler($error) { 85 display_header(); 86 if ( is_wp_error($error) ) 87 $error = $error->get_error_message(); 88 echo "<p>$error</p>"; 89 display_footer(); 90 die(); 91 } 92 57 93 // 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>");94 if ( file_exists(ABSPATH . 'wp-config.php' )) 95 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 96 61 97 // 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>");98 if ( file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php') ) 99 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 100 65 if (isset($_GET['step'])) 101 if ( ! file_exists(ABSPATH . 'wp-config-sample.php') ) 102 wp_die( __('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.') ); 103 104 if ( isset($_GET['step']) ) 66 105 $step = $_GET['step']; 67 106 else 68 107 $step = 0; 69 108 109 display_header(); 110 if ( 2 == $step ) 111 step_2(); 112 elseif ( 1 == $step ) 113 step_1(); 114 else 115 step_0(); 116 display_footer(); 117 70 118 /** 71 119 * Display setup wp-config.php file header. 72 120 * … … 76 124 * @subpackage Installer_WP_Config 77 125 */ 78 126 function display_header() { 127 global $text_direction; 128 $is_rtl = ( !empty($text_direction) && 'rtl' == $text_direction); 79 129 header( 'Content-Type: text/html; charset=utf-8' ); 80 130 ?> 81 131 <!DOCTYPE html> 82 <html xmlns="http://www.w3.org/1999/xhtml" >132 <html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo ( $is_rtl ? 'rtl' : 'ltr' ); ?>"> 83 133 <head> 84 134 <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" /> 135 <title><?php _e('WordPress › Setup Configuration File'); ?></title> 136 <!-- Dev Edition: .dev.css to be minified later --> 137 <link rel="stylesheet" href="css/install.dev.css" type="text/css" /> 87 138 88 139 </head> 89 <body >140 <body<?php if ( $is_rtl ) echo ' class="rtl"'; ?>> 90 141 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1> 91 142 <?php 92 143 }//end function display_header(); 93 144 94 switch($step) { 95 case 0: 96 display_header(); 145 function step_0() { 97 146 ?> 98 147 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>148 <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 149 <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>150 <li><?php _e('Database name'); ?></li> 151 <li><?php _e('Database username'); ?></li> 152 <li><?php _e('Database password'); ?></li> 153 <li><?php _e('Database host'); ?></li> 154 <li><?php _e('Table prefix (if you want to run more than one WordPress in a single database)'); ?></li> 106 155 </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>156 <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> 157 <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 158 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>159 <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 160 <?php 112 break; 161 } 113 162 114 case 1: 115 display_header(); 163 function step_1( $details = array(), $errors = array() ) { 164 if ( empty($details) ) { 165 $details = array( 166 'dbname' => 'wordpress', 167 'uname' => _x('username', 'installer default username'), 168 'pwd' => _x('password', 'installer default password'), 169 'dbhost' => 'localhost', 170 'prefix' => 'wp_', 171 ); 172 } 173 174 foreach ( $errors as $error ) { 175 echo '<p class="error message">' . $error->get_error_message() . '</p>'; 176 } 177 116 178 ?> 117 179 <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>180 <p><?php _e("Below you should enter your database connection details. If you're not sure about these, contact your host."); ?></p> 119 181 <table class="form-table"> 120 182 <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>183 <th scope="row"><label for="dbname"><?php _e('Database Name'); ?></label></th> 184 <td><input name="dbname" id="dbname" type="text" size="25" value="<?php echo esc_attr($details['dbname']); ?>" /></td> 185 <td><?php _e('The name of the database you want to run WP in.'); ?></td> 124 186 </tr> 125 187 <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>188 <th scope="row"><label for="uname"><?php _e('User Name'); ?></label></th> 189 <td><input name="uname" id="uname" type="text" size="25" value="<?php echo esc_attr($details['uname']); ?>" /></td> 190 <td><?php _e('Your MySQL username'); ?></td> 129 191 </tr> 130 192 <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>193 <th scope="row"><label for="pwd"><?php _e('Password'); ?></label></th> 194 <td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo esc_attr($details['pwd']); ?>" /></td> 195 <td><?php _e('...and MySQL password.'); ?></td> 134 196 </tr> 135 197 <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>198 <th scope="row"><label for="dbhost"><?php _e('Database Host'); ?></label></th> 199 <td><input name="dbhost" id="dbhost" type="text" size="25" value="<?php echo esc_attr($details['dbhost']); ?>" /></td> 200 <td><?php _e('You should be able to get this info from your web host, if <code>localhost</code> does not work.'); ?></td> 139 201 </tr> 140 202 <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>203 <th scope="row"><label for="prefix"><?php _e('Table Prefix'); ?></label></th> 204 <td><input name="prefix" id="prefix" type="text" value="<?php echo esc_attr($details['prefix']); ?>" size="25" /></td> 205 <td><?php _e('If you want to run multiple WordPress installations in a single database, change this.'); ?></td> 144 206 </tr> 145 207 </table> 146 208 <?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>209 <p class="step"><input name="submit" type="submit" value="<?php esc_attr_e('Submit'); ?>" class="button" /></p> 148 210 </form> 149 211 <?php 150 break; 212 } 151 213 152 case 2: 153 $dbname = trim($_POST['dbname']); 154 $uname = trim($_POST['uname']); 155 $passwrd = trim($_POST['pwd']); 156 $dbhost = trim($_POST['dbhost']); 157 $prefix = trim($_POST['prefix']); 214 function step_2() { 215 global $wpdb; 216 217 $dbname = trim( stripslashes($_POST['dbname']) ); 218 $uname = trim( stripslashes($_POST['uname']) ); 219 $pwd = trim( stripslashes($_POST['pwd']) ); 220 $dbhost = trim( stripslashes($_POST['dbhost']) ); 221 $prefix = trim( stripslashes($_POST['prefix']) ); 222 223 $errors = array(); 224 158 225 if ( empty($prefix) ) 159 $ prefix = 'wp_';226 $errors[] = new WP_Error('empty_prefix', __('"Table Prefix" must not be empty.') ); 160 227 161 228 // Validate $prefix: it can only contain letters, numbers and underscores 162 229 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*/);230 $errors[] = new WP_Error('invalid_prefix', __('"Table Prefix" can only contain numbers, letters, and underscores.') ); 164 231 165 232 // Test the db connection. 166 233 /**#@+ … … 168 235 */ 169 236 define('DB_NAME', $dbname); 170 237 define('DB_USER', $uname); 171 define('DB_PASSWORD', $p asswrd);238 define('DB_PASSWORD', $pwd); 172 239 define('DB_HOST', $dbhost); 173 240 /**#@-*/ 174 241 175 242 // We'll fail here if the values are no good. 176 243 require_wp_db(); 244 177 245 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 ); 246 if ( is_string($wpdb->error) ) { 247 $errors[] = new WP_Error( 'unknown', $wpdb->error ); 248 } else if ( 'db_connect_fail' == $wpdb->error->get_error_code() ) { 249 // bad creds 250 $errors[] = new WP_Error( 'credentials', __('An error occured whilst connecting to the Database server listed, Please check the details below are correct.') ); 251 } else if ( 'db_select_fail' == $wpdb->error->get_error_code() ) { 252 // database doesn't exist. 253 $errors[] = new WP_Error( 'dbname', __("WordPress couldn't select te specified database, Please ensure it exists and the above user account can access it.") ); 254 } else { 255 $errors[] = $wpdb->error; 256 } 180 257 } 181 258 259 if ( ! empty($errors) ) 260 step_1( compact( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ), $errors); 261 else 262 write_config( $dbname, $uname, $pwd, $dbhost, $prefix ); 263 } 264 265 function write_config( $dbname, $uname, $pwd, $dbhost, $prefix ) { 266 global $wpdb; 267 182 268 // Fetch or generate keys and salts. 183 269 $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 270 if ( ! $no_api ) { 188 271 require_once( ABSPATH . WPINC . '/class-http.php' ); 189 272 require_once( ABSPATH . WPINC . '/http.php' ); … … 212 295 } 213 296 $key = 0; 214 297 215 foreach ($configFile as $line_num => $line) { 298 $config_file = file(ABSPATH . 'wp-config-sample.php'); 299 300 foreach ( $config_file as $line_num => $line ) { 216 301 switch (substr($line,0,16)) { 217 302 case "define('DB_NAME'": 218 $configFile[$line_num] = str_replace("database_name_here", $dbname, $line); 303 $dbname = addcslashes($dbname, "\\'"); 304 $config_file[$line_num] = str_replace("'database_name_here'", "'$dbname'", $line); 219 305 break; 220 306 case "define('DB_USER'": 221 $configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line); 307 $uname = addcslashes($uname, "\\'"); 308 $config_file[$line_num] = str_replace("'username_here'", "'$uname'", $line); 222 309 break; 223 310 case "define('DB_PASSW": 224 $configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line); 311 $pwd = addcslashes($pwd, "\\'"); 312 $config_file[$line_num] = str_replace("'password_here'", "'$pwd'", $line); 225 313 break; 226 314 case "define('DB_HOST'": 227 $config File[$line_num] = str_replace("localhost", $dbhost, $line);315 $config_file[$line_num] = str_replace("'localhost'", "'$dbhost'", $line); 228 316 break; 229 317 case '$table_prefix =': 230 $config File[$line_num] = str_replace('wp_', $prefix, $line);318 $config_file[$line_num] = str_replace("'wp_'", "'$prefix'", $line); 231 319 break; 232 320 case "define('AUTH_KEY": 233 321 case "define('SECURE_A": … … 237 325 case "define('SECURE_A": 238 326 case "define('LOGGED_I": 239 327 case "define('NONCE_SA": 240 $config File[$line_num] = str_replace('put your unique phrase here', $secret_keys[$key++], $line );328 $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 329 break; 242 330 } 243 331 } 244 332 if ( ! is_writable(ABSPATH) ) : 245 display_header();246 333 ?> 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>334 <p><?php _e("Sorry, but I can't write the <code>wp-config.php</code> file."); ?></p> 335 <p><?php _e('You can create the <code>wp-config.php</code> manually and paste the following text into it.'); ?></p> 249 336 <textarea cols="98" rows="15" class="code"><?php 250 foreach( $config File as $line ) {251 echo htmlentities($line, ENT_COMPAT, 'UTF-8');337 foreach( $config_file as $line ) { 338 echo esc_textarea($line); 252 339 } 253 340 ?></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>341 <p><?php _e('After you\'ve done that, click "Run the install."'); ?></p> 342 <p class="step"><a href="install.php" class="button"><?php _e('Run the install'); ?></a></p> 256 343 <?php 257 344 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(); 345 file_put_contents( ABSPATH . 'wp-config.php', implode('', $config_file) ); 346 chmod(ABSPATH . 'wp-config.php', 0644); 265 347 ?> 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>348 <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 349 268 <p class="step"><a href="install.php" class="button"> Run the install</a></p>350 <p class="step"><a href="install.php" class="button"><?php _e('Run the install'); ?></a></p> 269 351 <?php 270 352 endif; 271 break;272 353 } 354 355 function display_footer() { 273 356 ?> 274 357 </body> 275 358 </html> 359 <?php 360 }