<!--#include file="../../Conn.asp" -->
<!--#include file="../../Comm/Site_Class.asp" -->
<!--#include file="../../Comm/md5.asp" -->
<%
PagePath = "../../"

Set Qsite = New Site_Class

Qsite.SiteConfig_Master()
%>
<!--#include file="../Check_Login.asp" -->
<%
Qsite.Check_AdminFlag(arrAdminFlag(9 , 1))

Dim AdminName,AdminPass1,AdminPass2,IsLock,AdminType
Dim AdminFlag

If Request.Form <> "" Then
	AdminName = Qsite.chgStr(Trim(Request.Form("AdminName")))
	AdminPass1 = Qsite.chgStr(Trim(Request.Form("AdminPass1")))
	AdminPass2 = Qsite.chgStr(Trim(Request.Form("AdminPass2")))
	IsLock = Qsite.chgStr(Trim(Request.Form("IsLock")))
	AdminType = Qsite.chgStr(Trim(Request.Form("AdminType")))
	
	If AdminName = "" Or IsNull(AdminName) Then
		Qsite.ShowMsg "请输入用户名" , ""
	End If
	If Qsite.CheckStr(AdminName , "") Then
		Qsite.ShowMsg "输入的用户名含有非法字符" , ""
	End If
	If AdminPass1 = "" Or IsNull(AdminPass1) Then
		Qsite.ShowMsg "请输入登录密码" , ""
	End If
	If AdminPass2 = "" Or IsNull(AdminPass2) Then
		Qsite.ShowMsg "请输入确认密码" , ""
	End If
	If AdminPass1 <> AdminPass2 Then
		Qsite.ShowMsg "输入的登录密码和确认密码不一致" , ""
	End If
	
	If IsLock <> "1" Then IsLock = "0"
	
	AdminType = "0"
	
	Set Rs = Conn.Execute("select * from AdminTbl where AdminName = '"& AdminName &"'")
	If Not Rs.Eof Then
		Qsite.ShowMsg "此用户名已存在，请返回重新选择" , ""
	End If
	Set Rs = Nothing
	
	AdminPass1 = MD5(AdminPass1)
	
	AdminFlag = "0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	AdminFlag = AdminFlag & "$0|1|1|1|1|1|1|1|1|1|1"
	
	Conn.Execute("insert into AdminTbl (AdminName , AdminPass , AdminType , AdminFlag , IsLock) values ('"& AdminName &"' , '"& AdminPass1 &"' , '"& AdminType &"' , '"& AdminFlag &"' , '"& IsLock &"')")
	
	Qsite.ShowMsg "管理员添加成功" , "Admin_Add.asp"
End If
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加管理员</title>
<link href="../skins/css/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function CheckForm()
{
	if(PosForm.AdminName.value == "")
	{
		alert("请输入用户名");
		PosForm.AdminName.focus();
		return false;
	}
	if(PosForm.AdminPass1.value == "")
	{
		alert("请输入登录密码");
		PosForm.AdminPass1.focus();
		return false;
	}
	if(PosForm.AdminPass2.value == "")
	{
		alert("请输入确认密码");
		PosForm.AdminPass2.focus();
		return false;
	}
	if(PosForm.AdminPass1.value != PosForm.AdminPass2.value)
	{
		alert("输入登录密码和确认密码不一致");
		return false;
	}
	return true;
}
</script>
</head>

<body>
<form name="PosForm" method="post" action="Admin_Add.asp" style="margin:0" onSubmit="return CheckForm();">
	<table width="100%" border="0" cellspacing="1" cellpadding="5">
		<tr>
			<td height="25" colspan="2" class="td_title">添加管理员</td>
		</tr>
		<tr>
			<td width="12%" height="23" class="td_content">用户名：</td>
			<td width="88%" height="23" class="td_content"><input name="AdminName" type="text" class="input_1" id="AdminName" size="40"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">登录密码：</td>
			<td height="23" class="td_content"><input name="AdminPass1" type="password" class="input_1" id="AdminPass1" size="40"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">确认密码：</td>
			<td height="23" class="td_content"><input name="AdminPass2" type="password" class="input_1" id="AdminPass2" size="40"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">是否锁定：</td>
			<td height="23" class="td_content"><input name="IsLock" type="checkbox" id="IsLock" value="1"></td>
		</tr>
		<tr>
			<td height="23" class="td_content">&nbsp;</td>
			<td height="23" class="td_content"><input name="Submit" type="submit" class="input_1" value=" 添  加 "> &nbsp;
			<input name="Submit" type="reset" class="input_1" value=" 重  置 "></td>
		</tr>
	</table>
</form>
</body>
</html>
