/**
* Checks a password with a supplied username.
*
* @param string The username of the user.
* @param string The plain-text password.
* @return boolean|array False when no match, array with user info when match.
*/
function validate_password_from_username($username, $password)
{
global $db;
$query = $db->simple_select("users", "uid,username,email,password,salt,loginkey,coppauser,usergroup", "LOWER(email)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if(!$user['uid'])
{
return false;
}
else
{
return validate_password_from_uid($user['uid'], $password, $user);
}
}