Limit an IP access only once, reproduced in the BACDE technology blog, now the ASP code to share to everyone:
<%
'/////////////////////////////////////////////////////
'// //
'//function: One IP address is only allowed to access this page once//
'//Author: bacde March 1, 2010 //
'//reference:<!--#include file= "check_ip.asp"-->//
'// //
'/////////////////////////////////////////////////////
' Response.Charset = 936 ' Set output encoding to Simplified Chinese
' Response.Buffer = False ' closes buffer
Dim fso,ts,iplist,cfs
' Set cookies function
Function Setcookie ()
response.cookies ("isbrow") = "Brow"
response.cookies ("Isbrow"). Expires = date+365
End Function
' record IP address function
Function Writeip (FileName, IPAddress)
Set Fso = Server.CreateObject ("Scripting.FileSystemObject")
Set ts = fso.opentextfile (Server.MapPath (FileName), 8,true)
ts. WriteLine IPAddress
ts. Close
Set ts = Nothing
Set Fso = Nothing
End Function
' read IP address function
Function readiplist (FileName)
Set Fso = Server.CreateObject ("Scripting.FileSystemObject")
If not fso.fileexists (Server.MapPath (FileName)) Then
CreateFile ("Iplist.txt")
Exit Function
End If
Set ts = fso.opentextfile (Server.MapPath (FileName))
iplist = ts. ReadAll
ts. Close
Set ts = Nothing
Set Fso = Nothing
readiplist = IPList
End Function
' Create a file function
Function CreateFile (FileName)
Set Fso = Server.CreateObject ("Scripting.FileSystemObject")
Set Cfs = Fso.createtextfile (Server.MapPath (FileName))
cfs.close
Set Cfs = Nothing
Set Fso = Nothing
End Function
' Closes the current IE window function (Note: IE6 is passed, other browsers are not tested)
Function CloseWindow ()
' Response.Write ' <script>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
cookies = request.cookies ("Isbrow") ' Get current cookies
' Response.Write Cookie
If request.servervariables ("http_x_forwarded_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
Setcookie ()
End If
End If
%>