diff --git a/inc/functions.php b/inc/functions.php index 42cf41bc..cd83013d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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");