Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 IP based Website
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kolucoms6
Average Member

845 Posts

Posted - 23 November 2007 :  11:09:36  Show Profile

I want my online reporting site to be opened from few specific IPs....

Any Suggestions how to do it ?

Edited by - kolucoms6 on 23 November 2007 11:16:40

muzishun
Senior Member

United States
1079 Posts

Posted - 23 November 2007 :  18:31:21  Show Profile  Visit muzishun's Homepage
Are the users you're planning on allowing all behind static IP addresses? If so, all you'd really need to do is check the ServerVariables("REMOTE_ADDR") to make sure it's on your list of IPs.

Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 24 November 2007 :  07:35:04  Show Profile
Yes, static IP.
Go to Top of Page

muzishun
Senior Member

United States
1079 Posts

Posted - 24 November 2007 :  16:31:49  Show Profile  Visit muzishun's Homepage
Then the simplest way would just be to do something like this:


If Request.ServerVariables("REMOTE_ADDR") = "FIRST_IP" or _
Request.ServerVariables("REMOTE_ADDR") = "SECOND_IP" or _
Request.ServerVariables("REMOTE_ADDR") = "THIRD_IP" Then

Your code here.

End If


That would probably work. It may not be the cleanest or prettiest, but should do what you need.

Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 24 November 2007 :  16:43:43  Show Profile
That depends on how many that code could get large quickly.
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 24 November 2007 :  17:46:33  Show Profile
Total of 15...so, that Ok...
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 24 November 2007 :  19:04:43  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message
you can always use a TEXT file to store the IP's and read from it, could be a much better approach cause you can always use an Admin Page to modify that File and every time you add/remove/edit something it would be easier...

<% Const Filename = "/AllowedIPs.txt"    ' file to read

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

' Create a filesystem object
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")

' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)

if FSO.FileExists(Filepath) Then
' Get a handle to the file
Dim file
set file = FSO.GetFile(Filepath)

' Open the file
Dim TextStream
Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)

' Read the file line by line
Do While Not TextStream.AtEndOfStream
Dim Line
Line = TextStream.readline

' Do something with "Line"
If Request.ServerVariables("REMOTE_ADDR") = Line Then
' Found match to the IP Address

' YOUR CODE HERE

Exit Do
End if
Loop

' Dispose Object
Set TextStream = nothing

Else

' File does not exist

End If

' Dispose Object
Set FSO = nothing
%>


the
AllowedIPs.txt
file you should insert an IP per line, like:

192.168.2.1
192.168.2.2
192.168.2.3

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 24 November 2007 19:07:14
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 24 November 2007 :  22:11:05  Show Profile
Or a db solution like
SELECT IP IN List_of_IP WHERE IP=<IP in question>
If rows returned is 0 don't let them in.
Personally I think muzishun has the best solution, but now you can pick your poison.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07