<%@ CODEPAGE = "936" %> <% '##### ★ 参 数 设 置 ★ ##### ' 1、保存IP个数 SaveIP = 50 ' 2、数据文件名 DataFile = "#CountData.mdb" ' 3、统计器名称 CountName = "访问统计" ' 4、是否允许使用升级功能 CanUpgrade = 0 '##### ★ 代 码 开 始 ★ #####(以下请勿修改) ' 忽略所有错误 on error resume next ' 得到本文件的名字 mename=Request.ServerVariables("SCRIPT_NAME") ' 创建数据对象 tpage=Request("tpage") if tpage<> "noado" then Set conn=server.createobject("adodb.connection") If Err<>0 then Response.Redirect mename & "?tpage=noado" DBPath = Server.MapPath(DataFile) conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath end if '******************************* ' 转入相应的页面 '******************************* select case tpage '*************************************************************** ' 查看页面 case "view" %> <%=CountName%> - 查看统计数据 <% strold=ReadData() if not(isnull(strold) or len(strOld)<6) then '分解数据文件,获得数据 vstr=split(strold,vbcrlf) '访问天数、平均每天访问量 vdays=now()-cdate(vstr(4)) vdayavg=vstr(1)/vdays vdays=int((vdays*10^3)+0.5)/10^3 if vdays<1 then vdays="0" & vdays vdayavg=int((vdayavg*10^3)+0.5)/10^3 %>
<%=CountName%>
 总浏览量  <%=vstr(0)%>
 总访问数  <%=vstr(1)%>
 今日访问数  <%=vstr(2)%>
 昨日访问数  <%=vstr(3)%>
 开始统计日期  <%=vstr(4)%>
 统计天数  <%=vdays%>
 平均日访问量  <%=vdayavg%>
 最高日访问量  <%=vstr(7)%>
   发生日期  <%=vstr(8)%>
<%else%>
还没有任何统计数据。请将嵌入代码放
在您要统计的页面。
<%end if%> <% '*************************************************************** ' 不支持ADO的错误页面 case "upgrade" %> <%=CountName%> - 从旧版本升级
<% if canupgrade=true then textdata =Request("textdata") fsostr =Request("fsostr") if fsostr="" or textdata="" then %> <% else strok="" ' 数据文件的绝对路径 thedatafile=server.MapPath(textdata) '创建FSO对象,如果不支持FSO,则转入错误页 Set FSO = CreateObject(FSOstr) If Err<>0 then strok="
因为服务器不支持FSO数据对象,升级失败。" else ' 检查数据文件是否存在 infile=fso.FileExists(thedatafile) if infile=false then strok="
因为您指定的文本数据文件不存在,升级失败。" else set thefile=fso.OpenTextFile(thedatafile) stroldfile=thefile.readall thefile.close set thefile=nothing writedata stroldfile strok="
版本升级完成!" end if end if %> <% end if else '是否允许升级 %> <% end if %>

 ∷∷∷ 版本升级 ∷∷∷

 如果旧版本未做过任何修改,则下列文本框
 中的内容请不要改动
 1、原来保存数据的文本文件是
  
 2、创建FSO对象使用的字串
  

 

∷∷∷ 版本升级 ∷∷∷
<%=strok%>
∷∷∷ 版本升级 ∷∷∷

本系统升级功能已设置为禁止!
<% '*************************************************************** ' 不支持ADO的错误页面 case "noado" %> <%=CountName%> - 错误信息
对不起,您的服务器不支持ADO数据
对象,无法使用本系统。
<% '*************************************************************** ' 计数页面 case else ' 网页立即过期,防止漏统计 Response.Expires = -1 ' 检查客户端IP vip=Request.ServerVariables("Remote_Addr") '读取旧数据 strOld=ReadData() '如果还没有统计数据 if isnull(strold) or len(strOld)<6 then vtop=1 vips=1 vtoday=1 vyesterday = 0 vstarttime = now() vtodaytime = date() vmax=1 vmaxtime=date() SaveStr=vtop & VbCrlf & vips & VbCrlf & vtoday & VbCrlf & vyesterday & VbCrlf & _ vstarttime & VbCrlf & vtodaytime & vbcrlf & "#" & vip & "#" & vbcrlf & vmax & vbcrlf & vmaxtime '写入数据库 WriteData(savestr) '如果已经存在统计数据 else '分解数据文件,获得数据 vstr=split(StrOld,vbcrlf) vtop=vstr(0) vips=vstr(1) vtoday=vstr(2) vyesterday=vstr(3) vstarttime=vstr(4) vtodaytime=vstr(5) vsaveips=vstr(6) if ubound(vstr)>7 then vmax=vstr(7) vmaxtime=vstr(8) else vmax=0 end if '向现有数据中追加值 vtop=vtop+1 if instr(vsaveips,"#" & vip & "#")=false then vips=vips+1 if cdate(vtodaytime)=date() then vtoday=vtoday+1 else vyesterday=vtoday vtoday=1 vtodaytime=date() end if if clng(vtoday)>clng(vmax) then vmax=vtoday vmaxtime=date() end if vsaveips=left(vsaveips,len(vsaveips)-1) vsaveips=right(vsaveips,len(vsaveips)-1) howip=split(vsaveips,"#") if ubound(howip) < SaveIP then vsaveips="#" & vsaveips & "#" & vip & "#" else vsaveips=replace("#" & vsaveips,"#" & howip(0) & "#","#") & "#" & vip & "#" end if end if '写入数据文件 SaveStr=vtop & VbCrlf & vips & VbCrlf & vtoday & VbCrlf & vyesterday & VbCrlf & _ vstarttime & VbCrlf & vtodaytime & vbcrlf & vsaveips & vbcrlf & vmax & vbcrlf & vmaxtime '写入数据库 WriteData(Savestr) end if '根据要求输出 style=Request("style") select case style case "counter" 'LOGO outstr="
" outstr=outstr & "总访问量: " & vips & "  今日访问: " & vtoday & "  昨日访问: " & vyesterday & "  最高日访问: " & vmax & "  发生日期: " & vmaxtime outstr=outstr & "" outstr=outstr & "
" case "icon" 'ICON outstr="" case "atext" '带有连接的访问数 outstr="" & vips & "" case "textview" '不带连接的浏览数 outstr=vtop case "textip" '不带连接的访问数 outstr=vips end select '输出 Response.Write "document.write(" & chr(34) & outstr & chr(34) & ")" end select '选择要浏览的页面 if tpage<> "noado" then ' 关闭数据对象 set conn=nothing end if '****************** 自定义函数 ******************** '读取数据库中的数据 function ReadData() set rs=conn.Execute("select * from data") ReadData=rs(0) set rs=nothing end function '将数据写入数据库 function WriteData(strcontent) conn.Execute("update data set content='" & strcontent & "'") end function %>