2 /***************************************************************************
3 Copyright (c) 2005 Scuttle project
4 http://sourceforge.net/projects/scuttle/
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ***************************************************************************/
22 require_once('header.inc.php');
23 $userservice =& ServiceFactory::getServiceInstance('UserService');
24 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
28 if ($_POST['submitted']) {
31 if (!$_POST['username']) {
32 $tplVars['error'] = T_('You must enter your username.');
35 } elseif (!$_POST['email']) {
36 $tplVars['error'] = T_('You must enter your <abbr title="electronic mail">e-mail</abbr> address.');
38 // USERNAME AND E-MAIL
42 if (!($userinfo = $userservice->getUserByUsername($_POST['username']))) {
43 $tplVars['error'] = T_('No matches found for that username.');
45 } elseif ($_POST['email'] != $userinfo['email']) {
46 $tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
51 // GENERATE AND STORE PASSWORD
52 $password = $userservice->generatePassword($userinfo['uId']);
53 if (!($password = $userservice->generatePassword($userinfo['uId']))) {
54 $tplVars['error'] = T_('There was an error while generating your new password. Please try again.');
58 $message = T_('Your new password is:') ."\n". $password ."\n\n". T_('To keep your bookmarks secure, you should change this password in your profile the next time you log in.');
59 $message = wordwrap($message, 70);
60 $headers = 'From: '. $adminemail;
61 $mail = mail($_POST['email'], sprintf(T_('%s Account Information'), $sitename), $message);
63 $tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), $_POST['email']);
69 $templatename = 'password.tpl';
70 $tplVars['subtitle'] = T_('Forgotten Password');
71 $tplVars['formaction'] = createURL('password');
72 $templateservice->loadTemplate($templatename, $tplVars);