<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Function.asp"-->
<!--#include file="../inc/Config.asp"-->
<!--#include file="../inc/MD5.asp"-->
<%
Call ChkLogin(session("WebAdminsUserName"))
Call ConnectionDataBase(2)
Action = Request("Action")
Select Case Action
	Case "ModiPwd"
		Call ModiPwd
	Case "AddAdmin"
		Call AddAdmin
	Case "ModiAdminPwd"
		Call ModiAdminPwd
	Case "SetRights"
		Call SetRights
End Select
'修改密码
Sub ModiPwd()
	OldPwd = Request.Form("OldPwd")
	NewPwd = Request.Form("NewPwd")
	ConfirmPwd = Request.Form("ConfirmPwd")		
	Call ChkIsNull(OldPwd,"请输入旧密码!")
	Call ChkIsNull(NewPwd,"请输入新密码!")
	Call ChkIsNull(ConfirmPwd,"请输入确认密码!")
	IF NewPwd<>ConfirmPwd Then Call IsError("两次密码输入不一致!")
	NewPwd = MD5(NewPwd)
	strSql = "Select TOP 1 * From T_Admins Where UserName='"& Session("WebAdminsUserName") &"' And UserPwd='"& MD5(OldPwd) &"'"
	SetRs Rs,strSql,conn,1,3
	IF Rs.EOF Then Call IsError("帐号或旧密码输入错误!")
	Rs("UserPwd") = NewPwd	
	Rs.Update
	DisRs Rs
	Call CloseDatabase
	Call Success("密码修改成功!",Request.ServerVariables("HTTP_REFERER"))
End Sub
'添加管理员
Sub AddAdmin()
	UserName = Request.Form("UserName")
	UserPwd = Request.Form("UserPwd")	
	Call ChkIsNull(UserName,"请输入用户名!")
	Call ChkIsNull(UserPwd,"请输入密码!")
	UserPwd = MD5(UserPwd)
	strSql = "Select TOP 1 * From T_Admins Where UserName='"& UserName &"'"
	SetRs Rs,strSql,conn,1,3
	IF Not Rs.EOF Then 
		Call IsError("该帐号已经存在!")
	Else
		Rs.Addnew()
	End IF
	Rs("UserName") = UserName	
	Rs("UserPwd") = UserPwd	
	Rs.Update
	DisRs Rs
	Call CloseDatabase
	Call Success("记录添加成功!",Request.ServerVariables("HTTP_REFERER"))
End Sub
'修改管理员密码
Sub ModiAdminPwd()
	UserName = Request.QueryString("UserName")
	UserPwd = Request.QueryString("UserPwd")	
	Call ChkIsNull(UserName,"用户名错误!")
	Call ChkIsNull(UserPwd,"请输入密码!")
	UserPwd = MD5(UserPwd)
	strSql = "Select TOP 1 * From T_Admins Where UserName='"& UserName &"'"
	SetRs Rs,strSql,conn,1,3
	IF Rs.EOF Then Call IsError("该帐号不存在!")
	Rs("UserPwd") = UserPwd	
	Rs.Update
	DisRs Rs
	Call CloseDatabase
	Response.Write "密码修改成功!"
	'Call Success("密码修改成功!",Request.ServerVariables("HTTP_REFERER"))
End Sub

'设置权限
Sub SetRights()
	ChkBox = Request.Form("ChkBox")	
	role = Request.Form("role")	
	strSql = "Select TOP 1 * From T_Rights Where UserClassID="& role
	SetRs Rs,strSql,conn,1,3
	IF Rs.EOF Then Rs.Addnew
	Rs("UserClassID") = role	
	Rs("Rights") = Replace(ChkBox," ","") & ","	
	Rs.Update
	DisRs Rs
	Call CloseDatabase
	Call Success("权限设置成功!",Request.ServerVariables("HTTP_REFERER"))
End Sub
%>
