<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="Ex_Cls/Ex_CommonCls.asp"-->
<!--#include file="Ex_Cls/Ex_SplitPageCls.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css" />
</head>

<body>
<script language="javascript">
//全选
// name1---被点击的复选框  name2---被动改变的
function SelAll(name1,name2)
{
 var obj=document.getElementsByName(name2);
 for (var i=0;i<obj.length;i++)
 obj[i].checked=document.getElementById(name1).checked;
}
</script>
<%
Dim ExComm
Set ExComm=new Ex_CommonCls
	ExComm.IsAdLogin 
	ExComm.IsIpAllow
dim action
action=request.QueryString("action")
Select Case Action
	Case "all"
		DoUser
	Case "info"
		Info
	Case "modi"
		Modi
	Case Else 
		DoForm
End Select 
sub DoForm()
dim userRs
set userRs=server.CreateObject("adodb.recordset")
Dim ExPages,page,Rs
  Set ExPages=new Ex_SplitPageCls
  Expages.letConn=Conn
  Expages.letColumns="select id,username,homepage,email,regtime,id,lock"
  ExPages.letDataFrom="from Ex_user"
  if action<>"" then
	ExPages.letWhere=" where username like '%"&request("username")&"%'"
  end if
  ExPages.letOrder="order by regtime desc"
  Expages.letPageSize="15"
  If ExComm.G(request("page"))="" Then
	page=1
  Else
	page=ExComm.G(request("page"))
  End if
  ExPages.letPage=CInt(page)
  ExPages.letStrPage="&username="&request("username")
  ExPages.Execute()
%>
<table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF" class="border">
  <form action="?action=search" method="post">
<tr>
    <th colspan="3" class="topbg">用户搜索</th>
    </tr>
  <tr>
    <td width="38%" height="22" class="tdbg"><div align="center">用户名:</div></td>
    <td width="46%" class="tdbg"><div align="center">
      <input name="username" type="text" id="username">
    </div></td>
    <td width="16%" class="tdbg"><input type="submit" name="Submit" value="提交"></td>
  </tr>
  </form>
</table>

  <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <form id="form1" name="form1" method="post" action="?action=all">
<tr background="images/admin/topbg.gif">
      <td height="22" colspan="7" background="images/admin/topbg.gif"><div align="center" class="tile_white"><font color="white"><b>用户管理</b></font></div></td>
    </tr>
    <tr>
      <td width="18%" bgcolor="#E7EFFF" class="tdbg"><div align="center">用户名</div></td>
      <td width="21%" bgcolor="#E7EFFF" class="tdbg"><div align="center">主页</div></td>
      <td width="16%" bgcolor="#E7EFFF" class="tdbg"><div align="center">
        <label></label>
      Email</div></td>
      <td width="16%" bgcolor="#E7EFFF" class="tdbg"><div align="center">注册时间</div></td>
      <td width="9%" bgcolor="#E7EFFF" class="tdbg"><label>
        <div align="center">锁定
          <input name="lockall" type="checkbox" id="lockall" value="checkbox"  onclick="SelAll('lockall','lock')"/>
        </div>
        </label></td>
      <td width="8%" bgcolor="#E7EFFF" class="tdbg"><div align="center">解锁
          <input name="unlockall" type="checkbox" id="unlockall" value="checkbox"  onclick="SelAll('unlockall','unlock')"/>
      </div></td>
      <td width="12%" bgcolor="#E7EFFF" class="tdbg"><div align="center">删除
        <label>
        <input name="delall" type="checkbox" id="delall" value="checkbox" onClick="SelAll('delall','del')"/>
        </label>
      </div></td>
    </tr>
	<%
	Set userRs=ExPages.GetRs
	If ExPages.getRsCount<>0 Then 
		Do While Not userRs.eof
	%>
    <tr>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center"><a href="?action=info&id=<%=userRs("id")%>" title="点击查看详细信息"><%=userrs("username")%></a></div></td>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center"><a href="<%=userrs("homepage")%>" target="_blank"><%=userrs("homepage")%></a></div></td>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center"><%=userRS("email")%></div></td>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center"><%=userRS("regtime")%></div></td>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center">
        <input name="lock" type="checkbox" id="lock" value="<%=userRS("id")%>" <% if userRs("lock")=true then response.Write("checked")%>/>
      </div></td>
      <td bgcolor="#E7EFFF" class="tdbg"><div align="center">
        <input name="unlock" type="checkbox" id="unlock" value="<%=userRS("id")%>" <% if userRs("lock")=false then response.Write("checked")%>/>
      </div></td>
      <td bgcolor="#E7EFFF" class="tdbg">
        <div align="center">
          <input name="del" type="checkbox" id="del" value="<%=userRS("id")%>" />
        </div>      </td>
    </tr>
	<%userRs.movenext
	 loop
	 else
	 	response.Write("<tr colspan=5><td><font color=red>没有相关用户信息</font></td></tr>")
	 end if
	 %>
    <tr>
      <td colspan="7" bgcolor="#E7EFFF" class="tdbg">
	    <div align="center">
        <%=ExPAges.show%>        </div></td>
    </tr>
    <tr>
      <td colspan="7" bgcolor="#E7EFFF" class="tdbg">
        <div align="center">
          <input type="submit" name="Submit2" value="提交" />
        </div>      </td>
    </tr>
	</form>
  </table>
<%end sub
Sub Info
dim id,Rs
id=cint(Request.QueryString("id"))
Set Rs=Conn.Execute("select * from Ex_User where id="&id)
%>
<center>
<form action="?action=modi&id=<%=id%>" method="post">
<table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF" class="border">
  <tr>
    <th colspan="2" class="topbg">用户信息</th>
    </tr>
  <tr>
    <td width="27%" height="20" class="tdbg"><div align="center">用户名</div></td>
    <td width="73%" height="20" class="tdbg"><input type="text" name="username" value="<%=Rs("username")%>" readonly></td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">密码</div></td>
    <td height="20" class="tdbg"><input type="text" name="password">&nbsp;&nbsp;密码不修改请留空</td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">Email</div></td>
    <td height="20" class="tdbg"><input type="text" name="email" value="<%=Rs("email")%>"></td>
  </tr>
    <tr>
    <td height="20" class="tdbg"><div align="center">主页</div></td>
    <td height="20" class="tdbg"><input type="text" name="homepage" value="<%=Rs("homepage")%>"></td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">QQ</div></td>
    <td height="20" class="tdbg"><input type="text" name="qq" value="<%=Rs("qq")%>"></td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">性别</div></td>
    <td height="20" class="tdbg">
	<%If Rs("Sex")="男" Then %>
	<input type="radio" name="sex" value="男" checked/>男
	<input type="radio" name="sex" value="女" />女
	<%
	Else 
	%>
	<input type="radio" name="sex" value="男" />男
	<input type="radio" name="sex" value="女" checked/>女
	<%
	End If 
	%></td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">密码提示问题</div></td>
    <td height="20" class="tdbg"><input type="text" name="question" value="<%=Rs("question")%>"></td>
  </tr>
  <tr>
    <td height="20" class="tdbg"><div align="center">密码提示答案</div></td>
    <td height="20" class="tdbg"><input type="text" name="answer" value="<%=Rs("answer")%>"></td>
  </tr>
  <tr>
    <td height="20" colspan="2" class="tdbg"><div align="center">
      <input type="submit" name="Submit3" value="修改">
    </div></td>
    </tr>
</table>

</form>
</center>
<%
End Sub
Sub modi
	Dim username,password,sex,homepage,qq,email,question,answer,Sql
	UserName=ExComm.G(Request("username"))
	password=ExComm.G(Request("password"))
	sex=ExComm.G(Request("sex"))
	homepage=ExComm.G(Request("homepage"))
	qq=ExComm.G(Request("qq"))
	email=ExComm.G(Request("email"))
	question=ExComm.G(Request("question"))
	answer=ExComm.G(Request("answer"))
	If Trim(password)="" Then 
		Sql="update Ex_User set username='"&UserName&"',sex='"&sex&"',homepage='"&HomePage&"',qq='"&QQ&"',email='"&email&"',question='"&question&"',answer='"&answer&"' where id="&request.queryString("id")
	Else
		Sql="update Ex_User set username='"&UserName&"',sex='"&sex&"',homepage='"&HomePage&"',qq='"&QQ&"',email='"&email&"',question='"&question&"',answer='"&answer&"',userpwd='"&Md5(password)&"' where id="&request.queryString("id")
	End If 
	Conn.Execute Sql
	ExComm.ShowMsg "修改成功",""
End Sub 
'用户信息批量处理
sub DoUser()
Dim  ids,Sql
ids=request.Form("lock")
If ids<>"" Then 
	Sql="update Ex_user set lock=true where id in ("&ids&")"
	Conn.execute Sql
	ExComm.ShowMsg "操作成功",request.servervariables("http_referer")
End if
ids=request.Form("unlock")
If ids<>"" Then 
	Sql="update Ex_user set lock=false where id in ("&ids&")"
	Conn.execute Sql
	ExComm.ShowMsg "操作成功",request.servervariables("http_referer")
End if
ids=request.Form("del")
If ids<>"" Then 
	Sql="delete * from Ex_User where id in ("&ids&")"
	Conn.execute Sql
	ExComm.ShowMsg "操作成功",request.servervariables("http_referer")
End if
end Sub
%>
</body>
</html>
