admin

如何让帝国CMS支持手机号码登陆
帝国CMS登陆注册比较呆板,如何让帝国CMS支持手机号码登陆,更方便现在互联网的使用习惯。 **修改 e/m...
扫描右侧二维码阅读全文
30
2018/10

如何让帝国CMS支持手机号码登陆

帝国CMS登陆注册比较呆板,如何让帝国CMS支持手机号码登陆,更方便现在互联网的使用习惯。

修改 e/member/class/member_loginfun.php 函数qlogin
7.2及以上可以直接复制替换,其他版本最好修改按标准修改

//登录
 
function qlogin($add){
 
global $empire,$dbtbpre,$public_r,$ecms_config;
 
if($ecms_config['member']['loginurl'])
 
{
 
Header("Location:".$ecms_config['member']['loginurl']);
 
exit();
 
}
 
$dopr=1;
 
if($_POST['prtype'])
 
{
 
$dopr=9;
 
}
 
$username=trim($add['username']);
 
$password=trim($add['password']);
 
if(!$username||!$password)
 
{
 
printerror("EmptyLogin","history.go(-1)",$dopr);
 
}
 
$tobind=(int)$add['tobind'];
 
//验证码
 
$keyvname='checkloginkey';
 
if($public_r['loginkey_ok'])
 
{
 
ecmsCheckShowKey($keyvname,$add['key'],$dopr);
 
}
 
$username=RepPostVar($username);
 
$password=RepPostVar($password);
 
$num=0;
 
/*
 
*查询会员附加表手机号码字段(也可以是其他字段,自己看着来调整)
 
*/
 
$useradd=$empire->fetch1("select userid from {$dbtbpre}enewsmemberadd where phone='$username' limit 1");
 
if($useradd[userid]){
 
    $r=$empire->fetch1("select ".eReturnSelectMemberF('*')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$useradd[userid]' limit 1");
 
}else{
 
    $r=$empire->fetch1("select ".eReturnSelectMemberF('*')." from ".eReturnMemberTable()." where ".egetmf('username')."='$username' limit 1");
 
}
 
 
 
if(!$r['userid'])
 
{
 
printerror("FailPassword","history.go(-1)",$dopr);
 
}
 
 
 
$username=$r[username]; //重新复制用户名
 
 
 
if(!eDoCkMemberPw($password,$r['password'],$r['salt']))
 
{
 
printerror("FailPassword","history.go(-1)",$dopr);
 
}
 
if($r['checked']==0)
 
{
 
if($public_r['regacttype']==1)
 
{
 
printerror('NotCheckedUser','../member/register/regsend.php',1);
 
}
 
else
 
{
 
printerror('NotCheckedUser','',1);
 
}
 
}
 
//绑定帐号
 
if($tobind)
 
{
 
MemberConnect_BindUser($r['userid']);
 
}
 
$rnd=make_password(20);//取得随机密码
 
//默认会员组
 
if(empty($r['groupid']))
 
{
 
$r['groupid']=eReturnMemberDefGroupid();
 
}
 
$r['groupid']=(int)$r['groupid'];
 
$lasttime=time();
 
//IP
 
$lastip=egetip();
 
$lastipport=egetipport();
 
$usql=$empire->query("update ".eReturnMemberTable()." set ".egetmf('rnd')."='$rnd',".egetmf('groupid')."='$r[groupid]' where ".egetmf('userid')."='$r[userid]'");
 
$empire->query("update {$dbtbpre}enewsmemberadd set lasttime='$lasttime',lastip='$lastip',loginnum=loginnum+1,lastipport='$lastipport' where userid='$r[userid]'");
 
//设置cookie
 
$lifetime=(int)$add['lifetime'];
 
$logincookie=0;
 
if($lifetime)
 
{
 
$logincookie=time()+$lifetime;
 
}
 
$set1=esetcookie("mlusername",$username,$logincookie);
 
$set2=esetcookie("mluserid",$r['userid'],$logincookie);
 
$set3=esetcookie("mlgroupid",$r['groupid'],$logincookie);
 
$set4=esetcookie("mlrnd",$rnd,$logincookie);
 
//验证符
 
qGetLoginAuthstr($r['userid'],$username,$rnd,$r['groupid'],$logincookie);
 
//登录附加cookie
 
AddLoginCookie($r);
 
$location="../member/cp/";
 
$returnurl=getcvar('returnurl');
 
if($returnurl)
 
{
 
$location=$returnurl;
 
}
 
if(strstr($_SERVER['HTTP_REFERER'],"e/member/iframe"))
 
{
 
$location="../member/iframe/";
 
}
 
if(strstr($location,"enews=exit")||strstr($location,"e/member/register")||strstr($_SERVER['HTTP_REFERER'],"e/member/register"))
 
{
 
$location="../member/cp/";
 
$_POST['ecmsfrom']='';
 
}
 
ecmsEmptyShowKey($keyvname);//清空验证码
 
$set6=esetcookie("returnurl","");
 
if($set1&&$set2)
 
{
 
//易通行系统
 
DoEpassport('login',$r['userid'],$username,$password,$r['salt'],$r['email'],$r['groupid'],$r['registertime']);
 
$location=DoingReturnUrl($location,$_POST['ecmsfrom']);
 
printerror("LoginSuccess",$location,$dopr);
 
    }
 
else
 
{
 
printerror("NotCookie","history.go(-1)",$dopr);
 
}
 
}
最后修改:2018 年 10 月 30 日 04 : 04 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论