<?include('header.php');

if(!(isset($_SESSION["username"]) && isset($_SESSION["password"])))
{
	?>
	<script type="text/javascript">
	location.replace("login.php");
	</script>
	<noscript>
	<meta http-equiv="refresh" content="0; url=login.php">
	</noscript>
	<?
	exit();
}

$res=mysql_query("select valuta from tb_site where id='1'");
$v=mysql_result($res,0,0);
?>
<div class="menucenter">
<?
if(isset($_POST[email]))
{
     if( strtolower($_POST['code'])!= strtolower($_SESSION['logcaptcha']) OR !isset($_SESSION["logcaptcha"]))
     {
          echo "<div class='error'>Неверно введен код с картинки...</div>";
          require 'footer.php';
          exit();
     }

        $email =  $_POST["email"];
        if($emailreal!=$email){ 
        $res = mysql_query("UPDATE tb_users set email='$email' where username='$user'"); 
        echo "<div class='wait'>Ваш E-mail успешно изменен.</div>";
               }
}
if(isset($_POST[password]) and $_POST[cpassword]!='')
{

        $realPassword =  $_POST["password"];
        $newpass = strtolower($_POST["password"]);
        $cpass = strtolower($_POST["cpassword"]);


        $emailreal=$duser["email"];
        if($newpass==NULL OR $cpass==NULL OR strlen($newpass)<=5)
        {
        echo "<div class='error'>Пароль должен быть менее 5 символов!!!</div>";
        include('footer.php');
        exit();
        }
	
        if($newpass==$cpass)
	{
		$password = myHashData($newpass);
		$user=text($_SESSION["username"]);
		$res = mysql_query("UPDATE tb_users set password='$password' where username='$user'");
		$_SESSION[password]=$password;
		if($res != FALSE)
		{
			$msgtext = "<div class='wait'>Ваш пароль изменен на <b>$realPassword</b></div>";
		}
		else
		{
			$msgtext = "<div class='error'>Ваш пароль НЕ изменен!</div>";
		}
		echo "$msgtext";
	}
}
?><fieldset class='alert'>Не используйте большие буквы в пароле!!!!</fieldset>
<div align="center"><div id="form"><fieldset class='green'>
<span style="color:#f00; font-weight:bold">WMID и WM<?=$v?> кошелек изменить нельзя! В случае возникновения такой необходимости, обратитесь к Администрации!</span>
</fieldset>
<form action="profile.php" method="POST">
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<th align=left>Параметр</th>
<th align=left>Значение параметра</th>
</tr></thead>
  <tr>
    <td width="150" align="left">Новый пароль:</td>
    <td width="250" align="left"><input type="password" size="25" maxlength="15" name="password" class="field" value="" tabindex="1" style="text-transform:lowercase;" ></td>
  </tr>
  <tr>
    <td width="150" align="left">Новый пароль еще раз:</td>
    <td width="250" align="left"><input type="password" size="25" maxlength="15" name="cpassword" class="field" value="" tabindex="1" style="text-transform:lowercase;" ></td>
  </tr>
  <tr>
    <td width="150" align="left">E-mail:</td>
    <td width="250" align="left"><input type="email" size="25" maxlength="15" name="email" value="<? echo $duser["email"]; ?>" tabindex="1"></td>
  </tr>
<?if($duser["system"]==0){?>
  <tr>
    <td width="150" align="left">WMID:</td>
    <td width="250" align="left" style="padding:5px;"><font color='green'><span class='desctext3'><? echo $duser["wmid"]; ?></span></font></td>
  </tr>
  <tr>
    <td width="150" align="left">WM<?=$v ?> кошелек:</td>
    <td width="250" align="left" style="padding:5px;"><font color='green'><span class='desctext3'><? echo $duser["pemail"]; ?></span></font></td>
  </tr>
<?}elseif($duser["system"]==1){?>
<tr>
    <td width="150" align="left">Счет LiqPay:</td>
    <td width="250" align="left" style="padding:5px;"><font color='green'><span class='desctext3'>+<? echo $duser["pemail"]; ?></span></font></td>
  </tr>
<?}?>
  <tr>
<td width="150" align="left"><font color="#dd0000"><b>Введите код:</b></font> <img src="logincap.php" align="absmiddle"></td>
<td width="250" align="left">
<input type='text' size='3' maxlength='4' name='code' autocomplete="off" onChange="getZakaz(this.form)" value="">
</td>
</tr>
  <tr>
    <td width="150" align="left">&nbsp;</td>
    <td width="250" align="left"><input type="submit" class="ok_wm" value=" Сохранить данные " class="submit" tabindex="4"></td>
  </tr>
</table>
</form>

</div></div>

<? include('footer.php'); ?>
