<!--#include file="../include/config.asp"-->
<!--#include file="checkadmin.asp"-->
     <%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("10")%>
<script language=javascript src=../include/mouse_on_title.js></script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
</head>
<BODY bgcolor="#D9EAFC">
<%
if request("deladm")<>"" then
deladm=request("deladm")
call deladmin()
end if

admin=request("admin")
if admin="" then admin=request.cookies("buyok")("admin")
if request("edit")<>"ok" then
%>
		  <table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR> 
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">管理员权限设置</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30></TD>
    </TR>
  </TBODY>
</TABLE>		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <tr bgcolor="#FFFFFF"><td width=30% height="100" align=center>
    <table border=0 width=90%>
      <tr>
        <td>现有管理员：</td>
      </tr>
      <%
		Set rs = conn.Execute("select * from 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 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=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 bgcolor="#ffffff">
    <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"

	Set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from 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 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
%>
