| 22 | | |
|---|
| | 22 | case '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’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’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'); |
|---|
| | 92 | break; |
|---|
| | 93 | |
|---|
| | 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> |
|---|