Changeset 642

Show
Ignore:
Timestamp:
12/23/03 20:21:29 (5 years ago)
Author:
saxmatt
Message:

New user registration tweaks.

Files:

Legend:

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

    r628 r642  
    2020 
    2121switch ($action) { 
    22      
     22case 'adduser': 
     23    $standalone = 1; 
     24    require_once('admin-header.php'); 
     25    function filter($value) { 
     26        return ereg('^[a-zA-Z0-9\_-\|]+$',$value); 
     27    } 
     28 
     29    $user_login = $HTTP_POST_VARS['user_login']; 
     30    $pass1 = $HTTP_POST_VARS['pass1']; 
     31    $pass2 = $HTTP_POST_VARS['pass2']; 
     32    $user_email = $HTTP_POST_VARS['email']; 
     33    $user_firstname = $HTTP_POST_VARS['firstname']; 
     34    $user_lastname = $HTTP_POST_VARS['lastname']; 
     35         
     36    /* checking login has been typed */ 
     37    if ($user_login == '') { 
     38        die ('<strong>ERROR</strong>: Please enter a login.'); 
     39    } 
     40 
     41    /* checking the password has been typed twice */ 
     42    if ($pass1 == '' || $pass2 == '') { 
     43        die ('<strong>ERROR</strong>: Please enter your password twice.'); 
     44    } 
     45 
     46    /* checking the password has been typed twice the same */ 
     47    if ($pass1 != $pass2)   { 
     48        die ('<strong>ERROR</strong>: Please type the same password in the two password fields.'); 
     49    } 
     50    $user_nickname = $user_login; 
     51 
     52    /* checking e-mail address */ 
     53    if ($user_email == '') { 
     54        die ('<strong>ERROR</strong>: Please type your e-mail address.'); 
     55    } else if (!is_email($user_email)) { 
     56        die ('<strong>ERROR</strong>: The email address isn&#8217;t correct.'); 
     57    } 
     58 
     59    /* checking the login isn't already used by another user */ 
     60    $loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'"); 
     61    if ($loginthere) { 
     62        die ('<strong>ERROR</strong>: This login is already registered, please choose another one.'); 
     63    } 
     64 
     65 
     66    $user_login = addslashes(stripslashes($user_login)); 
     67    $pass1 = addslashes(stripslashes($pass1)); 
     68    $user_nickname = addslashes(stripslashes($user_nickname)); 
     69    $user_firstname = addslashes(stripslashes($user_firstname)); 
     70    $user_lastname = addslashes(stripslashes($user_lastname)); 
     71    $now = current_time('mysql'); 
     72 
     73    $result = $wpdb->query("INSERT INTO $tableusers  
     74        (user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode, user_firstname, user_lastname) 
     75    VALUES  
     76        ('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname', '$user_firstname', '$user_lastname')"); 
     77     
     78    if ($result == false) { 
     79        die ('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:'.$admin_email.'">webmaster</a> !'); 
     80    } 
     81 
     82    $stars = ''; 
     83    for ($i = 0; $i < strlen($pass1); $i = $i + 1) { 
     84        $stars .= '*'; 
     85    } 
     86 
     87    $message  = "New user registration on your blog $blogname:\r\n\r\n"; 
     88    $message .= "Login: $user_login\r\n\r\nE-mail: $user_email"; 
     89 
     90    @mail($admin_email, "[$blogname] New User Registration", $message); 
     91    header('Location: users.php'); 
     92break; 
     93 
    2394case 'promote': 
    2495 
     
    91162    <th>Name</th> 
    92163    <th>E-mail</th> 
    93     <th>URL</th> 
     164    <th>URI</th> 
    94165    <th>Level</th> 
    95166    <th>Posts</th> 
     
    144215        <th>Name</th> 
    145216        <th>E-mail</th> 
    146         <th>URL</th> 
     217        <th>URI</th> 
    147218        <th>Level</th> 
    148219    </tr> 
     
    186257<h2>Add User</h2> 
    187258<p>Users can <a href="<?php echo $siteurl ?>/wp-register.php">register themselves</a> or you can manually create users here.</p> 
     259<form action="" method="post" name="adduser" id="adduser"> 
     260  <table border="0" cellspacing="5" cellpadding="3"> 
     261    <tr> 
     262      <th scope="row">Nickname 
     263      <input name="action" type="hidden" id="action" value="adduser" /></th> 
     264      <td><input name="user_login" type="text" id="user_login" /></td> 
     265    </tr> 
     266    <tr> 
     267      <th scope="row">First Name </th> 
     268      <td><input name="firstname" type="text" id="firstname" /></td> 
     269    </tr> 
     270    <tr> 
     271      <th scope="row">Last Name </th> 
     272      <td><input name="lastname" type="text" id="lastname" /></td> 
     273    </tr> 
     274    <tr> 
     275      <th scope="row">Email</th> 
     276      <td><input name="email" type="text" id="email" /></td> 
     277    </tr> 
     278    <tr> 
     279      <th scope="row">URI</th> 
     280      <td><input name="uri" type="text" id="uri" /></td> 
     281    </tr> 
     282    <tr> 
     283      <th scope="row">Password (twice) </th> 
     284      <td><input name="pass1" type="text" id="pass1" /> 
     285      <br /> 
     286      <input name="pass2" type="text" id="pass2" /></td> 
     287    </tr> 
     288  </table> 
     289  <p> 
     290    <input name="adduser" type="submit" id="adduser" value="Add User"> 
     291  </p> 
     292  </form> 
    188293</div> 
    189294    <?php 
  • trunk/wp-register.php

    r628 r642  
    5151    $pass2 = $HTTP_POST_VARS['pass2']; 
    5252    $user_email = $HTTP_POST_VARS['user_email']; 
    53     $user_login = $HTTP_POST_VARS['user_login']; 
    5453         
    5554    /* checking login has been typed */ 
     
    8988    $pass1 = addslashes($pass1); 
    9089    $user_nickname = addslashes($user_nickname); 
     90    $now = current_time('mysql'); 
    9191 
    9292    $result = $wpdb->query("INSERT INTO $tableusers  
    9393        (user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode) 
    9494    VALUES  
    95         ('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', NOW(), '$new_users_can_blog', 'nickname')"); 
     95        ('$user_login', '$pass1', '$user_nickname', '$user_email', '$user_ip', '$user_domain', '$user_browser', '$now', '$new_users_can_blog', 'nickname')"); 
    9696     
    9797    if ($result == false) {