您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
完整的访问统计程序(二 程序篇)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 13:56:14
;     </table>
<%   
   end sub
%>
<%
   sub InsertData(userid)
      '处理浏览者信息
      ExecUserInfo userid
      '处理日统计
      ExecDayStatic userid
      '处理周统计
      ExecWeekStatic userid
      '处理月统计
      ExecMonthStatic userid
      '处理年统计
      ExecYearStatic userid
   end sub
%>
<%
   sub 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
         strPrPage="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
   end sub
%>
<%
   sub 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
         strSQL="delete from DateStatic where userid='" & userid & "'"
         conn.execute strSQL
         for i=0 to 23
            strSQL="insert into DateStatic values(datepart(dy,getdate())," & cStr(i) & ",'" & userid
& "',0)"
            conn.execute strSQL
         next
      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      
   end sub
%>
<%
   sub ExecWeekStatic(userid)
     '处理每周的日数据
     strSQL="select * from WeekStatic where weekid=datepart(ww,getdate()) and userid='" & userid & "'"
     set rst=openRst()
     rst.open strSQL,conn,3,3
     if rst.eof and rst.bof then
        strSQL="delete from WeekStatic  where userid='" & userid & "'"
        conn.execute strSQL
        for i=0 to 6
           strSQL="insert into WeekStatic values(datepart(ww,getdate())," & cStr(i) & ",'" & userid
& "',0)"
           conn.execute strSQL
        next
     end if
     strSQL="update weekstatic set num=num + 1 where weekid=datepart(ww,getdate()) and dayid+1= datepart
(dw,getdate())  and userid='" & userid & "'"
     conn.execute strSQL
  end sub
%>
<%
   sub 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
         strSQL="delete from MonthStatic  where userid='" & userid & "'"
         conn.execute strSQL
         for i=1 to 31
            strSQL="insert into MonthStatic values(datepart(mm,getdate())," & cStr(i) & ",'" & userid
& "',0)"
            conn.execute strSQL
         next
      end if
      strSQL="update monthstatic set num=num + 1 where monthid=datepart(mm,getdate()) and dayid= datepart
(dd,getdate())"
      conn.execute strSQL
   end sub
%>
<%
   sub ExecYearStatic(userid)
     '处理每年的月数据
     strSQL="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
         strSQL="delete from YearStatic where userid='" & userid & "'"
         conn.execute strSQL
         for i=1 to 12
            strSQL="insert into YearStatic values(datepart(yy,getdate())," & cStr(i) & ",'" & userid
& "',0)"
            conn.execute strSQL
         next
      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
   end sub
%>


上一页  [1] [2] [3] 


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |