この記事では、主にIPアクセスを1回のASP実装に制限する方法を紹介します。
IPを1回だけアクセスするように制限すると、ASPコードを共有します。
- <%
- '/////////////////////////////////////// ////////////////// /////
- '////
- '//関数:1つのIPアドレスでは、このページに1回のみアクセスできます//
- '// QUOTE:<! - #includefile = check_ip.asp-> //
- '////
- '/////////////////////////////////////// ////////////////// /////
- 'Response.Charset = 936'単純化された中国人に出力エンコードを設定します
- 'Response.Buffer = false'バッファを閉じます
- dimfso、ts、iplist、cfs
- 'Cookies関数を設定します
- functionsetcookie()
- Response.Cookies(isbrow)=眉
- Response.Cookies(isbrow).expires = date+365
- エンド機能
- 'IPアドレス機能を記録します
- functionwriteip(filename、iPaddress)
- setFSO = server.createObject(scripting.filesystemObject)
- setts = fso.opentextfile(server.mappath(filename)、8、true)
- Ts.WriteLineIpAddress
- ts.close
- セット=何もない
- setfso =何もない
- エンド機能
- 'IPアドレス関数を読む
- functionreadiprist(filename)
- setFSO = server.createObject(scripting.filesystemObject)
- ifnotfso.fileexists(server.mappath(filename))then
- createfile(iplist.txt)
- exitFunction
- endif
- setts = fso.opentextfile(server.mappath(filename)))
- iplist = ts.readall
- ts.close
- セット=何もない
- setfso =何もない
- readiplist = iplist
- エンド機能
- 'ファイル関数を作成します
- functionCreatefile(ファイル名)
- setFSO = server.createObject(scripting.filesystemObject)
- setcfs = fso.createTextfile(server.mappath(filename))
- cfs.close
- setcfs = Nothing
- setfso =何もない
- エンド機能
- '現在のIEウィンドウ関数を閉じます(注:IE6の下で渡され、他のブラウザはそれをテストしていません)
- functionclosewindow()
- 'Response.Write <Script> Window.Location =' JavaScript:window.opener = null; window.close(); '</scrip>
- Response.redirectthttp://www.baidu.com
- エンド機能
- ip = request.servervariables(remote_addr) '視聴者のIPアドレスを取得します
- cookie = request.cookies(isbrow) '現在のCookieを取得します
- 'Response.WriteCookie
- ifrequest.servervariables(http_x_forwarded_for)<> then
- Response.Writeこのサイトでは、プロキシアクセスを許可しません
- Response.End()
- それ以外
- ifcookie = browthen
- closewindow()
- それ以外
- ifinstr(readiplist(iplist.txt)、ip)<> 0then
- closewindow()
- それ以外
- writeipiplist.txt、ip
- endif
- setCookie()
- endif
- endif
- %>
上記は、あなたと共有されるASP実装コードです。それがあなたの学習に役立つことを願っています。