Location: PHPKode > projects > Bcom > bcom-1.99.1/bcom/include/order_lostpassword.inc
<?

require_once('lib/libmsg.inc');

$O['HEADING'] = 'Lost password?';
$O['BODY'] = 'something went wrong';
$O['BUTTONS'] = '';

if(!isset($lpact)) { $lpact = 'default'; }
if($lpact == 'default') {


	$O['BODY'] = '<B>Don\'t worry, simply enter your email address below</B> (the one you used when signing up)<B> and press the continue button.
	<BR><BR>
	We will send a special link to this email address, simply click on this link, or enter it into your browser\'s location bar and you will be given the opportunity to change your password.
	<BR><BR>
	If you no longer have access to your email address then you will need to create a new
	account, to do this
	<A HREF="order.php?action=signin&mode=replace&haspass=0&email='.urlencode($email).'">click here</A>.
	<BR><BR>
	<INPUT TYPE="hidden" NAME="action" VALUE="lostpassword">
	<INPUT TYPE="hidden" NAME="lpact" VALUE="sendlink">
	Your email address: <INPUT TYPE="text" NAME="email" SIZE="30">
	'.formbutton('continue','continue');
} elseif($lpact == 'sendlink') {
	$O['HEADING'] = 'Lost password?';
	$O['BODY'] = '';
	$O['BUTTONS'] = '';
	$row = bsql_quickrow('SELECT * FROM client_data WHERE cd_field = \'login\'
	AND cd_value = \''.addslashes($email).'\'');
	if($row && client_getval($row[0],'c_type') == 'site') { 
		 $O['BODY'] = 'Email sent, it may take a few minutes before the email arrives in your inbox.';
		 $lpkey = md5(uniqid(rand(),1)); //maybe wrap this in a define.. like bcom_makeuid.. anyway
		 client_setval($row[0],'lpkey',$lpkey);
		 client_setval($row[0],'lptime',time());
		$data = 'A request to change your '.getoption('site','shortname').' password was submited.
		If you did not request this, ignore this email.

		If you did request the change of password, please click on this link to take 
		you to the next step. If you have problems clicking the link you can copy and 
		paste it into your browsers location bar.

		'.$_BCOM['secureself'].'order.php?XL='.$lpkey.'
		
		';

		 $err = $GLOBALS['_mailer']->send(array($email),
			 array(
			 'Subject' => 'lost password?',
		 'From' => getoption('site','ord_fromaddress')
			),$data);
		if(is_object($err)) {
			print($err->getMessage());
		}
	}
	else{
		$O['BODY'] = 'No account exists for this email address.';
	}
} elseif ($lpact == 'verify') {
	$row = bsql_quickrow('SELECT * FROM client_data WHERE cd_field = \'lpkey\'
	AND cd_value = \''.addslashes($key).'\'');
	if($row && client_getval($row[0],'c_type') == 'site') { 
		$O['BODY'] = 'Email verification successfull, please enter your new password in the boxes below.';
		if(isset($pass1) && isset($pass2)) {
			if($pass1 == $pass2) {
				$O['BODY'] = 'Password update successful';
				client_setval($row[0],'password',$pass1);
				client_delval($row[0],'lpkey');
				client_delval($row[0],'lptime');
				order_display('default',$O);
			} else {
				$O['BODY'] = 'Passwords did not match! Please try again, make sure you type both passwords exactly the same.';
			}
		}
		$O['BODY'] .= '<BR>
		<INPUT TYPE="hidden" NAME="action" VALUE="lostpassword">
		<INPUT TYPE="hidden" NAME="lpact" VALUE="verify">
		<INPUT TYPE="hidden" NAME="key" VALUE="'.$key.'">
		Password: <INPUT TYPE="password" NAME="pass1" VALUE=""><BR>
		Verify: <INPUT TYPE="password" NAME="pass2" VALUE=""><BR>
		<INPUT TYPE="submit">
		';
	}
}
$O['NEXT'] = ''; 
order_display('default',$O);

?>
Return current item: Bcom