<!--#include file="../include/hf_conn.asp"-->
<!--#include file="../chopchar.asp"-->
<!--#include file="checkadmin.asp"-->
<script language=javascript src=../include/mouse_on_title.js></script>
<%call checkmanage("11")%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
</head>
<BODY background="../images/admin/back.gif">

<%
action=request("add")
if action<>"ok" then
%>

	<table width="98%" border="1" 
		style="border-collapse: collapse; border-style: dotted; border-width: 0px"  
		bordercolor="#333333" cellspacing="0" cellpadding="2">
	<form action=safe3.asp method=post>
	<tr class=backs><td colspan=2 class=td height=18>添加管理员</td></tr>
	<tr><td width=20% align=right height="18">管理员名称</td>
		<td><input type="text" name="Username" size="20" value="" maxlength=16>
  &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="用户名长度：6-16位，可使用中文和字母"> </td></TR>
	<tr><td width=20% align=right height="18">请输入密码</td>
		<td><input type="password" name="Pass1" size="20"  maxlength=16> 
  &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="密码长度：8-16位<br>建议使用数字和字母组合"> </td></TR>
	<tr><td width=20% align=right height="18">请确认密码</td>
		<td><input type="password" name="Pass2" size="20"  maxlength=16>
  &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="请确认密码"> </td></TR>
	<tr><td colspan=2><input type="submit" name="Submit" value="确认添加">
		<input type="hidden" name="add" value="ok"></td></tr>
	</form>
	</table>

<%   
else
	if checktext(Request("Username"))<>Request("Username") or checktext(Request("pass1"))<>Request("pass1") or checktext(Request("pass2"))<>Request("pass2") then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，您填写的内容中含有非法字符，请检查后重新输入！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	if trim(Request("Username"))="" or trim(Request("pass1"))="" or trim(Request("pass2"))="" then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，填写不完整，请检查后重新输入！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	if llen(trim(Request("Username")))<6 or llen(trim(Request("Username")))>16 then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，您输入的管理员名称不合要求，要求长度6-16位');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	if llen(trim(Request("pass1")))<8 or llen(trim(Request("pass1")))>16 then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，您输入的密码长度不合要求，要求长度8-16位');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	if trim(Request("pass1"))<>trim(Request("pass2")) then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，两次输入的密码不符，请检查后重新输入！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	Set rs = conn.Execute("select * from hf_manage where username='"&request.form("username")&"'")
	if not (rs.eof and rs.bof) then
	response.write "<script language='javascript'>"
	response.write "alert('出错了，该管理员已经存在，请选择其它名称！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
	end if

	Set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from hf_manage"
	rs.open sql,conn,1,3
		rs.addnew
		rs("username")=Request.form("Username")
		rs("password")=md5(Request("pass1"))
		rs("manage")="|01|02|03|04|05|06|07|08|09|10|11|12"
		rs.update
		rs.close
		set rs=nothing

	response.write "<script language='javascript'>"
	response.write "alert('操作成功，您已经成功添加一个管理员。\n\n接下来，请为该管理员设置权限！');"
	response.write "location.href='safe4.asp?admin="&Request.form("Username")&"';"
	response.write "</script>"

end if

%>