Friday, October 19, 2012

Block Multiple ip addresses in PHP

10/19/2012

Sometimes you need to disallow a visitor to access your website. The most common reason for this is Spammers. Although there are several other solutions to block multiple IP addresses, but in this post we are going to focus on simple php script.
<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/


$blacklisted_ips = array("304.456.789.66", "626.789.123.85", "578.123.45.46");

if(in_array($_SERVER['REMOTE_ADDR'], $blacklisted_ips)) {
    header("Location: http://www.examples.com/block.php");
    exit();
}

?>

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top