<?php
define('IN_SYS',TRUE);
define('IN_AdminMenu',TRUE);
require './admin_config.php';
require '../config.php';
require '../setup.php';
require("../lib/admin_chk.php");
?>
<?php
$pageTitle="管理员密码修改";

$infoTable="admin";
$Type = $_GET["type"];

switch($Type){
	case "up":

	$Type=$_GET["type"];
	$AuserName=$_POST["user"];
	$AuserPassword=$_POST["pwd"];
	$Apwd_old=$_POST["pwd_old"];
	$AuRealName=$_POST["realName"];
	
	$db = mysql_query("select * from ".DB_TablePre.$infoTable." where userName ='".$_SESSION["adminUsr"]."'");
	$rs = mysql_fetch_array($db);

	if($rs){
			if($AuserName=="")
			{
				OutErrorBack("用户名不能够为空!");
			}
			if($AuserPassword=="")
			{
				OutErrorBack("密码不能够为空!");
			}
			$rs_AuserName=$_POST["user"];
			if($AuserPassword != $Apwd_old)
			{
				$rs_AuserPassword=substr(md5($_POST["pwd"]),8,16);
				$_SESSION["adminPwd"] =  $rs_AuserPassword;
			}
			else
			{
				$rs_AuserPassword=$Apwd_old;
			}
			$rs_uRealName=$_POST["realName"];
			
			mysql_query("update ".DB_TablePre.$infoTable." set userName='$rs_AuserName',userPassword='$rs_AuserPassword',uRealName='$rs_uRealName'  where userName ='".$_SESSION["adminUsr"]."'");
			$_SESSION["adminUsr"]=$rs_AuserName;
			$_SESSION["adminPwd"]=$rs_AuserPassword;
			OutErrorGo("管理员信息修改成功!","?");
	}
	break;
}
?><!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
<title><?php echo $pageTitle?><?php echo $sysTitle?></title>
<link href="templates/admin.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../lib/jquery/jquery.js"></script>
<script type="text/javascript" src="js/controlPanelMenu.js"></script>
<script type="text/javascript" src="js/commmonAdmin.js"></script>
</head>
<body>
<?php
include("./admin_header.php")
?>
<div id="containerAdmin" class="wrapper_m">
<div id="sidebarAdmin">
<?php
include("./admin_controlPanelDir.php")
?>
</div>
<div id="contentbarAdmin">
<div class="tips_2"><?php echo adminPageLocation($pageTitle)?></div>

<?php
	$db = mysql_query("select * from ".DB_TablePre.$infoTable." where userName ='".$_SESSION["adminUsr"]."'");
	$rs = mysql_fetch_array($db);
	if($rs){
		$rsUserName=$rs["userName"];
		$rsUserPassword=$rs["userPassword"];
		$rsURealName=$rs["uRealName"];
	}
?>
<form action="?type=up" method="post" name="formAdmin" target="_parent" id="formAdmin">
<table cellspacing="1" class="adminTableV0">
<tr>
<td class="tw_1">管理账号：</td>
<td class="tw_2"><input name="user" type="text" value="<?php echo $rsUserName?>" class="moduleBorderA moduleInputA iW_300"></td>
</tr>
<tr>
<td class="tw_1">管理密码：</td>
<td class="tw_2"><input name="pwd" type="password" value="<?php echo $rsUserPassword?>" class="moduleBorderA moduleInputA iW_300"><input name="pwd_old" type="hidden" id="pwd_old" value="<?php echo $rsUserPassword?>"></td>
</tr>
<tr>
<td class="tw_1">真实姓名：</td>
<td class="tw_2"><input name="realName" type="text" value="<?php echo $rsURealName?>" class="moduleBorderA moduleInputA iW_300"></td>
</tr>
<tr>
<td class="tw_1">&nbsp;</td>
<td class="tw_2"><input name="Submit" type="submit" value="确认修改" class="btn_2"></td>
</tr>
</table>
</form>

</div>
<div class="clearfix"></div>
</div>
<?php
include("./admin_footer.php")
?>
</body>
</html>