Changeset 2215

Show
Ignore:
Timestamp:
02/05/05 02:19:00 (4 years ago)
Author:
saxmatt
Message:

Big buttons for login and registration, more robust registration and password recovery.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/wp-admin.css

    r2202 r2215  
    206206} 
    207207 
    208 .submit, #quicktags, .editform th, #postcustomsubmit, #login form
     208.submit, #quicktags, .editform th, #postcustomsubmit
    209209    text-align: right; 
    210210} 
  • trunk/wp-login.php

    r2130 r2215  
    4848    window.onload = focusit; 
    4949    </script> 
     50    <style type="text/css"> 
     51    #user_login, #email, #submit { 
     52        font-size: 1.7em; 
     53    } 
     54    </style> 
    5055</head> 
    5156<body> 
     
    6166<p> 
    6267<input type="hidden" name="action" value="retrievepassword" /> 
    63 <label><?php _e('Login') ?>: <input type="text" name="user_login" id="user_login" value="" size="12" tabindex="1" /></label><br /> 
    64 <label><?php _e('E-mail') ?>: <input type="text" name="email" id="email" value="" size="12" tabindex="2" /></label><br /> 
     68<label><?php _e('Login') ?>:<br /> 
     69<input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label></p> 
     70<p><label><?php _e('E-mail') ?>:<br /> 
     71<input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br /> 
    6572</p> 
    66 <p class="submit"><input type="submit" name="submit" value="<?php _e('Retrieve Password'); ?> &raquo;" tabindex="3" /></p> 
     73<p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> &raquo;" tabindex="3" /></p> 
    6774</form> 
     75<ul> 
     76    <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li> 
     77<?php if (get_settings('users_can_register')) : ?> 
     78    <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a></li> 
     79<?php endif; ?> 
     80    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 
     81</ul> 
    6882</div> 
    6983</body> 
     
    7387 
    7488case 'retrievepassword': 
    75  
    7689    $user_data = get_userdatabylogin($_POST['user_login']); 
    7790    // redefining user_login ensures we return the right case in the email 
     
    8396 
    8497    // Generate something random for a password... md5'ing current time with a rand salt 
    85     $user_pass = substr(md5(uniqid(microtime())), 0, 6); 
     98    $key = substr( md5( uniqid( microtime() ) ), 0, 50); 
    8699    // now insert the new pass md5'd into the db 
    87     $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$user_pass') WHERE user_login = '$user_login'"); 
    88     $message  = __('Login') . ": $user_login\r\n"; 
    89     $message .= __('Password') . ": $user_pass\r\n"; 
    90     $message .= get_settings('siteurl') . '/wp-login.php'; 
    91  
    92     $m = wp_mail($user_email, sprintf(__("[%s] Your login and password"), get_settings('blogname')), $message); 
     100    $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'"); 
     101    $message .= __("Someone has asked to reset a password for the login this site\n\n " . get_option('siteurl') ) . "\n\n"; 
     102    $message .= __('Login') . ": $user_login\r\n\r\n"; 
     103    $message .= __("To reset your password visit the following address, otherwise just ignore this email and nothing will happen.\n\n"); 
     104    $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key"; 
     105mail($user_email, sprintf(__("[%s] Password Reset"), get_settings('blogname')), $message); 
     106    $m = wp_mail($user_email, sprintf(__("[%s] Password Reset"), get_settings('blogname')), $message); 
    93107 
    94108    if ($m == false) { 
     
    98112    } else { 
    99113        echo '<p>' .  sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />'; 
     114        echo  "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>'; 
     115        die(); 
     116    } 
     117 
     118break; 
     119 
     120case 'resetpass' : 
     121 
     122    // Generate something random for a password... md5'ing current time with a rand salt 
     123    $key = $_GET['key']; 
     124    $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'"); 
     125    if ( !$user ) 
     126        die( __('Sorry, that key does not appear to be valid.') ); 
     127 
     128    $new_pass = md5( substr( md5( uniqid( microtime() ) ), 0, 7) ); 
     129    $wpdb->query("UPDATE $wpdb->users SET user_pass = '$new_pass', user_activation_key = '' WHERE user_login = '$user->user_login'"); 
     130    $message  = __('Login') . ": $user_login\r\n"; 
     131    $message .= __('Password') . ": $new_pass\r\n"; 
     132    $message .= get_settings('siteurl') . '/wp-login.php'; 
     133 
     134    $m = wp_mail($user->user_email, sprintf(__("[%s] Your new password"), get_settings('blogname')), $message); 
     135 
     136    if ($m == false) { 
     137         echo '<p>' . __('The e-mail could not be sent.') . "<br />\n"; 
     138         echo  __('Possible reason: your host may have disabled the mail() function...') . "</p>"; 
     139        die(); 
     140    } else { 
     141        echo '<p>' .  sprintf(__("Your new password is in the mail."), $user_login) . '<br />'; 
    100142        echo  "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>'; 
     143        die(); 
     144    }    
     145     
    101146        // send a copy of password change notification to the admin 
    102147        wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), sprintf(__('Password Lost and Changed for user: %s'), $user_login)); 
    103         die(); 
    104     } 
    105  
    106148break; 
    107149 
     
    159201    window.onload = focusit; 
    160202    </script> 
     203    <style type="text/css"> 
     204    #log, #pwd, #submit { 
     205        font-size: 1.7em; 
     206    } 
     207    </style> 
    161208</head> 
    162209<body> 
     
    170217 
    171218<form name="loginform" id="loginform" action="wp-login.php" method="post"> 
    172 <p><label><?php _e('Login') ?>: <input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label></p> 
    173 <p><label><?php _e('Password') ?>: <input type="password" name="pwd" value="" size="20" tabindex="2" /></label></p> 
     219<p><label><?php _e('Login') ?>:<br /><input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label></p> 
     220<p><label><?php _e('Password') ?>:<br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p> 
    174221<p class="submit"> 
    175     <input type="submit" name="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="3" /> 
     222    <input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="3" /> 
    176223    <input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" /> 
    177224</p> 
  • trunk/wp-register.php

    r1997 r2215  
    2727 
    2828    $user_login = $_POST['user_login']; 
    29     $pass1 = $_POST['pass1']; 
    30     $pass2 = $_POST['pass2']; 
    3129    $user_email = $_POST['user_email']; 
    3230         
     
    3533        die (__('<strong>ERROR</strong>: Please enter a login.')); 
    3634    } 
    37  
    38     /* checking the password has been typed twice */ 
    39     if ($pass1 == '' || $pass2 == '') { 
    40         die (__('<strong>ERROR</strong>: Please enter your password twice.')); 
    41     } 
    42  
    43     /* checking the password has been typed twice the same */ 
    44     if ($pass1 != $pass2)   { 
    45         die (__('<strong>ERROR</strong>: Please type the same password in the two password fields.')); 
    46     } 
    47     $user_nickname = $user_login; 
    4835 
    4936    /* checking e-mail address */ 
     
    6451    $user_browser = $wpdb->escape($_SERVER['HTTP_USER_AGENT']); 
    6552 
    66     $user_login = $wpdb->escape($user_login); 
    67     $pass1 = $wpdb->escape($pass1); 
    68     $user_nickname = $wpdb->escape($user_nickname); 
    69     $user_nicename = sanitize_title($user_nickname); 
     53    $user_login = $wpdb->escape( preg_replace('|a-z0-9 _.-|i', '', $user_login) ); 
     54    $user_nickname = $user_login; 
     55   $user_nicename = sanitize_title($user_nickname); 
    7056    $now = gmdate('Y-m-d H:i:s'); 
    7157    if (get_settings('new_users_can_blog') >= 1) $user_level = 1; 
     58    $password = substr( md5( uniqid( microtime() ) ), 0, 7); 
    7259 
    7360    $result = $wpdb->query("INSERT INTO $wpdb->users  
    7461        (user_login, user_pass, user_nickname, user_email, user_ip, user_browser, user_registered, user_level, user_idmode, user_nicename) 
    7562    VALUES  
    76         ('$user_login', MD5('$pass1'), '$user_nickname', '$user_email', '$user_ip', '$user_browser', '$now', '$user_level', 'nickname', '$user_nicename')"); 
     63        ('$user_login', MD5('$password'), '$user_nickname', '$user_email', '$user_ip', '$user_browser', '$now', '$user_level', 'nickname', '$user_nicename')"); 
    7764     
    7865    if ($result == false) { 
     
    8471        $stars .= '*'; 
    8572    } 
     73     
     74    $message  = __('Login') . ": $user_login\r\n"; 
     75    $message .= __('Password') . ": $new_pass\r\n"; 
     76    $message .= get_settings('siteurl') . '/wp-login.php'; 
     77     
     78    wp_mail($user_email, sprintf(__("[%s] Your login information"), get_settings('blogname')), $message); 
    8679 
    8780    $message  = sprintf(__("New user registration on your blog %1\$s:\n\nLogin: %2\$s \n\nE-mail: %3\$s"), get_settings('blogname'), $user_login, $user_email); 
     
    10295    <h2><?php _e('Registration Complete') ?></h2> 
    10396    <p><?php _e('Login:') ?> <strong><?php echo $user_login; ?></strong><br /> 
    104     <?php _e('Password:') ?> <strong><?php echo $stars; ?></strong><br /> 
     97    <?php _e('Password:') ?> <strong>emailed to you</strong><br /> 
    10598    <?php _e('E-mail:') ?> <strong><?php echo $user_email; ?></strong></p> 
    10699    <form action="wp-login.php" method="post" name="login"> 
     
    150143    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" /> 
    151144    <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" /> 
     145    <style type="text/css"> 
     146    #user_email, #user_login, #submit { 
     147        font-size: 1.7em; 
     148    } 
     149    </style> 
    152150</head> 
    153151 
    154152<body> 
    155153<div id="login"> 
    156 <h2><?php _e('Registration') ?></h2> 
     154<h1><a href="http://wordpress.org/">WordPress</a></h1> 
     155<h2><?php _e('Register for this blog') ?></h2> 
    157156 
    158 <form method="post" action="wp-register.php"> 
    159     <input type="hidden" name="action" value="register" /> 
    160     <label for="user_login"><?php _e('Login:') ?></label> <input type="text" name="user_login" id="user_login" size="10" maxlength="20" /><br /> 
    161     <label for="pass1"><?php _e('Password:') ?></label> <input type="password" name="pass1" id="pass1" size="10" maxlength="100" /><br /> 
    162   
    163     <input type="password" name="pass2" size="10" maxlength="100" /><br /> 
    164     <label for="user_email"><?php _e('E-mail') ?></label>: <input type="text" name="user_email" id="user_email" size="15" maxlength="100" /><br /> 
    165     <input type="submit" value="<?php _e('OK') ?>" class="search" name="submit" /> 
     157<form method="post" action="wp-register.php" id="registerform"> 
     158    <p><input type="hidden" name="action" value="register" /> 
     159    <label for="user_login"><?php _e('Login:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" /><br /></p> 
     160    <p><label for="user_email"><?php _e('E-mail') ?></label>:<br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" /></p> 
     161    <p>A password will be emailed to you.</p> 
     162    <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p> 
    166163</form> 
     164<ul> 
     165    <li><a href="<?php bloginfo('home'); ?>" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li> 
     166    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 
     167    <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> 
     168</ul> 
    167169</div> 
    168170