Sub Application_OnStart
Application("ActiveUsers") = 0
End Sub
Sub Session_OnStart
Session.Timeout = 20
Session("Start") = now
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
</SCRIPT>
<!--#include file=conn.asp-->
<% '统计访问人数!!
dim mycount
Set rs=Server.CreateObject("ADODB.Recordset")
sql= "select * from mycount where id=1"
rs.open sql,conn,1,3
rs("count")=rs("count")+1
rs.update
mycount=rs("count")
rs.close
set rs=nothing
%>
<% '纪录访问者的ip!!!
dim rs1,sql1
set rs1 = server.CreateObject("adodb.recordset")
sql1 = "select * from ip"
rs1.open sql1,conn,3,3
set rs11 = server.CreateObject("adodb.recordset")
sql11 = "select * from ip where theip='"& uip &"' and theday='"& uday &"' and themonth='"& umonth &"' and theyear='"& uyear &"'"
rs11.open sql11,conn,3,3
if not rs11.eof then
rs11("count")=rs11("count")+1
rs11.update '这里记住要update!!
else
rs1.addnew
rs1("theip")=uip
rs1("theyear")=year(now())
rs1("themonth")=month(now())
rs1("theday")=day(now())
rs1("thetime")=now()
rs1("count")=1
rs1.update
rs1.close
set rs1=nothing
end if
%>
<% '取得今天的访问人数!!!
dim rs2,sql2,todaycount
set rs2 = server.CreateObject("adodb.recordset")
sql2 = "select * from ip where theday='"&day(now())&"' and themonth='"&month(now())&"'"
rs2.open sql2,conn,3,3
do while not rs2.eof
todaycount=cint(rs2("count"))+cint(todaycount)
rs2.movenext
loop
rs2.close
set rs2=nothing
%>
<% '取得昨天的访问人数
dim rs3,sql3,sukeycount
set rs3 = server.CreateObject("adodb.recordset")
sql3 = "select * from ip where theday='"&day(now())-1&"' and themonth='"&month(now())&"'"
rs3.open sql3,conn,3,3
do while not rs3.eof
sukeycount=cint(rs3("count")) + cint(sukeycount)
rs3.movenext
loop
rs3.close
set rs3=nothing
%>