<!--#include file="../Include/conig.asp"-->
<!--#include file="Admin_check.asp"-->
<!--#include file="../Include/md5.asp"-->
<%
response.expires = 0 
response.expiresabsolute = now() - 1 
response.addHeader "pragma","no-cache" 
response.addHeader "cache-control","private" 
Response.cachecontrol = "no-cache"
if Instr(session("AdminPurview"),"|211,")=0 then 
  response.write ("<font color='red')>你不具有该管理模块的操作权限，请返回！</font>")
  response.end
end if
'========判断是否具有管理权限 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<meta http-equiv="Content-Language" content="zh-CN" />
<link href="images/Admin_css.css" type=text/css rel=stylesheet>
<script language="javascript" src="images/Admin.js"></script>
<title>管理员管理</title>
</head>
<body>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,AdminName,Working,Password,vPassword,UserName,Purview,Explain,AddTime
ID=request.QueryString("ID")
if ID="" then ID=0
call AdminEdit() 
%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6298E1">
  <tr>
    <td height="24" nowrap background="images/skin/th_bg.gif"><font color="#FFFFFF">&nbsp;<strong>网站管理员：添加，修改管理员</strong></font></td>
  </tr>
  <tr>
    <td height="24" align="center" nowrap  bgcolor="#EBF2F9"><a href="Admin_Edit.asp?Result=Add" >添加管理员</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="Admin_List.asp" >查看所有管理员</a>|&nbsp;</font><a href="Admin_log.asp" >查看登陆日志</a></td>    
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#6298E1">
  <form name="editForm" method="post" action="Admin_Edit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" onSubmit="return CheckAdminEdit()">
  <tr>
    <td height="24" nowrap bgcolor="#EBF2F9"><table width="100%" border="0" cellpadding="0" cellspacing="0" id=editProduct idth="100%">

      <tr>
        <td width="120" height="20" align="right">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="25" align="right">登录帐号：</td>
        <td><input name="AdminName" type="text" class="textfield" id="AdminName" style="WIDTH: 120;" value="<%=AdminName%>" maxlength="16" <%if Result="Modify" then response.write ("readonly")%>>
        &nbsp;*&nbsp;不少于3位字符，不可修改</td>
      </tr>
      <tr>
        <td height="25" align="right">生　　效：</td>
        <td><input name="Working" type="checkbox" value="1" style="HEIGHT: 13px;WIDTH: 13px;" <%if Working=1 then response.write ("checked")%>></td>
      </tr>
      <tr>
        <td height="25" align="right">密　　码：</td>
        <td><input name="Password" type="password" class="textfield" id="Password" maxlength="20" style="WIDTH: 120;">&nbsp;*&nbsp;不少于3位字符，不填表未修改密码</td>
      </tr>
      <tr>
        <td height="25" align="right">确认密码：</td>
        <td><input name="vPassword" type="password" class="textfield" id="vPassword" maxlength="20" style="WIDTH: 120;">&nbsp;*</td>
      </tr>
      <tr>
        <td height="25" align="right">管理员名：</td>
        <td><input name="UserName" type="text" class="textfield" id="UserName" style="WIDTH: 120;" value="<%=UserName%>"></td>
      </tr>
      <tr>
        <td height="25" align="right">权限设置：</td>
        <td> <input onClick="CheckOthers(this.form)" name="buttonOtherSelect" type="button" class="button"  id="submitOtherSelect" value="选择" style="HEIGHT: 18px;WIDTH: 36px;"></td>
      </tr>
      <tr >
        <td height="25" align="right">系统配置：</td>
        <td nowrap>
		  <input name="Purview111" type="checkbox" value="|111," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|111,")>0 then response.write ("checked")%>>&nbsp;网站配置
          <input name="Purview112" type="checkbox" value="|112," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|112,")>0 then response.write ("checked")%>>&nbsp;导航管理
		  <input name="Purview113" type="checkbox" value="|113," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|113,")>0 then response.write ("checked")%>>&nbsp;留言管理
		  <input name="Purview114" type="checkbox" value="|114," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|114,")>0 then response.write ("checked")%>>&nbsp;文件管理
          <input name="Purview115" type="checkbox" value="|115," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|115,")>0 then response.write ("checked")%>>&nbsp;扩展管理
		  <input name="Purview116" type="checkbox" value="|116," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|117,")>0 then response.write ("checked")%>>&nbsp;广告管理
		  <input name="Purview117" type="checkbox" value="|117," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|118,")>0 then response.write ("checked")%>>&nbsp;链接管理
          <input name="Purview118" type="checkbox" value="|118," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|118,")>0 then response.write ("checked")%>>&nbsp;关于我们
          <input name="Purview119" type="checkbox" value="|119," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|119,")>0 then response.write ("checked")%>>&nbsp;数据空间
		  <input name="Purview121" type="checkbox" value="|121," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|121,")>0 then response.write ("checked")%>>&nbsp;封锁管理
		  <input name="Purview122" type="checkbox" value="|122," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|122,")>0 then response.write ("checked")%>>&nbsp;评论管理
		  <input name="Purview123" type="checkbox" value="|123," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|123,")>0 then response.write ("checked")%>>&nbsp;安全注入
		  <input name="Purview124" type="checkbox" value="|124," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|124,")>0 then response.write ("checked")%>>&nbsp;CC攻击
		  </td>
      </tr>
      <tr >
        <td height="25" align="right">用户管理：</td>
        <td>
		  <input name="Purview211" type="checkbox" value="|211," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|211,")>0 then response.write ("checked")%>>&nbsp;管理帐号
		  <input name="Purview212" type="checkbox" value="|212," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|212,")>0 then response.write ("checked")%>>&nbsp;密码修改
          <input name="Purview213" type="checkbox" value="|213," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|213,")>0 then response.write ("checked")%>>&nbsp;添加会员
		  <input name="Purview214" type="checkbox" value="|214," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|214,")>0 then response.write ("checked")%>>&nbsp;查看会员</td>
      </tr>
      <tr >
        <td height="25" align="right">新闻管理：</td>
        <td>
		  <input name="Purview311" type="checkbox" value="|311," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|311,")>0 then response.write ("checked")%>>&nbsp;栏目管理
		  <input name="Purview312" type="checkbox" value="|312," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|312,")>0 then response.write ("checked")%>>&nbsp;栏目添加
		  <input name="Purview313" type="checkbox" value="|313," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|313,")>0 then response.write ("checked")%>>&nbsp;新闻管理
		  <input name="Purview314" type="checkbox" value="|314," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|314,")>0 then response.write ("checked")%>>&nbsp;新闻添加</td>
      </tr>
      <tr >
        <td height="25" align="right">评选管理：</td>
        <td>
		  <input name="Purview811" type="checkbox" value="|811," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|811,")>0 then response.write ("checked")%>>&nbsp;栏目管理
          <input name="Purview812" type="checkbox" value="|812," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|812,")>0 then response.write ("checked")%>>&nbsp;栏目添加
          <input name="Purview813" type="checkbox" value="|813," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|813,")>0 then response.write ("checked")%>>&nbsp;评选管理
          <input name="Purview814" type="checkbox" value="|814," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|814,")>0 then response.write ("checked")%>>&nbsp;评选添加
          <input name="Purview815" type="checkbox" value="|815," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|815,")>0 then response.write ("checked")%>>&nbsp;多图管理
		  </td>
      </tr>
      <tr >
        <td height="25" align="right">评选数据：</td>
        <td>
		  <input name="Purview911" type="checkbox" value="|911," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|911,")>0 then response.write ("checked")%>>&nbsp;投票数据
          <input name="Purview912" type="checkbox" value="|912," style="HEIGHT: 13px;WIDTH: 13px;"
		  <%if Instr(Purview,"|912,")>0 then response.write ("checked")%>>&nbsp;投票记录
		  </td>
      </tr>
      <tr>
        <td height="25" align="right" valign="top">备注说明：</td>
        <td><textarea name="Explain" cols="88" rows="3" class="textfield" id="Explain" style="WIDTH: 580;" ><%=Explain%></textarea></td>
      </tr>
      <tr>
        <td height="30" align="right">&nbsp;</td>
        <td valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 60;" ></td>
      </tr>
      <tr>
        <td height="20" align="right">&nbsp;</td>
        <td valign="bottom">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  </form>
</table>
</BODY>
</HTML>
<%
sub AdminEdit()
  dim Action,rsCheckAdd,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑管理员
    set rs = server.createobject("adodb.recordset")
    if Result="Add" then '创建网站管理员
      set rsCheckAdd = conn.execute("select AdminName from Web_rui_v_manage where AdminName='" & trim(Request.Form("AdminName")) & "'")
      if not (rsCheckAdd.bof and rsCheckAdd.eof) then '判断此管理员名是否存在
        response.write "<script language=javascript> alert('" & trim(Request.Form("AdminName")) & "管理员已经存在，请换一个登录名再试试！');history.back(-1);</script>"
        response.end
      end if  
	  sql="select * from Web_rui_v_manage"
      rs.open sql,conn,1,3
      rs.addnew
      if len(trim(Request.Form("AdminName")))<3 or len(trim(Request.Form("Password")))>10  then
        response.write "<script language=javascript> alert('管理员登录名必填，且字符数为3-10位！');history.back(-1);</script>"
        response.end
      end if	  
      if len(trim(Request.Form("Password")))<6 or len(trim(Request.Form("Password")))>16  then
        response.write "<script language=javascript> alert('管理员密码必填，且字符数为6-16位！');history.back(-1);</script>"
        response.end
      end if
	  if Request.Form("Password")<>Request.Form("vPassword") then 
        response.write "<script language=javascript> alert('两次输入的密码不一样！');history.back(-1);</script>"
        response.end
	  end if
      rs("AdminName")=trim(Request.Form("AdminName"))
	  if Request.Form("Working")=1 then
        rs("Working")=Request.Form("Working")
	  else
        rs("Working")=0
	  end if
	  rs("Password")=md5(Request.Form("Password"))
	  rs("UserName")=trim(Request.Form("UserName"))
	  rs("AdminPurview")=Request.Form("Purview111") & Request.Form("Purview112") & Request.Form("Purview113") & Request.Form("Purview114") & Request.Form("Purview115") &_
	                     Request.Form("Purview116") & Request.Form("Purview117") & Request.Form("Purview118") & Request.Form("Purview119") & Request.Form("Purview121") & Request.Form("Purview122") & Request.Form("Purview123") & Request.Form("Purview124") &_
	                     Request.Form("Purview211") & Request.Form("Purview212") & Request.Form("Purview213") & Request.Form("Purview214") &_
	                     Request.Form("Purview311") & Request.Form("Purview312") & Request.Form("Purview313") & Request.Form("Purview314") &_
						 Request.Form("Purview811") & Request.Form("Purview812") & Request.Form("Purview813") & Request.Form("Purview814") & Request.Form("Purview815") &_
	                     Request.Form("Purview911") & Request.Form("Purview912") 
	  rs("Explain")=trim(Request.Form("Explain"))
	  rs("AddTime")=now()
	end if  
	if Result="Modify" then '修改网站管理员
      sql="select * from Web_rui_v_manage where ID="&ID
      rs.open sql,conn,1,3
      rs("AdminName")=trim(Request.Form("AdminName"))
	  if Request.Form("Working")=1 then
        rs("Working")=Request.Form("Working")
	  else
        rs("Working")=0
	  end if
      if trim(Request.Form("Password"))<>"" then
	    if len(trim(Request.Form("Password")))<6 or len(trim(Request.Form("Password")))>20  then
          response.write "<script language=javascript> alert('管理员密码必填，且字符数为6-20位！');history.back(-1);</script>"
          response.end
        end if
	    if Request.Form("Password")<>Request.Form("vPassword") then 
          response.write "<script language=javascript> alert('两次输入的密码不一样！');history.back(-1);</script>"
          response.end
	    end if
	    rs("Password")=md5(Request.Form("Password"))
	  end if
	  rs("UserName")=trim(Request.Form("UserName"))
	  rs("AdminPurview")=Request.Form("Purview111") & Request.Form("Purview112") & Request.Form("Purview113") & Request.Form("Purview114") & Request.Form("Purview115") &_
	                     Request.Form("Purview116") & Request.Form("Purview117") & Request.Form("Purview118") & Request.Form("Purview119") & Request.Form("Purview121") & Request.Form("Purview122") & Request.Form("Purview123")  & Request.Form("Purview124") &_
	                     Request.Form("Purview211") & Request.Form("Purview212") & Request.Form("Purview213") & Request.Form("Purview214") &_
	                     Request.Form("Purview311") & Request.Form("Purview312") & Request.Form("Purview313") & Request.Form("Purview314") &_
						 Request.Form("Purview811") & Request.Form("Purview812") & Request.Form("Purview813") & Request.Form("Purview814") & Request.Form("Purview815") &_
	                     Request.Form("Purview911") & Request.Form("Purview912") 
	  rs("Explain")=trim(Request.Form("Explain"))
	end if
	rs.update
	rs.close
    set rs=nothing 
    response.write "<script language=javascript> alert('成功编辑网站管理员！');location.replace('Admin_List.asp');</script>"
  else '提取管理员
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Web_rui_v_manage where ID="& ID
      rs.open sql,conn,1,1
	  AdminName=rs("AdminName")
	  Working=rs("Working")
	  UserName=rs("UserName")
	  Purview=rs("AdminPurview")
	  Explain=rs("Explain")
	  rs.close
      set rs=nothing 
	end if
  end if
end sub
  
%>