ecshop登录支持手机号码登录、邮箱登录

更改users.php

加在 之上

 

if ($user->login($username, $password,isset($_POST['remember'])))
    {
        update_user_info();
        recalculate_price();

        $ucdata = isset($user->ucdata)? $user->ucdata : '';
        show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
    }

 

//添加 手机、邮箱登录
    if(is_email($username))
        {
        $sql ="select user_name from ".$ecs->table('users')." where email='".$username."'";
        $username_e = $db->getOne($sql);
        if($username_e) $username=$username_e;
        }

         

        if(is_telephone($username))
        {
        $sql ="select user_name from ".$ecs->table('users')." where mobile_phone='".$username."'";
        $username_e = $db->getOne($sql);
        if($username_e) $username=$username_e;
        }

//手机正则

//手机号码验证1/3/4/7/8
function is_telephone($phone){
    $chars = "/^13[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$/";
    if (preg_match($chars, $phone)){
    return true;
        }
    }

 

你可能感兴趣的:(ecshop)