public function getLocation($ip, $ipNumber) { $api = Config::inst()->get('DBIP_IpParser', 'api'); $url = "http://api.db-ip.com/v2/{$api}/{$ip}"; try { $json = file_get_contents($url); $data = Convert::json2array($json); $location = new ArrayData(array('Country' => $data['countryCode'], 'Region' => $data['stateProv'], 'City' => $data['city'], 'Type' => ContinentalContentUtils::IPType($ip))); $this->debugLocation($location); return $location; } catch (Exception $e) { } }
public function getLocation($ip, $ipNumber) { $location = IpToLocation::get()->filter(array('IPFrom:LessThanOrEqual' => $ipNumber, 'IPTo:GreaterThanOrEqual' => $ipNumber, 'Type' => ContinentalContentUtils::IPType($ip) == 'ipv4' ? 'IpV4' : 'IpV6'))->first(); $this->debugLocation($location); return $location; }