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;
|
|
|
|
if ( !$already_md5 )
|
|
|
|
$pwd = md5($password);
|
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.');
|
|
|
|
$pwd = '';
|
|
|
|
return false;
|
2004-08-09 04:29:51 -04:00
|
|
|
} else {
|
2004-10-04 04:03:52 -04:00
|
|
|
|
|
|
|
if ( $login->user_login == $username && $login->user_pass == $pwd ) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
$error = __('<strong>Error</strong>: Incorrect password.');
|
|
|
|
$pwd = '';
|
|
|
|
return false;
|
|
|
|
}
|
2004-08-09 04:29:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|