Checking for spammers

Status
Not open for further replies.

aeroguy

High In The Sky
Jul 16, 2006
37
1
0
Trying to implement the following php script that i found at php.net. My question how to mod the following script so that it redirects the users to index.php page if it is found that the ip is black listed.

$result=Array();
$dnsbl_check=array("bl.spamcop.net",
"list.dsbl.org",
"sbl.spamhaus.org");
if ($ip)
{
$quads=explode(".",$ip);
$rip=$quads[3].".".$quads[2].".".$quads.".".$quads[0];
for ($i=0; $i<count($dnsbl_check); $i++)
{
if (checkdnsrr($rip.".".$dnsbl_check[$i].".","A"))
{
$result1[]=Array($dnsbl_check[$i],$rip.".".$dnsbl_check[$i]);
}
}
}
 


One suggestion I'd make is that you cache the IPs that you verify as being spammers so that your script isn't pinging those three servers each time your page loads. This way, your script would first check your cached list for blacklisted IPs, and if its not found, then it would queryy the remote RBL servers.

Hitting up the RBL servers each time your page loads not only slows your site down bigtime, but they may actually ban you from running checks, and/or ask you to pay them.

You can cache the IPs by writing them to a simple text file, or if you want to get more involved, store them in a database. You can also write a cookie to their browser but they'll probably figure that out pretty quick so I wouldn't bother with cookies.
 
Status
Not open for further replies.