<%
'乘风多用户计数器 Sql版
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，就没有放在程序里，请自己上网站上查看
'有完整版本的演示
%>
<table class="tb_1">
<form name="form6" method="post" action="?"><tr> 
      <td colspan="7">选择查询的日期 
        <Select  name="adddate" size="1" onChange="window.location=form.adddate.options[form.adddate.selectedIndex].value">
          <option value='?Action=<%=Action%>'>请选择日期</option>
          <%Sql="Select AddDate From CFCount_Web_Day 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='?Action="&Action&"&AddDate="&Rs("AddDate")&"'"
 If ChkStr(Request("AddDate"),3)=Cstr(Rs("AddDate")) Then Response.Write " selected"
 Response.Write ">"&Rs("AddDate")&"</option>"  
Rs.MoveNext
Wend  
%>
        </select></td>
    </tr></form>
    <%

Px=ChkStr(Request("Px"),1)
AddDate=ChkStr(Request("AddDate"),3)
UserName=ChkStr(Request("UserName"),1)

If Px="" Then  Px="LastTime"
If AddDate="" Then AddDate=Date()


Call PxFilter(Px,"id,UserName,weburl,MyCounter,addtime,lasttime")


Sql="Select Count(*) From CFCount_Web_Day where Datediff(d,AddDate,'"&AddDate&"')=0"
If UserName<>"" Then Sql = Sql & " and UserName='" & UserName & "'"
Set Rs=Conn.execute(Sql)
WebTotal=Rs(0)

Sql="Select Top 1000 * From CFCount_Web_Day where Datediff(d,AddDate,'"&AddDate&"')=0"
If UserName<>"" Then Sql = Sql & " and UserName='" & UserName & "'"
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
%>
<tr class="tr_1">
      <td colspan="7"><%=AddDate%> 页面统计[可点击标题排序]</td>
    </tr>
    <tr class="tr_2"> 
      <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=ID">序号</a></td>
      <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=UserName">用户</a></td>
	  <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=WebUrl">页面地址</a></td>
      <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=MyCounter">Pv数量</a></td>
      <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=AddTime">上站时间</a></td>
      <td class="td_nowrap"><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=LastTime">最后访问时间</a></td>
    </tr>
    <%
While Not Rs.Eof And MyPageSize>0
%>
    <tr class="tr_2"> 
      <td><%=Rs.RecordCount-Rs.Pagesize*(page)+mypagesize%></td>
	  <td><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=Rs("UserName")%>"><%=Rs("UserName")%></a></td>
      <td width="500px" style="word-wrap: break-word;word-break:break-all;"> 
          <%If Rs("WebUrl")="" Then
  Response.Write "直接从浏览器输入"
 Else
  Response.Write "<a href='?Action=urlgo&Url="&Server.URLEncode(Rs("WebUrl"))&"' target='_blank'>"&server.HTMLEncode(Rs("WebUrl"))&"</a>"
 End If%>      </td>
      <td><%=Rs("MyCounter")%></td>


      <td><%=GetTurnTime(Hour(Rs("AddTime")))&":"&GetTurnTime(Minute(Rs("AddTime")))&":"&GetTurnTime(Second(Rs("AddTime")))%></td>
      <td><%=GetTurnTime(Hour(Rs("LastTime")))&":"&GetTurnTime(Minute(Rs("LastTime")))&":"&GetTurnTime(Second(Rs("LastTime")))%></td>
    </tr>
    <%rs.movenext
mypagesize=mypagesize-1
wend%>

</table>
  <table class="tb_3">
  <tr>
    <td><a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=<%=Px%>&Page=1">第一页</a>
            <%
if page>1 then%>
            <a href='?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=<%=Px%>&Page=<%=Page-1%>'>上一页</a>
            <%
end if
%>
            <%
if page<rs.pagecount   then%>
            <a href='?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=<%=Px%>&Page=<%=Page+1%>'>下一页</a>
            <%
end if
%>
            <a href="?Action=<%=Action%>&AddDate=<%=AddDate%>&UserName=<%=UserName%>&Px=<%=Px%>&Page=<%=totalpage%>">最后一页</a> 页次：<font color="#ff0000"><%=page%></font>/<%=totalpage%>页&nbsp;&nbsp;共<%=WebTotal%>条记录&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&"&AddDate="&AddDate&"&UserName="&UserName&"&Px="&Px&"&Page="&i
 If Page=I Then Response.Write " selected"
 Response.Write ">"& I &"</option>"
Next
Response.write "</select>页"
%>
</td>

  </tr>
</table>


<script language=JavaScript>
function searchcheck_web()
{ 
 var searchurl ="?Action=<%=Action%>&AddDate=<%=AddDate%>"
 searchurl += '&UserName=' + document.getElementById('UserName').value;
 document.getElementById('form_web').action = searchurl ;
 return true;
}
</script>
  <form name="form_web" id="form_web" method="post" action="?Action=<%=Action%>" onsubmit="return searchcheck_web()">
<table class="tb_3"><tr class="tr_1">
<td colspan="2">搜索：</td>
</tr>
      <tr>
        <td>用户名</td>
        <td><input name="UserName" type="text" id="UserName" value="<%=UserName%>" size="10" /></td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" value="查找" /></td>
      </tr>
</table></form>