<?
/*
	[SueamCMS] (C)2009-2010 ZMRNet Studio
	adm_pwd.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=='pwd'){
	$adm_name	= $sueam_admin;
	$adm_pwd	= trim($_POST['Password']);
	$new_pwd	= trim($_POST['NewPassword']);
	$new_pwd2	= trim($_POST['NewPassword2']);
	
	$adm_pwd = substr(md5($adm_pwd),8,16);
	
	$rs = $_VDB['adm'];
	if($row=$rs[$adm_name]){
		if($adm_pwd!=$row['pwd'])
			die(refresh().'<script>alert(\'旧密码错误！\')</script>');
	}else{
		die(refresh().'<script>alert(\'旧密码错误！\')</script>');
	}
	unset($rs);
	
	if($new_pwd==''){
		die(refresh().'<script>alert(\'新密码不能为空！\')</script>');
	}
	if($new_pwd!=$new_pwd2){
		die(refresh().'<script>alert(\'确认新密码错误！\')</script>');
	}
	
	$_VDB['adm'][$adm_name]['pwd'] = substr(md5($new_pwd),8,16);
	$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_pwd.php" method="post" style="margin:auto;padding:25px;width:400px;text-align:left">
		管理员帐户：<? echo $sueam_admin; ?><br><br>
		旧 的 密码：<input type="password" name="Password" class="input_txt"><br><br>
		新 的 密码：<input type="password" name="NewPassword" class="input_txt"><br><br>
		确认新密码：<input type="password" name="NewPassword2" 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="pwd">
	</form>
	</div>
</div>
</body>
</html>