1. Go to this page and download the library: Download nickurt/laravel-abuseipdb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$isSpamIp = \AbuseIpDb::setIp('8.8.8.8')->isSpamIp();
// Same
$isSpamIp = abuseipdb()->setIp('8.8.8.8')->isSpamIp();
$isSpamIp = abuseipdb()->isSpamIp('8.8.8.8');
// Cache the result for 10 minutes (default 10 seconds)
abuseipdb()->setCacheTTL(600);
// Lower the // Catch exceptions
try {
abuseipdb()->isSpamIp('invalid-ip');
} catch(\nickurt\AbuseIpDb\AbuseIpDbException $exception) {
dd($exception->getMessage());
// "The ip address must be a valid IPv4 or IPv6 address (e.g. 8.8.8.8 or 2001:4860:4860::8888)."
}
try {
// Do it twice (happens eg if hacker accesses two invalid urls and each reports this IP)
// Both commands do the same in just two different ways
abuseipdb()->setIp('127.0.0.2')->reportIp('18,22');
abuseipdb()->reportIp('18,22', '127.0.0.2');
} catch(\nickurt\AbuseIpDb\AbuseIpDbException $exception) {
dd($exception->getMessage());
// "You can only report the same IP address (`127.0.0.2`) once in 15 minutes."
}