Merge pull request #5886 from Thomas2500:patch-1

Switch IP2Country lookup backend to shortened version
This commit is contained in:
Niklas Meyer 2024-06-05 12:37:31 +02:00 committed by GitHub
commit 34b0574e56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -284,17 +284,17 @@ function last_login($action, $username, $sasl_limit_days = 7, $ui_offset = 1) {
} }
if (!$sasl[$k]['location']) { if (!$sasl[$k]['location']) {
$curl = curl_init(); $curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"https://dfdata.bella.network/lookup/" . $sasl[$k]['real_rip']); curl_setopt($curl, CURLOPT_URL,"https://dfdata.bella.network/country/" . $sasl[$k]['real_rip']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Moocow'); curl_setopt($curl, CURLOPT_USERAGENT, 'Moocow');
curl_setopt($curl, CURLOPT_TIMEOUT, 5); curl_setopt($curl, CURLOPT_TIMEOUT, 5);
$ip_data = curl_exec($curl); $ip_data = curl_exec($curl);
if (!curl_errno($curl)) { if (!curl_errno($curl)) {
$ip_data_array = json_decode($ip_data, true); $ip_data_array = json_decode($ip_data, true);
if ($ip_data_array !== false and !empty($ip_data_array['location']['shortcountry'])) { if ($ip_data_array !== false and !empty($ip_data_array['shortcountry'])) {
$sasl[$k]['location'] = $ip_data_array['location']['shortcountry']; $sasl[$k]['location'] = $ip_data_array['shortcountry'];
try { try {
$redis->hSet('IP_SHORTCOUNTRY', $sasl[$k]['real_rip'], $ip_data_array['location']['shortcountry']); $redis->hSet('IP_SHORTCOUNTRY', $sasl[$k]['real_rip'], $ip_data_array['shortcountry']);
} }
catch (RedisException $e) { catch (RedisException $e) {
$_SESSION['return'][] = array( $_SESSION['return'][] = array(