mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-18 08:36:04 +01:00
6337530119
git-svn-id: http://svn.automattic.com/wordpress/trunk@1754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
31 lines
754 B
PHP
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|