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

<%If RsSet("TopList")=0 Then%>
<table class="index_tb">
<tr class="tr_1">
<td > 对不起，排行榜功能目前已经关闭</td>
</tr>
</table>
<%End If%>


<%If RsSet("TopList")=-1 Then%>
        
<table class="index_tb">
<tr class="tr_1">
          <td colspan="3">今日排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>今日IP</td>
        </tr>
        <%
Sql="Select Top 10 * From CFCount_Count_Day Where AddDate='"&Date()&"' And UserName In (Select UserName From CFCount_User Where UserState=-1 And TjOpen=-1) Order By IpCounter Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td ><%=I%></td>
          <td ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td >  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("IpCounter")
				   Else
				    Response.write "***"
				   End If%>
          </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
	  
<table class="index_tb">
<tr class="tr_1">
          <td colspan="3">每日平均排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>每日IP</td>
        </tr>
        <%
Sql="Select Top 10 * From  (Select UserName,(RealIpTotal/(DateDiff(d,AddTime,GetDate())+1)) DayIP From CFCount_User Where UserState=-1 And TjOpen=-1) Temp Order By DayIP Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
I=0
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td><%=I%></td>
          <td><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td>  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("DayIp")
				   Else
				    Response.write "***"
				   End If%>
            </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
<table class="index_tb" >
<tr class="tr_1">
          <td colspan="3">本周排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>本周IP</td>
        </tr>
        <%
TYear=Year(Now())
TWeek=DatePart("ww",Now)

Sql="Select Top 10 * From CFCount_Count_Week Where AddYear="&TYear&" And AddWeek="&TWeek&" And UserName In (Select UserName From CFCount_User Where UserState=-1 And TjOpen=-1) Order By IpCounter Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
I=0
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td ><%=I%></td>
          <td ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td >  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("IpCounter")
				   Else
				    Response.write "***"
				   End If%>
          </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
<table class="index_tb">
<tr class="tr_1">
          <td colspan="3">本月排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>本月IP</td>
        </tr>
        <%
TYear=Year(Now())
TMonth=Month(Now())

Sql="Select Top 10 * From CFCount_Count_Month Where AddYear="&TYear&" And AddMonth="&TMonth&" And UserName In (Select UserName From CFCount_User Where UserState=-1 And TjOpen=-1) Order By IpCounter Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
I=0
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td ><%=I%></td>
          <td ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td >  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("IpCounter")
				   Else
				    Response.write "***"
				   End If%>
          </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
<table class="index_tb">
<tr class="tr_1">
          <td colspan="3">上周排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>上周IP</td>
        </tr>
<%
SzmDate = DateAdd("d", -weekday(Date()), Date())

YYear=Year(SzmDate)
YWeek=DatePart("ww",SzmDate)

Sql="Select Top 10 * From CFCount_Count_Week Where AddYear="&YYear&" And AddWeek="&YWeek&" And UserName In (Select UserName From CFCount_User Where UserState=-1 And TjOpen=-1) Order By IpCounter Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
I=0
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td ><%=I%></td>
          <td ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td >  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("IpCounter")
				   Else
				    Response.write "***"
				   End If%>
          </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
	  
<table class="index_tb">
<tr class="tr_1">
          <td colspan="3">上月排行榜</td>
        </tr>
        <tr class="tr_2"> 
          <td>序号</td>
          <td>网站名称</td>
          <td>上月IP</td>
        </tr>
<%
SyDate=dateadd("m",-1,cdate(year(now)&"-"&month(now)&"-1"))

YYear=Year(SyDate)
YMonth=Month(SyDate)

Sql="Select Top 10 * From CFCount_Count_Month Where AddYear="&YYear&" And AddMonth="&YMonth&" And UserName In (Select UserName From CFCount_User Where UserState=-1 And TjOpen=-1) Order By IpCounter Desc"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
I=0
While Not Rs.Eof
I=I+1

Set RsUser= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&Rs("UserName")&"'"
RsUser.Open Sql,Conn,1,1
%>
        <tr class="tr_2"> 
          <td ><%=I%></td>
          <td ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageName")%></a></td>
          <td >  
              <%If RsUser("TjOpen")=-1 Then
				    Response.write Rs("IpCounter")
				   Else
				    Response.write "***"
				   End If%>
          </td>
        </tr>
        <%Rs.MoveNext
Wend%>
      </table>
	  
    <%End If%>
  </p>
