<?php
function checkSpam($ipAddress) {
// Validate the IP address
if (!filter_var($ipAddress, FILTER_VALIDATE_IP)) {
echo "Invalid IP address format\n";
return;
}
// List of spam databases to check
$spamDatabases = array(
"b.barracudacentral.org",
"bl.spamcop.net",
"dnsbl.sorbs.net",
"zen.spamhaus.org"
);
// Check each database for the IP address
foreach ($spamDatabases as $db) {
$query = $ipAddress . "." . $db;
$result = gethostbyname($query);
// Check if the IP address is listed
if ($result == "127.0.0.2" || $result == "::1") {
echo "$ipAddress found in $db\n";
return;
} else {
echo "$ipAddress not found in $db\n";
}
}
}
// Example usage
$ipToCheck = "123.456.789.10"; // Replace this with the IP address you want to check
checkSpam($ipToCheck);
?>
It validates the IP address format, then checks it against several spam databases using DNSBL (DNS Blacklist) lookups. If the IP address is found in any of the databases, it prints a message indicating where it was found. Otherwise, it prints a message indicating that the IP address was not found in a particular database.
Comments (0)
There are no comments here yet, you can be the first!