PHP – Check IP is Blacklisted

The following example helps you to check the IP Address is blacklisted.
<?php 
function is_blacklisted($ip) { 
    $dnsbl_check=array("bl.spamcop.net", 
                       "relays.osirusoft.com", 
                       "list.dsbl.org", 
                       "sbl.spamhaus.org",
                       "bl.nszones.com",
                       "block.dnsbl.sorbs.net",
                       "dnsbl-2.uceprotect.net",
                       "dnsbl-3.uceprotect.net",
                       "dnsbl.anticaptcha.net",
                       "dyn.nszones.com"
                       "..."
                      ); 
    $listed = '';
    if ($ip) { 
       $quads=explode(".",$ip); 
        $rip=$quads[3].".".$quads[2].".".$quads[1].".".$quads[0]; 
        for ($i=0; $i<count($dnsbl_check); $i++) { 
            if (checkdnsrr($rip.".".$dnsbl_check[$i],"A")) { 
                $listed.=$dnsbl_check[$i]." "; 
                echo $dnsbl_check[$i]."<br>";
            }
         } 
         
       if ($listed) { return $listed; } else { return FALSE; } 
    } 
} 

is_blacklisted('IP_ADDRESS');
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail