Commit 9940ecf6 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch 'fix-location-data-by-ip' into 'develop'

Fix location retrieve with IP address

See merge request !78
parents b08f3041 884594cc
Pipeline #4905 failed with stages
in 10 seconds
......@@ -303,14 +303,12 @@ class FeManagerHooks
protected function getLocationDataByIp()
{
$location = '';
$locationData = file_get_contents('http://geoip.nekudo.com/api/' . $_SERVER['REMOTE_ADDR']);
if ($locationData !== false) {
$locationData = json_decode($locationData, true);
}
$locationDataAsJson = GeneralUtility::getUrl('http://geoip.nekudo.com/api/' . GeneralUtility::getIndpEnv('REMOTE_ADDR'));
$locationData = json_decode($locationDataAsJson, true);
if (!empty($locationData)) {
if (isset($locationData['error'])) {
$location = 'Location could not retrieved.';
if (isset($locationData['type']) && $locationData['type'] === 'error') {
$location = 'Location could not retrieved: ' . $locationData['msg'] . ' with IP: ' . GeneralUtility::getIndpEnv('REMOTE_ADDR');
} else {
if (isset($locationData['country']['name'])) {
$location = $locationData['country']['name'];
......@@ -326,4 +324,5 @@ class FeManagerHooks
return $location;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment