First, prohibit the designation of IP Web site, and perform the appropriate actions:
Copy Code code as follows:
<%
Dim Ip,ipstring,visitip
' Set IP address, with ' | ' Separated
Ipstring= "|192.168.0.42|192.168.0.43|"
' Get IP Address
IP = Request.ServerVariables ("Http_x_forwarded_for")
If IP = "" Then
IP = Request.ServerVariables ("REMOTE_ADDR")
End If
Visitip= "|" &IP& "|"
If InStr (1,ipstring,visitip) >0 Then
' Comply with the prohibited IP to perform the appropriate action
Response.Write "Your IP Prohibit access"
Response.End
End If
%>
Second, the code to modify, only allow the designated IP Web site, and perform the appropriate operation:
Copy Code code as follows:
<%
Dim Ip,ipstring,visitip
' Set IP address, with ' | ' Separated
Ipstring= "|192.168.0.42|192.168.0.42|"
' Get IP Address
IP = Request.ServerVariables ("Http_x_forwarded_for")
If IP = "" Then
IP = Request.ServerVariables ("REMOTE_ADDR")
End If
Visitip= "|" &IP& "|"
If InStr (1,ipstring,visitip) >0 Then
' Compliant IP to perform the appropriate action
Response.Write Your IP can access "
Else
' Non-conforming IP performs the appropriate action
Response.Write "Your IP Prohibit access"
Response.End
End If
%>
Third, the actual application of the use of methods:
Then save the above code as a ip.asp file and use the following method to add the following code to the ASP program page
<!--#include file= "ip.asp"-->