From db093a6020652b2285743b7cba89d87334974c97 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 4 Oct 2004 04:30:45 +0000 Subject: [PATCH] Move functions out of switch statement, PHP5 fix git-svn-id: http://svn.automattic.com/wordpress/trunk@1730 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-login.php | 98 ++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/wp-login.php b/wp-login.php index f4a1b5c901..033e6c5d4d 100644 --- a/wp-login.php +++ b/wp-login.php @@ -1,5 +1,53 @@ Error: the login field is empty.'); + return false; + } + + if (!$password) { + $error = __('Error: the password field is empty.'); + return false; + } + + $query = "SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login' AND user_pass = '$password'"; + + $login = $wpdb->get_row($query); + + if (!$login) { + $error = __('Error: wrong login or password.'); + $pwd = ''; + return false; + } else { + $user_ID = $login->ID; + if (($pass_is_md5 == 0 && $login->user_login == $user_login && $login->user_pass == $password) || ($pass_is_md5 == 1 && $login->user_login == $user_login && $login->user_pass == md5($password))) { + return true; + } else { + $error = __('Error: wrong login or password.'); + $pwd = ''; + return false; + } + } +} + +function checklogin() { + global $user_login, $user_pass_md5, $user_ID; + + $userdata = get_userdatabylogin($user_login); + + if ($user_pass_md5 != md5($userdata->user_pass)) { + return false; + } else { + return true; + } +} if (!function_exists('add_magic_quotes')) { function add_magic_quotes($array) { @@ -74,42 +122,6 @@ case 'login': $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php'; } - function login() { - global $wpdb, $log, $pwd, $error, $user_ID; - global $pass_is_md5; - $user_login = &$log; - $pwd = md5($pwd); - $password = &$pwd; - if (!$user_login) { - $error = __('Error: the login field is empty.'); - return false; - } - - if (!$password) { - $error = __('Error: the password field is empty.'); - return false; - } - - $query = "SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login' AND user_pass = '$password'"; - - $login = $wpdb->get_row($query); - - if (!$login) { - $error = __('Error: wrong login or password.'); - $pwd = ''; - return false; - } else { - $user_ID = $login->ID; - if (($pass_is_md5 == 0 && $login->user_login == $user_login && $login->user_pass == $password) || ($pass_is_md5 == 1 && $login->user_login == $user_login && $login->user_pass == md5($password))) { - return true; - } else { - $error = __('Error: wrong login or password.'); - $pwd = ''; - return false; - } - } - } - if (!login()) { header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); @@ -240,18 +252,6 @@ default: $user_pass_md5 = $_COOKIE['wordpresspass_'.$cookiehash]; } - function checklogin() { - global $user_login, $user_pass_md5, $user_ID; - - $userdata = get_userdatabylogin($user_login); - - if ($user_pass_md5 != md5($userdata->user_pass)) { - return false; - } else { - return true; - } - } - if ( !(checklogin()) ) { if (!empty($_COOKIE['wordpressuser_'.$cookiehash])) { $error="Error: wrong login/password"; //, or your session has expired.";