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