PHP – Block IP Address

There are many ways to stop the site access for an IP Address:  One Example is listed below:
Code Example:

Put the following code at the very top of index.php page or any required .php page

$bannedips = array("123.456.789.55", "987.654.321.88"); // array of blocked IP Addresses
if(in_array($_SERVER['REMOTE_ADDR'], $bannedips)){
  echo 'YOU ARE BANNED!';

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *