sub showProfile{
my $hrUser  = $m_oDatabase->fetch_hashref("select * from  users where user = '$m_sUser'");
$m_sContent .= qq|
<div class="ShowTables" style="margin-top:4%;padding:4%;width:92%;"><form name="changePassword" target="_parent" method="get" onsubmit="submitForm(this,'saveProfile','saveProfile');return false;">
<label for="user">|.translate('name').qq|</label>
<br/>
<input type="text" id="user" data-regexp=").'/^\w{4,100}$/'.qq(" data-error="$wrong_username_text" data-right="$right_username_text" name="user" value="$hrUser->{user}">
<br/>
<label for="password">|.translate('password').qq|</label>
<br/>
<input type="password" data-regexp="/.{6,50}/" data-error="$wrong_passwort_text"  data-right="$right_passwort_text" id="password" name="pass"/>
<br/>
<label for="newpass">|.translate('newpass').qq|</label>
<br/>
<input type="password" data-regexp="/.{6,50}/" data-error="$wrong_passwort_text"  data-right="$right_passwort_text" id="password" name="newpass"/>
<br/>
<label for="retry">|.translate('retry').qq|</label>
<br/>
<input type="password" data-regexp="/.{6,50}/" data-error="$wrong_passwort_text"  data-right="$right_passwort_text" id="password" name="retry"/>
<br/>
<br/>
<input type="submit"  name="submit" value="|.translate('save').qq|"/>
<input type="hidden" name="action" value="saveProfile"/>
</form></div>
|;
}

sub saveProfile
{
    my $pass      = param(translate('pass'));
    my $newpass   = param(translate('newpass'));
    my $retry     = param(translate('retry'));
    my $md5       = new MD5;
    $md5->add($m_sUser);
    $md5->add($pass);
    my $cyrptpass = $md5->hexdigest();
    my $pwChanged = 0;

    if ($m_oDatabase->checkPass($m_sUser, $cyrptpass) && $newpass eq $retry && $newpass =~ /^\S{6,50}$/) {
        $pwChanged = 1;
        my $md5 = new MD5;
        $md5->add($m_sUser);
        $md5->add($newpass);
        my $newpass = $md5->hexdigest();
        $m_oDatabase->void("update `users` set `pass` = '$newpass' where user = '$m_sUser'");
    }else{
     &showProfile();
    }
    $m_sContent .= '<div class="showTables"><b>' . translate('done') . '</b><br/>
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
    <tr><td >' . translate('newpass') . '</td><td>' . $newpass . '</td></tr>' if ($pwChanged);
    $m_sContent .= '</table>'
      . a(
          {
           href  => "javascript:requestURI('$ENV{SCRIPT_NAME}?action=showProfile','showProfile','showProfile')",
           class => 'links'
          },
          translate('next')
      ).'</div>';
}
1;
