summaryrefslogtreecommitdiff
path: root/remind_password.php
blob: bcbed4d12041e7c977f1e636ca2a8e6460f8f673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// $Header: /cvsroot/bitweaver/_bit_users/remind_password.php,v 1.1 2005/06/19 05:12:22 bitweaver Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// Initialization
require_once( '../bit_setup_inc.php' );
if ($forgotPass != 'y') {
	$smarty->assign('msg', tra("This feature is disabled").": forgotPass");
	$gBitSystem->display( 'error.tpl' );
	die;
}
if (isset($_REQUEST["remind"])) {
	if( $userInfo = $gBitUser->getUserInfo( array( 'login' => $_REQUEST["username"] ) ) ) {
		if ( $gBitSystem->isFeatureActive( 'feature_clear_passwords' ) && !empty($userInfo['password']) ) {
			$pass = $userInfo['password'];
			$tmp['success'] = tra("A password reminder email has been sent ");
		} else {
			$pass = $gBitUser->renew_user_password($_REQUEST["username"]);
			$tmp['success'] = tra("A new password has been sent ");
		}
		$tmp['success'] .= tra("to the registered email address for")." " . $_REQUEST["username"] . ".";

		$smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
		$smarty->assign('mail_user', $_REQUEST["username"]);
		$smarty->assign('mail_same', $gBitSystem->isFeatureActive( 'feature_clear_passwords' ));
		$smarty->assign('mail_pass', $pass);
		$mail_data = $smarty->fetch('bitpackage:users/password_reminder.tpl');
		$subject = "Your password for ".$gBitSystem->getPreference( 'siteTitle', $_SERVER['HTTP_HOST'] );
		mail( $userInfo['email'], $subject, $mail_data, "From: ".$gBitSystem->getPreference( 'sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n");
		// Just show "success" message and no form
	} else {
		// Show error message (and leave form visible so user can fix problem)
		$smarty->assign('showmsg', 'e');
		$tmp['error'] = tra("Invalid or unknown username").": ".$_REQUEST["username"];
	}
	$smarty->assign('msg', $tmp);
}
// Display the template
$gBitSystem->display( 'bitpackage:users/remind_password.tpl');
?>