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