|
oplysninger |
');
echo('IP Country ### ' . $ip_data['country'] . ' ');
echo('IP Country Code ### ' . $ip_data['country_code'] . ' ');
echo('IP Continent ### ' . $ip_data['continent'] . ' ');
echo('IP Region ### ' . $ip_data['region'] . ' ');
echo('IP Latitude ### ' . $ip_data['latitude'] . ' ');
echo('IP Longitude ### ' . $ip_data['longitude'] . ' ');
echo('Organization ### ' . $ip_data['organization'] . ' ');
echo('ISP Provider ### ' . $ip_data['isp']);
function get_ip_info($ip = NULL)
{
if(empty($ip)) return false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.ipaddresslocation.org/ip-address-locator.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('ip' => $ip));
$data = curl_exec($ch);
curl_close($ch);
preg_match_all('/([a-z\s]+)\:<\/i>\s+(.*)<\/b>/im', $data, $matches, PREG_SET_ORDER);
if(count($matches) == 0) return false;
$return = array();
$format_labels = array(
'Hostname' => 'host',
'IP Country' => 'country',
'IP Country Code' => 'country_code',
'IP Continent' => 'continent',
'IP Region' => 'region',
'IP Latitude' => 'latitude',
'IP Longitude' => 'longitude',
'Organization' => 'organization',
'ISP Provider' => 'isp'
);
foreach($matches as $info)
{
if(isset($info[2]) && !is_null($format_labels[$info[1]]))
{
$return[$format_labels[$info[1]]] = $info[2];
}
}
return (count($return)) ? $return : false;
}
?> | |
|