load_by_username also loads by email

create_user also sets email address if username looks like an email
This commit is contained in:
james 2009-10-22 19:03:29 +00:00
parent 4c44f40b3d
commit c4f5ed2ab7

View File

@ -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);