Example #1
0
 public static function getCityForMobile($mobile)
 {
     return Mobile::getInfoForMobile($mobile, 'city');
 }
Example #2
0
 private static function isInArea($mobile, $lmt)
 {
     // 验证IP城市
     if ($lmt['ipAreaLvl'] == '市') {
         $ipArea = IP::getCityForIP(self::getIp());
         // 确定IP模块正常,null表示故障,则不使用此功能
         if (is_null($ipArea)) {
             goto CHECK_M;
         }
         if ($ipArea != $lmt['ipArea']) {
             data()->setErr('mobile', '亲,你的IP地址不在' . $lmt['ipArea'] . '市,推荐你用微信免注册直接登录。');
             return false;
         }
     }
     // 验证IP省份
     if ($lmt['ipAreaLvl'] == '省') {
         $ipArea = IP::getProvinceForIP(self::getIp());
         // 确定IP模块正常,null表示故障,则不使用此功能
         if (is_null($ipArea)) {
             goto CHECK_M;
         }
         if ($ipArea != $lmt['ipArea']) {
             data()->setErr('mobile', '亲,你的IP地址不在' . $lmt['ipArea'] . '省,推荐你用微信免注册直接登录。');
             return false;
         }
     }
     CHECK_M:
     // 验证手机城市
     if ($lmt['mAreaLvl'] == '市') {
         $mArea = Mobile::getCityForMobile($mobile);
         // 确定手机模块正常
         if (is_null($mArea)) {
             goto END;
         }
         if ($mArea != $lmt['mArea']) {
             data()->setErr('mobile', '亲,你的手机号归属地不在' . $lmt['mArea'] . '市,推荐你用微信免注册直接登录。');
             return false;
         }
     }
     // 验证手机省份
     if ($lmt['mAreaLvl'] == '省') {
         $mArea = Mobile::getProvinceForMobile($mobile);
         // 确定手机模块正常
         if (is_null($mArea)) {
             goto END;
         }
         if ($mArea != $lmt['mArea']) {
             data()->setErr('mobile', '亲,你的手机号归属地不在' . $lmt['mArea'] . '省,推荐你用微信免注册直接登录。');
             return false;
         }
     }
     END:
     return true;
 }