<center>
<h2>Reseteaza parola</h2>
	</div>
	<div id="left_content">
	<br>
<?PHP

  if(isset($_POST['sfform']) && $_POST['sfform']=="reset") {
  
    if(!empty($_POST['account']) && !empty($_POST['sicherheitsf']) && !empty($_POST['sicherheitsa'])) {
  
      $acc = mysql_real_escape_string($_POST['account']);
      $frage = mysql_real_escape_string($_POST['sicherheitsf']);
      $antwort = mysql_real_escape_string(md5($_POST['sicherheitsa']));
      
      $sqlCmd = "SELECT id FROM account.account WHERE login='".$acc."' AND question1='".$frage."' AND answer1='".$antwort."' LIMIT 1";
      $sqlQry = mysql_query($sqlCmd,$sqlServ);
      
      if(mysql_num_rows($sqlQry)>0) {
        
        $newPass = substr(md5(rand(999,99999)),0,8);
        $setPass = "UPDATE account.account SET password=PASSWORD('".$newPass."') WHERE login='".$acc."' LIMIT 1";
        $qryPass = mysql_query($setPass);
        
        if($qryPass) {
          echo'<p class="meldung">Parola dvs. a fost stabilita cu succes.<br/><br/>Noua parola pentru contul dvs.<b>'.$acc.'</b> ist: <b>'.$newPass.'</b>.<br/><br/>Bucurati-va de joc.</p>';
        }
        else {
          echo'<p class="meldung">O noua parola nu poate fi setata. Īn acest raport, va rugam sa contactati un administrator.</p>';
        }
        
      }
      
    }
    else {
      echo'<p class="meldung">Nu ati introdus datele.</p>';
    }
    
  }
  
  if(isset($_POST['emailreset']) && $_POST['emailreset']=="reset") {
    
    if(!empty($_POST['account']) && checkMail($_POST['email']) && $_SESSION["captcha_id"] == $_POST['captcha']) {
      
      $acc = mysql_real_escape_string($_POST['account']);
      $email = mysql_real_escape_string($_POST['email']);
      $newPass = substr(md5(rand(999,99999)),0,8);
      
      $getUser = "SELECT id FROM account.account WHERE login='".$acc."' AND email='".$email."' LIMIT 1";
      $qryUser = mysql_query($getUser);
      
      if(mysql_num_rows($qryUser)>0) {
      
        $setPass = "UPDATE account.account SET password=PASSWORD('".$newPass."') WHERE login='".$acc."' LIMIT 1";
        $qryPass = mysql_query($setPass);
        
        if($qryPass) {
          echo'<p class="meldung">Parola dvs. a fost stabilit cu succes. Veti primi un e-mail cu noua parola.</p>';
          
          $absender = $serverSettings['titel']." Passwortservice";
          $email = $serverSettings['pass_mail'];
          $empfaenger = $_POST['email'];
          $mail_body = "Hallo,
          Parola dvs. a fost resetata cu succes.
          
          Cont: ".$acc."
          Parola noua: ".$newPass."
          
          Bucurati-va de joc,
          
          Dein ".$serverSettings['titel']."-Team
          
          
          Acest e-mail a fost generat automat. Va rog sa trimiteti raspunsurile la aceasta adresa.";
          $titel = "Passwort auf ".$serverSettings['titel'];
          
          $header .= "X-Priority: 3\n";
          $header .= "X-Mailer: mtVision Homepage Mailer\n";
          $header .= "MIME-Version: 1.0\n";
          $header .= "From: ".$absender." <".$serverSettings['pass_mail'].">\n";
          $header .= "Reply-To: ".$serverSettings['pass_mail']."\n";
          //$header .= "Content-Transfer-Encoding: 8bit\n"; 
          $header .= "Content-Type: text/plain; charset=iso-8859-1\n";
          
          if(!mail($empfaenger, $titel, $mail_body, $header)) {
            echo'<p class="meldung">Eroare cu serverul de mail: Va rugam sa contactati un admin, cāt mai curānd posibil!</p>';
          }
          
        }
        else {
          echo'<p class="meldung">O noua parola nu poate fi setat. Īn acest raport, va rugam sa contactati un administrator.</p>';
        }
        
      }
      else {
        echo'<p class="meldung">Combinatia specificata nu exista.</p>';
      }
      
    }
    else {
      echo'<p class="meldung">Nu ati introdus toate datele corect.</p>';
    }
    
  }

?>

  <h3>Resetare prin īntrebarea secreta</h3>
  <p>Pentru a seta parola , īntrebarea secreta trebuie sa fie corecta.</p>
  <form action="index.php?s=lostpw" method="POST">
    <table>
      <tr>
        <th class="topLine">Cont:</th>
        <td class="tdunkel"><input class="bar" type="text" name="account" size="16" maxlength="16"/></td>
      </tr>
      <tr>
        <th class="topLine">Īntrebare de securitate:</th>
        <td class="thell">
          <select name="sicherheitsf">
            <?PHP
              foreach($sFrage AS $fragew => $frage) {
                echo'<option value="'.$fragew.'">'.$frage.'</option>';
              }
            ?>
          </select>
        </td>
      </tr>
      <tr>
        <th class="topLine">Raspuns:</th>
        <td class="tdunkel"><input class="bar type="text" name="sicherheitsa" size="16" maxlength="16"/></td>
      </tr>
      <tr>
        <th class="topLine" colspan="2" style="text-align:center;"><input class="btn" type="submit" name="sfform" value="reset"/></th>
      </tr>
    </table>