<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// Lost Password Send
	// ========================================================================================
	
	$PageTitle = $MsgText[0][506];
	$BrowserTitle = $MsgText[0][506];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > '.$MsgText[0][506];
	
	ReadFormArguments();
	Global $FormArguments;
	
	if (count($FormArguments) > 0) {
	
		
	$query = "select Username,Email from `".$Settings['DBPrefix']."core-Users` where Username='".addslashes($FormArguments['Username'])."' LIMIT 1";
	$result = mysql_query($query) or die (mysql_error());
	
	$row = mysql_fetch_array($result);
	
	if ($row['Email'] != '') {
		$Chars = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');

		for ($i = 1; $i <= 20; $i++) {
			$RandomNum = rand(0,35);
			$ResetCode .= $Chars[$RandomNum];
		}
		
		$query = "update `".$Settings['DBPrefix']."core-Users` set ResetCode='".$ResetCode."' where Username='".$FormArguments['Username']."' LIMIT 1";
		$result = mysql_query($query) or die (mysql_error());
		
		
		$Message = $Settings['SiteName'].' '.$MsgText[0][509]."\n\n".$MsgText[0][510]."\n\n".$MainURL.'/lost_password-unlock/'.$row['Username'].'/'.$ResetCode."\n\n".$MsgText[0][511]."\n\n\n\n".$MsgText[0][142].','."\n".$Settings['SiteName']."\n".$IndexURL;
		mail($row['Email'], $Settings['SiteName'].' '.$MsgText[0][512], $Message, 'From: "'.$Settings['SiteName'].'" <'.$Settings['ContactEmail'].'>','-f'.$Settings['ContactEmail']);
		
		$PageContents = $MsgText[0][513];	
		
	}
	else {
		$PageContents = $MsgText[0][514];	
	}
	
	
	}
	else {
		$PageContents = $MsgText[0][98];
	}
	
	
	// ========================================================================================




?>
