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)
The following is a reference fragment:
<meta http-equiv= "Content-type" content= "text/html; Charset=gb_2312-80 ">
<meta name= "generator" content= "Microsoft FrontPage Express 2.0"
<style>
<!--
. as{line-height:15px Font-size:9pt}
a:hover {Color:rgb (0,51,240); Text-decoration:underline}
. p9 {font-family: "XXFarEastFont-Arial"; font-size:9pt line-height:15pt}
. p12 {font-family: "XXFarEastFont-Arial"; font-size:12pt line-height:18pt}
a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {Text-decoration:underline;font-size:125%;color:blue}
-->
</style>
<title> ASP page firewall feature demo </title>
<body background= "Back.jpg"
<%
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
%>
<p> <font color= "#ff0000" > 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! <BR> /font> </p>
<form action= "demo.asp" method= "POST" Id=form1 name=form1>
<p> Please enter access password: <input type= "password" name= "Passwd" > <input type= "Submit" value= "confirm" name= "B1";
</p>
</form>
<%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%>
</body>
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.