[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/> |
---|
[396] | 5 | * Copyright 2001-2012 Strangecode, LLC |
---|
[497] | 6 | * |
---|
[362] | 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. |
---|
[497] | 13 | * |
---|
[362] | 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. |
---|
[497] | 18 | * |
---|
[362] | 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 | |
---|
[497] | 36 | // Redefine include_path including the codebase/services but allow local templates override global ones. |
---|
| 37 | ini_set('include_path', join(PATH_SEPARATOR, array( |
---|
| 38 | get_include_path(), |
---|
| 39 | dirname(__FILE__) . '/templates' |
---|
| 40 | ))); |
---|
| 41 | |
---|
[189] | 42 | // The object to validate form input from the user. |
---|
| 43 | require_once 'codebase/lib/FormValidator.inc.php'; |
---|
| 44 | $fv = new FormValidator(); |
---|
| 45 | |
---|
[497] | 46 | require_once 'codebase/lib/HTML.inc.php'; |
---|
| 47 | |
---|
[189] | 48 | /******************************************************************** |
---|
| 49 | * MAIN |
---|
| 50 | ********************************************************************/ |
---|
| 51 | |
---|
| 52 | // If boomerang is set remember which page we came from so we can go back there. |
---|
| 53 | if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { |
---|
| 54 | $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'reset_password'); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | $app->sslOn(); |
---|
| 58 | |
---|
| 59 | switch (getFormData('op')) { |
---|
| 60 | case 'reset' : |
---|
| 61 | $fv->notEmpty('username', sprintf(_("You must enter your %s."), _("Username"))); |
---|
| 62 | if (!$fv->anyErrors()) { |
---|
| 63 | // Get the user id for this username, if it exists. |
---|
| 64 | $qid = $db->query(" |
---|
| 65 | SELECT " . $db->escapeString($auth->getParam('db_primary_key')) . " |
---|
| 66 | FROM " . $db->escapeString($auth->getParam('db_table')) . " |
---|
| 67 | WHERE " . $db->escapeString($auth->getParam('db_username_column')) . " = '" . $db->escapeString(getFormData('username')) . "' |
---|
| 68 | "); |
---|
| 69 | if ((list($user_id) = mysql_fetch_row($qid)) && $auth->resetPassword($user_id, 'This was requested on the "I forgot my password" page.')) { |
---|
| 70 | $app->raiseMsg(sprintf(_("Your password has been reset. Your new password has been sent to you in an email."), null), MSG_SUCCESS, __FILE__, __LINE__); |
---|
| 71 | $app->dieURL($auth->getParam('login_url')); |
---|
| 72 | } else { |
---|
| 73 | $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__); |
---|
| 74 | $app->logMsg(sprintf('Password reset for %s failed.', getFormData('username')), LOG_NOTICE, __FILE__, __LINE__); |
---|
| 75 | $frm = array('username' => getFormData('username')); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | break; |
---|
| 79 | |
---|
| 80 | case 'form' : |
---|
| 81 | default : |
---|
| 82 | $frm = array('username' => ''); |
---|
| 83 | break; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | /******************************************************************** |
---|
| 88 | * OUTPUT |
---|
| 89 | ********************************************************************/ |
---|
| 90 | |
---|
| 91 | $nav->add(_("Reset Password")); |
---|
[535] | 92 | $nav->set('id', 'reset_password'); |
---|
[189] | 93 | |
---|
| 94 | include 'header.ihtml'; |
---|
[497] | 95 | include 'reset_password.ihtml'; |
---|
[189] | 96 | include 'footer.ihtml'; |
---|
| 97 | |
---|