FIX
This commit is contained in:
parent
b7d01af3eb
commit
89b158e462
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class IpInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
static public function geo($ip)
|
||||||
|
{
|
||||||
|
App::log('ip', $ip);
|
||||||
|
$ch = curl_init("http://ipinfo.io/".$ip);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
|
||||||
|
$result = $result ? json_decode($result, true) : NULL;
|
||||||
|
|
||||||
|
$loc = array('lat' => 59.937, 'lng' => 30.349);
|
||||||
|
if (isset($result['loc'])) {
|
||||||
|
$tmp = explode(',', $result['loc']);
|
||||||
|
$loc = array('lat' => $tmp[0], 'lng' => $tmp[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue