WordPress.org

Make WordPress Core

Ticket #2870: install.php.diff

File install.php.diff, 4.0 KB (added by darkfate, 9 years ago)

allow user the select username and password

  • install.php

     
    104104<td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td> 
    105105</tr> 
    106106<tr> 
     107<th><?php _e('Your username:'); ?></th> 
     108        <td><input name="admin_username" type="text" id="admin_username" size="25" /></td> 
     109</tr> 
     110<tr> 
     111<th><?php _e('Your password:'); ?></th> 
     112        <td><input name="admin_password" type="password" id="admin_password" size="25" /></td> 
     113</tr> 
     114<tr> 
    107115<th><?php _e('Your e-mail:'); ?></th> 
    108116        <td><input name="admin_email" type="text" id="admin_email" size="25" /></td> 
    109117</tr> 
     
    120128 
    121129// Fill in the data we gathered 
    122130$weblog_title = stripslashes($_POST['weblog_title']); 
     131$admin_username = stripslashes($_POST['admin_username']); 
     132$admin_password = stripslashes($_POST['admin_password']); 
    123133$admin_email = stripslashes($_POST['admin_email']); 
    124134// check e-mail address 
     135if (empty($admin_username)) { 
     136        die (__("<strong>ERROR</strong>: please type a username"));} 
     137if (empty($admin_password)) { 
     138        die (__("<strong>ERROR</strong>: please type a password"));}     
    125139if (empty($admin_email)) { 
    126140        die (__("<strong>ERROR</strong>: please type your e-mail address")); 
    127141} else if (!is_email($admin_email)) { 
     
    174188$wp_rewrite->flush_rules(); 
    175189 
    176190// Set up admin user 
    177 $random_password = substr(md5(uniqid(microtime())), 0, 6); 
    178191$display_name_array = explode('@', $admin_email); 
    179192$display_name = $display_name_array[0]; 
    180 $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')"); 
     193$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', '$admin_username', MD5('$admin_password'), '$admin_email', NOW(), '$display_name', '$admin_username')"); 
    181194$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');"); 
    182195$admin_caps = serialize(array('administrator' => true)); 
    183196$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');"); 
     
    189202 
    190203You can log in to the administrator account with the following information: 
    191204 
    192 Username: admin 
    193 Password: %2\$s 
     205Username: $admin_username 
     206Password: $admin_password 
    194207 
    195208We hope you enjoy your new weblog. Thanks! 
    196209 
    197210--The WordPress Team 
    198211http://wordpress.org/ 
    199 "), $guessurl, $random_password); 
     212"), $guessurl, $admin_password); 
    200213 
    201214@wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers); 
    202215 
     
    205218 
    206219<p><em><?php _e('Finished!'); ?></em></p> 
    207220 
    208 <p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p> 
    209 <p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?> 
     221<p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>'.$admin_username.'</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $admin_password); ?></p> 
     222<p><?php _e('<strong><em>Note that password</em></strong> carefully! If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?> 
    210223</p> 
    211224<dl> 
    212225<dt><?php _e('Username'); ?></dt> 
    213 <dd><code>admin</code></dd> 
     226<dd><code><?php echo $admin_username; ?></code></dd> 
    214227<dt><?php _e('Password'); ?></dt> 
    215 <dd><code><?php echo $random_password; ?></code></dd> 
     228<dd><code><?php echo $admin_password; ?></code></dd> 
    216229        <dt><?php _e('Login address'); ?></dt> 
    217230<dd><a href="../wp-login.php">wp-login.php</a></dd> 
    218231</dl>