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

<%
SiteFlag=ChkStr(Request("SiteFlag"),1)
Px=ChkStr(Request("Px"),1)

If Px="" Then  Px="IpCounter"

Call PxFilter(Px,"id,keyword,MyCounter,IpCounter,addtime,lasttime")
%>
<table class="tb_1">
  <tr> 
    <form name="form2" method="post" action="?Action=<%=Action%>">
      <td colspan="8">请选择搜索引擎 
        <Select  name="SiteFlag" size="1">
          <%Sql="Select * From CFCount_Search_Set"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1

While Not Rs.Eof 
 Response.Write "<option value='"&Rs("SiteFlag")&"'"
 If Cstr(SiteFlag)=Cstr(Rs("SiteFlag")) Then Response.Write " selected"
 Response.Write ">"&Rs("SiteDesc")&"</option>"  
 
 If SiteFlag="" Then
  If Instr(Rs("SiteFlag"),"baidu.com") Then
   SiteFlag = Rs("SiteFlag")
   SiteDesc = Rs("SiteDesc") 
  End If
 Else
  If Cstr(SiteFlag)=Cstr(Rs("SiteFlag")) Then
   SiteDesc = Rs("SiteDesc") 
  End if
 End If
Rs.MoveNext
Wend  
%>
        </select> <input type="submit" name="Submit3" value="查询"></td>
    </form>
  </tr>
<tr class="tr_1">
    <td colspan="8"><%=SiteDesc%>&nbsp&nbsp全部时间地区统计[可点击标题排序]</td>
  </tr>
  <tr class="tr_2"> 
    <td><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=ID">序号</a></td>
    <td><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=Keyword">关键字</a></td>
    <td colspan="2"><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=MyCounter">PV数量</a></td>
    <td colspan="2"><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=IpCounter">IP数量</a></td>
    <td><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=AddTime">加入时间</a></td>
    <td><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=LastTime">最后访问时间</a></td>
  </tr>
  <%
Sql="Select Sum(MyCounter),Sum(IpCounter) From CFCount_SearchKeyword where UserName='"&UserName&"' And SiteFlag='"&SiteFlag&"'"
Set Rs=Conn.execute(Sql)
ShowTotal=Rs(0)
IpTotal=Rs(1)

Sql="Select Count(*) From CFCount_SearchKeyword where UserName='"&UserName&"' And SiteFlag='"&SiteFlag&"'"
Set Rs=Conn.execute(Sql)
TotalRs=Rs(0)

Sql="Select Top 2000 * From CFCount_SearchKeyword where UserName='"&UserName&"' And SiteFlag='"&SiteFlag&"'"
Sql=Sql&" Order By "&Px&" Desc"

Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
If Not rs.eof then
 If ChkStr(Request("Page"),2) = "" Then
  Page = 1
 Else 
  Page = CInt(ChkStr(Request("Page"),2))
 End If
 
 rs.pagesize=20
 totalpage=rs.pageCount
 mypagesize=rs.pagesize
 rs.absolutepage=page
End If
%>
  <%
While Not Rs.Eof And MyPageSize>0
%>
  <tr  class="tr_2"> 
    <td><%=Rs.RecordCount-Rs.Pagesize*(page)+mypagesize%></td>
    <td >
<a href="<%=Rs("LastLy")%>" target='_blank'> 
<%
 If Instr(Rs("LastLy"),"google")>0 Or Instr(Rs("LastLy"),"yahoo")>0 Then
  KeyWord_2=UTF2GB(Rs("KeyWord"))  
 Else
  KeyWord_2=URLDecode(Rs("KeyWord"))
 End If
 If Len(KeyWord_2)=0 Then KeyWord_2=KeyWord
 Response.write Server.HTMLEncode(KeyWord_2)
%>
</a>
</td>
    <td><%=Rs("MyCounter")%></td>
    <td class="td_1"><img src=images/bar_blue.gif width=<%=CInt(Rs("MyCounter")/ShowTotal*80)%> height=10><%=MyRate(Rs("MyCounter"),ShowTotal)%>%</td>
    <td><%=Rs("IpCounter")%></td>
    <td class="td_1"><img src=images/bar_green.gif width=<%=CInt(Rs("IpCounter")/IpTotal*80)%> height=10><%=MyRate(Rs("IpCounter"),IpTotal)%>%</td>
    <td><%=Rs("AddTime")%></td>
    <td><%=Rs("LastTime")%></td>
  </tr>
  <%rs.movenext
mypagesize=mypagesize-1
wend%>
</table>
<table class="tb_3">
  <tr>
    <td><a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=<%=Px%>&Page=1">第一页</a>
            <%
if page>1 then%>
            <a href='?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=<%=Px%>&Page=<%=Page-1%>'>上一页</a>
            <%
end if
%>
            <%
if page<rs.pagecount   then%>
            <a href='?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=<%=Px%>&Page=<%=Page+1%>'>下一页</a>
            <%

end if
%>
            <a href="?Action=<%=Action%>&SiteFlag=<%=SiteFlag%>&Px=<%=Px%>&Page=<%=totalpage%>">最后一页</a> 页次：<font color="#ff0000"><%=page%></font>/<%=totalpage%>页&nbsp;&nbsp;共<%=totalrs%>条记录&nbsp;&nbsp;每页显示<%=rs.pagesize%>条

<%
Response.write "&nbsp;&nbsp;转到第<select id='page' onChange=""window.location=document.getElementById('page').options[document.getElementById('page').selectedIndex].value"">"
For I=1 To TotalPage
    Response.Write "<option value=?Action="&Action&"&SiteFlag="&SiteFlag&"&Px="&Px&"&Page="&i
 If Page=I Then Response.Write " selected"
 Response.Write ">"& I &"</option>"
Next
Response.write "</select>页"
%>
</td>
  </tr>
</table>