Forum Moderators: open
Is there a better way of doing this? I would like to be able to specific the upper and lower limites, and possibly wildcard characters.
Thanks...
this will get you most of the way toward what you are looking for(i think):
'
' Had to put comment marks on the empty lines in order for the code show correctly here in the forums
'
<%@ Language="VBScript" %>
<% OPTION EXPLICIT %>
<%
Dim userIP, ipRange, ip
Dim lowerBound, upperBound
Dim block
block = false
userIP = Request.ServerVariables("REMOTE_ADDR")
'userIP = "127.0.2.3" 'for your testing
'
Set ip = Server.CreateObject("Scripting.Dictionary")
Set ipRange = Server.CreateObject("Scripting.Dictionary")
'
'add individual IP addresses here to block
ip.Add "", "127.0.0.1"
'
'add a partial IP address here to block .. just does simple 'Left' matching
ipRange.Add "", "127.0.0."
'
Dim key
'
For each key in ip.Keys
If( ip.Item(key) = userIP ) Then
Response.Write("blocked specific IP")
block = true
End If
Next
'
For each key in ipRange.Keys
If( ipRange.Item(key) = Left(userIP, Len(ipRange.Item(key))) ) Then
Response.Write("blocked IP range")
block = true
End If
Next
'
If block Then
Response.Write "<br>block and send to alternate url or send alternate header information"
'Response.Redirect "blockedUserPage.asp"
Else
'Do nothing here
'Response.Write "<br>no block"
End If
%>
HTH,
Mark