From 3eb0e1f1492d2596bb063c591c19c1a352554ac2 Mon Sep 17 00:00:00 2001 From: SubleXBle <51033045+SubleXBle@users.noreply.github.com> Date: Wed, 30 Jul 2025 03:48:53 +0200 Subject: [PATCH] Update abuseipdb.php --- includes/actions/reports/abuseipdb.php | 33 +++++++------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/includes/actions/reports/abuseipdb.php b/includes/actions/reports/abuseipdb.php index dc4c0b4..e397817 100644 --- a/includes/actions/reports/abuseipdb.php +++ b/includes/actions/reports/abuseipdb.php @@ -1,5 +1,4 @@ false, - 'message' => 'AbuseIPDB API key not set.', + 'message' => 'AbuseIPDB API key is not set.', 'type' => 'error' ]); return; } -$ipToCheck = $ip ?? null; - -if (!$ipToCheck) { - echo json_encode([ - 'success' => false, - 'message' => 'No IP specified for AbuseIPDB check.', - 'type' => 'error' - ]); - return; -} +$ipToCheck = $ip; +// Prepare and send API request $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.abuseipdb.com/api/v2/check?ipAddress=$ipToCheck", @@ -31,26 +22,18 @@ curl_setopt_array($curl, [ CURLOPT_HTTPHEADER => [ "Key: $apiKey", "Accept: application/json" - ], + ] ]); $response = curl_exec($curl); curl_close($curl); +// Process response if ($response) { $json = json_decode($response, true); - $count = $json['data']['totalReports'] ?? null; + $count = $json['data']['totalReports'] ?? 0; - if ($count === null) { - echo json_encode([ - 'success' => false, - 'message' => 'AbuseIPDB: Unexpected API response.', - 'type' => 'error' - ]); - return; - } - - $msg = "AbuseIPDB: $ipToCheck wurde $count mal gefunden"; + $msg = "AbuseIPDB: $ipToCheck was reported $count time(s)."; echo json_encode([ 'success' => true, @@ -60,7 +43,7 @@ if ($response) { } else { echo json_encode([ 'success' => false, - 'message' => 'AbuseIPDB request failed.', + 'message' => 'Failed to connect to AbuseIPDB.', 'type' => 'error' ]); }