<?
include('data.php');
if($_COOKIE['x_Cookie']!=$adminname or $_COOKIE['y_Cookie']!=md5($password)){
	echo"<script>location.href='index.php';</script>";
	exit;
}
?>
<html>
<head>
<title>帐户管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/admin.css">
<link href="css/jquery.css" rel="stylesheet" type="text/css">


<script>
function chk(){
	if(form.adminname.value==''){
		alert('管理员帐号为空');
		return false;
	}
	if(form.password.value=='' || form.password.value!=form.password1.value){
		alert('密码为空或再次输入不一致');
		return false;
}
}
</script>
</head>
<body> 
<?
$id=$_GET['id'];
if($id=='edit'){
	
?>
<div class="right">
  <? include "welcome.php"; ?>
  <div class="right_main">
  
  
  <form action="?id=save"  method="post">
    <table width="98%" border="0" cellpadding="4" cellspacing="1" class="tableoutline"> 
        <tr nowrap  class="tb_head">
          <td colspan="2"><h2>修改密码：</h2></td>
        </tr>
        <tr nowrap class="firstalt">
          <td width="260"><b>用户名</b><br><font color="#666666">不修改，请保留</font></td>
          <td><input  type="text" name="adminname" size="33" value="<?=$adminname; ?>" onFocus="this.style.borderColor='#00CC00'" onBlur="this.style.borderColor='#dcdcdc'" >
          </td>
        </tr>
		<tr nowrap class="firstalt">
          <td width="260"><b>新密码</b><br><font color="#666666">输入新的密码</font></td>
          <td><input  type="password" name="password" size="37" onFocus="this.style.borderColor='#00CC00'" onBlur="this.style.borderColor='#dcdcdc'" >
          </td>
        </tr>
        <tr nowrap class="firstalt">
          <td width="260"><b>重复新密码</b><br><font color="#666666">重复输入新的密码</font></td>
          <td><input  type="password" name="password1" size="37" onFocus="this.style.borderColor='#00CC00'" onBlur="this.style.borderColor='#dcdcdc'" >
          </td>
        </tr>
      </tbody>
        <tr class="firstalt">
          <td colspan="2" align="center"><input type="hidden" name="action" value="setting">
            <input class="bginput" type="submit" name="submit" value=" 提交 " >
            <input class="bginput" type="reset" name="Input" value=" 重置 " >
          </td>
        </tr>
      </form>
    </table>  
  
 
  </div>
</div>
</body>
</html>

<?
}elseif ($id=='save'){
	$con='<?'."\r\n".'$adminname='.'"'.$_POST['adminname'].'"'.";\r\n".'$password='.'"'.$_POST['password'].'"'.";\r\n?>";
	if(preg_match("/{|}|fputs|fopen/i", $con)){   
    echo"<script>alert('含有非法字符！');location.href='?id=edit';</script>";
}   
else{
	$fp=fopen("data.php","w");
	fwrite($fp,$con);
	fclose($fp);
	echo"<script>alert('修改成功！');location.href='?id=edit';</script>";
}
}
?>



