count.asp

来自「一款优秀的网站访问计数器」· ASP 代码 · 共 63 行

ASP
63
字号
<%
Dim Cnn
Set Cnn = Server.CreateObject("ADODB.Connection")
Cnn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../admin/bme.mdb")

dim uip,uie
   uip = Request.ServerVariables("remote_addr")
   uie = request.servervariables("http_user_agent")

dim rs1,jsqsql,jsqtype

jsqtype = "3"

Rem  这里选择计数方式
Rem  jsqtype = "1",每刷新一次,计数+1
Rem  jsqtype = "2",每访问一次计数+1,刷新不增加
Rem  jsqtype = "3",每一IP,一日之内只记录一次,再次访问,刷新均不增加

if jsqtype="1" then
   jsqsql = "insert into jsq (visitdate,visittime,userip,userie) values (date(),time(),'"&uip&"','"&uie&"')"
   cnn.execute jsqsql
   set jsqsql = nothing
elseif jsqtype="2" then
   if session("jsqhascount")<>"hascount" then
      jsqsql = "insert into jsq (visitdate,visittime,userip,userie) values (date(),time(),'"&uip&"','"&uie&"')"
      cnn.execute jsqsql
      set jsqsql = nothing
      session("jsqhascount")="hascount"
   end if
elseif jsqtype="3" then
   set rs1 = Server.CreateObject("ADODB.RecordSet")
   rs1.open "select id from jsq where visitdate=#"&date()&"#",cnn,1,1
   if rs1.eof then
      rs1.close
      set rs1=nothing
      jsqsql = "insert into jsq (visitdate,visittime,userip,userie) values (date(),time(),'"&uip&"','"&uie&"')"
      cnn.execute jsqsql
      set jsqsql = nothing
   end if
end if

dim jsq,totalhits,Length
   set jsq = Server.CreateObject("ADODB.RecordSet")
   jsq.open "select id from jsq",cnn,1,1
   totalhits = jsq.recordcount
   jsq.close
   set jsq=nothing

cnn.close
set cnn=nothing

   Length = Len(totalhits)
   do until length >= 6
      totalhits = "0" & totalhits
      length = length + 1
   loop
   for i = 1 to Length
   %>
      document.write('<img src="2/<%=Mid(totalhits,i,1)%>.gif" border="0">');
   <%
   next
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?