<?php /*
   +------------------------------------------------------------------+
   | MikeCherim.com                                                   |
   | PHP: IP Blacklister                                              |
   | PHP Hypertext Preprocessor                                       |
   | Copyright Feb 2007                                               |
   | Use with attribution by visible link please!                     |
   | Attribute to: <a href="http://green-beast.com/">Mike Cherim</a>  |
   +------------------------------------------------------------------+
*/
?>

<?php
/*
* INSTRUCTIONS:
*
* Place the script method of your choice below at the very top of
* every page you want to protect or simply apply it to your global
* header. If using WordPress, for example, add this code above
* everything else in your header.php file.
*
* Instead of posting a message you can choose to redirect the user to
* another site, give them a JavaScript alert box, whatever you choose.
*
* WARNING: Not all users have a static IP address. Thus, this method
* will not be effective against all miscreants. Also, when blocking
* IP addresses, do so with care so you don't block the innocent.
*
*/
?>



<?php // OPTION 1 - Standard error message method
  
$spammer_ip = getenv("REMOTE_ADDR");
  
$spammer_ips = array(
#### ENTER THE IP ADDRESSES YOU WANT TO BLOCK ####
  
"00.00.00.00",
  
"01.001.01.001",
  
"111.222.333.444",  
##################################################
);
  if(
in_array($spammer_ip, $spammer_ips)) {
     exit(
'<h2>You have been banned from this site!</h2>');
  }
?>



<?php // OPTION 2 - Error message method with JavaScript alert
  
$spammer_ip = getenv("REMOTE_ADDR");
  
$spammer_ips = array(
#### ENTER THE IP ADDRESSES YOU WANT TO BLOCK ####
  
"00.00.00.00",
  
"01.001.01.001",
  
"111.222.333.444",  
##################################################
);
  if(
in_array($spammer_ip, $spammer_ips)) {
     exit(
'<h2>Hello Spammer!</h2>
            <script type="text/javascript">alert("A package has been delivered in your name. Click OK to accept your gift.")</script>'
);
  }
?>



<?php // OPTION 3 - Redirection error method
  
$spammer_ip = getenv("REMOTE_ADDR");
  
$spammer_ips = array(
#### ENTER THE IP ADDRESSES YOU WANT TO BLOCK ####
  
"00.00.00.00",
  
"01.001.01.001",
  
"111.222.333.444",  
##################################################
);
  if(
in_array($spammer_ip, $spammer_ips)) {
     
header("Location: http://www.google.com/");
    exit();
  }
?>