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

AddYear_2=ChkStr(Request("AddYear_2"),2)
AddWeek_2=ChkStr(Request("AddWeek_2"),2)

If AddYear_1="" Or AddWeek_1="" Or AddYear_2="" Or AddWeek_2="" Then
 AddYear_2=Year(Now)
 AddWeek_2=DatePart("ww",Now)
 
 MyDate=DateAdd("d",-(DatePart("w",Now)),Now) 

 AddYear_1=Year(MyDate)
 AddWeek_1=DatePart("ww",MyDate)
End If
%>

<form name="form2" method="post" action="?Action=<%=Action%>" onSubmit="return weekcheck();">
<table class="tb_1"><tr>
    <td>选择查询周数
<Select  name="addyear_1" size="1">
<option>请选择年份</option>
<%Sql="Select AddYear From CFCount_IPHead_Week Where UserName='"&UserName&"' Group By AddYear Order By AddYear Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddYear")&"'"
 If Cstr(AddYear_1)=Cstr(Rs("AddYear")) Then Response.Write " selected"
 Response.Write ">"&Rs("AddYear")&"年</option>"  
Rs.MoveNext
Wend  
%>
        </select>
<Select  name="addweek_1" size="1">
<option>请选择周数</option>
<%Sql="Select AddWeek From CFCount_IPHead_Week Where UserName='"&UserName&"' Group By AddWeek Order By AddWeek Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddWeek")&"'"
 If Cstr(AddWeek_1)=Cstr(Rs("AddWeek")) Then Response.Write " selected"
 Response.Write ">第"&Rs("AddWeek")&"周</option>"  
Rs.MoveNext
Wend  
%>
        </select> -
<Select  name="addyear_2" size="1">
<option>请选择年份</option>
<%Sql="Select AddYear From CFCount_IPHead_Week Where UserName='"&UserName&"' Group By AddYear Order By AddYear Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddYear")&"'"
 If Cstr(AddYear_2)=Cstr(Rs("AddYear")) Then Response.Write " selected"
 Response.Write ">"&Rs("AddYear")&"年</option>"  
Rs.MoveNext
Wend  
%>
        </select>
<Select  name="addweek_2" size="1">
<option>请选择周数</option>
<%Sql="Select AddWeek From CFCount_IPHead_Week Where UserName='"&UserName&"' Group By AddWeek Order By AddWeek Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("AddWeek")&"'"
 If Cstr(AddWeek_2)=Cstr(Rs("AddWeek")) Then Response.Write " selected"
 Response.Write ">第"&Rs("AddWeek")&"周</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_IPHead_Week where UserName='"&UserName&"' And AddYear="&AddYear_1&" And AddWeek="&AddWeek_1
Set Rs=Conn.Execute(Sql)
IpTotal=Rs(0)


Sql="Select Top 200 IPHead,IpCounter From CFCount_IPHead_Week where UserName='"&UserName&"' And AddYear="&AddYear_1&" And AddWeek="&AddWeek_1&" 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"><%=AddYear_1%>年第<%=AddWeek_1%>周 IP报表</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;&nbsp;IP<%=IpTotal%></td>
        </tr>
        <tr class="tr_2"> 
          <td>IP头</td>
          <td colspan="2">IP数量</td>
        </tr>
<%
I=0
For I=0 To Ubound(Session("CFCountTemp"),2)
IPHead=""
IpNum=0

IpHead=Session("CFCountTemp")(0,I)
IpNum=Session("CFCountTemp")(1,I)
%>
        <tr class="tr_2"> 
          <td><%=IPHead%></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_IPHead_Week where UserName='"&UserName&"' And AddYear="&AddYear_2&" And AddWeek="&AddWeek_2
Set Rs=Conn.Execute(Sql)
IpTotal=Rs(0)


Sql="Select Top 200 IpHead,IpCounter From CFCount_IPHead_Week where UserName='"&UserName&"' And AddYear="&AddYear_2&" And AddWeek="&AddWeek_2&" 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"><%=AddYear_2%>年第<%=AddWeek_2%>周 IP报表</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>IP头</td>
          <td colspan="2">IP数量</td>
        </tr>
<%
I=0
For I=0 To Ubound(Session("CFCountTemp"),2)
IPHead=""
IpNum=0

IpHead=Session("CFCountTemp")(0,I)
IpNum=Session("CFCountTemp")(1,I)
%>
        <tr class="tr_2"> 
          <td><%=IPHead%></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>