mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -07:00
Minor improvements (#1482)
* Minor improvements * Update functions.php * Update functions.php * Update CHANGELOG.md * Update composer.lock
This commit is contained in:
parent
f584cf5d29
commit
430825c3e7
3 changed files with 23 additions and 188 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue