<?
include_once("../inc/config.php");
include_once("../inc/publicfun.php");
include_once("../inc/ftbbsdbclass.php");
include_once("../conn.php");
include_once("check_master.php");

$kid=$_GET["id"];
$mod_user=$_GET["mod_user"];
$admin_qs=$_SESSION["admin_qs"];
if ($_SESSION['qs']!=2){
$dis="disabled";
}
$str="select * from {$tablepre}ftbbs_admin where id=".$kid;
$rs=mysql_query($str);
$myrow = mysql_fetch_array($rs);

if ($_POST["kadmin_pwd"]!=""){
   $id=$_POST["id"];
   $kadmin_pwd=md5($_POST["kadmin_pwd"]);
   $old_admin_pwd=md5($_POST["old_admin_pwd"]);
   $list=$_POST["adminqs"];
   $dbadmin_pwd=$myrow["admin_pwd"];
   if (count($list)==1){
   $adminqs=$list[0];
   }
   elseif (count($list)==2){
   $adminqs=$list[0].",".$list[1];
   }
   elseif (count($list)==3){
   $adminqs=$list[0].",".$list[1].",".$list[2];
   }
   else{
   $adminqs="0,0,0";
   }

   if ($dbadmin_pwd==$old_admin_pwd){
	if ($_SESSION['qs']==2){
       $sql="update {$tablepre}ftbbs_admin set admin_pwd='".$kadmin_pwd."',adminqs='".$adminqs."' where id=".$kid;
       mysql_query($sql);
	   }
	else{
	   $sql="update {$tablepre}ftbbs_admin set admin_pwd='".$kadmin_pwd."' where id=".$kid;
	   mysql_query($sql);
	}
	
    $_SESSION['admin_qs']=$adminqs;
	$_SESSION['admin_pwd']=$kadmin_pwd;

    header("Location:ftbbs_admin.php");
    }
   else{
	echo "<br><br><br><br><center>对不起，你输入的旧密码是错误的，密码修改不成功！</center>";      
    exit;
   }
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$charset?>">
<title>修改管理用户</title>
<link href="../css/xmwuye.css" rel="stylesheet" type="text/css">
</head>

<body>
  <br>
  <br>
  <br>
  <br>
  <table width="71%" border="0" align="center">
  <form name="form1" method="post" action="">
    <tr bgcolor="f8f8f8"> 
      <td height="30" colspan="2"> <div align="center">修改密码</div></td>
    </tr>
    <tr bgcolor="f8f8f8"> 
      <td width="24%" height="30"> <div align="right">旧密码：</div></td>
      <td width="76%" height="30"> <input name="old_admin_pwd" type="text" size="26"></td>
    </tr>
    <tr bgcolor="f8f8f8"> 
      <td width="24%" height="30"> <div align="right">新密码：</div></td>
      <td width="76%" height="30"> <input name="kadmin_pwd" type="password" size="26"></td>
    </tr>
    <tr bgcolor="f8f8f8"> 
      <td height="30"> 
        <div align="right">操作权限：</div></td>
      <td height="30"><input name="adminqs[]" type="checkbox" id="adminqs" value="1" <? if (false!==strrpos($admin_qs,"1")){?>checked<? }?>>
        添加 
        <input name="adminqs[]" type="checkbox" id="adminqs" value="2" <? if (false!==strrpos($admin_qs,"2")){?>checked<? }?>>
        修改 
        <input name="adminqs[]" type="checkbox" id="adminqs" value="3" <? if (false!==strrpos($admin_qs,"3")){?>checked<? }?>>
        删除</td>
    </tr>
    <tr bgcolor="f8f8f8"> 
      <td height="30">&nbsp;</td>
      <td height="30"><input type="submit" name="Submit" value="修改"> <input name="id" type="hidden" id="id" value="<?=$id?>">
        <input name="mod_user" type="hidden" id="mod_user" value="<?=$mod_user?>"></td>
    </tr>
	</form>
  </table>
</body>
</html>