Add arg to make special chars optional when generating passwords. fixes #6842 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@7836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cbf1aed77d
commit
87b1154989
|
@ -1168,8 +1168,11 @@ if ( !function_exists('wp_generate_password') ) :
|
|||
*
|
||||
* @return string The random password
|
||||
**/
|
||||
function wp_generate_password($length = 12) {
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()";
|
||||
function wp_generate_password($length = 12, $special_chars = true) {
|
||||
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
if ( $special_chars )
|
||||
$chars .= '!@#$%^&*()';
|
||||
|
||||
$password = '';
|
||||
for ( $i = 0; $i < $length; $i++ )
|
||||
$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
||||
|
|
|
@ -93,7 +93,7 @@ function retrieve_password() {
|
|||
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
|
||||
if ( empty($key) ) {
|
||||
// Generate something random for a key...
|
||||
$key = wp_generate_password();
|
||||
$key = wp_generate_password(20, false);
|
||||
do_action('retrieve_password_key', $user_login, $key);
|
||||
// Now insert the new md5 key into the db
|
||||
$wpdb->query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key, $user_login));
|
||||
|
|
Loading…
Reference in New Issue