Page 1 of 1

How to ban Ip from your website?

Posted: Fri Jun 08, 2007 8:48 am
by anish
It is one of the effective code for banning the IP address from your website.
Just paste the codeinto your PHP page.

[PHP]<?php
// This will retrieve ip!
$ip = getenv('REMOTE_ADDR');
// Replace 'x' with ip address!
$blocked = "****.****.****.****";

if (ereg($blocked,$ip))
{
echo "You Have Been Banned";
exit();
}
?> [/PHP]

'echo "You Have Been Banned";' <-- this is the message which will be displayed when the banned ip goes on the page.

Remember to swap the x's with the IP you wish to ban.

Posted: Mon Jun 11, 2007 3:48 pm
by SHAdmin
You have been credited 10 points for sharing that trick with the community.