Created
September 11, 2014 15:28
-
-
Save khoand0000/f3308829064c81996af5 to your computer and use it in GitHub Desktop.
http://phpsnips.com/544/Blacklist-Lookup#.VBG-zfmSySo
This blacklist lookup function is a modification of this snippet. The difference is, that it returns if it suspects an ip is a spammer. If 50% or more of the lookups think your a spammer, the function returns true otherwise false.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function blacklist($ip){ | |
$listed = true; | |
$dnsbl_lookup = array( | |
"dnsbl-1.uceprotect.net", | |
"dnsbl-2.uceprotect.net", | |
"dnsbl-3.uceprotect.net", | |
"dnsbl.dronebl.org", | |
"dnsbl.sorbs.net", | |
"zen.spamhaus.org" | |
); // Add your preferred list of DNSBL's | |
$lookups = count($dnsbl_lookup); | |
$total = 0; | |
if($ip){ | |
$reverse_ip = implode(".", array_reverse(explode(".", $ip))); | |
foreach($dnsbl_lookup as $host){ | |
if(checkdnsrr($reverse_ip.".".$host.".", "A")){ | |
$total++; | |
} | |
} | |
} | |
$percent = ($total / $lookups) * 100; | |
if($percent >= 50){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
if(blacklist($_SERVER["REMOTE_ADDR"])){ | |
die("Your on the blacklist!"); | |
} | |
// Continue with page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment