Ecshop会员注册的Email 电子邮箱改成非必填项 并带非空验证邮箱合法性

1、修改模板文件
    <span id="email_notice" style="color:#FF0000"> *</span>去掉*号就好
2、打开  /js/user.js 文件,找到下面JS代码段并修改(大概在466行左右)
     if (email.length == 0)
      {
        msg += email_empty + '\n';
      }
      else
      {
        if ( ! (Utils.isEmail(email)))
        {
          msg += email_invalid + '\n';
        }
      }
    修改为
        if (email.length != 0 && ! (Utils.isEmail(email)))
        {
          msg += email_invalid + '\n';
        }
3、打开 /includes/lib_passport.php 文件,  找到下面代码,同样是修改(大概在40行左右) ,注意是修改
        /* 检查email */
         if (!empty($email))
            {
                $GLOBALS['err']->add($GLOBALS['_LANG']['email_empty']);
            }
            else
            {
                if (!is_email($email))
                {
                    $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], htmlspecialchars($email)));
                }
            }
        修改为
            if (!empty($email) && !is_email($email))
            {
               $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], htmlspecialchars($email)));
             }
4、继续打开 includes/modules/integrates/integrate.php 文件,找到下面代码修改之(大概在196行左右)
        
/* 检查email是否重复 */
        $sql = "SELECT " . $this->field_id .
               " FROM " . $this->table($this->user_table).
               " WHERE " . $this->field_email . " = '$email'";
        if ($this->db->getOne($sql, true) > 0 )
        {
            $this->error = ERR_EMAIL_EXISTS;
            return false;
        }
       修改为
        
/* 检查email是否重复 */
        if(!empty($email)){//如果邮箱没有填写,则不检查邮箱是否重复
        $sql = "SELECT " . $this->field_id .
               " FROM " . $this->table($this->user_table).
               " WHERE " . $this->field_email . " = '$email'";
        if ($this->db->getOne($sql, true) > 0 )
        {
            $this->error = ERR_EMAIL_EXISTS;
            return false;
        }
        }
5。支持邮箱登录:
打开文件:/includes/modules/integrates/integrate.php
约145– 162行的用户登入函数.如下
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 ($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;
         }
     }

你可能感兴趣的:(Ecshop会员注册的Email 电子邮箱改成非必填项 并带非空验证邮箱合法性)