Go Back   DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums > Webmaster / Coding / Web Design Discussion > PHP, CGI, ASP, Server-Side Programming

PHP, CGI, ASP, Server-Side Programming Discuss server-side programming such as PHP, CGI, ASP, and others.

Have A Look At Some Of Our Webmaster Related Sponsors!


Script Directory


Advertise Here


Market Leverage


Free Templates

3D Guide-Characters
3D Guide-characters


Advertise Here

Reply
 
LinkBack Thread Tools Display Modes
Old 01-11-2008, 05:30 PM   #1 (permalink)
Field Master
 
karthikeyan's Avatar
 

Join Date: Jun 2007
Posts: 611
iTrader: 0 / 0%
Hunter Bux: 509.00
karthikeyan is on a distinguished road
Send a message via MSN to karthikeyan Send a message via Yahoo to karthikeyan
Default Ban IP in php script

This is the script which bans multiple ip's

PHP Code:
<?php
$ip 
= (array) $_SERVER['REMOTE_ADDR'];
$blocked = array('xx.xx.xx.xx','xx.xx.xx.xx');
if(
in_array($blocked,$ip))
{
die(
'You have been banned!');
}
?>
karthikeyan is offline   Reply With Quote
Old 01-11-2008, 09:33 PM   #3 (permalink)
Sharp Shooter
 
weblord's Avatar
 

Join Date: Mar 2007
Location: Philippines
Posts: 1,323
iTrader: 1 / 100%
Hunter Bux: 611.00
weblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud ofweblord has much to be proud of
Send a message via ICQ to weblord Send a message via AIM to weblord Send a message via MSN to weblord Send a message via Yahoo to weblord Send a message via Skype™ to weblord
Default

and if you're using this and want to know country's ip use this
http://blockacountry.com/
weblord is offline   Reply With Quote
Old 01-12-2008, 09:31 AM   #4 (permalink)
New Hunter
 

Join Date: Aug 2007
Posts: 56
iTrader: 0 / 0%
Hunter Bux: 0
stackhacks is on a distinguished road
Default

If you're not having much luck with the first one, here's an alternate source:

Code:
<?php

//Set banned IP
$banned  = '123.123.123.123';

//get user IP address
$userip = $_SERVER['REMOTE_ADDR'];

//check for banned IP address
if($userip == $banned){ 
    echo "<BR>This IP address has been banned";
    exit(); 
}

//continue with script...

?>
stackhacks is offline   Reply With Quote
Old 01-12-2008, 10:18 AM   #5 (permalink)
Field Master
 
htnho's Avatar
 

Join Date: Dec 2007
Posts: 268
iTrader: 1 / 100%
Hunter Bux: 30.00
htnho is on a distinguished road
Default

nice code
Thank you very much
htnho is offline   Reply With Quote
Old 01-14-2008, 06:30 PM   #6 (permalink)
Field Master
 

Join Date: Dec 2007
Posts: 179
iTrader: 0 / 0%
Hunter Bux: 0
sekuchi is on a distinguished road
Default

Thanks for the tips...
sekuchi is offline   Reply With Quote
Old 01-15-2008, 03:12 AM   #7 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 88
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default

Cos of IP banning, people use like unfilter sites and that crap to show a different IP, letting them on the site.

I saw a script once which like, would uncover there original IP, prety useful.
Ill try and find it soon for you.
Smiggy is offline   Reply With Quote
Old 01-15-2008, 12:42 PM   #8 (permalink)
Field Master
 
sunken's Avatar
 

Join Date: Sep 2007
Posts: 544
iTrader: 0 / 0%
Hunter Bux: 0
sunken is on a distinguished road
Default

Also something to keep in mind when banning IP or IP blocks. If the person you are banning is on a dynamic IP, then it will most likely change each time he resets his account. This will mean that someone else will be assigned that IP most likely and he will be unbanned. Then the new person (which is rare, I'll admit) will not now why he is banned. If you ban an entire IP block, be sure it's not something like some central hub as you may ban the entire network from coming to your site.

You can always do a whois with the IP address to find out who the IP block belongs to.
sunken is offline   Reply With Quote
Old 01-16-2008, 05:44 AM   #9 (permalink)
Field Master
 
karthikeyan's Avatar
 

Join Date: Jun 2007
Posts: 611
iTrader: 0 / 0%
Hunter Bux: 509.00
karthikeyan is on a distinguished road
Send a message via MSN to karthikeyan Send a message via Yahoo to karthikeyan
Default

Quote:
Originally Posted by weblord View Post
and if you're using this and want to know country's ip use this
http://blockacountry.com/
Thanks Weblord !
karthikeyan is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 12:47 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios