ITs pretty crude, and also only works if the IP address has four sections each 3 digits long, so its a got structure to build up on:
<% Dim strMaxRange 'Upper bound IP blocking range Dim strMinRange 'Lower bound IP blocking range Dim intLoop 'Loop counter Dim strCurrentIP 'Visitors IP address Dim intSectionMin 'Lower bound IP address slice Dim intSectionMax 'Upper bound IP address slice Dim intVisIPSlice 'Slice of visitors IP Dim blnIsIPOK 'Is the IP address ok so far
'Set variables strMinRange = "000.000.000.000" strMaxRange = "255.255.255.255" intLoop = 0 strCurrentIP = Request.ServerVariables("REMOTE_ADDR")
blnIsIPOK = True
'Take out the dots strMinRange = Replace(strMinRange,".","") strMaxRange = Replace(strMaxRange,".","") strCurrentIP = Replace(strCurrentIP,".","")
'Loop through all the sections Do until intLoop = 4 or blnIsIPOK = False intLoop = intLoop + 1 'Get the slices of the IP range intSectionMin = mid(strMinRange,intLoop*3,3) intSectionMax = mid(strMaxRange,intLoop*3,3) intVisIPSlice = mid(strCurrentIP,intLoop*3,3)
'If the slice falls out of range IP is blocked IF intVisIPSlice < intSectionMax AND intVisIPSlice > intSectionMin then blnIsIPOK = False End if Loop
Select case blnIsIPOK Case True Response.write("IP Address of current visitor is not in the blocked range") Case False Response.write("IP Address of current visitor is in the blocked range") End select
Response.write(" <BR><BR>Visitors current IP Address is " & Request.ServerVariables("REMOTE_ADDR")) %>
|
Edited by Gullanian