Skip to content

Commit a083c26

Browse files
committed
[TASK] Replace iplist.cc (dropped service) with ipapi.is
1 parent cf7d442 commit a083c26

4 files changed

Lines changed: 39 additions & 23 deletions

File tree

‎Classes/Domain/Factory/Ipinformation/AbstractIpinformation.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use In2code\Lux\Utility\IpUtility;
99
use Throwable;
1010
use TYPO3\CMS\Core\Http\RequestFactory;
11+
use TYPO3\CMS\Core\Utility\ArrayUtility;
1112
use TYPO3\CMS\Core\Utility\GeneralUtility;
1213

1314
abstract class AbstractIpinformation
@@ -92,8 +93,11 @@ public function mapKeys(array $array): array
9293
{
9394
$newArray = [];
9495
foreach ($this->mapping as $from => $to) {
95-
if (array_key_exists($from, $array)) {
96-
$newArray[$to] = $array[$from];
96+
try {
97+
$value = ArrayUtility::getValueByPath($array, $from, '.');
98+
$newArray[$to] = $value;
99+
} catch (Throwable $exception) {
100+
// Do nothing
97101
}
98102
}
99103
return $newArray;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
namespace In2code\Lux\Domain\Factory\Ipinformation;
5+
6+
class IpApiIs extends AbstractIpinformation implements IpinformationInterface
7+
{
8+
/**
9+
* Key in LUX => Key from request
10+
*
11+
* @var array|string[]
12+
*/
13+
protected array $mapping = [
14+
'company.name' => 'org',
15+
'company.domain' => 'domain',
16+
'location.country' => 'country',
17+
'location.country_code' => 'countryCode',
18+
'location.city' => 'city',
19+
'location.latitude' => 'lat',
20+
'location.longitude' => 'lon',
21+
'location.zip' => 'zip',
22+
'location.state' => 'region',
23+
];
24+
}

‎Classes/Domain/Factory/Ipinformation/Iplist.php‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎Configuration/TypoScript/Lux/05_IpinformationConfiguration.typoscript‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ lib.lux.settings {
55
# Main switch for using external IP services
66
_enable = 1
77

8-
# ipapi.co
8+
# ipapi.is
9+
# Useful database with many company information with 1,000 free requests per day (used by Salesflare, Mailmeteor, etc...)
910
# Check website for gdpr information
1011
1 {
11-
class = In2code\Lux\Domain\Factory\Ipinformation\IpApiCo
12+
class = In2code\Lux\Domain\Factory\Ipinformation\IpApiIs
1213
configuration {
13-
url = https://ipapi.co/{ip}/json/
14+
url = https://api.ipapi.is/?q={ip}
1415
}
1516
}
1617

17-
# iplist.cc
18-
# as a complete free provider service with https connection but information depth is worse then others
19-
# no company details, no geo coordinates, no zip and region
18+
# ipapi.co
19+
# Up to 30,000 free lookups per month without registration (used by Amazon, IBM, Oracle, etc...)
20+
# Check website for gdpr information
2021
2 {
21-
class = In2code\Lux\Domain\Factory\Ipinformation\Iplist
22+
class = In2code\Lux\Domain\Factory\Ipinformation\IpApiCo
2223
configuration {
23-
url = https://iplist.cc/api/{ip}
24+
url = https://ipapi.co/{ip}/json/
2425
}
2526
}
2627
}

0 commit comments

Comments
 (0)