<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
if (!isset($UserCurrentPassword)) $UserCurrentPassword = '';
if (!isset($Input_UserCurrentPassword)) $Input_UserCurrentPassword = '';
if (!isset($UserNewPassword)) $UserNewPassword = '';
if (!isset($UserNewPasswordRepeated)) $UserNewPasswordRepeated = '';
if (!isset($senden)) $senden = '';
// POST-Variablen definieren
//   if (!$senden) {
//     $SQLQuery = "SELECT * FROM ".$prefix."user Where UserName = '".getCurrentUser()."'";
//     $Result = mysqli_query($db, $SQLQuery);
//     while ($row = mysqli_fetch_array($Result))
//       extract($row); }
// Formular überprüfen
  if ( loggedIn()
       && $senden
       && !empty($Input_UserCurrentPassword)
       && password_verify($_POST['Input_UserCurrentPassword'], getCurrentUserVar('UserCurrentPassword'))
       && !empty($UserNewPassword)
       && !empty($UserNewPasswordRepeated)
       && $UserNewPassword>=$MinPasswordChars
       && $UserNewPassword==$UserNewPasswordRepeated)
    $FormularKorrektAusgefuellt = true;
  else
    $FormularKorrektAusgefuellt = false;

echo '<p class="Headline">'.$L_Headline21.'</p>';
if (!loggedIn()) {
  echo $L_003; }
else {
  // Inhalt hier einfügen
  if ($FormularKorrektAusgefuellt==true) {
//     if (empty($_POST['UserNewPassword']))
//       $UserNewPassword = $Input_UserCurrentPassword;
//     else
//       $UserNewPassword = $_POST['UserNewPassword'];
    if (editCurrentPassword($UserNewPassword)) {
      echo $L_053.'<br>'; }
    else {
      echo $L_054.'<br>'; }
    echo '<br>
            <form method="post" action="index.php?submenue=user&amp;content=editCurrentPassword" accept-charset="UTF-8">
              <fieldset>
                <input type="submit" value="'.$L_Button26.'" class="button" />
              </fieldset>
            </form>'; }
  else {
    echo '<form id="addUser" method="post" action="index.php?submenue=user&amp;content=editCurrentPassword" accept-charset="UTF-8">
            <table summary="addUser">';
    // Current Password
    if ($senden) {
      if ($Input_UserCurrentPassword=="")
        echo '<tr><td></td><td class="ErrorMessage">'.$L_050.'</td></tr>';
      else
        if (!password_verify($_POST['Input_UserCurrentPassword'], getCurrentUserVar('UserCurrentPassword')))
          echo '<tr><td></td><td class="ErrorMessage">'.$L_143.'</td></tr>'; }
    echo '<tr>
            <td>'.$L_UserCurrentPassword.':</td>
            <td>
              <input type="password" name="Input_UserCurrentPassword" maxlength="'.$MaxPasswordChars.'" value="'.$Input_UserCurrentPassword.'" />
            </td>
          </tr>';
    // New Password
    if (($senden && empty($UserNewPassword))) {
      echo '<tr><td></td><td class="ErrorMessage">'.$L_050.'</td></tr>'; }
//     if (!$senden AND $job=='edit') {
//       $UserNewPassword = $UserCurrentPassword; }
    echo '<tr>
            <td>'.$L_UserNewPassword.':</td>
            <td>
              <input type="password" name="UserNewPassword" minlength="'.$MinPasswordChars.'" maxlength="'.$MaxPasswordChars.'" value="'.$UserNewPassword.'" />
            </td>
          </tr>';
    // New Password Repeated
    if ($senden && empty($UserNewPasswordRepeated))
      echo '<tr><td></td><td class="ErrorMessage">'.$L_050.'</td></tr>';
    if ($senden && !empty($UserNewPasswordRepeated) && $UserNewPassword!=$UserNewPasswordRepeated) {
      echo '<tr><td></td><td class="ErrorMessage">'.$L_070.'</td></tr>'; }
    echo '<tr>
            <td>'.$L_UserNewPasswordRepeated.':</td>
            <td>
              <input type="password" name="UserNewPasswordRepeated" minlength="'.$MinPasswordChars.'" maxlength="'.$MaxPasswordChars.'" value="'.$UserNewPasswordRepeated.'" />
            </td>
          </tr>';
    // Buttons
    // <input type="hidden" name="UserSession" maxlength="32" value="'.$UserSession.'" readonly="readonly" />
    echo '<tr>
            <td></td>
            <td>
              <input type="submit" name="senden" value="'.$L_Button01.'" class="button" />
		          <input type="hidden" name="CurrentUserName" value="'.getCurrentUser().'" />
              <input type="reset" value="'.$L_Button38.'" class="button" />
            </td>
          </tr>
        </table>
      </form>'; }}