source: trunk/services/reset_password.php @ 189

Last change on this file since 189 was 189, checked in by scdev, 18 years ago

Q - Added reset_password service. Fixed some bugs. Change the interface of humanTime() (it was called timeElapsed).

File size: 2.6 KB
Line 
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.
16require_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.
24if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
25    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'reset_password');
26}
27
28$app->sslOn();
29
30switch (getFormData('op')) {
31case '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
51case 'form' :
52default :
53    $frm = array('username' => '');
54    break;
55}
56
57
58/********************************************************************
59* OUTPUT
60********************************************************************/
61
62$nav->add(_("Reset Password"));
63
64include 'header.ihtml';
65include 'codebase/services/templates/reset_password.ihtml';
66include 'footer.ihtml';
67
68?>
Note: See TracBrowser for help on using the repository browser.