﻿£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
<?

require_once "include/db.inc.php";
require_once "include/form.inc.php";
require_once "include/user.inc.php";
require_once "include/mailtemplate.inc.php";

class ForgotPasswordForm extends Form
{
	public $email = "";
	public $saved = 0;

	function FillFromPost()
	{
		ObjectFromArray($this, $_REQUEST);
	}

	function Validate()
	{
		if (IsEmpty($this->email))
			$this->AddError("Please enter your email address.", "email");

		if (count($this->errors) == 0)
		{
			$u = User::LoadByEmail($this->email);
	 		if ($u === FALSE)
	 			$this->AddError("Oops, you have entered an invalid email address.", "email");
	 		else
	 		{	 			$u->GenPassword();
	 			$u->Save();
	 			$mt = MailTemplate::LoadByName("forgot");
	 			$mt->ApplyAndSend($u->email, $u->id);	 		}
		}
		return (count($this->errors) == 0);
	}

	function Save()
	{
		$this->saved = 1;
		//send mail
	}
}

$f = new ForgotPasswordForm();
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
	$f->FillFromPost();
	if ($f->Validate())
		$f->Save();
}

include "header.inc.php";
$f->Render("forgot.xslt", FALSE);
include "footer.inc.php";

?>