<%
'乘风多用户计数器 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
 

If IsNumeric(AddYear_1)=False Or IsNumeric(AddWeek_1)=False Or IsNumeric(AddYear_2)=False Or IsNumeric(AddWeek_2)=False  Then Call AlertBack("输入了错误的时间",1)
%>

<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_Search_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_Search_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_Search_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_Search_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_1">
<TR class="tr_2">
<TD>
<%
Session("CFCountTemp")=""
Sql="Select Top 100 b.SiteDesc,a.MyCounter,a.IpCounter From CFCount_Search_Week a Left Join CFCount_Search_Set b on a.siteflag=b.siteflag where a.UserName='"&UserName&"' And a.AddYear="&AddYear_2&" And a.AddWeek="&AddWeek_2&" Order By a.IpCounter Desc"
Set Rs=Conn.Execute(Sql)
If Not Rs.eof Then
  Session("CFCountTemp")=Rs.GetRows(-1)
End If

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

SiteDesc=Session("CFCountTemp")(0,I)
ShowNum=Session("CFCountTemp")(1,I)
IpNum=Session("CFCountTemp")(2,I)

colorstr="AFD8F8"
If I=0 Then colorstr="AFD8F8"
If I=1 Then colorstr="F6BD0F"
If I=2 Then colorstr="8BBA00"
If I=3 Then colorstr="FF8E46"
If I=4 Then colorstr="008E8E"
If I=5 Then colorstr="D64646"
If I=6 Then colorstr="8E468E"
If I=7 Then colorstr="588526"

TitleStr=TitleStr&"<set name='"&SiteDesc&"' value='"&IpNum&"' color='"&colorstr&"'/>"


Next
%>
<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=750 height=450>
<PARAM NAME="FlashVars" VALUE="dataXML=<graph baseFont='SunSim' baseFontSize='12' caption='搜索引擎统计' showFCMenuItem='0' subcaption='<%=AddYear_2%>年第<%=AddWeek_2%>周' yAxisMinValue='51650.1' yAxisMaxValue='71118.3' xaxisname='日期' yaxisname='数量' hovercapbg='FFECAA' hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='0' showvalues='1' numdivlines='10' numVdivlines='0' shownames='1' rotateNames='1'><%=TitleStr%></graph>">
<PARAM NAME="movie" VALUE="images/Pie2D.swf">
<embed src="images/Pie2D.swf" width="750" height="450" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" FlashVars="dataXML=<graph baseFont='SunSim' baseFontSize='12' caption='搜索引擎统计' showFCMenuItem='0' subcaption='<%=AddYear_2%>年第<%=AddWeek_2%>周' yAxisMinValue='51650.1' yAxisMaxValue='71118.3' xaxisname='日期' yaxisname='数量' hovercapbg='FFECAA' hovercapborder='F47E00' formatNumberScale='0' decimalPrecision='0' showvalues='1' numdivlines='10' numVdivlines='0' shownames='1' rotateNames='1'><%=TitleStr%></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_Search_Week where UserName='"&UserName&"' And AddYear="&AddYear_1&" And AddWeek="&AddWeek_1
Set Rs=Conn.Execute(Sql)
ShowTotal=Rs(0)
IpTotal=Rs(1)


Sql="Select Top 100 b.SiteDesc,a.MyCounter,a.IpCounter From CFCount_Search_Week a Left Join CFCount_Search_Set b on a.siteflag=b.siteflag where a.UserName='"&UserName&"' And a.AddYear="&AddYear_1&" And a.AddWeek="&AddWeek_1&" Order By a.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="5"><%=AddYear_1%>年第<%=AddWeek_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">共&nbsp;<%=ShowTotal%>&nbsp;PV</td>
          <td colspan="2">共&nbsp;<%=IpTotal%>&nbsp;IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>搜索引擎</td>
          <td colspan="2">PV数量</td>
          <td colspan="2">IP数量</td>
        </tr>
        <%
For I=0 To Ubound(Session("CFCountTemp"),2)
SiteDesc=""
ShowNum=0
IpNum=0

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


Sql="Select Top 100 b.SiteDesc,a.MyCounter,a.IpCounter From CFCount_Search_Week a Left Join CFCount_Search_Set b on a.siteflag=b.siteflag where a.UserName='"&UserName&"' And a.AddYear="&AddYear_2&" And a.AddWeek="&AddWeek_2&" Order By a.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="5"><%=AddYear_2%>年第<%=AddWeek_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">共&nbsp;<%=ShowTotal%>&nbsp;PV</td>
          <td colspan="2">共&nbsp;<%=IpTotal%>&nbsp;IP</td>
        </tr>
        <tr class="tr_2"> 
          <td>搜索引擎</td>
          <td colspan="2">PV数量</td>
          <td colspan="2">IP数量</td>
        </tr>
        <%
For I=0 To Ubound(Session("CFCountTemp"),2)
SiteDesc=""
ShowNum=0
IpNum=0

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