| 1 | <?php |
|---|
| 2 | // $Id$ |
|---|
| 3 | /********************************************************************\ |
|---|
| 4 | * This program is free software; you can redistribute it and/or * |
|---|
| 5 | * modify it under the terms of the GNU General Public License as * |
|---|
| 6 | * published by the Free Software Foundation; either version 2 of * |
|---|
| 7 | * the License, or (at your option) any later version. * |
|---|
| 8 | * * |
|---|
| 9 | * This program is distributed in the hope that it will be useful, * |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|---|
| 12 | * GNU General Public License for more details. * |
|---|
| 13 | * * |
|---|
| 14 | * You should have received a copy of the GNU General Public License* |
|---|
| 15 | * along with this program; if not, contact: * |
|---|
| 16 | * * |
|---|
| 17 | * Free Software Foundation Voice: +1-617-542-5942 * |
|---|
| 18 | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
|---|
| 19 | * Boston, MA 02111-1307, USA gnu@gnu.org * |
|---|
| 20 | * * |
|---|
| 21 | \********************************************************************/ |
|---|
| 22 | /**@file |
|---|
| 23 | * Login page |
|---|
| 24 | * @author Copyright (C) 2004 Benoit Grégoire et Philippe April |
|---|
| 25 | */ |
|---|
| 26 | define('BASEPATH','./'); |
|---|
| 27 | require_once BASEPATH.'include/common.php'; |
|---|
| 28 | require_once BASEPATH.'include/common_interface.php'; |
|---|
| 29 | require_once BASEPATH.'classes/User.php'; |
|---|
| 30 | |
|---|
| 31 | if (isset($_REQUEST['submit'])) { |
|---|
| 32 | if (!$_REQUEST['username'] && !$_REQUEST['email']) { |
|---|
| 33 | $smarty->assign("error", _("Please specify a username or email address")); |
|---|
| 34 | } else { |
|---|
| 35 | $username = $db->EscapeString($_REQUEST['username']); |
|---|
| 36 | $email = $db->EscapeString($_REQUEST['email']); |
|---|
| 37 | // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use |
|---|
| 38 | $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; |
|---|
| 39 | |
|---|
| 40 | try { |
|---|
| 41 | if(empty($account_origin)) |
|---|
| 42 | throw new Exception(_("Sorry, this network does not exist !")); |
|---|
| 43 | |
|---|
| 44 | // Get a list of users associated with either a username of an e-mail |
|---|
| 45 | $username && $user = User::getUserByUsernameAndOrigin($username, $account_origin); |
|---|
| 46 | $email && $user = User::getUserByEmailAndOrigin($email, $account_origin); |
|---|
| 47 | |
|---|
| 48 | // In the case that both previous function calls failed to return a users list |
|---|
| 49 | // Throw an exception |
|---|
| 50 | if($user != null) |
|---|
| 51 | $user->sendLostPasswordEmail(); |
|---|
| 52 | else |
|---|
| 53 | throw new Exception(_("This username or email could not be found in our database")); |
|---|
| 54 | |
|---|
| 55 | $smarty->assign('message', _('A new password has been emailed to you.')); |
|---|
| 56 | $smarty->display('templates/validate.html'); |
|---|
| 57 | exit; |
|---|
| 58 | } catch (Exception $e) { |
|---|
| 59 | $smarty->assign("error", $e->getMessage()); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | // Add the auth servers list to smarty variables |
|---|
| 65 | $sources = array (); |
|---|
| 66 | // Preserve keys |
|---|
| 67 | foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) |
|---|
| 68 | if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) |
|---|
| 69 | $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; |
|---|
| 70 | |
|---|
| 71 | isset ($sources) && $smarty->assign('auth_sources', $sources); |
|---|
| 72 | // Pass the account_origin along, if it's set |
|---|
| 73 | isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); |
|---|
| 74 | |
|---|
| 75 | $smarty->display("templates/lost_password.html"); |
|---|
| 76 | ?> |
|---|