source: trunk/bookmarks/password.php @ 103

Revision 103, 2.8 KB checked in by admin, 4 years ago (diff)

Merged 1.003 into Trunk

Line 
1<?
2/*
3       
4        This file is part of omCollab.
5       
6        Copyright (c) 2008 omCollab (Openmethodology Project)
7        http://www.openmethodology.org
8        http://mike2.openmethodology.org/wiki/OmCollab
9       
10        And parts copyright of Scuttle project
11        (http://sourceforge.net/projects/scuttle/, http://scuttle.org/)
12       
13        omCollab is free software: you can redistribute it and/or modify
14        it under the terms of the GNU General Public License as published by
15        the Free Software Foundation, either version 3 of the License, or
16        (at your option) any later version.
17       
18        omCollab is distributed in the hope that it will be useful,
19        but WITHOUT ANY WARRANTY; without even the implied warranty of
20        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21        GNU General Public License for more details.
22
23*/
24
25require_once('header.inc.php');
26$userservice =& ServiceFactory::getServiceInstance('UserService');
27$templateservice =& ServiceFactory::getServiceInstance('TemplateService');
28$tplVars = array();
29
30// IF SUBMITTED
31if ($_POST['submitted']) {
32
33    // NO USERNAME
34    if (!$_POST['username']) {
35        $tplVars['error'] = T_('You must enter your username.');
36
37    // NO E-MAIL
38    } elseif (!$_POST['email']) {
39        $tplVars['error'] = T_('You must enter your e-mail address.');
40
41    // USERNAME AND E-MAIL
42    } else {
43
44        // NO MATCH
45        if (!($userinfo = $userservice->getUserByUsername($_POST['username']))) {
46            $tplVars['error'] = T_('No matches found for that username.');
47
48        } elseif ($_POST['email'] != $userinfo['email']) {
49            $tplVars['error'] = T_('No matches found for that combination of username and <abbr title="electronic mail">e-mail</abbr> address.');
50
51        // MATCH
52        } else {
53
54            // GENERATE AND STORE PASSWORD
55            $password = $userservice->generatePassword($userinfo['uId']);
56            if (!($password = $userservice->generatePassword($userinfo['uId']))) {
57                $tplVars['error'] = T_('There was an error while generating your new password. Please try again.');   
58
59            } else {
60                // SEND E-MAIL
61                $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.');
62                $message = wordwrap($message, 70);
63                $headers = 'From: '. $adminemail;
64                $mail = mail($_POST['email'], sprintf(T_('%s Account Information'), $sitename), $message);
65
66                $tplVars['msg'] = sprintf(T_('New password generated and sent to %s'), $_POST['email']);
67            }
68        }
69    }
70}
71
72$templatename = 'password.tpl';
73$tplVars['subtitle'] = T_('Forgotten Password');
74$tplVars['formaction']  = createURL('password');
75$templateservice->loadTemplate($templatename, $tplVars);
76?>
Note: See TracBrowser for help on using the repository browser.