summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/user.inc24
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