Ban IP From Site

April 13th, 2009 | Tags:

Tutorial Description:

Ever had a user that was bugging you? Just add his IP address to the list and he will be banned from your site!

Simply add this script above your site script, and add the IP’s of the users to want to ban into the array, and you’re set!

<?php
// Define user IP.
$ip = $_SERVER['REMOTE_ADDR'];

// Allowed IP's.
$deny = array("00.000.00.00");

for (

$i = 0; $i < count($deny); $i++)
{
if (
$ip == $deny[$i])// user is not welcome.
{
// print some text + kick them out.
exit("User [IP - $ip] - <font color='red'>Access Denied!</font>");
}
}
?>

No comments yet.
TOP