home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2756
Discussions: 188,382, Posts: 2,243,482, Members: 232,612
Old February 17th, 2003, 10:38 PM   Digg it!   #1 (permalink)
Member
 
grandma's Avatar
 
Join Date: Mar 2002
Location: Northern Michigan
Posts: 89
PHP IP Blocking

Here is a simple IP Blocking prog. Keep in mind I am a newbie

Quote:
<?

$blockip = array("222.394.142.8","2.2.2.2","3.3.3.3");

$x = count($blockip);

for ($y = 0; $y < $x; $y++) {

if ($REMOTE_ADDR == $blockip[$y]) {

echo ("No Way baby!");

Exit;} ELSE {

echo ("Yer ok, bud");
EXit; }

} //END FOR

?>
Is there a way I can ban a range of IP's? Like a wildcard.

192.33.43.* or 192.33.43.XX

Thanks in Advance

Grandma

grandma is offline   Reply With Quote
Old February 18th, 2003, 07:52 PM     #2 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Sure, just depends how how you want to define the comparison between $REMOTE_ADDR and $blockip.

you need to define what those are:

192.33.43.* or 192.33.43.XX

wait just use:

int ereg ( string pattern, string string [, array regs])

"192.33.43.*" will match all IPs, even invalid IPs

"192.33.43..." will match second. I need to brush up my regular expressions.

Anyway, fiddle around with them and you should be able to get what you want.

qball is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2887)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
hp compaq nc6000 problems (138)
Folderchat Weekday thread (439)
Antec 300 bulk purchase? (11)
Help with an Ati Radeon HD 4850 512.. (27)
Recent Discussions
G&Z 10th Anniversary Specia.. (0)
How to increase my ram? (5)
Building a gaming computer advi.. (2)
Help with an Ati Radeon HD 4850.. (27)
CPU wont boot (4)
2nd video card (1)
special characters in quarkxpre.. (3)
Need help removing my front usb.. (2)
Genuine Broadband Connection my.. (14)
BATCH FILE WONT OPEN!!! HELP!!! (3)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)


All times are GMT -4. The time now is 09:23 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28