Rev 193 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?php
function IPtoCoordinates($ip)
{
// $dom = new DOMDocument();
if($ipcheck == -1 || $ipcheck === false)
trigger_error('Invalid IP, what are you doing? :|', E_USER_ERROR);
else
$key='482198dbcb57d1747babb7acebc5c02e';
$uri = 'http://api.ipstack.com/' . $ip . '?access_key=' . $key . '&output=json&legacy=1';
$location = $data['country_name'];
$longitude = $data['longitude'];
$latitude = $data['latitude'];
/*
$uri = 'http://freegeoip.net/xml/' . $ip;
$dom->load($uri);
$location = $dom->getElementsByTagName('CountryName')->item(0)->nodeValue;
$longitude = $dom->getElementsByTagName('Longitude')->item(0)->nodeValue;
$latitude = $dom->getElementsByTagName('Latitude')->item(0)->nodeValue;
*/
return array('location' => $location, 'longitude' => $longitude, 'latitude' => $latitude);
}
?>