Recommended: Reveal the simple way to solve AJAX Chinese garbled code When using AJAX to develop websites, friends often encounter garbled code problems, and it is difficult to find a solution at once. In fact, it is very simple to solve the problem of Chinese garbled by AJAX. 1. Server program: The following is the reference
To use the ServerVariables property of the request object, use it to get the value of the environment variable. The syntax used is: Request.ServerVariables(variable), variable represents the name of the environment variable, such as the server host name, Web server software name, etc. If the variable is REMOTE_ADDR, it represents the visitor's IP address, and through it, the IP address filtering can be achieved.
The source program is as follows: (File name: demo.ASP)
| The following is the quoted content: <html> <head> <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: 安体; font-size: 9pt; line-height: 15pt} .p12 { font-family: 安体; 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 function demonstration</title> </head> <body background=back.jpg> <% ′ Use Request.ServerVariables(REMOTE_ADDR) to get the IP address and save it in the variable rip rip=Request.ServerVariables(REMOTE_ADDR) strip=cstr(rip) ′ Get the value of the third segment of the IP address and save it to strip for i=1 to 2 strip=right(strip,len(strip)-instr(1,strip,.))) next strip=left(str,instr(1,str,.)-1) ′IP address validity verification and password verification, including two aspects: 'If the IP address is in compliance, pass verification; if the IP address does not conform, check whether the entered password is correct (here the password is asp) if (left(rip,5) <> 127.1 or strip<1 or strip>50) and request(Passwd)<>asp then %> <p<font color=#FF0000> Sorry, your IP is <%=rip%>, the IP that can be accessed on this page is between 127.1.1.* and 127.1.50.*. If you are a user of the internal network of this unit, please make sure that your browser does not use a proxy! <BR></font> <form action=demo.asp method=POST id=form1 name=form1> <p> Please enter the access password: <input type=password name=Passwd > <input type=submit value=confirm name=B1>; </p> </form> <%else %> ′A page that legal users can access, any information can be added here Congratulations, you have successfully passed the page security certification and can directly use the resources of this site! <%end if %> </body> </html> |
In fact, just slightly modify the above program (such as IP address and other information). Of course, this only implements security prevention functions in one page. If a website has multiple pages, you can set a session variable to mark the user to make judgments in the subsequent page.
Share: Teach you 17 basic ASP programming typical codes 1. Method for ASP to obtain input data in table: GET POST 1.get: After the user adds the data to the URL, the format is "? Field 1 = input data 1 & Field 2 = input data 2 &..., and then send it to the server. For example: action is www.abc.c