diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index a621cb113..426bce393 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -466,7 +466,7 @@ if ($tor_reged && $tor_info) { if (IS_AM || $peer['user_id'] == $userdata['user_id'] || !bf($peer['user_opt'], 'user_opt', 'user_hide_peer_country')) { if ($infoByIP = infoByIP((!empty($peer['ipv6']) ? $peer['ipv6'] : $peer['ip']), $peer['port'])) { if (!empty($infoByIP['countryCode'])) { - $peerCountry = render_flag($infoByIP['countryCode']); + $peerCountry = render_flag($infoByIP['countryCode'], false); } } } diff --git a/library/includes/functions.php b/library/includes/functions.php index efc0bee13..8bc2933ef 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2189,7 +2189,9 @@ function readUpdaterFile(): array|bool */ function infoByIP(string $ipAddress, int $port = 0): array { - if (!$data = CACHE('bb_ip2countries')->get($ipAddress . '_' . $port)) { + $ipAddress = \TorrentPier\Helpers\IPHelper::long2ip_extended($ipAddress); + $cacheName = hash('xxh128', ($ipAddress . '_' . $port)); + if (!$data = CACHE('bb_ip2countries')->get($cacheName)) { $data = []; $response = file_get_contents(API_IP_URL . $ipAddress); $json = json_decode($response, true); @@ -2200,7 +2202,7 @@ function infoByIP(string $ipAddress, int $port = 0): array 'continent' => $json['continent'], 'continentCode' => $json['continentCode'] ]; - CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200); + CACHE('bb_ip2countries')->set($cacheName, $data, 1200); } }