<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'……………………版权信息……………………
'本软件已登记软件著作权，版权归广州恒浪网络科技有限公司所有。所有代码都已经注册登记！
'任何未经许可的修改、复制、提供下载、出售等均属违法侵权行为，请尊重版权，勿以身试法！谢谢！
'请保留此版权信息，请尊重版权，勿以身试法！谢谢！
'网    址：http://www.Howave.Net
'技术论坛：http://BBS.Howave.Net
'联系邮箱：websky888@gmail.com 
'……………………版权信息……………………
%>
<!--#include file="conn/hl_conn.asp" -->
<!--#include file="inc/hl_manage.inc" -->
<!--#include file="inc/hl_function.asp"-->
<!--#include file="inc/a_upiconfig.asp"-->
<!--#include file="inc/md5.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
}
.td{font-size:12px

}
a:link {
	text-decoration: none;
	color: #000000;
}
a:visited {
	text-decoration: none;
	color: #7996DE;
}
a:hover {
	text-decoration: none;
	color: #FF6600;
}
a:active {
	text-decoration: none;
}
-->
</style>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理员管理</title>
<script language="javascript">
<!-- 
function formCheck() 
{ if (document.Modifpwd.Password.value == "") 
{ 
alert("请输入密码"); 
return false; 
}
 if ((document.Modifpwd.Password.value)!= (document.Modifpwd.repassword.value)) 
{ alert("两次输入密码不相同");
 return false; 
 }
 }
function AddCheck() { 
  if (document.Add.AdminName.value == ""){
  alert("请输入管理员");
  return false;
  }
  if (document.Add.Password.value == "") { 
  alert("请输入密码"); 
  return false; 
}
  if ((document.Add.Password.value)!= (document.Add.Repassword.value)){ 
 alert("两次输入密码不相同");
 return false; 
}
 }
//--> 
</script>
</head>

<body>
<table width="808" border="0" align="center" cellpadding="0" cellspacing="0" background="img/r3_c3.jpg">
  <tr>
    <td width="50" height="20" rowspan="3">&nbsp;</td>
    <td width="758"></td>
  </tr>
  <tr>
    <td height="10" valign="top"></td>
  </tr>
  <tr>
    <td height="17" valign="top"><span class="td"><a href="Admin_Manager.asp" target="_self">管理员管理</a> | <a href="Admin_Manager.asp?action=Add" target="_self">新增管理员</a></span></td>
  </tr>
</table>

<table width="808" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
    <td width="10" height="24"></td>
    <td colspan="2" valign="top">
<%
'Dim UserID,ComeUrl,password,admin_frontname,AdminName
Dim Interface_Action,Md5Info,Purview
UserID=ReplaceBadChar(replace(request("UserID"),"'",""))
ComeUrl = Request.ServerVariables("HTTP_REFERER")
Action=ReplaceBadChar(replace(request("action"),"'",""))
passwords=ReplaceBadChar(replace(request("Password"),"'",""))
password=MD5(passwords,32)
admin_frontname=ReplaceBadChar(replace(request("UserName"),"'",""))
AdminName=ReplaceBadChar(replace(request("AdminName"),"'",""))
if Action="" then 
  Call Main()
  else
  Select Case Action
  Case "Add"
     Call Add()
  Case "Modifypwd"
     Call Modifypwd()
	 
  Case "SaveModifyPwd"
     Call SaveModifyPwd()
	 'Call Return()
  Case "SaveAddAdmin"
     Call SaveAddAdmin()
	 'Call Return()
  Case "AddUser"
     Call AddUser()
  Case "DelAdmin"
     Call DelAdmin()
	 'Call Return()
  end Select
end if
%>
	<%Sub Main()%>
	<table width="796" style="BORDER-COLLAPSE: collapse" bordercolor="#A0D3FE" cellspacing="0" cellpadding="2"  align="center" border="1" bgcolor="#EEF9FD"  class="td">
      <tr align="middle" height="22">
        <td width="28" align="center" ><strong>选中</strong></td>
        <td width="28" height="22" align="center" ><strong>序号</strong></td>
        <td width="72" align="center" ><strong>管理员名</strong></td>
        <td width="71" align="center" ><strong>前台会员名</strong></td>
        <td width="83" align="center" ><strong>权 限</strong></td>
        <td width="60" align="center" ><strong>多人登录</strong></td>
        <td width="99" align="center" ><strong>最后登录IP</strong></td>
        <td width="84" align="center" ><strong>最后登录时间</strong></td>
        <td width="63" align="center" ><strong>登录次数</strong></td>
        <td width="146" align="center" ><strong >操 作</strong></td>
      </tr>
<%
	  set rs=server.CreateObject("adodb.recordset")
        sql="select * from hl_admin"
		rs.open sql,conn,1,1
		iNum=1
		do while not rs.eof 
		iNum=iNum+1
		select case rs("admin_pass")
		case "10"
		 admin_name="超级管理员"
		 case "1"
		 admin_name="普通管理员"
		end select
		 
response.Write "<TR onmouseover=""this.style.backgroundColor='#BFDFFF'"" onmouseout=""this.style.backgroundColor=''"" align='middle'>"
response.Write "<TD align='center'><Input type='checkbox' name=ID></TD>"
response.Write "<TD align='center'>"&iNum&"</TD>"
response.Write "<TD align='center'><strong>"&rs("hl_adminuser")&"</strong></TD>"
response.Write "<TD align='center'>"&rs("hl_admin_frontname")&"</TD>"
response.Write "<TD align='center'>"&admin_name&"</TD>"
response.Write "<TD align='center'>允许</TD>"
response.Write "<TD align='center'>"&rs("loginip")&"</TD>"
response.Write "<TD align='center'>"&rs("lastlogin")&"</TD>"
response.Write "<TD align='center'>"&rs("logins")&"</TD>"
response.Write "<TD align='center'><a href='Admin_Manager.asp?action=Modifypwd&UserID="&rs("hl_adminid")&"' target='_self'>修改密码</a> <a href='Admin_Manager.asp?action=DelAdmin&UserID="&rs("hl_adminid")&"' target='_self'>删除</a></TD>"
response.Write "</TR>"
          rs.movenext
		  loop
		  rs.close
		  set rs=nothing
End Sub
 %>
    </table>
<%
Sub Modifypwd()
     set rs=server.CreateObject("adodb.recordset")
	     sql="select * from hl_admin where hl_adminid="&UserID
		
		 rs.open sql,conn,1,1 
		 if rs("hl_adminuser")<>Request.Cookies("hl_manage")("username") then
		    response.Write ("对不起，你不能更改他人密码")
			response.End()
		 end if 


%>

<table width="100%" border="1"  align="center" cellpadding="2" cellspacing="0" bordercolor="#A0D3FE" bgcolor="#EEF9FD"  class="td" style="BORDER-COLLAPSE: collapse">
  <form action="Admin_Manager.asp?action=SaveModifyPwd" method="post" name=Modifpwd onSubmit="return formCheck()">
    <tr>
	<input type="hidden" name="UserID" value="<%=rs("hl_adminid")%>" />
      <td align="center" colspan="2" height="22"><strong>修改管理员密码</strong></td>
    </tr>
    <tr>
      <td width="15%"><strong>管理员名:</strong></td>
      <td width="85%"><%=rs("hl_adminuser")%>
          <input type="hidden" value="1" name="ID" /></td>
    </tr>
    <tr>
      <td width="15%"><strong>前台会员名:</strong></td>
      <td width="85%"><input value="<%=rs("hl_admin_frontname")%>" name="UserName" /></td>
    </tr>
    <tr>
      <td width="15%"><strong>新密码:</strong></td>
      <td width="85%"><input type="password" value="" name="Password" />      </td>
    </tr>
    <tr>
      <td width="15%"><strong>确认密码:</strong></td>
      <td width="85%"><input name="repassword" type="password" id="repassword" /></td>
    </tr>
    <tr>
      <td >&nbsp;</td>
      <td align="center"><input type="submit" value="确　认" name="Submit" onClick="return confirm('将修改所有整合系统的管理员密码！');"/>
        <input id="Cancel2" onClick="window.location.href='Admin_Manager.asp'" type="button" value=" 取 消 " name="Cancel2" /></td>
    </tr></form>
</table>
<%End Sub
Sub Add()
call CheckSuperAdmin()
%>
<table width="100%" border="1"  align="center" cellpadding="2" cellspacing="0" bordercolor="#A0D3FE" bgcolor="#EEF9FD"  class="td" style="BORDER-COLLAPSE: collapse"><form action="Admin_Manager.asp?action=SaveAddAdmin" method="post" name="Add">
  <tr>
    <td align="right" width="12%"><strong>管理员名：</strong></td>
    <td width="88%"><input name="AdminName" type="text" id="AdminName"/></td>
  </tr>
  <tr>
    <td align="right" width="12%"><strong>初始密码：</strong></td>
    <td width="88%"><input name="Password" type="password" id="Password" /></td>
  </tr>
  <tr>
    <td align="right" width="12%"><strong>确认密码：</strong></td>
    <td width="88%"><input type="password" value="" name="Repassword" /></td>
  </tr>
  <tr>
    <td align="right" width="12%"><strong>权限设置： </strong></td>
    <td width="88%"><input  type="radio" value="10" name="Purview" checked="checked"/>
      超级管理员：拥有添加管理员权限。并且在每个系统都会增加该管理员 <br />      </td>
  </tr>
  <tr>
    <td align="left">&nbsp;</td>
    <td align="left"><input type="submit" value="确　认" name="Submit9" onClick="return AddCheck();"/>
      <input id="Cancel" onClick="window.location.href='Admin_Manager.asp'" type="button" value=" 取 消 " name="Cancel" /></td>
  </tr>
</form>
</table>
<%End Sub%>
</td>
  </tr>
</table>
<%
Sub SaveModifyPwd()

     set rs=server.CreateObject("Adodb.recordset")
	     sql="select * from hl_admin where hl_adminid="&UserID
		 rs.open sql,conn,1,3
		 if rs("hl_adminuser")<>Request.Cookies("hl_manage")("username") then
		    response.Write("对不起，你不能更改他人密码")
			response.End()
		 end if 
		    AdminName=rs("hl_adminuser") 
		    Md5Info=MD5(AdminName & SecurityKey, 32)
			Interface_Action="ModifyInfo"
			call Interface()
		   rs("hl_adminpass")=password
		   rs("hl_admin_frontname")=admin_frontname
		   rs.update
		   rs.close
		   set rs=nothing
		    Response.Cookies("hl_manage")("password")=password 

End Sub	

Sub Interface()
            Response.Write "<html>" & vbCrLf
            Response.Write "<head>" & vbCrLf
            Response.Write "<meta http-equiv=""refresh"" content=""" & RefreshTime & ";URL=Admin_Manager.asp"" />"&vbCrLf
            Response.Write "<title>正在更新管理员资料</title>" & vbCrLf
            Response.Write "</head>" & vbCrLf
            Response.Write "<body>" & vbCrLf
            Response.Write "<span style='font-size:9pt'>正在更新管理员资料，请稍等...</span>" & vbCrLf
           
            If IsNull(SecurityKey) = False And SecurityKey <> "" And IsNull(arrUpiUrls) = False And arrUpiUrls <> "" Then
            HLUpi = Split(arrUpiUrls, "|")
			RegSiteId=split(RegSiteIds,",")   
            For iNums = 0 To UBound(HLUpi)
			Response.Write "<iframe id='ModifyInfo' width='100%' height='0' frameborder='0' src=""" & HLUpi(iNums) & "?action="&Interface_Action&"&Md5Info=" & Md5Info & "&name=" & AdminName & "&pass=" & password & """></iframe>"& vbCrLf	
			Next
            End If
			Response.Write "<div align='center'><img src='img/interface.gif'  /></div>"
            Response.Write "</body>" & vbCrLf
            Response.Write "</html>" & vbCrLf
End Sub

Sub SaveAddAdmin()
 call CheckSuperAdmin()
      set rs=server.CreateObject("Adodb.recordset")
	     sql="select * from hl_admin where hl_adminuser='"&AdminName&"'"
		 rs.open sql,conn,1,3
		 if rs.eof and rs.bof then
		    Md5Info=MD5(AdminName & SecurityKey, 32)
			Interface_Action="AddUser"
			Purview=Request("Purview")
			if Purview="10" then
		      call Interface()
		    end if
		 rs.addnew
rs("hl_adminuser")=AdminName
rs("hl_adminpass")=password
rs("admin_pass")=ReplaceBadChar(replace(request("Purview"),"'",""))
         rs.update
		 rs.close
		 set rs=nothing
		else 
		response.Write "该帐号已存在"
		response.End()
		end if
		if Purview<>"10" then
		      Response.Redirect "Admin_Manager.asp"
		end if
	
		 
End Sub

Sub DelAdmin()
    call CheckSuperAdmin()
     set rs=server.CreateObject("Adodb.recordset")
	     sql2="select * from hl_admin where hl_adminid="&UserID
		 rs.open sql2,conn,1,1
		 AdminName=rs("hl_adminuser")
		 Purview=rs("admin_pass")
		 rs.close
		 set rs=nothing
		  Md5Info=MD5(AdminName & SecurityKey, 32)
		 Interface_Action="DelUser"
		 if AdminName=Request.Cookies("hl_manage")("username") then
		 response.Write ("不能删除自己")
		 response.end()
		 end if 
		 if Purview="10" then
		  call Interface()
		 end if
		 set rs=server.CreateObject("Adodb.recordset")
		 sql3="delete * from hl_admin where hl_adminid="&UserID
		 rs.open sql3,conn,1,3
		 'rs.close
		 set rs=nothing
		 if Purview<>"10" then
		      Response.Redirect "Admin_Manager.asp"
		end if
End Sub

Sub Return()
response.Redirect ComeUrl
End Sub

Sub CheckSuperAdmin()
     adminUserId=Request.Cookies("hl_manage")("username")
	 adminPassword=Request.Cookies("hl_manage")("password")
	  set rs=server.CreateObject("adodb.recordset")
	     sql="select admin_pass from hl_admin where hl_adminuser='"&adminUserId&"' and hl_adminpass='"&adminPassword&"'"
		 
		 rs.open sql,conn,1,1
		 admin_pass=rs("admin_pass")
		  rs.close
		 set rs=nothing
	if admin_pass<>10 then 
		 response.Write("对不起，你不是超级管理员，此操作禁止")
		 response.End()
		 
	end if
End Sub


%>

</body>
</html>
