Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Ban by IP (See related posts)

PHP code to get user IP and compare to others in a file, and ban if there

$ip = $_SERVER['REMOTE_ADDR'];
$ipArray = preg_replace("#\r\n?|\n#","",file('IP.txt'));
foreach ($ipArray as $ipTest) {
  if (substr_count($ip, $ipTest) != "0") { 
    header('location: http://google.com');
    die();
  }
}



You need to create an account or log in to post comments to this site.


Click here to browse all 7299 code snippets

Related Posts