request->userIP; } public static function LimitIp() { $ip =Yii::$app->request->userIP; $curl = new \linslin\yii2\curl\Curl(); $iphttp = 'http://ossimg.niufangw.com/public/ipadopt?ip='.$ip.'&type=1'; $ipResult = $curl->get($iphttp); if(!empty($ipResult)) { $iprow = json_decode($ipResult,true); } if(!empty($ip) && (isset($iprow) && $iprow['code'] == 300)) { $http = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip; $result = $curl->get($http); if(!empty($result)) { $res = json_decode($result,true); if(!empty($res) && $res['code'] == 0 && strpos($res['data']['region'],'海南') !== false) { header('Location:http://www.baidu.com'); exit ; } if(empty($res)) { header('Location:http://www.baidu.com'); exit ; } $inputHttp = 'http://ossimg.niufangw.com/public/ipadd?ip='.$ip.'&type=1'; $curl->get($inputHttp); } } } }