functions.php: handle bad json from iphub

This commit is contained in:
Zankaria 2024-10-10 22:20:14 +02:00
parent f1bbd09751
commit 155a6eae84

View file

@ -1881,6 +1881,17 @@ function checkIPAPI(string $ip): bool {
}
$json = json_decode($reply);
if ($json === null) {
error_log('IPHub query failed: api returned incorrect json');
if ($config['cache']['enabled']) {
// Store the result for 4 hours.
cache::set("ip_api_block_$ip", 'api_error', 14400);
}
return false;
}
if (isset($json->error)) {
error_log("IPHub query failed: $json->error");