<%
'if instr(session("bolma_manage_user_flag"),"71")=0 then
  ' response.redirect "../login.asp"
  ' response.end
'end if
%>
<!--#include file="../db_conn.asp"-->
<!--#include file="include/menu.asp"-->
<script LANGUAGE="JavaScript">
function check()
{

  if (document.Form1.username.value=="")
     {
      alert("请输入用户名！")
      document.Form1.username.focus()
      document.Form1.username.select()
      return
     }
  if (document.Form1.password.value=="")
     {
      alert("请输入密码！")
      document.Form1.password.focus()
      document.Form1.password.select()		
      return
     }
     document.Form1.submit()
}
</SCRIPT>
<!--#include file="include/header.asp" -->
<body marginheight=0 marginwidth=0 leftmargin=0>
<%
'response.write "权限：" & session("bolma_manage_user_flag")
'response.end
if instr(session("bolma_manage_user_flag"),"41")=0 then
   Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请以<a href=../manage/login.asp><font color=#ff0000>管理员身份登陆</font></a>后进入。<br><li>您没有管理本页面的权限。"
   response.write Errmsg
   response.end
else
   call main()
   set rs=nothing
   conn.close
   set conn=nothing
end if
sub main()
%>
<center>
<table cellpadding=4 cellspacing=1 border=0 width=700>
        <tr>
          <td width="100%" valign=top>
          <%
           if request("action")="editsave" then 
              call editsave()
           elseif request("action")="add" then 
              call add()
           elseif request("action")="addsave" then 
              call addsave()
           else
              call manager()
           end if
           %>
           <p><%=body%></p>
	   </td>
    </tr>
  </table>
<%
end sub
sub manager()
dim sql
dim rs
dim id
id=request("id")
sql="select * from admin_users where id="&cstr(id)
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
<table border=0 cellPadding=0 cellSpacing=0 width="700">
  <tr>
    <td align="center">
      <form action="admin_user_ok.asp?action=editsave&id=<%=id%>" method="post" name="Form1">
      <table cellPadding=0 cellSpacing=0 width=700>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff>&nbsp;&nbsp;管理员信息修改--</td>
      </tr>
      <tr> 
         <td align="center" height="28">用&nbsp;户&nbsp;名：</td>
         <td><font color="#FFFFFF">&nbsp;&nbsp;<input type=text name=username size="20" class="smallInput" value=<%=rs("username")%>></font>
         </td>
      </tr>
      <tr>
         <td align="center" height="28">密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
         <td><font color="#FFFFFF">&nbsp;&nbsp;<input type=text name=password size="20" class="smallInput" value=<%=rs("password")%>></font></td>
      </tr>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff>管理权限</td>
      </tr>
      <tr>
         <td colspan=2>
         <%for i=0 to ubound(menu,1)%>
         <b><%=menu(i,0)%></b><br>
         <%
         for j=1 to ubound(menu,2)
         if isempty(menu(i,j)) then exit for
         tmpmenu=split(menu(i,j),",")
         menuname=tmpmenu(0)
         menurl=tmpmenu(1)
	 %>
	 <input type="checkbox" name="flag" <% if instr(session("bolma_manage_user_flag"),"31")=0 then response.write "disabled=true" %> value="<%=i&j%>" <% if instr(rs("flag"),i&j)<>0 then response.write "checked" %>><%=menuname%></a>&nbsp;&nbsp;
	<%next%><br><br>
<%next%></td>
       </tr>
       <tr>
         <td colspan=2 height="28" align="center" bgcolor=#e8f4ff> 
         <input type="button" value="修  改"  class="smallInput" onclick=check()>&nbsp;&nbsp;&nbsp;&nbsp;<input name=chkall type=checkbox value=on onclick=CheckAll(this.form)>选择所有权限
         </td>
       </tr>
     </table>
	 </form>
   </td>
  </tr>
</table>
<%
rs.close
set rs=nothing
end sub
sub editsave()
    if request("flag")="" then
		response.write "请至少选择一项权限！<a href=# onClick=history.go(-1)><font color=#ff0000>返回</font></a> "
		response.end
	end if
	set rs=server.createobject("adodb.recordset")
    sql="select * from admin_users where id="&request("id")
    rs.open sql,conn,3,2
    rs("username")=request("username")
    rs("password")=request("password")
    rs("flag")=request("flag")
    rs.update
    response.write "管理员信息修改成功，请<a href=admin_list.asp><font color=#ff000>继续</font></a>其他操作。"
end sub
sub add()
%>
<script language="JavaScript">
<!--
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked; 
   }
  }
//-->
</script>
<table border=0 cellPadding=0 cellSpacing=0 width="700">
  <tr>
    <td align="center">
      <form action="admin_user_ok.asp?action=addsave&id=<%=id%>" method="post" name="Form1">
      <table cellPadding=0 cellSpacing=0 width=700>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff><b>添加管理员--</b></td>
      </tr>
      <tr> 
         <td align="center" height="28">用&nbsp;户&nbsp;名：</td>
         <td><font color="#FFFFFF">&nbsp;&nbsp;<input type=text name=username size="20"></font>
         </td>
      </tr>
      <tr>
         <td align="center" height="28">密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
         <td>&nbsp;&nbsp;<input type=text name=password size="20"></td>
      </tr>
      <tr> 
         <td align="left" height="28" colspan=2 bgcolor=#e8f4ff><b>管理权限</b></td>
      </tr>
      <tr> 
         <td height="20" colspan=2></td>
      </tr>
      <tr>
         <td colspan=2>
         <%for i=0 to ubound(menu,1)%>
         <%=menu(i,0)%><br>
         <%
         for j=1 to ubound(menu,2)
         if isempty(menu(i,j)) then exit for
         tmpmenu=split(menu(i,j),",")
         menuname=tmpmenu(0)
         menurl=tmpmenu(1)
	 %>
	 <input type="checkbox" name="flag" <% if instr(session("bolma_manage_user_flag"),"31")=0 then response.write "disabled=true" %> value="<%=i&j%>"><%=menuname%></a>&nbsp;&nbsp;
	<%next%><br><br>
<%next%></td>
       </tr>
       <tr>
         <td colspan=2 height="28" align="center" bgcolor=#e8f4ff> 
         <input type="button" value="添  加"  class="smallInput" onclick=check()>&nbsp;&nbsp;&nbsp;&nbsp;<input name=chkall type=checkbox value=on onclick=CheckAll(this.form) <% if instr(session("bolma_manage_user_flag"),"31")=0 then response.write "disabled=true" %>>选择所有权限
         </td>
       </tr>
     </table>
	 </form>
   </td>
  </tr>
</table>
<%
end sub
sub addsave()
    if request("flag")="" then
		response.write "请至少选择一项权限！<a href=# onClick=history.go(-1)><font color=#ff0000>返回</font></a> "
		response.end
	end if
	set rs=server.createobject("adodb.recordset")
    sql="select * from admin_users"
    rs.open sql,conn,3,2
    rs.addnew
    rs("username")=request("username")
    rs("password")=request("password")
    rs("flag")=request("flag")
    rs.update
    response.write "管理员信息添加成功，请<a href=admin_user_ok.asp?action=add&ver=cn><font color=#ff000>继续添加</font></a>，或<a href=admin_list.asp?ver=cn>返回</a>进行其它操作。"
end sub
%>
</center>
