私人领地

ecshop登录

邮箱登录

a.找到function login(){} ,增加一个邮箱判断is_mail()  ,

b.如果通过,增读取出username ,

c.再通过默认的login功能

1.需要修改文件include/modules/integrates/integrate.php

原代码 第145行

function login($username, $password, $remember = null)
    {
        
        if ($this->check_user($username, $password) > 0)
        {
            if ($this->need_sync)
            {
                $this->sync($username,$password);
            }
            $this->set_session($username);
            $this->set_cookie($username, $remember);

            return true;
        }
        else
        {
            return false;
        }
    }

 

修改代码

 function login($username, $password, $remember = null)
    {
     // 邮箱验证
if(is_email($username)){ $sql = "select ".$this->field_name." from ".$this->table($this->user_table)." where ".$this->field_email."='".$username."'"; $username = $this->db->getOne($sql); if(!$username) return false; }
     // 手机验证
if(is_telephone($username)){ $sql = "select ".$this->field_name." from ".$this->table($this->user_table)." where mobile_phone ='".$username."'"; $username = $this->db->getOne($sql); if(!$username) return false; } if ($this->check_user($username, $password) > 0) { if ($this->need_sync) { $this->sync($username,$password); } $this->set_session($username); $this->set_cookie($username, $remember); return true; } else { return false; } }

2.include/lib_common.php 增加手机判断格式  第40行

function is_telephone($phone){
    $chars = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$/";
    if(preg_match($chars, $phone)){
        return true;
    }else{
        return false;    
    }
}

 

posted @ 2016-02-26 16:09  狂奔的蜗牛Snails  阅读(1031)  评论(0编辑  收藏  举报