欢迎光临爱时尚女性网

<%
爀nd sub
%>
<%
爏ub writeDayStatic(userid)
'生成日统计
爄=0
燿im strArray(100)
爁or i=0 to 23
strArray(i)= cStr(i) & "点--" & cstr(i+1) & "点"
爊ext
爄=0
爏et rst=openRst()
爏trSQL="select sum(num) as ccount from dateStatic where userid='" & userid & "'"
爎st.open strSQL,conn,3,3
爄f isnull(Rst("ccount")) then
燾count=0
爀lse
燾count=Rst("ccount")
爀nd if
爏trSQL="select * from dateStatic where userid='" & userid & "' order by hourid"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
%>
访问总数<%=ccount%>
 

完整的访问统计程序(二 程序篇)

2012-7-14 编辑:knwz 来源:爱时尚女性网 阅读次数:678
  导读:/* dbcn.asp 牬唇ㄊ菘饬拥 公用程序 */ /* staticFunc 统计程序所需要用到的函数库 */ % 牱梦首苁隣 犘 号 ...
/* dbcn.asp
牬唇ㄊ菘饬拥 公用程序
*/
<%
function OpenConn()
'创建数据库连接
燿im ConnStr
燿im uid
燿im pwd
燿im db
爑id="BBC"
爌wd="BBC"
燿b="BBC"
燬oftserver="Softdepserver"
燬et Conn = Server.CreateObject("ADODB.Connection")
燙onnStr="PRovider=SQLOLEDB.1;UID=" & uid & ";PWD=" & pwd & ";database=" & db & ";server=" & Softserver & ""

燙onn.Open ConnStr

爏et OpenConn=Conn
end function

function OpenRst()
'创建数据库记录集
爏et Rst=Server.CreateObject ("ADODB.Recordset")
爏et OpenRst=Rst
end function
%>
/*
staticFunc
统计程序所需要用到的函数库
*/

<%
爏et conn=openConn()
爏et rst=openRst()
爏ub WriteDateTable(intStart,intEnd,strArray,ccount)
'生成统计表
%>

<%for i= intStart to intEnd%>




<%next%>
<%=strArray(i)%>
<%
爄f rst.eof then
setbar 0,ccount
爀lse
if rst(1)=i then
爏etbar rst(3),ccount
爄f not rst.eof then rst.movenext
else
爏etbar 0,ccount
end if
爀nd if
%>

<%
爀nd sub
%>
<%
爏ub setBar(num,ccount)
'生成统计条
爄f ccount=0 then
percent=0
爀lse
爌ercent=cInt(num/ccount*10000)/100
爀nd if 牋
爏trGif="bar.gif"
%>
<%=percent%>%

<%=num%>





<% WriteDateTable 0, 11, strArray ,ccount %> <%WriteDateTable 12, 23, strArray ,ccount %>

<%
end sub
%>
<%
爏ub writeWeekStatic(userid)
'生成周统计 牋
爄=0
燿im strArray(7)
爏trArray(0)="星期日"
爏trArray(1)="星期一"
爏trArray(2)="星期二"
爏trArray(3)="星期三"
爏trArray(4)="星期四"
爏trArray(5)="星期五"
爏trArray(6)="星期六"
爄=0
爏trSQL="select sum(num) as ccount from weekStatic where userid='" & userid & "'"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
爄f isnull(Rst("ccount")) then
燾count=0
爀lse
燾count=Rst("ccount")
爀nd if
爏trSQL="select * from WeekStatic where userid='" & userid & "' order by dayid"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
%>
牱梦首苁<%=ccount%>




<% WriteDateTable 0, 6, strArray ,ccount %>

<%
爀nd sub
%>
<%
爏ub writeMonthStatic(userid)
'生成月统计
爄=0
燿im strArray(32)
爁or i=1 to 31
爏trArray(i)=cStr(i) & "日"
爊ext
爄=0
爏trSQL="select sum(num) as ccount from MonthStatic where userid='" & userid & "'"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
爄f isnull(Rst("ccount")) then
燾count=0
爀lse
燾count=Rst("ccount")
爀nd if
爏trSQL="select * from MonthStatic where userid='" & userid & "' order by dayid"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
%>
牱梦首苁<%=ccount%>





<% WriteDateTable 1, 16, strArray ,ccount %> <% WriteDateTable 17, 31, strArray ,ccount %>

<%
爀nd sub
%>
<%
爏ub writeYearStatic(userid)
爄=0
燿im strArray(13)
爁or i=1 to 12
爏trArray(i)=cStr(i) & "月"
爊ext
爄=0
爏trSQL="select sum(num) as ccount from YearStatic where userid='" & userid & "'"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
爄f isnull(Rst("ccount")) then
燾count=0
爀lse
燾count=Rst("ccount")
爀nd if
爏trSQL="select * from YearStatic where userid='" & userid & "' order by monthid"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
%>
牱梦首苁<%=ccount%>





<% WriteDateTable 1, 6, strArray ,ccount %> <% WriteDateTable 7, 12, strArray ,ccount %>

<%
爀nd sub
%>
<%
爏ub WriteRecentInfo(userid)
'显示访问者的浏览器分布
StrSQL="select top 10 * from accessstat where userid='" & userid & "' order by VisitTime desc"
set rst=openRst()
Rst.open StrSQL,Conn,3,1
%>










<% for i=1 to Rst.RecordCount %> 牋









<% Rst.MoveNext%>
<% Next %>
序 号 来访时间 ip地址 所用操作系统 所用浏览器类型 浏览的上一页
<%=i%> <%=Rst("VisitTime")%> <%=Rst("IPAddr")%> <%=Rst("UseSystem")%> <%=Rst("BrowserType")%> ><%Response.Write Rst("LastPage")%>

<%
爀nd sub
%>
<%
爏ub WriteBrowserInfo(userid)
Set Rst=OpenRst()
strSQL="select count(*) as VisitCount from AccessStat where userid='" & userid & "'"
Rst.open strSQL,Conn,3,1
TotalVisit=rst(0)
StrSQL="select BrowserType,count(BrowserType) as visitcount from AccessStat where userid='" & userid & "' group by BrowserType order by VisitCount desc"
Set Rst=OpenRst()
Rst.open StrSQL,Conn,3,1
%>








<%for i=1 to Rst.RecordCount %>







<%Rst.MoveNext%>
<% Next %>
序 号 所用浏览器类型 访问比例尺表示 访问次数
<%=i%> <%=Rst("BrowserType")%> <%setbar Rst("VisitCount"),TotalVisit %>

<% 牋
爀nd sub
%>
<%
爏ub InsertData(userid)
'处理浏览者信息
ExecUserInfo userid
'处理日统计
ExecDayStatic userid
'处理周统计
ExecWeekStatic userid
'处理月统计
ExecMonthStatic userid
'处理年统计
ExecYearStatic userid
爀nd sub
%>
<%
爏ub ExecUserInfo(userid)
'处理浏览者信息
strRet=Request.ServerVariables("HTTP_USER_AGENT")
strArray=split(strRet,"(")
strRet=left(strArray(1),len(strArray(1))-1)
strArray=split(strRet,";")
strBrowserName=strArray(1) '浏览器
strUseSystem=strArray(2) '用户操作系统
strPrPage=Request.ServerVariables("HTTP_REFERER") '从何而来
if strPrPage="" then
爏trPrPage="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
end if
strIPAddr=Request.ServerVariables ("REMOTE_ADDR") '用户IP地址
strSQL="insert into AccessStat(UserID,VisitTime,IPAddr,UseSystem,BrowserType,LastPage) "
strSQL=strSQL & "values ('" & trim(userid) & "',getDate(),'" & trim(strIPAddr) & "','"
strSQL=strSQL & trim(strUseSystem) & "','" & trim(strBrowserName) & "','" & trim(strPrPage) & "')"
conn.execute strSQL
爀nd sub
%>
<%
爏ub ExecDayStatic(userid)
'处理每日的小时数据
strSQL="select * from DateStatic where dateid=datepart(dy,getdate()) and userid='" & userid & "'"
set rst=openrst()
rst.open strSQL,conn,3,3
if rst.eof and rst.bof then
爏trSQL="delete from DateStatic where userid='" & userid & "'"
燾onn.execute strSQL
爁or i=0 to 23
strSQL="insert into DateStatic values(datepart(dy,getdate())," & cStr(i) & ",'" & userid & "',0)"
conn.execute strSQL
爊ext
end if
strSQL="update datestatic set num=num + 1 where dateid=datepart(dy,getdate()) and hourid= datepart(hh,getdate()) and userid='" & userid & "'"
conn.execute strSQL
爀nd sub
%>
<%
爏ub ExecWeekStatic(userid)
'处理每周的日数据
爏trSQL="select * from WeekStatic where weekid=datepart(ww,getdate()) and userid='" & userid & "'"
爏et rst=openRst()
爎st.open strSQL,conn,3,3
爄f rst.eof and rst.bof then
strSQL="delete from WeekStatic 爓here userid='" & userid & "'"
conn.execute strSQL
for i=0 to 6
爏trSQL="insert into WeekStatic values(datepart(ww,getdate())," & cStr(i) & ",'" & userid & "',0)"
燾onn.execute strSQL
next
爀nd if
爏trSQL="update weekstatic set num=num + 1 where weekid=datepart(ww,getdate()) and dayid+1= datepart(dw,getdate()) 燼nd userid='" & userid & "'"
燾onn.execute strSQL
end sub
%>
<%
爏ub ExecMonthStatic(userid)
'处理每月的日数据
strSQL="select * from MonthStatic where monthid=datepart(mm,getdate()) and userid='" & userid & "'"
set rst=openRst()
rst.open strSQL,conn,3,3
if rst.eof and rst.bof then
爏trSQL="delete from MonthStatic 爓here userid='" & userid & "'"
燾onn.execute strSQL
爁or i=1 to 31
strSQL="insert into MonthStatic values(datepart(mm,getdate())," & cStr(i) & ",'" & userid & "',0)"
conn.execute strSQL
爊ext
end if
strSQL="update monthstatic set num=num + 1 where monthid=datepart(mm,getdate()) and dayid= datepart(dd,getdate())"
conn.execute strSQL
爀nd sub
%>
<%
爏ub ExecYearStatic(userid)
'处理每年的月数据
爏trSQL="select * from YearStatic where yearid=datepart(yy,getdate()) and userid='" & userid & "'"
set rst=openRst()
rst.open strSQL,conn,3,3
if rst.eof and rst.bof then
爏trSQL="delete from YearStatic where userid='" & userid & "'"
燾onn.execute strSQL
爁or i=1 to 12
strSQL="insert into YearStatic values(datepart(yy,getdate())," & cStr(i) & ",'" & userid & "',0)"
conn.execute strSQL
爊ext
end if
strSQL="update YearStatic set num=num + 1 where Yearid=datepart(yy,getdate()) and Monthid= datepart(mm,getdate()) and userid='" & userid & "'"
conn.execute strSQL
爀nd sub
%>

文章出自:爱时尚女性网www.aspjc.com,尊重版权是美德,转载请保留原地址,感谢合作!

上一篇:完整的站点访问统计系统(一:数
下一篇:完整的访问统计程序(三 应用篇)
 推荐产品
 经典回顾
 近日关注
   
链接交换请联系:QQ:790646582 首页链接要求百度快照在一周以内,不符合以上要求的各站,我们将定期把友情连接转入内页,谢谢合作。
Copyright @ 2012-2015 爱时尚女性网 保留所有权利吉ICP备14005127号-1 服务QQ:175529508 e-mail:zk8312@163.com
本站部分资源来自网友上传,如果无意之中侵犯了您的版权,请联系本站,本站将在3个工作日内删除。