<%
'乘风多用户计数器 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="" Or AddDate_2="" Then
 AddDate_1=DateAdd("d",-1,Date)
 AddDate_2=Date()
End If
%>

<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_Area_Day Where UserName='"&UserName&"' 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")&"&nbsp["&GetWeek(Rs("AddDate"))&"]</option>"  
Rs.MoveNext
Wend  
%>
        </select>
        - 
        <Select  name="adddate_2" size="1">
		<option>请选择日期</option>
<%Sql="Select AddDate From CFCount_Area_Day Where UserName='"&UserName&"' 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")&"&nbsp["&GetWeek(Rs("AddDate"))&"]</option>"  
Rs.MoveNext
Wend  
%>
        </select>
        <input type="submit" name="Submit3" value="查询">(可同时选择两个日期对比查询)
      </td>
  </tr>
</table></form>
  
<table class="tb_4">
<tr>
    <td width="50%" valign="top">
	<table class="tb_3" width="98%">
        <%
IpTotal=0
Session("CFCountTemp")=""

Sql="Select Sum(IpCounter) From CFCount_Area_Day where UserName='"&UserName&"' And Datediff(d,AddDate,'"&AddDate_1&"')=0"
Set Rs=Conn.Execute(Sql)
IpTotal=Rs(0)


Sql="Select Top 200 Area,IpCounter From CFCount_Area_Day where UserName='"&UserName&"' And Datediff(d,AddDate,'"&AddDate_1&"')=0 Order By IpCounter Desc"
Set Rs=Conn.Execute(Sql)
If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If
%>
	<tr class="tr_1">
          <td colspan="3"><%=AddDate_1%>&nbsp;[<%=GetWeek(AddDate_1)%>] 地区报表</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">唯一IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">共&nbsp;<%=IpTotal%>&nbsp;IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>地区</td>
          <td colspan="2">IP数量</td>
        </tr>
<%
I=0

For I=0 To Ubound(Session("CFCountTemp"),2)
Area=""
IpNum=0

Area=Session("CFCountTemp")(0,I)
IpNum=Session("CFCountTemp")(1,I)
If Area="" Then Area="未知地区"
%>
        <tr class="tr_2"> 
          <td><%=Area%></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%">
        <%
IpTotal=0
Session("CFCountTemp")=""

Sql="Select Sum(IpCounter) From CFCount_Area_Day where UserName='"&UserName&"' And Datediff(d,AddDate,'"&AddDate_2&"')=0"
Set Rs=Conn.Execute(Sql)
IpTotal=Rs(0)


Sql="Select Top 200 Area,IpCounter From CFCount_Area_Day where UserName='"&UserName&"' And Datediff(d,AddDate,'"&AddDate_2&"')=0 Order By IpCounter Desc"
Set Rs=Conn.Execute(Sql)
If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If


%>
	<tr class="tr_1">
          <td colspan="3"><%=AddDate_2%>&nbsp;[<%=GetWeek(AddDate_2)%>] 地区报表</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">唯一IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>&nbsp;</td>
          <td colspan="2">共&nbsp;<%=IpTotal%>&nbsp;IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>地区</td>
          <td colspan="2">IP数量</td>
        </tr>
<%
I=0

For I=0 To Ubound(Session("CFCountTemp"),2)
Area=""
IpNum=0

Area=Session("CFCountTemp")(0,I)
IpNum=Session("CFCountTemp")(1,I)
If Area="" Then Area="未知地区"
%>
        <tr class="tr_2"> 
          <td><%=Area%></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>