How to IP ban people from your website
Got a Flamer on your site or forums? Ban'em!
I know alot of you guys already know how to do this but I thought I'd show everyone how to.
Copy and paste one of the two codes below into a new document and call it ipbanned.php
1.Single IP Ban
PHP Code:
$bad_ip = 'xxx.xxx.xxx.xxx'; // the "x's" are where you put the ip of who you want to ban.
$visitor_ip = $_SERVER['REMOTE_ADDR']; // the ip address of the visitor
if($visitor_ip == $bad_ip)
{
die("Tsk, tsk, tsk you got banned!!");
** ?>
Is there more than 1 person you just hate. Well here is the script to ban multiple people.
PHP Code:
$ban_ips = "xxx.xxx.xxx.1,xxx.xxx.xxx.2"); First ip goes before the comma, second goes after the comma.
$visitor_ip = $_SERVER['REMOTE_ADDR'];
$ip_list = explode(",", $ban_ips);
foreach($ip_list as $ip)
{
if($visitor_ip == $ip)
{
die("Tsk, tsk, tsk you got banned!");
**
**
?>
Now, if you just want to ban them from one page of your site, put that code in there. But if u just hate them, and you dont want them to access anything, then save the above code as ipbanned.php and use the include php code to easily put it on every site.
Now the person cant acsess the site anymore. Have Fun.:thumbup:
(the "**"'s are end brackets)