Location: PHPKode > projects > Kwalbum > kwalbum/pages/ChangePasswordPage.php
<?php
/*
 * Created on Aug 29, 2008
 * 2.0
 */
require_once 'include/IPage.php';

class ChangePasswordPage implements IPage
{
	private $msg;

	function GetHead(& $title)
	{
		if (0 == USER_ID)
			return;
		global $DB, $P;

		if (isset($P['act']))
		{
			$oldPass = $P['old'];
			$newPass1 = $P['new1'];
			$newPass2 = $P['new2'];
			$query = 'SELECT UserId
					FROM ' . USER_TABLE . "
					WHERE UserId=".USER_ID." AND UserPassword='".sha1($oldPass)."'";
			$result = $DB->query($query);
			if (0 < $result->num_rows)
			{
				if ($newPass1 == $newPass2)
				{
					require_once 'include/JoinValidate.php';
					$JV = new JoinValidate();
					if ($JV->validateAJAX($newPass1, 'txtPass1'))
					{
						if ($DB->UpdateSingle(USER_TABLE, 'UserPassword', "'".sha1($newPass2)."'", 'UserId='.USER_ID))
							$this->msg = 'Password has been changed.';
					}
					else
						$this->msg = '<div class="error">New password must be at least '.$JV->passLength.' characters long.</div>';
				}
				else
					$this->msg = '<div class="error">New passwords do not match.</div>';
			}
			else
				$this->msg = '<div class="error">Invalid password.</div>';
		}

		$title = 'Change Password';
		return '';
	}

	function ShowBody()
	{
		if (0 == USER_ID)
			return;
		global $URLP;
		require 'ChangePasswordPage.html.php';
	}
}
?>
Return current item: Kwalbum