<!--#include file="../inchuayuwebrlzywzhyweb/conn.asp"-->
<!--#include file="../inchuayuwebrlzywzhyweb/cls_huayuweb()^191563631.asp"-->
<!--#include file="../inchuayuwebrlzywzhyweb/md5.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript" src="../js/input.js" type="text/javascript"></script>
<%oa.chkadmin()%>
<%
  select case oa.act
         case "add"
		  useradd()
		 case "mod"
		  usermod()
		 case "del"
		   userdel()
		 case "main_mod"
		  main_mod()
		 case else
		 main_add()
  end select
sub userdel()
dim adminid
adminid=request("adminid")
if adminid="" or not isnumeric(adminid) then oa.msgshow("非法操作！")
oa.execute("delete from d_manage_ulevel where adminid="&adminid)
oa.execute("delete from admin where adminid="&adminid)
oa.msgshowurl "删除成功！","admin_manage.asp"

end sub

sub useradd()
dim adminid,username,pswd,pswd1,ulevel,i,level
username=request.Form("adminname")
pswd=request.Form("pswd")
pswd1=request.Form("pswd1")
ulevel=request.Form("ulevel")
level=request.Form("level")
if len(username)<5 or oa.chkchar(username,"char")=false then oa.msgshow("用户名必须为英文大小写、数字、组成！请不要输入非法字符！")
if pswd="" then oa.msgshow("密码不能为空！")
if pswd1<>pswd then oa.msgshow("两次输入的密码不同！请返回重新输入！")
if level=1 then
if ulevel="" then oa.msgshow("请为管理员选择栏目权限！")
end if
set rs=oa.execute("select * from admin where adminname='"&username&"'")
if not rs.eof then oa.msgshow("该用户名已经存在请返回重新输入！")
adminid=oa.getid("d_manage_ulevel")
if not isobject(conn) then connectiondatabase
set rs=server.createobject("adodb.recordset")
rs.open "select * from admin",conn,1,3
rs.addnew()
rs("adminid")=adminid
rs("adminname")=username
rs("adminpswd")=md5(pswd,32)
rs("level")=level
rs.update()
rs.close
oa.execute("delete from d_manage_ulevel where adminid="&adminid)

if level=1 then
for i=0 to ubound(split(ulevel,","))
if not isnumeric(split(ulevel,",")(i)) then oa.msgshow("非法操作！")
oa.execute("insert into d_manage_ulevel (classid,adminid) values ("&split(ulevel,",")(i)&","&adminid&")")
next
else
oa.execute("insert into d_manage_ulevel (classid,adminid) select classid,"&adminid&" from classlist where parentid=0")

end if


oa.msgshowurl "添加成功！","admin_manage.asp"

End sub


sub usermod()
dim adminid,username,pswd,pswd1,ulevel,i,level
username=request.Form("adminname")
pswd=request.Form("pswd")
pswd1=request.Form("pswd1")
ulevel=request.Form("ulevel")
adminid=request.form("adminid")
level=request.Form("level")
if adminid="" or not isnumeric(adminid) then oa.msgshow("非法操作！")
if len(username)<5 or oa.chkchar(username,"char")=false then oa.msgshow("用户名必须为英文大小写、数字、组成！请不要输入非法字符！")

if pswd1<>pswd then oa.msgshow("两次输入的密码不同！请返回重新输入！")
if level=1 then
if ulevel="" then oa.msgshow("请为管理员选择栏目权限！")
end if
set rs=oa.execute("select * from admin where adminname='"&username&"' and adminid<>"&adminid)
if not rs.eof then oa.msgshow("该用户名已经存在请返回重新输入！")

if not isobject(conn) then connectiondatabase
set rs=server.createobject("adodb.recordset")
rs.open "select * from admin where adminid="&adminid,conn,1,3
rs("adminname")=username
if pswd<>"" then
rs("adminpswd")=md5(pswd,32)
end if
rs("level")=level
rs.update()
rs.close
oa.execute("delete from d_manage_ulevel where adminid="&adminid)
if level=1 then
for i=0 to ubound(split(ulevel,","))
if not isnumeric(split(ulevel,",")(i)) then oa.msgshow("非法操作！")
oa.execute("insert into d_manage_ulevel (classid,adminid) values ("&split(ulevel,",")(i)&","&adminid&")")
next
else
oa.execute("insert into d_manage_ulevel (classid,adminid) select classid,"&adminid&" from classlist where parentid=0")

end if


oa.msgshowurl "修改成功！","admin_manage.asp"

End sub
%>
<link href="../inchuayuwebrlzywzhyweb/style.css" rel="stylesheet" type="text/css">

<% sub main_add()%>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
<table width="98%" height="35" border="0" align="center" cellpadding="0" cellspacing="0" background="../img/line.gif">
  <tr>
    <td align="center" bgcolor="#6298E1" style="color:white"><div align="left"><strong>&nbsp;<img src="../img/Explain.gif" width="18" height="18" align="absmiddle" />&nbsp;管理员添加</strong></div></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#6298E1">
  <form action="admin_manage.asp" method="post" name="form1" id="form1" onSubmit="return check()">
    
    <tr bgcolor="#FFFFFF">
      <td width="141" align="left" bgcolor="#EBF2F9"><U>管理员用户名：</U>      </td>
      <td width="698" bgcolor="#EBF2F9"><input name="adminname" type="text" class="wenbenkuang" id="adminname" size="20" />
        &nbsp;&nbsp;
      <input name="action" type="hidden" id="action" value="add" /></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>管理员密码：</U><br /></td>
      <td bgcolor="#EBF2F9"><input name="pswd" type="password" class="wenbenkuang" id="pswd" size="20" /><span class="STYLE1">注：5位以上的英文大小写、数字、组成</span></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>确认密码：</U></td>
      <td bgcolor="#EBF2F9"><input name="pswd1" type="password" class="wenbenkuang" id="pswd1" size="20" /></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>管理员等级：</U></td>
      <td bgcolor="#EBF2F9"><select name="level" id="level" onchange="if(this.value==1){document.getElementById('aaa').style.display='';}else{document.getElementById('aaa').style.display='none';}">
	    
	    <option value="1">普通管理员</option>
        <option value="0">超级管理员</option>
        
      </select>      </td>
    </tr>
   
    <tr bgcolor="#FFFFFF"  id="aaa">
      <td align="left" bgcolor="#EBF2F9"><U>管理员权限：</U></td>
      <td bgcolor="#EBF2F9"> <% dim classrs
	   set classrs=oa.execute("select classid,classname from classlist where parentid=0")
	  do while not classrs.eof%>
	  <input name="ulevel" type="checkbox" id="ulevel" value="<%=classrs(0)%>"><%=classrs(1)%>
	  
	  <%classrs.movenext
	  loop
	  classrs.close
	  set classrs=nothing	  
	  %></td>
    </tr>
    
    
    
    <tr bgcolor="#FFFFFF">
      <td colspan="2" align="center" bgcolor="#EBF2F9"><input name="Add" type="submit" value="添加"  /></td>
    </tr>
  </form>
</table>
<%end sub%>


<% sub main_mod()
dim adminid
adminid=request("adminid")
if adminid="" or not isnumeric(adminid) then oa.msgshow("非法操作！")
set rs=oa.execute("select * from admin where adminid="&adminid)
if rs.eof then oa.msgshow("该管理员不存在或已被删除！请返回重新选择！")

%>
<table width="98%" height="35" border="0" align="center" cellpadding="0" cellspacing="0" background="../img/line.gif">
  <tr>
    <td align="center" bgcolor="#6298E1" style="color:white"><div align="left"><strong>&nbsp;<img src="../img/Explain.gif" width="18" height="18" align="absmiddle" />&nbsp;管理员修改</strong></div></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#6298E1">
  <form action="admin_manage.asp" method="post" name="form1" id="form1" onSubmit="return check()">
    
    <tr bgcolor="#FFFFFF">
      <td width="140" align="left" bgcolor="#EBF2F9"><U>管理员用户名：</U>      </td>
      <td width="699" bgcolor="#EBF2F9"><input name="adminname" type="text" class="wenbenkuang" id="adminname" size="20" value="<%=rs("adminname")%>" />
        &nbsp;&nbsp;
      <input name="action" type="hidden" id="action" value="mod" /></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>管理员密码：</U><br /></td>
      <td bgcolor="#EBF2F9"><input name="pswd" type="password" class="wenbenkuang" id="pswd" size="20" />
      <span class="STYLE1">注：不修改密码请留空</span></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>确认密码：</U></td>
      <td bgcolor="#EBF2F9"><input name="pswd1" type="password" class="wenbenkuang" id="pswd1" size="20" />
      <span class="STYLE1">注：不修改密码请留空</span></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td align="left" bgcolor="#EBF2F9"><U>管理员等级：</U></td>
      <td bgcolor="#EBF2F9"><select name="level" id="level" onchange="if(this.value==1){document.getElementById('aaa').style.display='';}else{document.getElementById('aaa').style.display='none';}">
          <option value="1" <% if rs("level")=1 then response.write "selected='selected'"%>>普通管理员</option>
          <option value="0" <% if rs("level")=0 then response.write "selected='selected'"%>>超级管理员</option>
        </select>
      </td>
    </tr>
	 
    <tr bgcolor="#FFFFFF"  id="aaa" style="display:<%if rs("level")=0 then response.write "none"%>">
      <td align="left" bgcolor="#EBF2F9"><U>管理员权限：</U></td>
      <td bgcolor="#EBF2F9">
	  <% dim classrs,ulevelrs,i
	  ulevelrs=oa.getrow("select * from d_manage_ulevel where adminid="&adminid)
	   set classrs=oa.execute("select classid,classname from classlist where parentid=0")
	  do while not classrs.eof%>
	  <input name="ulevel" type="checkbox" id="ulevel" value="<%=classrs(0)%>" 
	  <% if not isnull(ulevelrs) then
	       for i=0 to ubound(ulevelrs,2)
		      if ulevelrs(0,i)=classrs(0) then
			    response.write "checked"
			  end if
		   next
	     end if
	  %>><%=classrs(1)%>
	  
	  <%classrs.movenext
	  loop
	  classrs.close
	  set classrs=nothing	  
	  %>	 </td>
    </tr>
    
    
    
    <tr bgcolor="#FFFFFF">
      <td colspan="2" align="center" bgcolor="#EBF2F9"><input name="Add" type="submit" value="修改"  />
      <input name="adminid" type="hidden" id="adminid" value="<%=adminid%>"></td>
    </tr>
  </form>
</table>
<%end sub%>

 <br>
 <table width="98%" height="35" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#6298E1">
   <tr>
     <td align="center" style="color:white"><div align="left"><strong>&nbsp;<img src="../img/Explain.gif" width="18" height="18" align="absmiddle" />&nbsp;用 户 管 理</strong></div></td>
   </tr>
</table><table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6298E1">
  <tr>
    <td width="99" height="22" align="center" bgcolor="#FFFFFF"><div align="center"><strong>用户名</strong></div></td>
    <td width="343" align="center" bgcolor="#FFFFFF"><div align="center"><strong>用户权限</strong><strong></strong></div></td>
    <td width="404"  align="center" bgcolor="#FFFFFF"><div align="center"><strong>操作</strong></div></td>
  </tr>
  <% 
  dim clars,userrs,ulevelrs,i,j,k
   clars=oa.getrow("select classid,classname from classlist where parentid=0")
  
   userrs=oa.getrow("select adminid,adminname,[level] from admin order by [level]")
   
   ulevelrs=oa.getrow("select adminid,classid from d_manage_ulevel")
 
 if not isnull(userrs) then
    for i=0 to ubound(userrs,2)
%>
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''"> 
    <td height="22" align="left" bgcolor="#FFFFFF" style="padding-left:5px" ><div align="center"><%=userrs(1,i)%>   </div></td>
    <td align="center" bgcolor="#FFFFFF" ><div align="center">
      <%
 if userrs(2,i)=1 then
	if not isnull(ulevelrs) then
	    for j=0 to ubound(ulevelrs,2)
		    if ulevelrs(0,j)=userrs(0,i) then
			      if not isnull(clars) then
				       for k=0 to ubound(clars,2)
					       if clars(0,k)=ulevelrs(1,j) then
						     response.write clars(1,k)&" | "
						   end if
						next
				  
				  
				  end if
			end if
		next
	end if	
 else
 response.Write("<font color='red'>超级管理员</font>")
 end if
	%>
    </div></td>
    <td align="center" bgcolor="#FFFFFF"><div align="center">

        <a href="admin_manage.asp?action=main_mod&adminid=<%=userrs(0,i)%>" class="a2">修改</a> 
    | <a href="admin_manage.asp?adminid=<%=userrs(0,i)%>&action=del" onclick="return confirm('您确认要删除该管理员吗？删除后将不能恢复！')" class="a2">删除</a>
   
    </div></td>
  </tr>
  <% 
   next  
end if

%>
</table>


