Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-02-2008, 01:46 PM   #1 (permalink)
liquidx
Recruit
 
Join Date: May 2008
Posts: 1
liquidx is on a distinguished road
How to allow 2 IP ranges

Hey All,
I would like to have a script that allows 2 IP ranges to access a certain part of php page on my website. Right now all I can get is one range to work correctly. Here is what I have

PHP Code:
$ip $_SERVER['REMOTE_ADDR']; 
$ip explode(".",$ip); 

$ip_from "192.168.0.1"
$ip_to "192.168.255.254"

$ip_from2 "10.0.0.1"
$ip_to2 "10.255.255.254"

$ip_from explode(".",$ip_from); 
$ip_to explode(".",$ip_to); 

$ip_from2 explode(".",$ip_from); 
$ip_to2 explode(".",$ip_to); 

$a 0
while(
$a <= 3) { 
if (
$ip[$a] < $ip_from[$a] or $ip_from2[$a] || $ip[$a] > $ip_to[$a] or $ip_to2[$a]) { die("Access Denied"); } 
$a++; 

It however will not work, it still denies acces to the $ip_from2 and $ip_to2

Please help? Thank you
liquidx is offline   Reply With Quote
Old 05-02-2008, 02:20 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
This post does the opposite of what you want to do. it blocks ips in the array sent in.

you could modify it to only allow the ips sent into it.
__________________
Mike
sde 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



All times are GMT -8. The time now is 09:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting