IP Ban Script

Junior Spellweaver
Joined
Feb 5, 2010
Messages
149
Reaction score
19
some people have no idea how to ban from a site
this script is a very simple lockout function to block
the ip you have put into this script from seeing your site


PHP:
<center>
<?PHP
$ban_ips = ("0.0.0.0,0.0.0.0"); //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("You Have Been Banned From This Network. Have A Nice Day. :]"); 
}}
?>
</center>

for this script to work and not slow down your site

save this code as ipbanned.php and put a copy in every folder in your www folder then

type in

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

at the very top of every .php file you have in your www folder

this will result in a message like this

oOBlissOo - IP Ban Script - RaGEZONE Forums


for this example i used 127.0.0.1 to ban my local host

replace the 0.0.0.0 with the ip of the person you would like to ban

to ban fully from your network access your firewall setting and to blocked ips (could be named something else or hard to find) and add that persons ip and they cannot log in game either
 
yea well those people cant be banned unless you add their isp's ip
and .htaccess doesn't give you the you were banned message they will just think somethings wrong with the site
also if you want to you can create a seperate section of the site for staff members and copy n paste the ip's from the db (account_tbl - select all - copy paste ms excel select ip collum copy n paste) that blocks every one but the staff altho doesnt work if some one uses a proxy site but u can google for a list of all the proxy server ips and just copy n paste
 
Mac address ban of the router/modem along with ip ban is better. Obviously as we all known ip addresses can be changed if on dynamic and mac addresses can be spoofed. Nothing is full proof.
 
Last edited:
You could do an array function, and a header function.

Anyway, Nice job.
 
Is it possible to have wildcards for the IP? For example to ban a country or a pool of IP'S instead of single ones?
 
first off, you should make it read ips from a document or from a db.
also
if you want to ban the user which uses the ip: e.g. 123.456.789.000
you could place: "123.456.*.*" into the ip area,
as if people do not have a static ip; they could restart their router
and their "789.000" or just the ".000" would change.
 
Back