diff options
author | natrak <> | 2001-06-18 20:29:36 +0000 |
---|---|---|
committer | natrak <> | 2001-06-18 20:29:36 +0000 |
commit | 6e64691450be0ec2a77fa7c6da74d67f4376db62 (patch) | |
tree | b9662698c8a45cc85f81c69449d7e1b9d7fa6616 /includes | |
parent | e381f5b34a195f35fde904ddd7d2a40cf795aecb (diff) | |
download | brdo-6e64691450be0ec2a77fa7c6da74d67f4376db62.tar.gz brdo-6e64691450be0ec2a77fa7c6da74d67f4376db62.tar.bz2 |
Changes
- Moved account_password() and account_validate() to user.inc.
- Greatly reduced the number of SQL calls in account_save() when editing an
account. Now uses one db_query() call instead of 1 + (2 * # of access
granted).
- Fixed access not being saved when account was added.
- Should now be possible to edit and add accounts. There were certain bugs
before that would cause odd errors.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/user.inc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/includes/user.inc b/includes/user.inc index 0b99a6af5..082bd3f5e 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -63,4 +63,28 @@ function user_ban($mask, $type) { return db_fetch_object($result); } +function account_password($min_length=6) { + mt_srand((double)microtime() * 1000000); + $words = array("foo","bar","guy","neo","tux","moo","sun","asm","dot","god","axe","geek","nerd","fish","hack","star","mice","warp","moon","hero","cola","girl","fish","java","perl","boss","dark","sith","jedi","drop","mojo"); + while(strlen($password) < $min_length) $password .= $words[mt_rand(0, count($words))]; + return $password; +} + +function account_validate($user) { + // Verify username and e-mail address: + if (empty($user[real_email]) || (!check_mail($user[real_email]))) $error = t("the e-mail address '$user[real_email]' is not valid"); + if (empty($user[userid]) || (!check_name($user[userid]))) $error = t("the username '$user[userid]' is not valid"); + if (strlen($user[userid]) > 15) $error = t("the username '$user[userid]' is too long: it must be less than 15 characters"); + + // Check to see whether the username or e-mail address are banned: + if ($ban = user_ban($user[userid], "username")) $error = t("the username '$user[userid]' is banned") .": <I>$ban->reason</I>"; + if ($ban = user_ban($user[real_email], "e-mail address")) $error = t("the e-mail address '$user[real_email]' is banned") .": <I>$ban->reason</I>"; + + // Verify whether username and e-mail address are unique: + if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) $error = t("the username '$user[userid]' is already taken"); + if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$user[real_email]')")) > 0) $error = t("the e-mail address '$user[real_email]' is already in use by another account"); + + return $error; +} + ?>
\ No newline at end of file |