<%
'乘风多用户计数器 Sql版
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，就没有放在程序里，请自己上网站上查看
'有完整版本的演示
%>



			
<%
AddDate_1=ChkStr(Request("AddDate_1"),3)
AddDate_2=ChkStr(Request("AddDate_2"),3)

If AddDate_1="" Then AddDate_1=Date()-1

If AddDate_2="" Then AddDate_2=Date()
%>

<form name="form2" method="post" action="?Action=<%=Action%>" onSubmit="return datecheck();">
<table class="tb_1">
<tr>
    <td>选择查询日期
<Select  name="adddate_1" size="1">
<option>请选择查询日期</option>
<%Sql="Select AddDate From CFCount_Count_Hour Where 1=1 Group By AddDate Order By AddDate Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddDate")&"'"
 If Cstr(AddDate_1)=Cstr(Rs("AddDate")) Then Response.Write " selected"
 Response.Write ">"&Rs("AddDate")&"["&GetWeek(Rs("AddDate"))&"]</option>"  
Rs.MoveNext
Wend  
%>
        </select>
-
<Select  name="adddate_2" size="1">
<option>请选择查询日期</option>
<%Sql="Select AddDate From CFCount_Count_Hour Where 1=1 Group By AddDate Order By AddDate Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddDate")&"'"
 If Cstr(AddDate_2)=Cstr(Rs("AddDate")) Then Response.Write " selected"
 Response.Write ">"&Rs("AddDate")&"["&GetWeek(Rs("AddDate"))&"]</option>"  
Rs.MoveNext
Wend  
%>
        </select>    
      
        <input type="submit" name="Submit3" value="查询">(可同时选择两个日期对比查询)
      </td>
  </tr>
</table></form>


<table class="tb_1">
<TR class="tr_2">
<TD>
<%
Session("CFCountTemp")=""
Sql="Select Sum(MyCounter),Sum(IpCounter),min(AddHour) From CFCount_Count_Hour where 1=1 And AddDate='"&AddDate_2&"' group by addhour"
Set Rs=Conn.Execute(Sql)

If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If

H=24
If Cstr(Date)=CStr(AddDate_2) Then H=hour(now)
For I=0 To 23
ShowNum=0
IpNum=0
J=0

For J=0 To Ubound(Session("CFCountTemp"),2)
 If Session("CFCountTemp")(2,J)=I Then
  ShowNum=Session("CFCountTemp")(0,J)
  IpNum=Session("CFCountTemp")(1,J)
 End If
Next

TitleStr=TitleStr&"<category label='"&I+1&":00' />"
IpStr=IpStr & "<set value='"&IpNum&"' />"
PvStr=PvStr & "<set value='"&ShowNum&"' />"

Next
%>
<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=750 height=450>
<PARAM NAME="FlashVars" VALUE="dataXML=<graph caption='系统每小时总流量统计' subcaption='<%=AddDate_2%>[<%=GetWeek(AddDate_2)%>]' showFCMenuItem='0' lineThickness='1' showValues='0' formatNumberScale='0' anchorRadius='3'   divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='10' alternateHGridColor='#CCCC00' shadowAlpha='40' numvdivlines='5'  bgColor='cccccc,cccccc' bgAngle='270' bgAlpha='10,10' baseFontSize='12' bordercolor='ffffff'  rotateNames='1' slantLabels='1'><categories ><%=TitleStr%></categories><dataset seriesName='IP' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'><%=IpStr%></dataset><dataset seriesName='PV' color='F1683C' anchorBorderColor='F1683C' anchorBgColor='F1683C'><%=PvStr%></dataset></graph>">
<PARAM NAME="movie" VALUE="images/MSLine.swf">
<embed src="images/MSLine.swf" width="750" height="450" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" FlashVars="dataXML=<graph caption='每小时统计' subcaption='<%=AddDate_2%>[<%=GetWeek(AddDate_2)%>]' showFCMenuItem='0' lineThickness='1' showValues='0' formatNumberScale='0' anchorRadius='3'   divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='10' alternateHGridColor='#CCCC00' shadowAlpha='40' numvdivlines='5'  bgColor='cccccc,cccccc' bgAngle='270' bgAlpha='10,10' baseFontSize='12' bordercolor='ffffff'  rotateNames='1' slantLabels='1'><categories ><%=TitleStr%></categories><dataset seriesName='IP' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'><%=IpStr%></dataset><dataset seriesName='PV' color='F1683C' anchorBorderColor='F1683C' anchorBgColor='F1683C'><%=PvStr%></dataset></graph>"></embed>
</OBJECT>
</TD></TR>
<table>	


<table class="tb_4">
<tr>
<td width="50%" valign="top">
<table class="tb_3" width="98%">

        <%
ShowTotal=0
IpTotal=0
Session("CFCountTemp")=""
Sql="Select Sum(MyCounter),Sum(IpCounter) From CFCount_Count_Hour where 1=1 And AddDate='"&AddDate_1&"'"
Set Rs=Conn.Execute(Sql)
ShowTotal=Rs(0)
IpTotal=Rs(1)

Sql="Select Sum(MyCounter),Sum(IpCounter),min(AddHour) From CFCount_Count_Hour where 1=1 And AddDate='"&AddDate_1&"' group by addhour"

Set Rs=Conn.Execute(Sql)

If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If

H=24
If Cstr(Date)=CStr(AddDate_1) Then H=hour(now)
%>
  <tr class="tr_1">
          <td colspan="5"><%=AddDate_1%>[<%=GetWeek(AddDate_1)%>] 每小时报表</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">PV访问量</td>
          <td colspan="2">唯一IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">共<%=ShowTotal%>次,平均每小时<%=Int(ShowTotal/H)%>次</td>
          <td colspan="2">共<%=IpTotal%>IP,平均每小时<%=Int(IpTotal/H)%>IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>小时</td>
          <td colspan="2">显示数量</td>
          <td colspan="2">IP数量</td>
        </tr>
        <%
For I=0 To 23
ShowNum=0
IpNum=0
J=0

For J=0 To Ubound(Session("CFCountTemp"),2)
 If Session("CFCountTemp")(2,J)=I Then
  ShowNum=Session("CFCountTemp")(0,J)
  IpNum=Session("CFCountTemp")(1,J)
 End If
Next

%>
        <tr class="tr_2"> 
          <td class="td_nowrap"><%=I&":00"%>-<%=I+1&":00"%></td>
          <td><%=ShowNum%></td>
          <td class="td_1"><img src=images/bar_blue.gif width=<%=CInt(ShowNum/ShowTotal*60)%> height=10><%=MyRate(ShowNum,ShowTotal)%>%</td>
          <td><%=IpNum%></td>
          <td class="td_1"><img src=images/bar_green.gif width=<%=CInt(IpNum/IpTotal*60)%> height=10><%=MyRate(IpNum,IpTotal)%>%</td>
        </tr>
        <%
Next%>
      </table></td>
    <td valign="top">
	<table class="tb_3 " width="98%">
<%
ShowTotal=0
IpTotal=0
Session("CFCountTemp")=""
Sql="Select Sum(MyCounter),Sum(IpCounter) From CFCount_Count_Hour where 1=1 And AddDate='"&AddDate_2&"'"
Set Rs=Conn.Execute(Sql)
ShowTotal=Rs(0)
IpTotal=Rs(1)

Sql="Select Sum(MyCounter),Sum(IpCounter),min(AddHour) From CFCount_Count_Hour where 1=1 And AddDate='"&AddDate_2&"' group by addhour"
Set Rs=Conn.Execute(Sql)

If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If

H=24
If Cstr(Date)=CStr(AddDate_2) Then H=hour(now)

%>
  <tr class="tr_1">
          <td colspan="5"><%=AddDate_2%>[<%=GetWeek(AddDate_2)%>] 每小时报表</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">PV访问量</td>
          <td colspan="2">唯一IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">共<%=ShowTotal%>次,平均每小时<%=Int(ShowTotal/H)%>次</td>
          <td colspan="2">共<%=IpTotal%>IP,平均每小时<%=Int(IpTotal/H)%>IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>小时</td>
          <td colspan="2">显示数量</td>
          <td colspan="2">IP数量</td>
        </tr>
        <%
For I=0 To 23
ShowNum=0
IpNum=0
J=0

For J=0 To Ubound(Session("CFCountTemp"),2)
 If Session("CFCountTemp")(2,J)=I Then
  ShowNum=Session("CFCountTemp")(0,J)
  IpNum=Session("CFCountTemp")(1,J)
 End If
Next

%>
        <tr class="tr_2"> 
          <td class="td_nowrap"><%=I&":00"%>-<%=I+1&":00"%></td>
          <td><%=ShowNum%></td>
          <td class="td_1"><img src=images/bar_blue.gif width=<%=CInt(ShowNum/ShowTotal*60)%> height=10><%=MyRate(ShowNum,ShowTotal)%>%</td>
          <td><%=IpNum%></td>
          <td class="td_1"><img src=images/bar_green.gif width=<%=CInt(IpNum/IpTotal*60)%> height=10><%=MyRate(IpNum,IpTotal)%>%</td>

        </tr>
        <%
Next%>
      </table></td>
  </tr>
</table>