<link  href="../css/plugins.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../js/jquery-latest.pack.js"></script>
<script type="text/javascript" src="../js/jquery.validationEngine.modified.js"></script>
<script type="text/javascript" src="../js/jquery.validationEngine.rules.html"></script>
<script type="text/javascript" src="../js/iepngfix_tilebg.js"></script>
<script type="text/javascript" src="../js/jquery.tools.min.js"></script>
<script type="text/javascript" src="../js/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript" src="../js/jquery.bgiframe.js"></script>
<script type="text/javascript" src="../js/main.js"></script>
<div id="register" class="col-2">
	<div class="content content-last">
		<div class="content-bg">
			<div class="content-bg-bottom">
				<h2><?PHP echo $serverSettings['titel']; ?> - Cambio de Contraseña</h2>
				<div class="inner-form-border">
					<div class="inner-form-box">
	<h3><a id="toLogin" href="index.php?s=profil" title="Datele utilizatorului">Volver</a>Cambio de Contraseña</h3>
 <div class="trenner"></div><br/>
 <?PHP

  if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=0) {
    
    if(isset($_POST['submit']) && $_POST['submit']=="Schimba") {
    
      if(checkAnum($_POST['npass']) && !empty($_POST['opass']) && (!empty($_POST['npass']) && strlen($_POST['npass'])>=8 && strlen($_POST['npass'])<=16) && $_POST['npass']==$_POST['npass2']) {
        
        $oldPass = mysql_real_escape_string($_POST['opass']);
        $newPass = mysql_real_escape_string($_POST['npass']);
        
        $sqlCmd = "SELECT id,login FROM account.account WHERE password=PASSWORD('".$oldPass."') AND id='".$_SESSION['user_id']."' LIMIT 1";
        $sqlQry = mysql_query($sqlCmd,$sqlServ);
        
        if(mysql_num_rows($sqlQry)==1) {
        
          $passCmd = "UPDATE account.account SET password=PASSWORD('".$newPass."') WHERE id='".$_SESSION['user_id']."' LIMIT 1;";
          $passUpdate = mysql_query($passCmd,$sqlServ);
          
          if($passUpdate) {
            echo'<h1>Contraseña Cambiada con exito!.<br/><br/></h1><div class="trenner"></div>';
          }
          else {
            echo'<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Schimbarea parolei a e&#351;uat.<br/><br/></h1><div class="trenner"></div>';
          }
          
        }
        else {
          echo'<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parola care a&#355;i introduso a fost incorect&#259;.<br/><br/></h1><div class="trenner"></div>';
        }
        
      }
      else {
        echo'<h1>Debes introducir la informacion corracta y requerida para continuar.<br/><br/></h1><div class="trenner"></div>';
      }
      
    }
  ?>
  <?PHP
  }
  else {
    echo'<h1><br/>Trebuie s&#259; fi &#238;nregistrat pentru a vedea aceast&#259; zon&#259;!</h1><br/>';
  }
?>
        <form name="registerForm" id="registerForm" action="index.php?s=password" method="POST">
					         <div>
							<label for="password">Contraseña Actual:*
								</label>
								<input
								type="password"
								class="validate[required,custom[noSpecialCharacters],length[4,16]]"
								id="password"
								name="opass"
								maxlength="16"
								value=""
								AUTOCOMPLETE="off"
								/>
							</div>
							<div>
							<label for="password">Contraseña Nueva:*
								</label>
								<input
								type="password"
								class="validate[required,custom[noSpecialCharacters],length[6,16]]"
								id="password"
								name="npass"
								maxlength="16"
								value=""
								AUTOCOMPLETE="off"
								/>
							</div>
							<div>
								<label for="password">Repita la Contraseña Nueva:*
								</label>
								<input
								type="password"
								class="validate[required,custom[noSpecialCharacters],length[6,16]]"
								id="password"
								name="npass2"
								maxlength="16"
								value=""
								AUTOCOMPLETE="off"
								/>
							</div>	
              <br/><input id="submitBtn" type="submit" name="submit" value="Schimba" class="btn-bg"/>
        </form>
						<p id="regLegend">* todos los campos son necesarios.</p>
                    </div>
				</div>
			</div>
		</div>
	</div>
</div>