{"id":240,"date":"2005-12-15T11:12:18","date_gmt":"2005-12-15T03:12:18","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/240.aspx"},"modified":"2006-03-26T19:03:23","modified_gmt":"2006-03-26T11:03:23","slug":"%e4%b9%9f%e8%ae%a8%e8%ae%ba%e4%b8%80%e4%b8%8bASP%e5%9c%a8%e7%ba%bf%e4%ba%ba%e6%95%b0%e7%bb%9f%e8%ae%a1%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/240","title":{"rendered":"\u4e5f\u8ba8\u8bba\u4e00\u4e0bASP\u5728\u7ebf\u4eba\u6570\u7edf\u8ba1\uff08\u4e8c\uff09"},"content":{"rendered":"<p>\u7b2c\u4e09\u79cd\u65b9\u6cd5\u548c\u8fd9\u4e2a\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u662f\u6839\u636e\u7528\u6237\u7684 IP \u6765\u5224\u65ad\u5728\u7ebf\u4eba\u6570\uff0c\u8fd9\u6837\u5c31\u907f\u514d\u4e86\u4e09\u9762\u7684\u7279\u6b8a\u60c5\u51b5\uff0c\u800c\u4e14\u4e0d\u9700\u8981\u7528 session \u54e6\uff01<br \/>\u9996\u5148\u8fd8\u662f\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\uff1acount.mdb\uff0c\u5305\u542b\u4e00\u4e2a\u8868\uff1acount\uff0c\u8868\u4e2d\u5b57\u6bb5\u4e3a\uff1a<\/p>\n<blockquote>\n<p>ID  \u81ea\u52a8\u7f16\u53f7<br \/>ip  \u6587\u672c<br \/>posttime \u65e5\u671f\/\u65f6\u95f4<\/p>\n<\/blockquote>\n<p>\u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff0c\u6587\u4ef6\u540d\u4e3a online.asp\uff1a<br \/>[#afdream.com#]<\/p>\n<blockquote>\n<p><% <br \/>&#8216;&#8212;&#8212;&#8212;\u5b9a\u4e49\u53d8\u91cf<br \/>dim rs<br \/>dim ip<br \/>dim timeouted<br \/>dim x<br \/>dim conn<br \/>dim dbpath<br \/>&#8216;&#8212;&#8212;&#8212;\u5b9a\u4e49\u53d8\u91cf\u7ed3\u675f<\/p>\n<p>&#8216;&#8212;&#8212;&#8212;\u5efa\u8bae\u6570\u636e\u5e93\u94fe\u63a5<br \/>set conn=server.cr&#101;ateobject(&#8220;adodb.connection&#8221;)<br \/>DBPath = Server.MapPath(&#8220;count.mdb&#8221;)<br \/>conn.Open &#8220;driver={Microsoft Access Driver (*.mdb)};dbq=&#8221; &#038; DBPath<br \/>&#8216;&#8212;&#8212;&#8212;\u5efa\u7acb\u6570\u636e\u5e93\u94fe\u63a5\u5b8c\u6210 <\/p>\n<p>&#8216;&#8212;&#8212;&#8212;\u65b0\u5efa\u6570\u636e\u5e93RS\u5bf9\u8c61<br \/>set rs = server.cr&#101;ateobject(&#8220;adodb.recordset&#8221;)<br \/>&#8216;&#8212;&#8212;&#8212;\u5efa\u7acb\u6570\u636e\u5e93RS\u5bf9\u8c61\u5b8c\u6210<\/p>\n<p>&#8216;&#8212;&#8212;&#8212;\u8bfb\u53d6\u5ba2\u6237\u7aefIP\u5730\u5740<br \/>ip = Request.ServerVariables(&#8220;HTTP_X_FORWARDED_FOR&#8221;) &#8216;\u82e5\u662f\u5bf9\u65b9\u4f7f\u7528\u7684\u662f\u4ee3\u7406\u670d\u52a1\u5668\u4e0a\u7f51\u7684\u8bdd,\u7528Request.ServerVariables(&#8220;HTTP_X_FORWARDED_FOR&#8221;)\u53ef\u4ee5\u5f97\u5230\u5bf9\u65b9\u7684\u771f\u5b9eIP,\u82e5\u5bf9\u65b9\u4e0d\u662f\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u4e0a\u7f51\u7684\u8bdd,\u5219IP\u7684\u503c\u4e3a\u7a7a<br \/>If ip = &#8220;&#8221; Then ip = Request.ServerVariables(&#8220;REMOTE_ADDR&#8221;) &#8216;\u5982\u679cIP\u7684\u503c\u4e3a\u7a7a,\u5219\u5f97\u5230\u4ed6\u7684\u672c\u5730\u5ba2\u6237\u7aef\u5730\u5740<br \/>&#8216;&#8212;&#8212;&#8212;IP\u8bfb\u53d6\u5b8c\u6bd5<\/p>\n<p>&#8216;&#8212;&#8212;&#8212;\u8bfb\u51fa\u6570\u636e\u5e93\u5185\u8fd120\u5206\u949f\u6240\u52a0\u5165\u7684\u65b0\u5185\u5bb9\u6570,group by ip-\u8868IP\u503c\u76f8\u540c\u7684\u8bb0\u4f5c1<br \/>sql=&#8221;sel&#101;ct ip from count wh&#101;re posttime >= dateadd(&#8216;n&#8217;,-20,now()) group by ip&#8221;<br \/>rs.Open sql,conn,1,1<br \/>online=rs.RecordCount<br \/>rs.Close<br \/>&#8216;&#8212;&#8212;&#8212;\u5f97\u5230\u5728\u7ebf\u4eba\u6570\u503c<\/p>\n<p>&#8216;&#8212;&#8212;&#8212;\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5df2\u7ecf\u6709\u76f8\u540c\u7684\u503c,\u6ca1\u6709\u5219 x=&#8221;yes&#8221;\u6709\u5219x=&#8221;no&#8221; <br \/>sql=&#8221;sel&#101;ct ip from count wh&#101;re ip='&#8221; &#038; ip &#038; &#8220;&#8216;&#8221;<br \/>rs.Open sql,conn,1,1<br \/>if rs.eof and rs.bof then <br \/>x=&#8221;yes&#8221;<br \/>else<br \/>x=&#8221;no&#8221;<br \/>end if <br \/>rs.close<br \/>&#8216;&#8212;&#8212;&#8211;\u5224\u65ad\u5b8c\u6bd5<\/p>\n<p>&#8216;&#8212;&#8212;&#8211;\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u76f8\u540c\u7684\u503c\u5219\u52a0\u5165\u4e00\u4e2a\u65b0\u503c<br \/>if x=&#8221;yes&#8221; then&#8217;\u3000\u3000\u3000\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\uff29\uff30\u5219\u589e\u52a0\u4e00\u6761\u8bb0\u5f55<br \/>sql=&#8221;sel&#101;ct top 1 * from count&#8221;<br \/>rs.Open sql,conn,1,3<br \/>rs.AddNew<br \/>rs(&#8220;ip&#8221;)=ip<br \/>rs(&#8220;posttime&#8221;)=now()<br \/>rs.up&#100;ate<br \/>rs.close <br \/>else\u3000\u3000\u3000&#8217;\u5982\u679c\u6709\u8fd9\u4e2a\uff29\uff30\u5219\u628a\u65f6\u95f4\u6539\u4e3a\u73b0\u5728\u7684\u65f6\u95f4<\/p>\n<p>sql=&#8221;sel&#101;ct * from count wh&#101;re ip='&#8221; &#038; ip &#038; &#8220;&#8216;&#8221;<br \/>rs.Open sql,conn,1,3<br \/>rs(&#8220;posttime&#8221;)=now()<br \/>rs.up&#100;ate<br \/>rs.close <br \/>end if<br \/>&#8216;&#8212;&#8212;&#8211;\u5224\u65ad\u52a0\u5165\u5b8c\u6bd5<\/p>\n<p>&#8216;&#8212;&#8212;&#8211;\u5220\u966420\u5206\u949f\u4ee5\u524d\u6240\u52a0\u5165\u7684\u503c<br \/>timeouted = dateadd(&#8220;n&#8221;, -20, now())<br \/>sql=&#8221;del&#101;te * from count wh&#101;re posttime < #\" &#038; timeouted &#038; \"#\"<br \/>conn.Execute sql<br \/>&#8216;&#8212;&#8212;&#8211;\u5220\u9664\u5b8c\u6bd5<\/p>\n<p>&#8216;&#8212;&#8212;&#8211;\u5173\u95ed\u6570\u636e\u5bf9\u8c61<br \/>set rs=nothing<br \/>conn.Close <br \/>set conn=nothing<br \/>%><br \/>document.write(&#8220;\u5171<%=online%>\u4eba\u5728\u7ebf&#8221;)<\/p>\n<\/blockquote>\n<p>\u8c03\u7528\u65b9\u5f0f\u5982\u4e0b\uff0c\u5728\u4f60\u8981\u663e\u793a\u7684\u5730\u65b9\u63d2\u5165\u5982\u4e0b\u4ee3\u7801\uff08\u6ce8\u610f\u8def\u5f84\u4e00\u5b9a\u8981\u5199\u5bf9\u54e6\uff01\uff09\uff1a<\/p>\n<blockquote>\n<p><script language=\u201cjavascript\u201d src=\u201conline.asp\u201d><\/script><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e09\u79cd\u65b9\u6cd5\u548c\u8fd9\u4e2a\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u662f\u6839\u636e\u7528\u6237\u7684 IP \u6765\u5224\u65ad\u5728\u7ebf\u4eba\u6570\uff0c\u8fd9\u6837\u5c31\u907f\u514d\u4e86\u4e09\u9762\u7684\u7279\u6b8a\u60c5\u51b5\uff0c\u800c\u4e14\u4e0d\u9700\u8981\u7528 session \u54e6\uff01\u9996\u5148\u8fd8\u662f\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\uff1acount.mdb\uff0c\u5305\u542b\u4e00\u4e2a\u8868\uff1acount\uff0c\u8868\u4e2d\u5b57\u6bb5\u4e3a\uff1a ID \u81ea\u52a8\u7f16\u53f7ip \u6587\u672cposttime \u65e5\u671f\/\u65f6\u95f4 \u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff0c\u6587\u4ef6\u540d\u4e3a online.asp\uff1a[#afdream.com#] = dateadd(&#8216;n&#8217;,-20,now()) group by ip&#8221;rs.Open sql,conn,1,1online=rs.RecordCountrs.Close&#8216;&#8212;&#8212;&#8212;\u5f97\u5230\u5728\u7ebf\u4eba\u6570\u503c &#8216;&#8212;&#8212;&#8212;\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u662f\u5426\u5df2\u7ecf\u6709\u76f8\u540c\u7684\u503c,\u6ca1\u6709\u5219 x=&#8221;yes&#8221;\u6709\u5219x=&#8221;no&#8221; sql=&#8221;sel&#101;ct ip from count wh&#101;re ip=&#8217;&#8221; &#038; ip &#038; &#8220;&#8216;&#8221;rs.Open sql,conn,1,1if rs.eof and rs.bof then x=&#8221;yes&#8221;elsex=&#8221;no&#8221;end if rs.close&#8216;&#8212;&#8212;&#8211;\u5224\u65ad\u5b8c\u6bd5 &#8216;&#8212;&#8212;&#8211;\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u76f8\u540c\u7684\u503c\u5219\u52a0\u5165\u4e00\u4e2a\u65b0\u503cif x=&#8221;yes&#8221; then&#8217;\u3000\u3000\u3000\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\uff29\uff30\u5219\u589e\u52a0\u4e00\u6761\u8bb0\u5f55sql=&#8221;sel&#101;ct top 1 * from count&#8221;rs.Open sql,conn,1,3rs.AddNewrs(&#8220;ip&#8221;)=iprs(&#8220;posttime&#8221;)=now()rs.up&#100;aters.close else\u3000\u3000\u3000&#8217;\u5982\u679c\u6709\u8fd9\u4e2a\uff29\uff30\u5219\u628a\u65f6\u95f4\u6539\u4e3a\u73b0\u5728\u7684\u65f6\u95f4 sql=&#8221;sel&#101;ct * from count wh&#101;re ip=&#8217;&#8221; &#038; ip &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[25,68,26],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-coding","tag-ASP","tag-68","tag-26"],"views":42751,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}