From c4f5ed2ab7d09a73cc49dbe48a1eaffc088f8359 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 22 Oct 2009 19:03:29 +0000 Subject: [PATCH] load_by_username also loads by email create_user also sets email address if username looks like an email --- user.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user.inc.php b/user.inc.php index dd618c8..fc4bc79 100644 --- a/user.inc.php +++ b/user.inc.php @@ -257,7 +257,7 @@ function user_load_by_email($email) { /* Find the most recent uid for the email, regardless of deleted status */ $e = mysql_real_escape_string($email); - $q = mysql_query("SELECT uid FROM users WHERE email='$e' ORDER BY year DESC LIMIT 1"); + $q = mysql_query("SELECT uid FROM users WHERE email='$e' OR username='$e' ORDER BY year DESC LIMIT 1"); if(mysql_num_rows($q) == 1) { $i = mysql_fetch_assoc($q); @@ -707,6 +707,9 @@ function user_create($type, $username, $u = NULL) VALUES ('$type','$username','0000-00-00', NOW(), '{$config['FAIRYEAR']}')"); echo mysql_error(); $uid = mysql_insert_id(); + if(user_valid_email($username)) { + mysql_query("UPDATE users SET email='$username' WHERE id='$uid'"); + } mysql_query("UPDATE users SET uid='$uid' WHERE id='$uid'"); echo mysql_error(); user_set_password($uid, NULL);