<?php
include_once("inc/config.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/publicfun.php");
include_once("inc/ftcode.php");
include_once("conn.php");
include_once("checkuser.php");
include_once("bbsuser.php");

$userid=intval(get_cookie('clubuser_id'));
if ($_POST["newpwd1"]!=""){
   $password=ftbbs_request(trim($_POST["newpwd1"]));
   $oldpwd=ftbbs_request(trim($_POST["oldpwd"]));
   $sql="select clubuser_password from {$tablepre}clubuser where clubuser_password='".md5($oldpwd)."' and clubuser_id=".$userid;
   $rs=mysql_query($sql);
   $myrow = mysql_fetch_array($rs);
   $numrows = mysql_num_rows($rs);
   if ($numrows!=0){
   $str="update {$tablepre}clubuser set clubuser_password='".md5($password)."' where clubuser_id=".$userid;
   mysql_query($str);
   set_cookie('clubuser_password', base64_encode($password), 3600);
   $msg="(<font color=red>密码修改成功!</font>)";
   }
   else{
   $msg="(<font color=red>你的旧密码不正确,修改不成功!</font>)";
   }
}
$sql="select clubuser_name,clubuser_password,userimg,homepagetitle,cssfile,bokeer from {$tablepre}clubuser where clubuser_id=".$userid;
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
if ($numrows!=0){
   $cssfile="blogcss/".$myrow["cssfile"];
   $bokeer=$myrow["bokeer"];
   if ($cssfile=="blogcss/"){
      $cssfile="blogcss/2.css";
	}
}
?>
<html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<script language="javascript">
<!--
	function check(form)
	{
    if (form.oldpwd.value=="")
    	{
    		alert("请填写旧密码！");
    		form.oldpwd.focus();
    		return false;
  	}
    if (form.newpwd1.value=="")
    	{
    		alert("请填写新密码！");
    		form.newpwd1.focus();
    		return false;
  	}
    if (form.newpwd2.value=="")
    	{
    		alert("请填写确认密码！");
    		form.newpwd2.focus();
    		return false;
  	}
    if (form.newpwd1.value!=form.newpwd2.value)
    	{
    		alert("新密码和新密码确认不一致！");
    		form.newpwd2.focus();
    		return false;
  	}
   return true;
	}
//-->
</script>
<body>
<center>
<title></title>
<link rel="stylesheet" type="text/css" href="<?=$cssfile?>">
<?
include_once("usernav.php");
include_once("myhead.php");
?>
<div class="stage">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="layout">
<tr>
<td width="22%" valign="top" class="c2t3">
<div id="mod_profile" class="mod" rel="drag">
<?
include_once("usercalog.php");
?>
</div>
</td>
<td width="78%" valign="top" class="c2t1">
<div id="m_blog" class="modbox"><br>
              <br>
              <br>
              <br>
              <table width="80%" border="0" align="center">
                <form name="form1" method="post" action="" onsubmit="return check(this)">
                  <tr> 
                    <td height="30"><div align="center"></div></td>
                    <td height="30"><strong>修改密码</strong><?=$msg?></td>
                  </tr>
                  <tr> 
                    <td width="17%" height="30"><div align="right">旧密码:</div></td>
                    <td width="83%"><input name="oldpwd" type="password" id="oldpwd" value="<?=$myrow["clubuser_password"]?>"></td>
                  </tr>
                  <tr> 
                    <td height="30"><div align="right">新密码:</div></td>
                    <td><input name="newpwd1" type="password" id="newpwd1"></td>
                  </tr>
                  <tr> 
                    <td height="30"><div align="right">新密码确认:</div></td>
                    <td><input name="newpwd2" type="password" id="newpwd2"></td>
                  </tr>
                  <tr> 
                    <td height="30"><div align="right"></div></td>
                    <td><input type="submit" name="Submit" value="确认修改"></td>
                  </tr>
                </form>
              </table>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
            </div>
</td>
</tr></table>
</div>
</div>
<br><center>
<?
include_once("tail.php");
?>
  </center>
</center>
</body>
</html>