[189] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * reset_password.php |
---|
| 4 | * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information. |
---|
| 5 | * @author Quinn Comendant <quinn@strangecode.com> |
---|
| 6 | * @version 1.0 |
---|
| 7 | * @since 30 Jun 2006 01:39:32 |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | /******************************************************************** |
---|
| 12 | * CONFIG |
---|
| 13 | ********************************************************************/ |
---|
| 14 | |
---|
| 15 | // The object to validate form input from the user. |
---|
| 16 | require_once 'codebase/lib/FormValidator.inc.php'; |
---|
| 17 | $fv = new FormValidator(); |
---|
| 18 | |
---|
| 19 | /******************************************************************** |
---|
| 20 | * MAIN |
---|
| 21 | ********************************************************************/ |
---|
| 22 | |
---|
| 23 | // If boomerang is set remember which page we came from so we can go back there. |
---|
| 24 | if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { |
---|
| 25 | $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'reset_password'); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | $app->sslOn(); |
---|
| 29 | |
---|
| 30 | switch (getFormData('op')) { |
---|
| 31 | case 'reset' : |
---|
| 32 | $fv->notEmpty('username', sprintf(_("You must enter your %s."), _("Username"))); |
---|
| 33 | if (!$fv->anyErrors()) { |
---|
| 34 | // Get the user id for this username, if it exists. |
---|
| 35 | $qid = $db->query(" |
---|
| 36 | SELECT " . $db->escapeString($auth->getParam('db_primary_key')) . " |
---|
| 37 | FROM " . $db->escapeString($auth->getParam('db_table')) . " |
---|
| 38 | WHERE " . $db->escapeString($auth->getParam('db_username_column')) . " = '" . $db->escapeString(getFormData('username')) . "' |
---|
| 39 | "); |
---|
| 40 | if ((list($user_id) = mysql_fetch_row($qid)) && $auth->resetPassword($user_id, 'This was requested on the "I forgot my password" page.')) { |
---|
| 41 | $app->raiseMsg(sprintf(_("Your password has been reset. Your new password has been sent to you in an email."), null), MSG_SUCCESS, __FILE__, __LINE__); |
---|
| 42 | $app->dieURL($auth->getParam('login_url')); |
---|
| 43 | } else { |
---|
| 44 | $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__); |
---|
| 45 | $app->logMsg(sprintf('Password reset for %s failed.', getFormData('username')), LOG_NOTICE, __FILE__, __LINE__); |
---|
| 46 | $frm = array('username' => getFormData('username')); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | break; |
---|
| 50 | |
---|
| 51 | case 'form' : |
---|
| 52 | default : |
---|
| 53 | $frm = array('username' => ''); |
---|
| 54 | break; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | /******************************************************************** |
---|
| 59 | * OUTPUT |
---|
| 60 | ********************************************************************/ |
---|
| 61 | |
---|
| 62 | $nav->add(_("Reset Password")); |
---|
| 63 | |
---|
| 64 | include 'header.ihtml'; |
---|
| 65 | include 'codebase/services/templates/reset_password.ihtml'; |
---|
| 66 | include 'footer.ihtml'; |
---|
| 67 | |
---|
| 68 | ?> |
---|