Implementation of the program code for restricting IP access under ASP-application techniques

Source: Internet
Author: User
<%
"Get the address of the visitor
Ip=request.servervariables ("REMOTE_ADDR")

' The allowed IP address segment is 10.0.0.0~10.68.63.255
allowip1= "10.0.0.0"
Allowip2= "10.68.10.71"
Response.Write Checkip (IP,ALLOWIP1,ALLOWIP2)
function Checkip (IP,ALLOWIP1,ALLOWIP2)
Dim Check (4)
Checkip=false
Ipstr=split (IP, ".")
Allow1=split (Allowip1, ".")
Allow2=split (ALLOWIP2, ".")
If CInt (Allow1 (0)) >cint (allow2 (0)) then ' to determine if the IP address segment is legitimate
Response.Write "No Access"
Exit function
End If
For i=0 to UBound (IPSTR)
If CInt (Allow1 (i)) <cint (Allow2 (i)) then
If CInt (Allow1 (i)) =cint (Ipstr (i)) then
Check (i) =true
Checkip=true
Exit For
Else
If CInt (Ipstr (i)) <cint (Allow2 (i)) then
Check (i) =true
Checkip=true
Exit For
Else
If CInt (Ipstr (i)) >cint (Allow2 (i)) then
Check (i) =false
Checkip=false
Exit For
Else
Check (i) =true
Checkip=true
End If
End If
End If
Else
If CInt (Allow1 (i)) >cint (Ipstr (i)) or CInt (Allow1 (i)) <cint (Ipstr (i)) then
Check (i) =false
Checkip=false
If I<>ubound (IPSTR) Then
Exit For
End If
Else
Check (i) =true
End If
End If
Next
if (check (0) =true and check (1) =true and check (2) =true and check (3) =false) and (CInt (Allow2 (2)) >cint (IPSTR (2))) then
Checkip=true
End If
End Function
%>
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.