<!--#include file="../common/conn.asp"-->
<!--#include file="../common/md5.asp"-->

<%
'检查用户权限
call checkuser("管理员管理")
%>

<%
userid=GetVariable("id")
loginname=GetVariable("txtname")

realname=GetVariable("txtrealname")
password1=GetVariable("txtpass1")
'对密码进行MD5加密
password=md5(password1)

limit=GetVariable("chkLimit")
if userid="" then
	sqlst="select * from web_admin where loginname='" & loginname & "'"
	rSub.open sqlst,conn,1,1
	usercount=rSub.recordcount
	rSub.close
	
	if usercount>0 then
		'此账号已经有人占用
		response.Write("<script language='javascript'>alert('该账号已经被人使用，请改用其它账号！　');</script>")
		response.End()
	end if
	sqlst="insert into web_admin(loginname,password,realname,limit,m_id) values('" & loginname & "','" & password & "','" & realname & "','" & limit & "'," & WebUserID & ")" 
	response.Write("<script language='javascript'>window.parent.opener.location=window.parent.opener.location;window.parent.close();</script>")
else
	sqlst="update web_admin set "
	if GetVariable("txtpass1")<>"" then
		sqlst=sqlst & "password='" & password & "',"
	end if
	sqlst=sqlst & "realname='" & realname & "',limit='" & limit & "' where id=" & userid
	response.Write("<script language='javascript'>window.parent.opener.location=window.parent.opener.location;alert('修改成功！　');</script>")
end if
conn.execute sqlst,0,1
%>
