<?
/*
	[SueamCMS] (C)2009-2010 ZMRNet Studio
	adm_add.php by 2009-10-11 zmrnet
*/
require_once(dirname(__FILE__).'/include/manage.php');

$sueam_act = trim($_POST['action']);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $sys_title; ?></title>
<link href="images/sueam.css" rel="stylesheet" type="text/css" />
<?
if($sueam_act=='add'){
	$adm_name = trim($_POST['AdminName']);
	$adm_pwd = trim($_POST['Password']);
	$adm_pwd2 = trim($_POST['Password2']);
	$adm_name = strtolower($adm_name);
	
	if($adm_name==''){
		die(refresh().'<script>alert(\'帐户不能为空！\')</script>');
	}
	if($adm_pwd==''){
		die(refresh().'<script>alert(\'密码不能为空！\')</script>');
	}
	if($adm_pwd!=$adm_pwd2){
		die(refresh().'<script>alert(\'确认密码错误！\')</script>');
	}
	
	$rs = $_VDB['adm'];
	if($row=$rs[$adm_name]){
		die(refresh().'<script>alert(\'该帐户已经存在！\')</script>');
	}
	unset($rs);
	
	$_VDB['adm'][$adm_name] = array(
		'ip' => '0.0.0.0',
		'pwd' => substr(md5($adm_pwd),8,16),
		'num' => 0,
		'time' => '',
		'lock' => false,
	);
	$vdb->update($_VDB);
	$vdb->save();

	die(refresh('adm_list.php').'<script>alert(\'管理员添加成功！\')</script>');
}
?>
</head>
<body>
<div style="margin:20px;">
	<div style="margin:10px;font-size:14px;color:green"><b>添加管理员</b></div>
	<div class="sec_menu">
	<form action="adm_add.php" method="post" style="margin:auto;padding:25px;width:400px;text-align:left">
		管理帐户：<input type="text" name="AdminName" class="input_txt"><br><br>
		登录密码：<input type="password" name="Password" class="input_txt"><br><br>
		确认密码：<input type="password" name="Password2" class="input_txt"><br><br>
		<input type="reset" value="还 原" class="input_btn">&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="提 交" class="input_btn">
		<input type="hidden" name="action" value="add">
	</form>
	</div>
</div>
</body>
</html>