Minor improvements (#1482)

* Minor improvements

* Update functions.php

* Update functions.php

* Update CHANGELOG.md

* Update composer.lock
This commit is contained in:
Roman Kelesidis 2024-05-23 23:31:21 +07:00 committed by GitHub
commit 430825c3e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 188 deletions

View file

@ -2170,14 +2170,23 @@ function readUpdaterFile(): array|bool
*
* @param string $ipAddress
* @param int $port
* @return mixed|string|null
* @return array
*/
function infoByIP(string $ipAddress, int $port = 0): mixed
function infoByIP(string $ipAddress, int $port = 0): array
{
if (!$data = CACHE('bb_ip2countries')->get($ipAddress . '_' . $port)) {
$data = [];
$response = file_get_contents(API_IP_URL . $ipAddress);
$data = json_decode($response, true);
CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200);
$json = json_decode($response, true);
if (is_array($json) && !empty($json)) {
$data = [
'ipVersion' => $json['ipVersion'],
'countryCode' => $json['countryCode'],
'continent' => $json['continent'],
'continentCode' => $json['continentCode']
];
CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200);
}
}
return $data;