forked from TestLinkOpenSourceTRMS/testlink-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlostPassword.php
79 lines (71 loc) · 2.07 KB
/
lostPassword.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* TestLink Open Source Project - http://testlink.sourceforge.net/
* This script is distributed under the GNU General Public License 2 or later.
*
* Filename $RCSfile: lostPassword.php,v $
*
* @version $Revision: 1.15 $
* @modified $Date: 2006/08/21 13:21:59 $ $Author: franciscom $
*
* 20060103 - scs - ADOdb changes
* 20060819 - franciscom - logo added
**/
require_once('config.inc.php');
require_once('common.php');
require_once('users.inc.php');
require_once('email_api.php');
$_POST = strings_stripSlashes($_POST);
$login = isset($_POST['login']) ? $_POST['login']: null;
$op = doDBConnect($db);
if ($op['status'] == 0)
{
$smarty = new TLSmarty();
$smarty->assign('title', lang_get('fatal_page_title'));
$smarty->assign('msg', $op['dbms_msg']);
$smarty->display('fatal_error.tpl');
exit();
}
$message = lang_get('your_info_for_passwd');
if (strlen($login))
{
if(!existLogin($db,$login,$userInfo))
{
$message = lang_get('bad_user');
}
else
{
$emailAddress = $userInfo['email'];
$userID = $userInfo['id'];
if (strlen($emailAddress))
{
// because pwds are now hashed we cannot simply resend
// the password instead we must generate a new one
$newPassword = md5(uniqid(rand(),1));
//Setup the message body
$msgBody = lang_get('your_password_is') . $newPassword . lang_get('contact_admin');
// 20051209 - fm - BUGID 289
$mail_op = email_send(config_get('from_email'), $emailAddress,
lang_get('mail_passwd_subject'), $msgBody);
if ($mail_op->status_ok)
{
if (setUserPassword($db,$userID,$newPassword))
{
redirect(TL_BASE_HREF ."login.php?note=lost");
exit();
}
}
else
$message = lang_get('mail_problems') . " - " . $mail_op->msg;
}
else
$message = lang_get('mail_empty_address');
}
}
$smarty = new TLSmarty();
$smarty->assign('login_logo', LOGO_LOGIN_PAGE);
$smarty->assign('css', TL_BASE_HREF . TL_LOGIN_CSS);
$smarty->assign('note',$message);
$smarty->assign('page_title',lang_get('page_title_lost_passwd'));
$smarty->display('loginLost.tpl');
?>