protected function KernelTerminateSubscriber::_getGeoipData in Visitors 8.2
Retrieve geoip data for ip.
Parameters
ip: A string containing an ip address.
Return value
array Geoip data array.
1 call to KernelTerminateSubscriber::_getGeoipData()
- KernelTerminateSubscriber::onTerminate in src/
EventSubscriber/ KernelTerminateSubscriber.php - Store visitors data when a request terminates.
File
- src/
EventSubscriber/ KernelTerminateSubscriber.php, line 168 - Contains Drupal\visitors\EventSubscriber\KernelTerminateSubscriber.
Class
- KernelTerminateSubscriber
- Store visitors data when a request terminates.
Namespace
Drupal\visitors\EventSubscriberCode
protected function _getGeoipData($ip) {
$result = array(
'continent_code' => '',
'country_code' => '',
'country_code3' => '',
'country_name' => '',
'region' => '',
'city' => '',
'postal_code' => '',
'latitude' => '0',
'longitude' => '0',
'dma_code' => '0',
'area_code' => '0',
);
if (function_exists('geoip_record_by_name')) {
$data = @geoip_record_by_name($ip);
if (!is_null($data) && $data !== FALSE) {
/* Transform city value from iso-8859-1 into the utf8. */
$data['city'] = utf8_encode($data['city']);
$result = $data;
}
}
return $result;
}