Commit 884594cc authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Fix location retrieve with IP address

parent 0fe7fa63
Pipeline #4904 passed with stages
in 4 minutes and 22 seconds
......@@ -313,14 +313,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'];
......@@ -336,4 +334,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