WordPress/wp-includes/functions-user.php
saxmatt 6337530119 Automatic login fixes.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2004-10-06 05:31:52 +00:00

31 lines
754 B
PHP

<?php
function login($username, $password, $already_md5 = false) {
global $wpdb, $error;
if ( !$username )
return false;
if ( !$password ) {
$error = __('<strong>Error</strong>: The password field is empty.');
return false;
}
$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
if (!$login) {
$error = __('<strong>Error</strong>: Wrong login.');
return false;
} else {
if ( ($login->user_login == $username && $login->user_pass == $password) || ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) ) {
return true;
} else {
$error = __('<strong>Error</strong>: Incorrect password.');
$pwd = '';
return false;
}
}
}
?>