<?php

$str = "";

if ($this->aKe($postData,"pass_change")) {
	if ($this->oDb->getKey("password","SELECT `password` FROM `user`
		WHERE id_user = '".$this->oSession->idUser."'") == md5($postData['curpass'])) {
		if (empty($postData['pass']))
			$str .= '<div class="chyba">Empty password? Drugs?</div>'."\n";
		elseif ($postData['pass'] == $postData['pass_retype']) {
			$this->oDb->query("UPDATE `user` SET
				`password` = '".md5($postData['pass'])."'
				WHERE id_user = '".$this->oSession->idUser."'");
			$str .= '<div class="okmsg">Password changed.</div>'."\n";
		} else
			$str .= '<div class="chyba">Passwords doesn\'t match.</div>'."\n";
	} else
		$str .= '<div class="chyba">Incorrect current password.</div>'."\n";
}

$oForm = new cForm();
$content = $oForm->passwordBox("Current password", "curpass");
$content .= '<hr />'."\n";
$content .= $oForm->passwordBox("New password", "pass");
$content .= $oForm->passwordBox("Confirm password", "pass_retype");
$content .= $oForm->hiddenF("pass_change", "1");
$content .= '<hr />'."\n";
$content .= $oForm->submitButton(0, "Change my password", FALSE);

$str .= '<form method="post" action="'.$this->oUrl->href().'" enctype="multipart/form-data">'."\n";
$str .= $content;
$str .= '</form>'."\n";

return $str;

?>
