介绍
扩展现有Dzz登录功能,以便支持使用系统手机号进行登录。
实现方法
文件:core/function/function_core.php
在
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);
}
文件:user/function/function_user.php
在
elseif ($isuid == 2) {
$user = C::t('user')->fetch_by_email($username);
}
后添加
elseif ($isuid == 3) {//手机号码登录
$user = C::t('user')->fetch_by_phone($username);
}
在
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);
}
文件:user/language/zh-cn/lang.php
将’email_username’ => ‘邮箱或用户名’,修改为’email_username’ => ‘邮箱、用户名或手机号’,
注意
系统手机号需由管理员在机构用户中进行设置,不是用户个人资料中的手机号。