diff --git a/Application/Base/Service/UserService.class.php b/Application/Base/Service/UserService.class.php index 358da11c..bc42e563 100644 --- a/Application/Base/Service/UserService.class.php +++ b/Application/Base/Service/UserService.class.php @@ -4,6 +4,7 @@ namespace Base\Service; use Base\Tool\TaskClient; use Think\Log; use Base\Tool\Redis; +use Base\Tool\IPTool; /** * @@ -216,14 +217,16 @@ class UserService protected function isIpWarning($user, $clientIp) { - $newResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIp); - $oldResult = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$user['login_ip']); - $newResult = json_decode($newResult, true); - $oldResult = json_decode($oldResult, true); - if($newResult['data']['city'] != $oldResult['data']['city']) { - return true; + $newResult = IPTool::getIpInfo($clientIp); + $oldResult = IPTool::getIpInfo($user['login_ip']); + if ( + $newResult['data']['country_id'] == $oldResult['data']['country_id'] && + $newResult['data']['region_id'] == $oldResult['data']['region_id'] && + $newResult['data']['city_id'] == $oldResult['data']['city_id'] + ) { + return false; } - return false; + return true; } /** diff --git a/Application/Base/Tool/IPTool.class.php b/Application/Base/Tool/IPTool.class.php new file mode 100644 index 00000000..043430f5 --- /dev/null +++ b/Application/Base/Tool/IPTool.class.php @@ -0,0 +1,41 @@ +