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

Px=ChkStr(Request("Px"),1)

If Px="" Then Px="AddTime"

Call PxFilter(Px,"ID,UserName,ParentName,LoginTotal,RealIpTotal,PageName,AddTime,UserState,VipState,AgentLevel,LastTime")

%>
          
        
<table class="tb_1">
  <tr>
    <td colspan="12">点击标题可以选择其相应的排序方式 
<%

Sql="Select Count(*) From CFCount_User" 
Set Rs=Conn.Execute(Sql)

Response.write "<b><font color=ff0000>目前账号总数："&Rs(0)&"</font></b>"

Sql="Select Count(*) From CFCount_User Where UserState=-1" 
Set Rs=Conn.Execute(Sql)

Response.write "<b><font color=ff0000>，有效账号数："&Rs(0)&"</font></b>"
%>
</td>
  </tr>
  
<% 
'--列表最多列表多少个记录
ListRsNum=2000

Sql="Select Top "&ListRsNum&" * From CFCount_User Where 1=1" 

If UserName<>"" Then Sql=Sql&" And (UserName Like '%"&UserName&"%' Or ParentName Like '%"&UserName&"%')"
If UserState<>"" Then Sql=Sql&" And UserState = "&UserState
If VipState<>"" Then Sql=Sql&" And VipState = "&VipState

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=10
TotalRs=Rs.RecordCount
TotalPage=Rs.PageCount
MyPageSize=Rs.PageSize
Rs.AbsolutePage=Page
End If
%>
  <tr class="tr_1">
    <td colspan="12">用户列表<%If TotalRs>=ListRsNum Then Response.Write "&nbsp;&nbsp;列表只列出"&ListRsNum&"个"%></td>
 </tr>
  
  <tr class="tr_2"> 
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=ID">ID</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=UserName">用户名</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=ParentName">账号</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=LoginTotal">登陆</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=RealIpTotal">实际计数</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=PageName">主页</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=AddTime">注册时间</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=UserState">帐号状态</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=VipState">Vip状态</a></td>
    <td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=AgentLevel">折扣</a></td>
	<td class="td_nowrap"><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=LastTime">最后更新</a></td>
    <td class="td_nowrap">操作</td>
  </tr>
  <%While Not Rs.Eof And MyPageSize>0%>
  <tr class="tr_2"> 
    <td class="td_nowrap"><%=Rs("ID")%></td>
    <td class="td_nowrap"><%=Rs("UserName")%></td>
    <td> 
        <%
	If Rs("ParentName")="" Then
	 Response.write "无父账号"
    Else
	 Response.write "父账号:"&Rs("ParentName")
	End If
	%>      </td>
    <td class="td_nowrap"><%=Rs("LoginTotal")%></td>
    <td class="td_nowrap"><%=Rs("RealIpTotal")%></td>
    <td width="90px" style="word-wrap: break-word;word-break:break-all;"><a href=?Action=urlgo&Url=<%=Server.URLEncode(Rs("PageUrl"))%> target="_blank"><%=Rs("PageName")%></a></td>
    <td class="td_nowrap" title='<%=Rs("AddTime")%>'><%=month(Rs("AddTime"))&"-"&day(Rs("AddTime"))%></td>
    <td class="td_nowrap"> 
        <%if rs("UserState")=-1 then
			  response.Write "有效"
			  elseif rs("UserState")=0 then
			  response.Write "无效"
			  end if%>      </td>
    <td class="td_nowrap"> 
<%if rs("VipState")=-1 then
			  response.Write "<font color=#ff0000>是</font>"
			  elseif rs("VipState")=0 then
			  response.Write "否"
			  end if%></td>
    <td class="td_nowrap"><%=Rs("AgentLevel")%></td>
	<td class="td_nowrap">

[<a href=?Action=urlgo&Url=<%=Server.URLEncode(Rs("LastLy"))%> target="_blank">来源</a>]
[<a href=?Action=urlgo&Url=<%=Server.URLEncode(Rs("LastWeb"))%> target="_blank">页面</a>]
<br />
[<%=Rs("LastTime")%>]
</td>
    <td class="td_nowrap"><a href="?Action=usergo&UserName=<%=Rs("UserName")%>" target="_blank">查看</a> 
        <a href="?Action=usermodify&UserName=<%=Rs("UserName")%>">修改</a> 
<%
If Rs("UserName")<>"mytest" Then
 Response.write "<a href='AdminUser.aspx?Action=userdel&UserName="&Rs("UserName")&"' onClick=""return confirm('确定要删除吗?')"">删除</a>"
Else
 Response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
End If
%>

</td>
  </tr>
  <%rs.movenext
mypagesize=mypagesize-1
wend%>
</table>

  <table class="tb_3">
    <tr> 
      <td><a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=<%=Px%>&Page=1">第一页</a> 
          <%
if page>1 then%>
          <a href='?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=<%=Px%>&Page=<%=Page-1%>'>上一页</a> 
          <%
end if
%>
          <%
if page<rs.pagecount   then%>
          <a href='?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&Px=<%=Px%>&Page=<%=Page+1%>'>下一页</a> 
          <%
end if
%>
          <a href="?Action=<%=Action%>&UserName=<%=UserName%>&UserState=<%=UserState%>&VipState=<%=VipState%>&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&"&UserName="&UserName&"&UserState="&UserState&"&VipState="&VipState&"&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_user()
{ 
 var searchurl ="?Action=<%=Action%>"
 searchurl += '&UserName=' + document.getElementById('UserName').value;
 searchurl += '&UserState=' + document.getElementById('UserState').value;
 searchurl += '&VipState=' + document.getElementById('VipState').value;
 document.getElementById('form_user').action = searchurl ;
 return true;
}
</script>
  <form name="form_user" id="form_user" method="post" action="?Action=<%=Action%>" onsubmit="return searchcheck_user()">
<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>
账号状态</td>
        <td><select name="UserState">
          <option value=""<%If CStr(UserState)="" Then Response.write " selected"%>>全部</option>
          <option value="-1"<%If CStr(UserState)="-1" Then Response.write " selected"%>>有效</option>
          <option value="0"<%If CStr(UserState)="0" Then Response.write " selected"%>>无效</option>
        </select></td>
      </tr>
	  
      <tr>
        <td>
VIP状态</td>
        <td><select name="VipState">
          <option value=""<%If CStr(VipState)="" Then Response.write " selected"%>>全部</option>
          <option value="-1"<%If CStr(VipState)="-1" Then Response.write " selected"%>>VIP用户</option>
          <option value="0"<%If CStr(VipState)="0" Then Response.write " selected"%>>免费用户</option>
        </select></td>
      </tr>
	  
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" value="查找" /></td>
      </tr>
</table></form>
