diff --git a/core/function/function_core.php b/core/function/function_core.php index f8c6dcf..f508b43 100644 --- a/core/function/function_core.php +++ b/core/function/function_core.php @@ -628,6 +628,11 @@ function isemail($email) return strlen($email) > 6 && strlen($email) <= 32 && preg_match("/^([A-Za-z0-9\-_.+]+)@([A-Za-z0-9\-]+[.][A-Za-z0-9\-.]+)$/", $email); } +function isphone($phone) +{ + return preg_match("/^1[3456789]\d{9,10}$/", $phone); +} + function quescrypt($questionid, $answer) { return $questionid > 0 && $answer != '' ? substr(md5($answer . md5($questionid)), 16, 8) : ''; diff --git a/user/function/function_user.php b/user/function/function_user.php index 7287f20..82a5057 100644 --- a/user/function/function_user.php +++ b/user/function/function_user.php @@ -23,7 +23,9 @@ function uc_user_login($username, $password, $isuid, $checkques = '', $questioni } elseif ($isuid == 2) { $user = C::t('user')->fetch_by_email($username); - } else { + } elseif ($isuid == 3) {//手机号码登录 + $user = C::t('user')->fetch_by_phone($username); + }else { $user = C::t('user')->fetch_by_username($username); } @@ -61,6 +63,8 @@ function userlogin($username, $password, $questionid = '', $answer = '', $loginf $return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer, $ip); } elseif (isemail($username)) { $return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer, $ip); + } elseif (isphone($username)) { + $return['ucresult'] = uc_user_login($username, $password, 3, 1, $questionid, $answer, $ip); } if ($return['ucresult'][0] <= 0 && $return['ucresult'][0] != -3) { $return['ucresult'] = uc_user_login(addslashes($username), $password, 0, 1, $questionid, $answer, $ip); diff --git a/user/language/zh-cn/lang.php b/user/language/zh-cn/lang.php index db6536c..835e6b0 100644 --- a/user/language/zh-cn/lang.php +++ b/user/language/zh-cn/lang.php @@ -98,7 +98,7 @@ $lang=array ( 'other_login' => '其他登录', 'qq_login' => 'QQ登录', 'automatic_login_within_thirtydays' => '30天内自动登录', - 'email_username' => '邮箱或用户名', + 'email_username' => '邮箱、用户名或手机号', 'binding_for_account' => '绑定已有账号', 'register_new_account_bound' => '注册新账号并绑定', 'register_new_account' => '注册新账号',