Sometimes we will display the user's area on the page, the principle is: first get the user's IP, and then go to the query to convert IP to a number, and finally to check the range of the number, come to the user's place.
IP conversion to numeric methods:
Suppose IP is 192.168.0.1
192*255*255*255+168*255*255+0*255+1
The result is the value to be obtained.
Converts an IP address to a long integer
<%
Function Clngip (ByVal asnewip)
Dim Lnresults
Dim Lnindex
Dim lnipary
Lnipary = Split (Asnewip, ".", 4)
For lnindex = 0 to 3
If not Lnindex = 3 Then
Lnipary (Lnindex) = Lnipary (lnindex) * (256 ^ (3-lnindex))
End If
Lnresults = Lnresults + lnipary (lnindex)
Next
CLNGIP = Lnresults
End Function
%>
Inverse function
<%
Function Cstrip (ByVal annewip)
Dim Lsresults
Dim lntemp
Dim Lnindex
For lnindex = 3 to 0 Step-1
Lntemp = Int (Annewip/(256 ^ lnindex))
Lsresults = lsresults & Lntemp & "."
Annewip = Annewip-(lntemp * (256 ^ lnindex))
Next
Lsresults = Left (Lsresults, Len (lsresults)-1)
Cstrip = Lsresults
End Function
%>
-->