教程集 www.jiaochengji.com
教程集 >  建站教程  >  phpcms  >  正文 PHPCMS v9使用Email登陆的修改方法

PHPCMS v9使用Email登陆的修改方法

发布时间:2014-08-15   编辑:jiaochengji.com
本文介绍下,在phpcms v9系统中,如何让用户可以用email登录后台呢?参考本文介绍的方法,可以轻松实现这个功能。

共分为二个步骤完成。

第一步:修改登陆的验证JS
修改 statics/js/formvalidatorregex.js找到
 

<span style="font-size: 13px; font-family: 'courier new', courier;">ps_username:"^[\\u4E00-\\u9FA5\\uF900-\\uFA2D_\\w]+$"
</span>

修改为:
 

<span style="font-size: 13px; font-family: 'courier new', courier;">ps_username:"^[\\u4E00-\\u9FA5\\uF900-\\uFA2D_\\w@\.]+$"
</span>

第二步: 修改登录文件
修改 phpcms/modules/member/index.php

1,找到
 

<span style="font-size: 13px; font-family: 'courier new', courier;">$synloginstr = ''; //同步登陆js代码
</span>

在下面添加:
 

<span style="font-size: 13px; font-family: 'courier new', courier;">preg_match('/^[a-z]+\w*@\w+\.[a-z0-9]{2,6}$/i', $username, $is_email);
</span>

2,找到下面的
 

<span style="font-size: 13px; font-family: 'courier new', courier;">$status = $this->client->ps_member_login($username, $password);
</span>

修改为:
 

<span style="font-size: 13px; font-family: 'courier new', courier;">$status = $this->client->ps_member_login($username, $password, $is_email);
</span>

3,找到下面的
 

<span style="font-size: 13px; font-family: 'courier new', courier;">$r = $this->db->get_one(array('username'=>$username));
</span>
 

修改为:
 

<span style="font-size: 13px; font-family: 'courier new', courier;">$r = $this->db->get_one(array($is_email ? 'email' : 'username'=>$username));
</span>

如此之后,便可以用Email能登陆了。快动手实践下吧。

您可能感兴趣的文章:

[关闭]
~ ~