打印本文 打印本文  关闭窗口 关闭窗口
完整的访问统计程序(二 程序篇)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 13:56:18
sp;</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] 



打印本文 打印本文  关闭窗口 关闭窗口