定型管 電子鈑金
返回列表 回復 發帖

帖子標題:[分享] 如何實現ecshop 讓用戶名和email都可以登陸

改动程序: /includes/modules/integrates/integrate.php
改动代码:145--162行的用户登陆函数.如下     function login($username, $password)
    {
        if ($this->check_user($username, $password) > 0)
        {
            if ($this->need_sync)
            {
                $this->sync($username,$password);
            }
            $this->set_session($username);
            $this->set_cookie($username);

            return true;
        }
        else
        {
            return false;
        }
    }
改为
    function login($username, $password)
    {
        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;
                //echo $sql;exit;
        }
        if ($this->check_user($username, $password) > 0)
        {
            if ($this->need_sync)
            {
                $this->sync($username,$password);
            }
            $this->set_session($username);
            $this->set_cookie($username);

            return true;
        }
        else
        {
            return false;
        }
    }
提醒您: 您在"ECSHOP 交流討論區"交流請遵守台灣法律規範,"最模板" 發表的文章《如何實現ecshop 讓用戶名和email都可以登陸》版權歸屬作者所有,如是轉貼版權歸屬原作者所有.本論壇不對其真實性做任何考證.
返回列表