PDA

View Full Version : How to block IPs


steff
05-30-2005, 01:09 PM
need to block one or more IPs from visiting your pages?
surfing the web, I was able to find this hint:


$addr = array("1.2.3.4", "1.2.3.5", "1.2.3.6"); // array of IPs..
foreach($addr AS $key=>$value)
if (strstr($_SERVER['REMOTE_ADDR'], $value))
{
Header("Location:www.yahoo.com");
}


you can insert this code just before the line starting with
error_reporting(0)
in the /index.php file.

I used it to block a static IP of a person I didn't want, and it works!
others could find it useful to permanently block spammers, ex-girlfriends, and so on

Connie
05-30-2005, 01:39 PM
I just wanted to add ex-boyfriends but I must admit that nearly 99,9% of my ex-boyfriends are computer-illiterate, even my beloved husband :lol:

steff
05-30-2005, 09:29 PM
well, I did it for that reason, really :twisted:
now, when she visits my blog (if ever) she gets a wonderful
http://steff.altervista.org/403.html

anyway, joking apart, don't you think this can be useful to stop spam?

Connie
05-30-2005, 09:43 PM
yes, it could be an addon

more and more this security topic is coming ahead, anti-comment-spam, anti-referrer-spam, blocking IP-adresses

but I would be careful with blocking IP-adresses, I once used it in another script (like an online-lottery), and even participants who did not enter any answer before were blogged by the IP-list, were told they couldn't enter again..

there was the IP of one of the biggest providers in that IP-list ... how to take care of these adresses? most likely users will come with a dynamic adress ...