| 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 | isset($_REQUEST["username"]) && $smarty->assign("username", $_REQUEST["username"]); |
|---|
| 32 | |
|---|
| 33 | if (isset($_REQUEST["submit"])) { |
|---|
| 34 | try { |
|---|
| 35 | if (!$_REQUEST["username"] || !$_REQUEST["oldpassword"] || !$_REQUEST["newpassword"] || !$_REQUEST["newpassword_again"]) |
|---|
| 36 | throw new Exception(_('You MUST fill in all the fields.')); |
|---|
| 37 | $username = $db->EscapeString(trim($_REQUEST['username'])); |
|---|
| 38 | $current_password = $db->EscapeString(trim($_REQUEST['oldpassword'])); |
|---|
| 39 | $new_password = $db->EscapeString(trim($_REQUEST['newpassword'])); |
|---|
| 40 | |
|---|
| 41 | if ($_REQUEST["newpassword"] != $_REQUEST["newpassword_again"]) |
|---|
| 42 | throw new Exception(_("Passwords do not match.")); |
|---|
| 43 | |
|---|
| 44 | $user = User::getUserById($username); |
|---|
| 45 | if ($user->getPasswordHash() != User::passwordHash($current_password)) |
|---|
| 46 | throw new Exception(_("Wrong password.")); |
|---|
| 47 | |
|---|
| 48 | $user->SetPassword($new_password); |
|---|
| 49 | $smarty->assign("message", _("Your password has been changed succesfully.")); |
|---|
| 50 | $smarty->display("templates/validate.html"); |
|---|
| 51 | exit; |
|---|
| 52 | } catch (Exception $e) { |
|---|
| 53 | $smarty->assign("error", $e->getMessage()); |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | $smarty->display("templates/change_password.html"); |
|---|
| 57 | ?> |
|---|