Thread: [PHP] IP Ban
View Single Post
  #1 (permalink)  
Old 02-04-2007, 01:28 AM
-=sIN=- -=sIN=- is offline
Junior Member
 
Join Date: Feb 2007
Posts: 20
-=sIN=- is on a distinguished road
[PHP] IP Ban

1. Create a file called ban.php and add this sctip to it.

PHP Code:
<?php
// For a single user ban
$ban_ip 'xxx.xxx.xxx.xxx'// ip address of the person you want to ban

// DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING
$visitor_ip $_SERVER['REMOTE_ADDR']; // the ip address of the visitor
if($visitor_ip == $ban_ip)
{
die(
"You are banned from this site!");
}

// DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING
$visitor_ip $_SERVER['REMOTE_ADDR'];
$ip_list explode(","$ban_ip);
foreach(
$ip_list as $ip)
{
if(
$visitor_ip == $ip)
{
die(
"You are banned from this site!");
}
}

?>
2. Add this code to any page you what the ip banned from

PHP Code:
<?php
include('ban.php');
?>

Reply With Quote