<!--#include file="../include/hf_conn.asp"-->
<!--#include file="checkadmin.asp"-->
<%call checkmanage("11")%>
<script language=javascript src=../include/mouse_on_title.js></script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
</head>
<BODY background="../images/admin/back.gif">

<%
if request("deladm")<>"" then
deladm=request("deladm")
call deladmin()
end if

admin=request("admin")
if admin="" then admin=request.cookies("hfvipok")("admin")
if request("edit")<>"ok" then
%>

<table width="98%" border="1" 
		style="border-collapse: collapse; border-style: dotted; border-width: 0px"  
		bordercolor="#333333" cellspacing="0" cellpadding="2">
	<tr class=backs><td colspan=2 class=td height=18>管理员权限设置</td></tr>
	<tr><td width=30% align=right height="100" align=center>
		<table border=0 width=90%>
		<tr><td>现有管理员：</td></tr>
		<%
		Set rs = conn.Execute("select * from hf_manage")
		do while not rs.eof
		response.write "<tr><td><img border=0 src=../images/admin/small_left.gif> "
		if admin=rs("username") then
		response.write "<a href=safe4.asp?admin="&rs("username")&"><font color=red><b>"&rs("username")&"</b></font></a>"
		else
		response.write "<a href=safe4.asp?admin="&rs("username")&">"&rs("username")&"</a>"
	end if
%>
	</td><td><img border=0 src=../images/admin/delete.gif alt="删除此管理员" style="cursor:hand" onClick="{if(confirm('该操作不可恢复！\n\n确实要删除这个管理员吗？ ')){location.href='safe4.asp?deladm=<%=rs("username")%>';}}"></td></tr>
	<%
	rs.movenext
	loop
	%>
	</table>
    </td>		
    <td align=center>
	<table border=0 width=60%>
	<form action="safe4.asp" method=post name=manage>
	<tr><td><font color=red><b><%=admin%></b></font> 的管理权限：</td></tr>
	<%
	Set rs = conn.Execute("select * from hf_manage where username='"&admin&"'")
		  if rs.eof and rs.bof then
			response.write "<script language='javascript'>"
			response.write "alert('没有此管理员！');"
			response.write "location.href='javascript:history.go(-1)';"
			response.write "</script>"
			response.end
		  end if
 		  manage=rs("manage")
		%>
		<tr><td><input type=checkbox value='yes' name=manage01 
			<%if instr(manage,"01")>0 then%>checked<%end if%>>综合设置</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage02 
			<%if instr(manage,"02")>0 then%>checked<%end if%>>栏目管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage03 
			<%if instr(manage,"03")>0 then%>checked<%end if%>>商品管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage13 
			<%if instr(manage,"13")>0 then%>checked<%end if%>>设备管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage04 
			<%if instr(manage,"04")>0 then%>checked<%end if%>>订单管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage05 
			<%if instr(manage,"05")>0 then%>checked<%end if%>>会员管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage06 
			<%if instr(manage,"06")>0 then%>checked<%end if%>>短信管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage07 
			<%if instr(manage,"07")>0 then%>checked<%end if%>>新闻管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage08 
			<%if instr(manage,"08")>0 then%>checked<%end if%>>支付方式</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage09 
			<%if instr(manage,"09")>0 then%>checked<%end if%>>广告管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage10 
			<%if instr(manage,"10")>0 then%>checked<%end if%>>留言管理</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage11 
			<%if instr(manage,"11")>0 then%>checked<%end if%>>安全设置</td></tr>
		<tr><td><input type=checkbox value='yes' name=manage12 
			<%if instr(manage,"12")>0 then%>checked<%end if%>>访问统计</td></tr>	

		</table>
	    </td>
	</tr>

	<tr><td colspan=2>
		<input type="submit" name="Submit" value="保存设置">
		<input type="hidden" name="edit" value="ok">
		<input type="hidden" name="admin" value="<%=admin%>">
	</td></tr>
</table>		
</form>

<%   
else

	manage=""
	if request.form("manage01")="yes" then manage=manage+"|01"
	if request.form("manage02")="yes" then manage=manage+"|02"
	if request.form("manage03")="yes" then manage=manage+"|03"
	if request.form("manage04")="yes" then manage=manage+"|04"
	if request.form("manage05")="yes" then manage=manage+"|05"
	if request.form("manage06")="yes" then manage=manage+"|06"
	if request.form("manage07")="yes" then manage=manage+"|07"
	if request.form("manage08")="yes" then manage=manage+"|08"
	if request.form("manage09")="yes" then manage=manage+"|09"
	if request.form("manage10")="yes" then manage=manage+"|10"
	if request.form("manage11")="yes" then manage=manage+"|11"
	if request.form("manage12")="yes" then manage=manage+"|12"
	if request.form("manage13")="yes" then manage=manage+"|13"

	Set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from hf_manage where username='"&admin&"'"
	rs.open sql,conn,1,3
		rs("manage")=manage
		rs.update
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing

	response.write "<script language='javascript'>"
	response.write "alert('管理权限设置成功！');"
	response.write "location.href='safe4.asp?admin="&admin&"';"
	response.write "</script>"
end if


sub deladmin()

	Set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from hf_manage where username='"&deladm&"'"
	rs.open sql,conn,1,3
		if (rs.bof and rs.eof) then
			response.write "<script language='javascript'>"
			response.write "alert('操作失败，没有此管理员！');"
			response.write "location.href='safe4.asp?admin="&admin&"';"
			response.write "</script>"
			response.end
		elseif deladm=request.cookies("buyok")("admin") then
			response.write "<script language='javascript'>"
			response.write "alert('您不能删除自己！');"
			response.write "location.href='safe4.asp?admin="&admin&"';"
			response.write "</script>"
			response.end
		else
		rs.delete
		rs.update
			response.write "<script language='javascript'>"
			response.write "alert('您已成功删除管理员"&deladm&"');"
			response.write "location.href='safe4.asp?admin="&admin&"';"
			response.write "</script>"
			response.end
		end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing

end sub
%>