Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
t3o
my.typo3.org
Commits
27c0b819
Commit
27c0b819
authored
Feb 24, 2019
by
Stefan Busemann
Browse files
[BUGFIX] Update API calls, to retrieve IP locations
parent
47805b2a
Pipeline
#6368
failed with stages
in 14 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extensions/t3omy/Classes/Hooks/FeManagerHooks.php
View file @
27c0b819
...
...
@@ -324,26 +324,32 @@ class FeManagerHooks
*/
protected
function
getLocationDataByIp
()
{
$location
=
''
;
$locationDataAsJson
=
GeneralUtility
::
getUrl
(
'http://geoip.nekudo.com/api/'
.
GeneralUtility
::
getIndpEnv
(
'REMOTE_ADDR'
));
$locationData
=
json_decode
(
$locationDataAsJson
,
true
);
if
(
!
empty
(
$locationData
))
{
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'
];
}
if
(
isset
(
$locationData
[
'city'
])
&&
$locationData
[
'city'
])
{
$location
.
=
', '
.
$locationData
[
'city'
];
if
(
$this
->
settings
[
'ipapi'
][
'access_key'
])
{
$apiUrl
=
'http://api.ipapi.com/'
.
GeneralUtility
::
getIndpEnv
(
'REMOTE_ADDR'
);
$apiUrl
.
=
'?access_key='
.
$this
->
settings
[
'ipapi'
][
'access_key'
];
$location
=
''
;
$locationDataAsJson
=
GeneralUtility
::
getUrl
(
$apiUrl
);
$locationData
=
json_decode
(
$locationDataAsJson
,
true
);
if
(
!
empty
(
$locationData
))
{
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'
];
}
if
(
isset
(
$locationData
[
'city'
])
&&
$locationData
[
'city'
])
{
$location
.
=
', '
.
$locationData
[
'city'
];
}
}
}
else
{
$location
=
'Empty result from api.ipapi.com.'
;
}
return
$location
;
}
else
{
$location
=
'Empty result from geoip.nekudo.com/api/.
'
;
return
'No Access key is set in typoscript constants - tx_t3omy.ipapi.access_key
'
;
}
return
$location
;
}
}
extensions/t3omy/Configuration/TypoScript/main.txt
View file @
27c0b819
...
...
@@ -18,6 +18,7 @@ plugin.tx_t3omy {
url =
}
}
ipapi.access_key = {$tx_t3omy.ipapi.access_key}
}
config.tx_realurl_enable = 1
...
...
extensions/t3omy/ext_typoscript_constants.txt
View file @
27c0b819
...
...
@@ -13,6 +13,12 @@ plugin.tx_femanager.settings.adminName = TYPO3 Association / typo3.org Administr
plugin.tx_femanager.settings.adminEmail = confirm-t3o-account@typo3.org
plugin.tx_femanager.persistence.storagePid = 5
#################
### Settings ###
#################
# cat=T3Omy Settings/ipapi/001; type=string; label = Access Key for api.ipapi.com
tx_t3omy.ipapi.access_key =
###############
### PageIds ###
###############
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment