ASP implementation limits one IP access to only one method _ Application Tips

Source: Internet
Author: User

Limit an IP access only once, now share the ASP code to everyone:

<% '/////////////////////////////////////////////////////'/////function: One IP address is only allowed to access this page once/////reference:<!--#include f Ile= "check_ip.asp"-->//'////'/////////////////////////////////////////////////////' Response.Charset = 936 ' setting Output encoding for Simplified Chinese ' response.buffer = False ' Close buffer Dim fso,ts,iplist,cfs ' Set Cookies function Setcookie () Response.Cookies ( "Isbrow") = "Brow" Response.Cookies ("Isbrow"). Expires = date+365 End Function ' records IP address functions function Writeip (FileName, ipaddress) Set Fso = Server.CreateObject ("Script Ing. FileSystemObject ") Set ts = fso.opentextfile (Server.MapPath (FileName), 8,true) ts. WriteLine IPAddress ts. The close Set ts = The Nothing Set FSO = the Nothing End Function ' reads IP address functions function readiplist (FileName) Set fso = Server.crea Teobject ("Scripting.FileSystemObject") If not Fso.fileexists (Server.MapPath (FileName)) Then CreateFile ("Iplist.txt" The Exit Function end If Set ts = fso.opentextfile (Server.MapPath (FileName)) IPList = ts. ReadAll ts. Close Setts = Nothing Set fso = no readiplist = IPList End Function ' Create file functions function CreateFile (FileName) Set fso = Ser Ver. CreateObject ("Scripting.FileSystemObject") Set cfs = Fso.createtextfile (Server.MapPath (FileName)) Cfs.close Set cfs = N othing Set Fso = Nothing End Function ' closes the current IE window function (Note: IE6 is passed, other browsers are not tested) function CloseWindow () ' Response.Write ' &LT;SCR Ipt>window.location= ' Javascript:window.opener=null;window.close (); ' </script> "Response.Redirect" http://www.baidu.com "end Function Ip = Request.ServerVariables (" remote_addr ") ' Get Browser IP Address cookie = request.cookies ("Isbrow") ' Get current cookies ' Response.Write cookie If request.servervariables ("Http_x_for 
Warded_for ") <>" "Then Response.Write" This site is not allowed to use proxy access "Response.End () Else If Cookie =" Brow "Then CloseWindow () else If Instr (readiplist ("Iplist.txt"), IP) <> 0 Then CloseWindow () Else Writeip "Iplist.txt", IP End If setc
 Ookie () End If End If%>

The above is to share to everyone's ASP implementation code, I hope to help you learn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.