<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/function.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员管理</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="style/js.js"></script>

</head>
<body id="page">
<%
'//批量操作
if request("action")=3 then
 select case request("sub")
   case 1
     conn.execute "update cw_user set pass='"&md5("123456")&"' where id in("&request("cid")&")"	 
   case 2
     uid=trim(request("cid"))
     call del_user(uid,"cw_info")
	 call del_user(uid,"cw_job")
	 call del_user(uid,"cw_bbs")
	 call del_user(uid,"cw_shop")
	 conn.execute "delete from cw_user where id in("&uid&")"
   case 3
     conn.execute("update cw_user set ismail=1 where id in("&request("cid")&")")
   case 4
     conn.execute("update cw_user set istel=1 where id in("&request("cid")&")")
   case 5
     conn.execute("update cw_user set iscard=1 where id in("&request("cid")&")")
   case 6
     conn.execute("update cw_user set isshiop=1 where id in("&request("cid")&")")
   case 7
     conn.execute("update cw_user set ismail=0 where id in("&request("cid")&")")
   case 8
     conn.execute("update cw_user set istel=0 where id in("&request("cid")&")")
   case 9
     conn.execute("update cw_user set iscard=0 where id in("&request("cid")&")")
   case 10
     conn.execute("update cw_user set isshop=0 where id in("&request("cid")&")")
   end select
   response.Write("<script>alert('操作成功!');</script>")  
end if
'//删除用户信息
function del_user(id,tab)
  set rs=server.CreateObject("adodb.recordset")
  sql="select userid from "&tab&" where userid in("&id&")"
  rs.open sql,conn,1,1
  if rs.recordcount>0 then
   response.Write("<script>alert('请先删除该用户相关的信息，再删除该用户！');history.back();</script>")
   response.End()
  end if
  rs.close
  set rs=nothing
end function
%>
<h2 class="title">会员管理</h2>
<table width="99%" border="0" align="center" class="line_table">
  <tr>
    <td height="20">&nbsp;网站后台管理 &gt;&gt; <a href="cw_user.asp">会员管理</a></td>
	<td align="right"><form action="cw_user.asp" method="post" name="form" onsubmit="if(this.key.value==''){this.key.focus();return false}">会员搜索
          <select name="lei" id="lei">
            <option value="1" <%if request("lei")=1 then%>selected="selected"<%end if%>>用户名</option>
            <option value="2" <%if request("lei")=2 then%>selected="selected"<%end if%>>用户ID</option>
          </select>
          <input name="key" type="text" id="key" size="18" maxlength="50" style="height:18px; line-height:18px" value="<%=request("key")%>" />
        <input type="submit" name="Submit2" value="搜索" /></form></td>
  </tr>
  </tr>
</table>
<%if request("add")="" then%>
<form action="cw_user.asp?action=3" method="post" name="form">
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
      <tr>
        <td width="3%" align="center" bgcolor="#F0F3F5">&nbsp;</td>
        <td width="6%" align="center" bgcolor="#F0F3F5">ID</td>
        <td width="13%" align="center" bgcolor="#F0F3F5">用户名</td>
		<td width="8%" align="center" bgcolor="#F0F3F5">用户类型</td>
        <td width="8%" align="center" bgcolor="#F0F3F5">联系人</td>
        <td width="12%" align="center" bgcolor="#F0F3F5">联系电话</td>
		<td width="11%" align="center" bgcolor="#F0F3F5">邮箱</td>	
		<td width="11%" align="center" bgcolor="#F0F3F5">上次登录</td>		
        <td width="14%" align="center" bgcolor="#F0F3F5">认证</td>
        <td width="13%" align="center" bgcolor="#F0F3F5">管理</td>
      </tr>
    <%
	   lei=request("lei")
	   key=trim(request("key"))
	   select case lei
	     case 1
		   sql="select * from cw_user where user like '%"&key&"%' order by id desc"
		 case 2
		   sql="select * from cw_user where id="&key&" order by id desc"
		 case else
		   sql="select * from cw_user order by id desc"
	   end select
		set rs1=server.CreateObject("adodb.recordset")
		rs1.open sql,conn,1,1
		if not rs1.eof then
		         page_count=15
  				 if Request("page")="" or Request("page")="0" then
   				  page=1
  				 else
    				 page=cint(Request("page"))
  				 End if 
					 totalcount=rs1.RecordCount
   				  totalpage=int(totalcount/page_count+(page_count-1)/page_count)
  				 if page>totalpage then page=totalpage
  				 if rs1.EOF then    
   				  else
   				  for i = 1 to (page-1)*page_count
    				   rs1.MoveNext
   				  Next
   				  if page<totalpage then
    				   psize=page_count
   				  else
   				    psize=totalcount-(page-1)*page_count
   				  End if
   				  for i = 1 to psize
		%>
      <tr>
        <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="cid" id="cid" value="<%=rs1("id")%>" /></td>
        <td align="center" bgcolor="#FFFFFF"><%=rs1("id")%></td>
        <td bgcolor="#FFFFFF">&nbsp;<%=rs1("user")%></td>
		<td align="center" bgcolor="#FFFFFF"><%if rs1("type")=0 then%>个人<%end if%><%if rs1("type")=1 then%>商家<%end if%><%if rs1("type")=2 then%>中介<%end if%></td>
        <td align="center" bgcolor="#FFFFFF"><%=rs1("names")%></td>
        <td align="center" bgcolor="#FFFFFF"><%=rs1("tel")%></td>
		<td align="center" bgcolor="#FFFFFF"><%=rs1("email")%></td>
		<td align="center" bgcolor="#FFFFFF" title="注册时间：<%=cw_date(rs1("adddate"),"yyyy/mm/dd")%>"><%=cw_date(rs1("logindate"),"yyyy/mm/dd")%></td>
		<td align="center" bgcolor="#FFFFFF">
		<a title="邮件验证" href="#"><span class="<%if rs1("ismail")=0 then%>sjyzw<%else%>sjyz<%end if%>"></span></a>&nbsp;
		<a title="手机验证" href="#"><span class="<%if rs1("istel")=0 then%>maileyzw<%else%>maileyz<%end if%>"></span></a>&nbsp;
		<a title="身份认证" href="#"><span class="<%if rs1("iscard")=0 then%>nameyzw<%else%>nameyz<%end if%>"></span></a>&nbsp;
		<a title="营业执照验证" href="#"><span class="<%if rs1("isshop")=0 then%>zzyzw<%else%>zzyz<%end if%>"></span></a></td>
	    <td align="center" bgcolor="#FFFFFF" ><a href="cw_user.asp?action=3&sub=1&cid=<%=rs1("id")%>" target="_self">重置密码</a> | <a href="cw_user.asp?sub=2&cid=<%=rs1("id")%>&action=3" onclick="return confirm('你确定要删除？')">删除</a></td>
      </tr>
	    <%
		rs1.MoveNext
 		next
		end if
		end if
		rs1.close
		set rs1=nothing
		%>
      <tr>
        <td colspan="10" bgcolor="#FFFFFF">
		<div style="float:left">
		<input name="button" type="button" onclick="qxbox(this.form.cid)" value="全 选" />
        &nbsp;&nbsp;
        <input name="button" type="button"  onclick="fxbox(this.form.cid)" value="反 选" />
        &nbsp;&nbsp;
        <select name="sub" id="sub">
          <option value="">请选择操作</option>
          <option value="3">通过邮箱认证</option>
		  <option value="4">通过手机认证</option>
		  <option value="5">通过身份认证</option>
		  <option value="6">通过商家认证</option>
		  <optgroup label="&nbsp;&nbsp;"></optgroup>
		  <option value="7">取消邮箱认证</option>
		  <option value="8">取消手机认证</option>
		  <option value="9">取消身份认证</option>
		  <option value="10">取消商家认证</option>
		  <optgroup label="&nbsp;&nbsp;"></optgroup>
		  <option value="1">重置密码</option>
		  <option value="2">删除用户</option>
        </select>
        <input type="submit" name="Submit" value="批量执行操作" onclick="return confirm('你确定要执行？')" />
        &nbsp;&nbsp;重置密码为123456</div>
		<!--#include file="../inc/page.asp"-->
		</td>
      </tr>
    </table>
</form>
	<%end if%>
<%
call closes()
%>
</body>
</html>
