<!--#include file="conn.asp"-->
<%
	'On Error Resume Next '遇有错误仍继续执行 
	
	'检查访问的来源是否合法
	call checkPrePage()
	
	'检查用户访问的权限
	call checkuser(1)


if GetFormVariable("txtaction")="dele" then
	'删除用户
	strDelete="('"
	'1、删除站点文件
	strSQL="Select m_name From member Where id in(0" & GetFormVariable("isDel") & ")"
	rs.open strSQL,conn,1,1
	Set fs = Server.CreateObject( Const_ScriptFileSystem )
	for i=1 to rs.recordcount
		strm_Name=Trim(rs("m_name"))
		webFolder=Server.MapPath( "Home/" & strm_Name)
		if fs.FolderExists(webFolder) then
			fs.DeleteFolder webFolder,true
		end if
		
		webFolder=Server.MapPath( "Home/" & strm_Name & "_Big5")
		if fs.FolderExists(webFolder) then
			fs.DeleteFolder webFolder,true
		end if
		
		webFolder=Server.MapPath( "Home/" & strm_Name & "_Eng")
		if fs.FolderExists(webFolder) then
			fs.DeleteFolder webFolder,true
		end if
		
		webFolder=Server.MapPath( "Home/" & strm_Name & "_Kor")
		if fs.FolderExists(webFolder) then
			fs.DeleteFolder webFolder,true
		end if
		
		webFolder=Server.MapPath( "Home/" & strm_Name & "_Jap")
		if fs.FolderExists(webFolder) then
			fs.DeleteFolder webFolder,true
		end if
		
		strDelete=strDelete & strm_Name & "','" & strm_Name & "_Big5','" & strm_Name & "_Eng','" & strm_Name & "_Kor','" & strm_Name & "_Jap','"
		
		rs.movenext
	next
	strDelete=strDelete & "')"
	rs.close
	Set fs=nothing
	
	strSQL="Select id From member Where m_name in " & strDelete
	set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open strSQL,conn,1,1
	strIDs="("
	for i=1 to rs.recordcount
		strIDs=strIDs & Trim(rs("id")) & ","
		rs.movenext
	next
	strIDs=strIDs & "0)"
	rs.close
	
	'2、删除用户表记录
	conn.execute "Delete From member Where id in " & strIDs,0,1
	
	'3、删除网站表记录
	strSQL="Delete From website Where m_id in " & strIDs
	conn.execute strSQL,0,1
	
	'4、删除菜单表记录
	strSQL="Delete From menu Where m_id in " & strIDs
	conn.execute strSQL,0,1
	
end if

if GetFormVariable("txtaction")="lock" then

	'封杀用户
	strSQL="Select m_name From member Where id in(0" & GetFormVariable("isNotUse") & ") And m_lock=0"
	Set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open strSQL,conn,1,1
	Set fs = Server.CreateObject( Const_ScriptFileSystem )
	for i=1 to rs.recordcount
		strm_Name=Trim(rs("m_name"))
		if fs.FolderExists(Server.MapPath( "Home/" & strm_Name)) then
			fs.CopyFile Server.MapPath( "Home/close.asp"),Server.MapPath( "Home/" & strm_Name & "/conn.asp"),true
		end if
		rs.movenext
	Next
	rs.close
	
	strSQL="Update member Set m_lock=1  Where id in(0" & GetFormVariable("isNotUse") & ") And m_lock=0"
	conn.execute strSQL,0,1
	
	
	'解锁用户
	strSQL="Select m_name From member Where id in(0" & GetFormVariable("txtUnlock") & ") And m_lock=1"
	Set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open strSQL,conn,1,1
	Set fs = Server.CreateObject( Const_ScriptFileSystem )
	for i=1 to rs.recordcount
		strm_Name=Trim(rs("m_name"))
		if fs.FolderExists(Server.MapPath( "Home/" & strm_Name)) then
			fs.CopyFile Server.MapPath( "Home/open.asp"),Server.MapPath( "Home/" & strm_Name & "/conn.asp"),true
		end if
		rs.movenext
	Next
	rs.close
	
	strSQL="Update member Set m_lock=0  Where id in(0" & GetFormVariable("txtUnlock") & ") And m_lock=1"
	conn.execute strSQL,0,1
	
end if


strQueryString="&type=" & GetVariable("type") & "&code=" & GetVariable("code") & "&state=" & GetVariable("state") & "&txtkey=" & GetVariable("txtkey") & "&SchType=" & GetVariable("SchType") & "&agent=" & GetVariable("agent")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>电子商务自助建站--您理想的助手</title>
<link href="common/styleMain.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function CCA(objCheckBox){
	alert(objCheckBox.length);
}

function LockUser(){
	if(!confirm('确定要封杀选择的用户吗？　')){
		return false;
	}
	else{
		form1.txtaction.value="lock";
		form1.txtUnlock.value="";
		if (form1.isNotUse.length==null){
			if (!form1.isNotUse.checked){
				form1.txtUnlock.value=form1.isNotUse.value;
			}
		}else
		{
			for(i=0;i<form1.isNotUse.length;i++){
				if (!form1.isNotUse[i].checked){
					form1.txtUnlock.value+=form1.isNotUse[i].value + ",";
				}
			}
			form1.txtUnlock.value+="0";
		}
		return true;
	}
}

function DeleUser(){
	if(!confirm('确定要删除选择的用户吗？　')){
		return false;
	}
	else{
		form1.txtaction.value="dele";
		return true;
	}
}

function checksearch(theform){
	if (theform.txtkey.value==""){
		alert("请输入搜索关键字 ");
		return false;
	}
}

function CheckAll(objCheck,isChecked){
	if (objCheck==null) return false;
		if (objCheck.length==null){
			objCheck.checked=isChecked;
		}
		else
		{
			for(i=0;i<objCheck.length;i++){
				objCheck[i].checked=isChecked;
			}
		}
}
</script>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="0" align="center">
		  <!--#include file="common/top.asp"-->
          </td>
        </tr>
        <tr> 
          <td height="100%" align="center" valign="top">
<TABLE class=table002 cellSpacing=0 cellPadding=0 border=0>
              <TBODY>
                <TR> 
                  <!--左边开始-->
                  <TD width="20%" align=right vAlign=top> <!--#include file="common/adminleft.asp"--> </TD>
                  <!--左边结束-->
                  <TD width="2%" background="images/rowline.gif">&nbsp;</TD>
                  <!--右边开始-->
                  <TD vAlign=top align=center width="78%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr> 
                        <td><form name="form1" method="post" action="?t=<%=strQueryString%>">
                            <TABLE width="100%" height="100%" border=0 cellPadding=6 cellSpacing=0>
                              <TBODY>
                                <TR> 
                                  <TD vAlign=top align=left bgColor=#ffffff><strong><font color="#FF0000">网站<%=GetQueryString("state")%></font></strong> 
                                    <input name="txtaction" type="hidden" id="txtaction3" value="dele"> 
                                    <input name="txtUnlock" type="hidden" id="txtUnlock3"> 
                                    <BR> <HR SIZE=1> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr> 
                                        <td> 
                                          <%
	strCode=GetQueryString("code")
	strType=GetQueryString("type")
	strKey=GetVariable("txtkey")
	strSchType=GetVariable("SchType")
	strQuery=""
	if strCode<>"" then
		strQuery=" And m_code=" & strCode
	end if
	Select Case strType
		Case ""
		
		Case "1"
			'付费用户
			strQuery=strQuery & " And m_expire>getdate() And m_expire<>m_regdate+7"		
		
		Case "2"
			'过期用户
			strQuery=strQuery & " And m_expire<getdate() "		
		
		Case "3"
			'试用用户
			strQuery=strQuery & " And m_expire=m_regdate+7 And m_money<=0 "		
		
		Case "4"
			'开通用户
			strQuery=strQuery & " And m_lock=0 "		
		
		Case "5"
			'封杀用户
			strQuery=strQuery & " And m_lock=1 "		
		
	End Select
	
	if strKey<>"" then
	Select Case strSchType
		Case ""
			strQuery=strQuery & " And (m_name Like '%" & strKey & "%' Or m_email Like '%" & strKey & "%')"
		
		Case "id"
			strQuery=strQuery & " And id=" & strKey
		
		Case "email"
			strQuery=strQuery & " And m_email Like '%" & strKey & "%'"
		
		Case "oicq"
			strQuery=strQuery & " And m_oicq Like '%" & strKey & "%'"
	End Select
	end if

	'不是网站管家只能看到自己的用户
	'查看代理商下面的用户 ，默认情况是自己下的用户
	'if Request.QueryString("agent")<>"" then
	'	strQuery=strQuery & " And m_AgentName=" & Cint(Request.QueryString("agent"))
	'else
		if Trim(Session("UserCode"))<=5 then
			strQuery=strQuery & " And m_AgentName=" &  Session("UserID")
		end if
	'end if
		
'	strSQL="Select * From v_member_agent Where Not(m_name Like '%[_]%') " & strQuery & " Order by id Desc"
	strSQL="Select * From v_member_agent Where 1=1 " & strQuery & " Order by id Desc"
	set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open strSQL,conn,1,1
	
	'分页显示初始化
page=GetVariable("page")
if page="" then
	page=1
else
	page=Cint(page)
end if

Section=GetVariable("section")
if Section="" then
	Section=1
else
	Section=Cint(Section)
end if
'变量赋值
intPageSize=20		'每页显示记录数
intSectionSize=5		'多少页为一段，像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>"		'上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>"		'下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>"			'上页的链接文字	
NextPageText="<FONT face=webdings>4</FONT>"			'下页的链接文字

strPageUrl="?t=" & strQueryString

rs.pagesize=intPageSize
intCount=rs.RecordCount 
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
if intCount>0 then
	rs.AbsolutePage=page  
end if

%>
                                          <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#5F8AC5">
                                            <tr align="center" bgcolor="#5F8AC5"> 
                                              <td width="46"><b><font color="#FFFFFF" face=verdana>ID</font></b></td>
                                              <td width="78"><font color="#FFFFFF"><b>用户名称</b></font></td>
                                              <td width="82" bgcolor="#5F8AC5"><font color="#FFFFFF"><b>使用期限</b></font></td>
                                              <td width="122"><font color="#FFFFFF"><strong>注册时间</strong></font></td>
                                              <td width="45"><font color="#FFFFFF"><strong>状态</strong></font></td>
                                              <td width="63"><font color="#FFFFFF"><strong>级别</strong></font></td>
                                              <td width="49"> <font color="#FFFFFF"> 
                                                <input type="submit" name="submit2" value="封杀" onClick="return LockUser()">
                                                </font></td>
                                              <td width="47"> <font color="#FFFFFF"> 
                                                <input type="submit" name="submit3" value="删除" onClick="return DeleUser()">
                                                </font></td>
                                            </tr>
                                            <%
									 '循环输出
									 for i=1 to intPageSize
										if rs.eof then exit for
										if i mod 2=0 then
											strColor="#F8F8F8"
										else
											strColor="#fFfFfF"
										end if
									 %>
                                            <tr bgcolor="<%=strColor%>"> 
                                              <td align="right" bgcolor="<%=strColor%>"><font color=#5E5E5E face=verdana><%=rs("id")%></font></td>
                                              <td><a href="Admin_Userinfo.asp?id=<%=rs("id")%>"><%=rs("m_name")%></a></td>
                                              <td><%=rs("m_expire")%></td>
                                              <td><%=rs("m_regdate")%></td>
                                              <td align="center"> <font color="#5E5E5E"> 
                                                <%
										regdate=rs("m_regdate")
										expire=rs("m_expire")
										if DateDiff("d",regdate,expire)=7 And DateDiff("d",date,expire)>=0 then
											response.Write("试用")
										end if
										
										if DateDiff("d",regdate,expire)>7 And DateDiff("d",date,expire)>=0 then
											response.Write("正常")
										end if
										
										if DateDiff("d",date,expire)<0 then
											response.Write("过期")
										end if
										
										%>
                                                </font> </td>
                                              <td align="center">
											  <%
	Dim DIS_MemberLevel
	Select Case Trim(rs("m_code"))
		Case "0"
			DIS_MemberLevel="普通会员"
		Case "1"
			DIS_MemberLevel="普通代理"
		Case "2"
			DIS_MemberLevel="高级代理"
		Case "3"
			DIS_MemberLevel="合作伙伴"
		Case "4"
			DIS_MemberLevel="战略伙伴"
		Case "5"
			DIS_MemberLevel="区域管家"
		Case "6"
			DIS_MemberLevel="总管家"
	End select
%><%=DIS_MemberLevel%>											  </td>
                                              <td align="center"> 
                                                <%
										strChecked=""
										if rs("m_lock") then
											strChecked="Checked"
										end if
										%>
                                                <input type="checkbox" name="isNotUse" value="<%=rs("id")%>" <%=strChecked%>> 
                                              </td>
                                              <td align="center"> <input type="checkbox" name="isDel" value="<%=rs("id")%>"></td>
                                            </tr>
                                            <%
										 rs.movenext
									  next
									  %>
                                          </table></td>
                                      </tr>
                                      <tr> 
                                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr> 
                                              <td width="87%" height="25" align="right">全选<input name="chkAllLock" type="checkbox" id="chkAllLock" onClick="CheckAll(form1.isNotUse,this.checked)">
                                              </td>
                                              <td width="13%" align="center">全选<input name="chkAllDele" type="checkbox" id="chkAllDele" onClick="CheckAll(form1.isDel,this.checked)">
                                              </td>
                                            </tr>
                                            <tr> 
                                              <td height="25" colspan="2" align="right"> 
                                                共有<%=intCount%>记录，分<%=intPageCount%>页，当前页<%=Page%>，每页显示<%=intPageSize%>条记录 
                                                <%
												'计算每一段的开始页
												intStarPage=(Section-2) * intSectionSize + 1
												'前一段
												if Section<=1 then
													response.Write(PrevSectionText & " ")
												else
													response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
												end if 
												
												'显示页码列表
												response.Write("第")
												intStarPage=(Section-1) * intSectionSize + 1
												for p=intStarPage to intStarPage + intSectionSize - 1
													if p > intPageCount then exit for
													if p=page then
														response.Write("<strong>[" & p & "]</strong> ")
													else
														response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
													end if	
												next
												response.Write("页")
												'后一段
												intStarPage=(Section) * intSectionSize + 1
												if Section>=intSectionCount then
													response.Write(" " & NextSectionText)
												else
													response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
												end if 
											  %>
                                                　 </td>
                                            </tr>
                                          </table></td>
                                      </tr>
                                    </table></TD>
                                </TR>
                              </TBODY>
                            </TABLE>
                          </form>
						 </td>
                      </tr>
                      <tr>
                        <td align="center"> 
                          <form action="?state=用户搜索：搜索结果" method="post" name="search" id="search" onSubmit="return checksearch(this)">
                            <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#5F8AC5">
                              <tr> 
                                <td bgcolor="#5F8AC5">&nbsp<strong><font color="#FFFFFF">用户搜索</font></strong></td>
                              </tr>
                              <tr> 
                                <td height="40" align="center" bgcolor="F9F9F9"> 
                                  关键字： 
                                  <input name="txtkey" type=text id="txtkey" value="" size=30> 
                                  <select name="SchType">
                                    <option value="" selected>模糊查询</option>
                                    <option value="id" >用户ID</option>
                                    <option value="name" >单位域名</option>
                                    <option value="email" >email</option>
                                    <option value="oicq" >oicq</option>
                                  </select> <input type=submit name="submit" value="搜 索">
                                </td>
                              </tr>
                            </table>
                          </form></td>
                      </tr>
                    </table> 
                  </TD>
                </TR>
              </TBODY>
            </TABLE>
          </td>
        </tr>
        <tr> 
          <td height="0" align="center">
		  <!--#include file="common/bottom.asp"-->
		  </td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
