美国ip 贝塔版处理

master
tping 5 years ago
parent dc46561d2b
commit 770d3aeebf

@ -320,7 +320,7 @@ function ip_is_country($ip, $country_id=['US'], $country=['美国'])
$res = file_get_contents($url); $res = file_get_contents($url);
if (!$res) { // 走淘宝 if (!$res) { // 走淘宝
$res = file_get_contents($url2); $res = file_get_contents($url2);
Log::write("taobal:".serialize($res)); Log::write("taobao:".serialize($res));
if (!empty($res)) { if (!empty($res)) {
$ipData = json_decode($res,true); $ipData = json_decode($res,true);
if ($ipData['code']==0 && in_array($ipData['data']['country_id'],$country_id)) { if ($ipData['code']==0 && in_array($ipData['data']['country_id'],$country_id)) {
@ -333,9 +333,10 @@ function ip_is_country($ip, $country_id=['US'], $country=['美国'])
} }
} else { } else {
$res= iconv('GB2312', 'UTF-8', $res);
$ipData = json_decode($res, true); $ipData = json_decode($res, true);
Log::write("taobal:".serialize($res)); Log::write("sina:".serialize($res));
if ($ipData['status']==0 && substr($ipData['location'], 0, strlen($country[0])-1) == $country[0]) { if ($ipData['status']==0 && substr($ipData['data'][0]['location'], 0, strlen($country[0])) == $country[0]) {
return true; return true;
} }
} }

Loading…
Cancel
Save