[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Today's Posts Domain Services
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Closed Thread
 
Thread Tools
Old 06-29-2005, 01:57 PM   · #1
i386
NamePros Member
 
Trader Rating: (3)
Join Date: Oct 2003
Posts: 126
NP$: 182.00 (Donate)
i386 is an unknown quantity at this point
[PHP] IP Banner

If you are looking to ban a few IPs, try this.

Code:
if (strcasecmp(getenv("REMOTE_ADDR"), "someIP") == 0) { echo "You have been banned.\n"; exit; }


Please register or log-in into NamePros to hide ads
i386 is offline   Reply With Quote
Old 06-29-2005, 02:00 PM   · #2
vip-ip
Account Closed
 
vip-ip's Avatar
 
Location: root@localhost
Trader Rating: (75)
Join Date: Jan 2005
Posts: 4,046
NP$: 0.00 (Donate)
vip-ip is an unknown quantity at this point
Hmm, nice! But you'll have to have that for every single IP and you can't ban an IP rande in 1 line.
vip-ip is offline   Reply With Quote
Old 06-29-2005, 02:58 PM   · #3
Porte
Template Designer
 
Porte's Avatar
 
Name: Ahmad
Location: Somewhere on earth!
Trader Rating: (29)
Join Date: May 2005
Posts: 3,528
NP$: 17.30 (Donate)
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
Well yea, it's better through cpanel though. But I think this is good for banning a few IPs.
Porte is offline   Reply With Quote
Old 06-29-2005, 03:50 PM   · #4
i386
NamePros Member
 
Trader Rating: (3)
Join Date: Oct 2003
Posts: 126
NP$: 182.00 (Donate)
i386 is an unknown quantity at this point
You could also use strstr

Code:
if (strstr(getenv("REMOTE_ADDR"), "1.2.3.4") != FALSE) { banned }
i386 is offline   Reply With Quote
Old 06-29-2005, 11:07 PM   · #5
Eric
while ($awake){ code(); }
 
Eric's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,289
NP$: 29.10 (Donate)
Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
Possibly this would work better: Allows the ban of multiple IPs, one per line.

PHP Code:
//Place this at the top of your php scripts/HTML to prevent access to those IP addresses listed.
<?php
$ip_ban
= array();
$ip_ban[] = '111.111.111.111';
$ip_ban[] = '111.111.111.112';

foreach(
$ip_ban as $denied) {
    
$ip = $_SERVER['REMOTE_ADDR'];
    if(
$ip == $denied){
        echo
"Access Denied! You have been banned!";
        exit();
    }
}

?>
__________________
Formerly SecondVersion...

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!

Last edited by SecondVersion : 06-30-2005 at 01:35 AM. Reason: tweaked
Eric is offline   Reply With Quote
Old 06-30-2005, 12:54 AM   · #6
hasif
Account Closed
 
Name: Hasif Ahmed
Location: NY, USA
Trader Rating: (12)
Join Date: May 2005
Posts: 285
NP$: 45.00 (Donate)
hasif has a spectacular aura abouthasif has a spectacular aura about
owow its very small. nice script.
hasif is offline   Reply With Quote
Old 06-30-2005, 09:52 AM   · #7
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (48)
Join Date: Nov 2003
Posts: 4,393
NP$: 2007.50 (Donate)
Peter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant future
Child Abuse Save The Children Save The Children
Originally Posted by SecondVersion
Possibly this would work better: Allows the ban of multiple IPs, one per line.

PHP Code:
//Place this at the top of your php scripts/HTML to prevent access to those IP addresses listed.
<?php
$ip_ban
= array();
$ip_ban[] = '111.111.111.111';
$ip_ban[] = '111.111.111.112';

foreach(
$ip_ban as $denied) {
    
$ip = $_SERVER['REMOTE_ADDR'];
    if(
$ip == $denied){
        echo
"Access Denied! You have been banned!";
        exit();
    }
}

?>



You would be as well doing the following

PHP Code:
<?php
$ip_ban
= array();
$ip_ban[] = '111.111.111.111';
$ip_ban[] = '111.111.111.112';

if (
in_array($_SERVER['REMOTE_ADDR'], $ip_ban)) {
   echo
"Access Denied! You have been banned!";
   exit();
}
?>
Peter is offline   Reply With Quote
Old 07-01-2005, 03:52 PM   · #8
.PJ
NamePros Regular
 
.PJ's Avatar
 
Trader Rating: (5)
Join Date: Aug 2004
Posts: 369
NP$: 0.00 (Donate)
.PJ is on a distinguished road
If I was to use them / this, I would use the array, and put it into like banned.php and then just call / include banned.php on the footer which is on every page or somthing...

PJ
__________________
L33TSig.net
.PJ is offline   Reply With Quote
Old 07-01-2005, 04:14 PM   · #9
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
tis a cool script, but I can never figure out how this kinda script works.

Firstly, with my service provider, my ip address changes every 5 minutes, so I can just wait a few minutes before re-accessing the site, and other people's ip addresses re-knew when they re-logon to their isps. These won't work, I'm telling you! The rest of the people will just use an ipscrambler.
PoorDoggie is offline   Reply With Quote
Old 07-02-2005, 01:52 AM   · #10
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (48)
Join Date: Nov 2003
Posts: 4,393
NP$: 2007.50 (Donate)
Peter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant futurePeter has a brilliant future
Child Abuse Save The Children Save The Children
yes that is a big problem for using ip's to ban a user.
Peter is offline   Reply With Quote
Old 07-08-2005, 09:51 PM   · #11
i386
NamePros Member
 
Trader Rating: (3)
Join Date: Oct 2003
Posts: 126
NP$: 182.00 (Donate)
i386 is an unknown quantity at this point
Cookies are a kind-of-good way to handle that.

If the visitor blocks cookies, you're out of luck...

I'd recommend setting them with a misleading name, so Firefox users don't think they say you're banned! (i.e. site_user). When the user visits the site, add the site_user cookie with no_c. If they're banned, add it with no_b.

Misleading titles of cookies should work!
i386 is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selling Premium Sitewide Banner Advertising WebbyMedia Advertising & SEO Services 2 06-08-2005 06:55 PM
Text, Button & Banner Space Available on Several Sites Starting @ $3/month!!! Mike Panic For Sale / Advertising Board 0 01-31-2005 05:29 AM
Page Rank 5 Site with Banner and Text Links!! MUCH MORE! High Traffic Sites ebizcraftsman Advertising & SEO Services 0 12-09-2004 10:43 PM
Text, Banner & Free Ad Space On Network of Sites: CHEAP Mike Panic For Sale / Advertising Board 0 09-14-2004 11:04 AM
Text and Banner spots available on gaming related site mr_sam For Sale / Advertising Board 3 08-04-2004 06:04 AM

Site Sponsors
Skilled Graphics http://www.domainate.com/y/ http://www.domainate.com/y/
Advertise your business at NamePros
All times are GMT -7. The time now is 02:01 PM.


Powered by: vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0