<?php

   $fd = fopen ("BlockIP.txt", "r");
   while (!feof ($fd))  {
      $buffer = fgets($fd, 4096);
      $lines[] = rtrim($buffer);
      if(preg_match("/".$buffer."/i",$_SERVER['REMOTE_ADDR'])) {
         echo '<meta http-equiv="refresh" content="0; URL=http://localhost">' ;
         exit();
      }
   fclose ($fd);

   //Cycle through all the IP Addresses in the file

   foreach($lines as $Spam)  {
      if(in_array($_SERVER['REMOTE_ADDR'],$lines))  {

      // this is for exact matches

      echo '<meta http-equiv="refresh" content="0; URL=http://localhost">' ;
      exit();
      }   }
 }