<?php
	session_start(); 
	require_once('../ls_admin/inc/conn.php');
	require_once('../ls_admin/inc/constant.php');
	require_once('../ls_admin/inc/ls_syscode.php');
	require_once('../ls_admin/inc/check.php');
	$opendb=new mydb();
	
	$oldpassword=trim($_POST['oldpassword']);
	$newpassword1=$_POST['newpassword1'];
	$newpassword2=$_POST['newpassword2'];
	//echo $_SESSION['username'];
	$sqlstr="select * from ls_mantain where adminName='". $_SESSION['username']."'";
	
	$opendb=new mydb();
	$query1=$opendb->query($sqlstr);
	$rows=mysql_fetch_assoc($query1);
	
if(isset($_POST['submit']))
{
	if(md5($oldpassword) == $rows['adminPwd'])
	{
		if ($newpassword1 ==$newpassword2)
		{	
			$sql_update="update ls_mantain  set adminPwd='".md5($newpassword2)."' where adminName='". $_SESSION['username']."'";
			//echo $sql_update;
			$query_update=$opendb->query($sql_update);
			writelog($_SERVER['PHP_SELF'],"modify password", $_SESSION['username']);

			$mess=$query_update?"密码修改成功！":"密码修改失败！";
			$_SESSION['password']=$_POST['newpassword2'];
		}
		else
		{
			$mess="两次输入的新密码不一致！";
		}
		
	}
	else
	{
		$mess="旧密码不正确！";
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../ls_admin/css/admin.css" rel="stylesheet" type="text/css">
<title>无标题文档</title>
</head>

<body>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6396D6">
  <tr> 
	<td height="18" background="../ls_admin/images/admin_bg.gif"><div align="center"><font color="#FFFFFF"><strong>修改密码 
</strong></font></div></td>
  </tr>

  <tr>
  	<td bgcolor="#E8F1FF" valign="top" align="center">
	<br>
		<form name="form1" method="post" action="?ls=eidt">
		<table border="0">
			<tr>
				<td>旧密码：</td>
				<td><input name="oldpassword" type="password" id="oldpassword" size="16" maxlength="16"></td>
			</tr>
			<tr>
				<td>新密码：</td>
				<td> <input name="newpassword1" type="password" id="newpassword1" size="16" maxlength="16"></td>
			</tr>
			<tr>
				<td>新密码验证：</td>
				<td><input name="newpassword2" type="password" id="newpassword2" size="16" maxlength="16"></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input name="submit" type="submit" id="submit" value="确认">
		  <input type="submit" name="Submit2" value="重填"><br><br>
		  <font color="#FF0000"><?php echo $mess; ?></font>
		  </td>
			</tr>
		</table>
		</form>
		<br>
	</td>
 </tr>
</table>

</body>
</html>
