From dfa31fd1a112fb18faf53dea8edfcc3d732b9ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=83=A1?= <3203164629@qq.com> Date: Mon, 4 Mar 2024 09:37:27 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=B3=BB=E7=BB=9F=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=E7=99=BB=E5=BD=95=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 小胡 <3203164629@qq.com> --- core/function/function_core.php | 5 +++++ user/function/function_user.php | 6 +++++- user/language/zh-cn/lang.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) 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' => '注册新账号',