1. Disable the specified IP address to prevent website attacks and perform the following operations:
Copy codeThe Code is as follows: <%
Dim IP, IPString, VisitIP
'Set IP addresses separated by' |'
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
'The prohibited IP address is allowed to perform the corresponding operation
Response. write "Access prohibited from your IP address"
Response. end
End If
%>
2. modify the code to only allow the specified IP address to defend against website attacks and perform the following operations:Copy codeThe Code is as follows: <%
Dim IP, IPString, VisitIP
'Set IP addresses separated by' |'
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
'Operation is performed on the correct IP address.
Response. write your IP address can access"
Else
'The non-conforming IP address performs the corresponding operation
Response. write "Access prohibited from your IP address"
Response. end
End If
%>
Iii. Usage in practical application:
Save the above Code as an IP. asp file, and then add the following code to the asp program page using the following method:
<! -- # Include file = "IP. asp" -->