'
'请设置参数
Option Explicit
Dim StartDate,StartCount,DelAll,Refresh,Countdigit,ImgPath
StartDate="2005-2-28" '设开始统计日期,必须按照 "2002-09-07"这样的格式输入日期,而日期不能在当前日期只后,2005-02-25是错误的表达,正确的表达是2005-2-25
StartCount=0 '设定统计初始访问量
ImgPath="count/img/" 'img目录的URL
Countdigit=6 '计数器位数,如果你不想让0.gif图片补齐的话请设置为1
Refresh=False '是否防止刷新?True防止,False不防止
DelAll=False '如果要清空数据库所有记录请把DellAll的值该为 True,并运行一次Count.asp即可,并再改回来False值
'参数设置完毕
''''''''''''''''打开数据库'''''''''''
Dim conn
Dim connstr
Dim db
db="qojuyyqjhjj34#.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.Open connstr
'''''''''本程序中用到的函数'''''''''''
Function OutImg(digit)
Dim i,Lencount,Out
Lencount=Len(digit)
Out=""
For i=1 to Countdigit-Lencount
Out=Out&""
Next
IF digit=0 Then
Out=Out&""
Else
For i=1 to Lencount
Out=Out&""
Next
End IF
OutImg=Out
End Function
''''''''''''''''''''如果DellAll为真,则清空记录
IF DelAll Then Conn.Execute "delete from egecount"
'''''''''''''插入记录'''''''''''''
GuestDate=Date
IF Not Refresh Then Session("Count")=False
IF Not Session("Count") Then Conn.Execute "insert into egecount(guestdate) values('"&GuestDate&"')"
Session("Count")=True
Dim AllCount,TodayCount,MonthCount,PerCount,GuestDate
AllCount=Conn.Execute("select Count(ID) from egecount")(0)+StartCount
MonthCount=Conn.Execute("select Count(ID) from egecount where Year(guestdate)='"&Year(GuestDate)&"' and Month(guestdate)='"&Month(GuestDate)&"'")(0)
TodayCount=Conn.Execute("select Count(ID) from egecount where guestdate=#"&GuestDate&"#")(0)
PerCount=Int(AllCount/(DateDiff("d",StartDate,GuestDate)+1))
Dim OutPut
OutPut="本站自"&StartDate&"起总共访问量:"&OutImg(AllCount)&"本日访问量:"&OutImg(TodayCount)&"本月访问量:"&OutImg(MonthCount)&"每日访问量:"&OutImg(PerCount)
Response.Write "document.write('"&Output&"');"
Conn.Close
Set Conn=Nothing
%>