function visitors_get_geoip_data in Visitors 7.2
Same name and namespace in other branches
- 8 visitors.exit.inc \visitors_get_geoip_data()
- 7 visitors.exit.inc \visitors_get_geoip_data()
Retrieve geoip data for ip.
Parameters
ip: A string containing an ip address.
Return value
array geoip data array.
1 call to visitors_get_geoip_data()
- visitors_exit in ./
visitors.exit.inc - Implements hook_exit().
File
- ./
visitors.exit.inc, line 133 - Implements hook_exit().
Code
function visitors_get_geoip_data($ip) {
if (function_exists('geoip_record_by_name')) {
$geoip_data = @geoip_record_by_name($ip);
if (!is_null($geoip_data) && $geoip_data !== FALSE) {
/* utf8_encode use for transform city value from iso-8859-1 into the
utf8. */
return array(
'visitors_continent_code' => $geoip_data['continent_code'],
'visitors_country_code' => $geoip_data['country_code'],
'visitors_country_code3' => $geoip_data['country_code3'],
'visitors_country_name' => $geoip_data['country_name'],
'visitors_region' => $geoip_data['region'],
'visitors_city' => utf8_encode($geoip_data['city']),
'visitors_postal_code' => $geoip_data['postal_code'],
'visitors_latitude' => $geoip_data['latitude'],
'visitors_longitude' => $geoip_data['longitude'],
'visitors_dma_code' => $geoip_data['dma_code'],
'visitors_area_code' => $geoip_data['area_code'],
);
}
}
return array(
'visitors_continent_code' => '',
'visitors_country_code' => '',
'visitors_country_code3' => '',
'visitors_country_name' => '',
'visitors_region' => '',
'visitors_city' => '',
'visitors_postal_code' => '',
'visitors_latitude' => '0',
'visitors_longitude' => '0',
'visitors_dma_code' => '0',
'visitors_area_code' => '0',
);
}