[189] | 1 | <?php |
---|
[362] | 2 | /** |
---|
| 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[376] | 5 | * Copyright 2001-2010 Strangecode, LLC |
---|
[362] | 6 | * |
---|
| 7 | * This file is part of The Strangecode Codebase. |
---|
| 8 | * |
---|
| 9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License as published by the |
---|
| 11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
| 12 | * any later version. |
---|
| 13 | * |
---|
| 14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 17 | * details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License along with |
---|
| 20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
| 21 | */ |
---|
| 22 | |
---|
[189] | 23 | /* |
---|
| 24 | * reset_password.php |
---|
[362] | 25 | * |
---|
[189] | 26 | * @author Quinn Comendant <quinn@strangecode.com> |
---|
| 27 | * @version 1.0 |
---|
| 28 | * @since 30 Jun 2006 01:39:32 |
---|
| 29 | */ |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | /******************************************************************** |
---|
| 33 | * CONFIG |
---|
| 34 | ********************************************************************/ |
---|
| 35 | |
---|
| 36 | // The object to validate form input from the user. |
---|
| 37 | require_once 'codebase/lib/FormValidator.inc.php'; |
---|
| 38 | $fv = new FormValidator(); |
---|
| 39 | |
---|
| 40 | /******************************************************************** |
---|
| 41 | * MAIN |
---|
| 42 | ********************************************************************/ |
---|
| 43 | |
---|
| 44 | // If boomerang is set remember which page we came from so we can go back there. |
---|
| 45 | if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { |
---|
| 46 | $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'reset_password'); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | $app->sslOn(); |
---|
| 50 | |
---|
| 51 | switch (getFormData('op')) { |
---|
| 52 | case 'reset' : |
---|
| 53 | $fv->notEmpty('username', sprintf(_("You must enter your %s."), _("Username"))); |
---|
| 54 | if (!$fv->anyErrors()) { |
---|
| 55 | // Get the user id for this username, if it exists. |
---|
| 56 | $qid = $db->query(" |
---|
| 57 | SELECT " . $db->escapeString($auth->getParam('db_primary_key')) . " |
---|
| 58 | FROM " . $db->escapeString($auth->getParam('db_table')) . " |
---|
| 59 | WHERE " . $db->escapeString($auth->getParam('db_username_column')) . " = '" . $db->escapeString(getFormData('username')) . "' |
---|
| 60 | "); |
---|
| 61 | if ((list($user_id) = mysql_fetch_row($qid)) && $auth->resetPassword($user_id, 'This was requested on the "I forgot my password" page.')) { |
---|
| 62 | $app->raiseMsg(sprintf(_("Your password has been reset. Your new password has been sent to you in an email."), null), MSG_SUCCESS, __FILE__, __LINE__); |
---|
| 63 | $app->dieURL($auth->getParam('login_url')); |
---|
| 64 | } else { |
---|
| 65 | $app->raiseMsg(sprintf(_("There was a problem resetting the password for <em>%s</em>. Please contact us if you need assistance."), getFormData('username')), MSG_WARNING, __FILE__, __LINE__); |
---|
| 66 | $app->logMsg(sprintf('Password reset for %s failed.', getFormData('username')), LOG_NOTICE, __FILE__, __LINE__); |
---|
| 67 | $frm = array('username' => getFormData('username')); |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | break; |
---|
| 71 | |
---|
| 72 | case 'form' : |
---|
| 73 | default : |
---|
| 74 | $frm = array('username' => ''); |
---|
| 75 | break; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /******************************************************************** |
---|
| 80 | * OUTPUT |
---|
| 81 | ********************************************************************/ |
---|
| 82 | |
---|
| 83 | $nav->add(_("Reset Password")); |
---|
| 84 | |
---|
| 85 | include 'header.ihtml'; |
---|
| 86 | include 'codebase/services/templates/reset_password.ihtml'; |
---|
| 87 | include 'footer.ihtml'; |
---|
| 88 | |
---|
| 89 | ?> |
---|