Web page
To use the ServerVariables property of the Request object, it is used to obtain the value of the environment variable. The syntax used is: request.servervariables (variable), "variable" means the name of the environment variable, such as server host name, Web server software name, and so on, if "variable" is "REMOTE_ADDR" That represents the IP address of the visitor, through which IP address filtering can be achieved.
The source program is as follows: (FileName: Demo.) ASP)
ASP page firewall feature demo
<%
It uses Request.ServerVariables ("REMOTE_ADDR") to get an IP address and save it in a variable rip
Rip=request.servervariables ("REMOTE_ADDR")
Strip=cstr (RIP)
It gets the value of the third segment of the IP address and saves it to the strip
For I=1 to 2
Strip=right (Strip,len (Strip)-instr (1,strip, "."))
Next
Strip=left (Strip,instr (1,strip, ".") -1)
′IP address validity test and password verification, including two aspects of content:
If the IP address is compliant, it is authenticated; If the IP address is not compliant, verify that the password you entered is correct (here is the password "ASP")
if (left (rip,5) <> "127.1" or strip< "1" or "strip>") and request ("PASSWD") <> "ASP" then
%>
Sorry, your IP is <%=rip%>, this page can access the IP is 127.1.1.* to 127.1.50.* between, if you are the intranet users, please confirm that your browser does not use the agent!
/font>
Please enter access password:
<%else%>
A page that a legitimate user can access, where any information can be added
Congratulations, you have successfully passed the page security certification, you can directly use the resources of this site!
<%end if%>
The actual use as long as the above program (such as IP address information) can be, of course, this is only a page in the implementation of security precautions, if a site has more than one page, you can set a session variable to the user logo, in the following page to judge.