Stop that spammer before he gets in !!!!

Started by rich357, April 01, 2010, 03:16:43 PM

Previous topic - Next topic

rich357

What is the point of even allowing a spammer to register in the first place?
The script below checks the IP list and if found, redirects to your designated website.
BEFORE he even gets a chance to see your board.
As is though, the script plays havoc with SMF.
Array() could actually be checked through the honeypot database.
Just so long as we don't have to manually enter each and ever blasted IP.

Personally, I'm tired of manually blocking IP's. I've had over 200 on my site.

Could you please work this into the SMF script?

Thank you



<?php
//array of ip's you wish to block.  Note that you can block an
//entire class by replacing it with 0, so to block a class c
//(254 computers) use something like 123.123.123.*
$blockIP = array('1.1.1.1','1.1..*.*');

$remote = explode('.',$_SERVER['REMOTE_ADDR']);
foreach($blockIP as $ip) {
  $goodIP = false;
   for($i=0;$i<4;$i++) {
    $ipSeg = explode('.',$ip);
    if($remote[$i] == $ipSeg[$i] || $ipSeg[$i] == '*') {
      //segment qualifies
      $goodIP = true;
    } else {
      //ip no good so move to the next
      $goodIP = false;
      continue 2;
    }
  }
  if($goodIP) {
    //ip passes so no need to check the rest
    $blockThisIP = $ip;
    break;         
  }

}
//for convenience test $blockThisIP and process here
//replace www.crayola.com [nofollow] with the place you wish to
//send ip's too
if($blockThisIP) {
  //php header method - can only use this if the page
  //has not begin to display in the browser
  header('Location: http://www.google.com [nofollow]');

  //javascript redirection - use this method if browser has
  //begun to display page
  echo "<script type=\"text/javascript\">
  window.location = \"http://www.google.com [nofollow]\";</script>";
}
?>

Arantor

You know that the ban system prevents people accessing the site even to register? All this will do is save you a little CPU time once you've already banned them.

As for linking to the honey pot site (or others)... it's actually all too easy to get added to these places.

Point of interest. We don't run ANY anti spam mods on SimpleDesk, other than the CAPTCHA, and haven't had a single spam post yet.

Advertisement: