Recommended code for IP address access with ASP-application techniques
Source: Internet
Author: User
by Zkxp 2/15/2006 http://zkxp.cnblogs.com
A collection of masked IP addresses (segments) with an asterisk of wildcard characters, usually stored in a configuration file.
<%
Const Badipgroup = "220.200.59.136|220.205.168.141"
If Isforbidip (badipgroup) = True Then
Response.Write (Getuserip & "IP address No Access")
Response.End ()
End If
'****************************************************************
' Parameter Vbadip: IP segment to be screened, set of IP addresses, separate multiple IP addresses by | symbol (segment)
' Returns bool:true User IP in the masked range, False conversely
'****************************************************************
Function Isforbidip (VBADIP)
Dim counter, Arrippart, Arrbadip, Arrbadippart, I, J
For i = 0 to UBound (ARRBADIP)
Counter = 0
Arrbadippart = Split (Arrbadip (i), ".")
For j = 0 to UBound (arrippart)
If (Arrbadippart (j)) = "*" or CStr (Arrippart (j)) = CStr (Arrbadippart (j)) Then
Counter = counter + 1
End If
Next
If counter = 4 Then
Isforbidip = True
Exit Function
End If
Next
Isforbidip = False
End Function
'***************
' Return client IP address
'***************
Function Getuserip ()
Dim IP
IP = Request.ServerVariables ("Http_x_forwarded_for")
If IP = "" Then IP = Request.ServerVariables ("REMOTE_ADDR")
Getuserip = IP
End Function
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service