source: trunk/services/reset_password.php @ 502

Last change on this file since 502 was 497, checked in by anonymous, 10 years ago

Beginning the process of adapting codebase to foundation styles.

File size: 3.6 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2012 Strangecode, LLC
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
23/*
24* reset_password.php
25*
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// Redefine include_path including the codebase/services but allow local templates override global ones.
37ini_set('include_path', join(PATH_SEPARATOR, array(
38    get_include_path(),
39    dirname(__FILE__) . '/templates'
40)));
41
42// The object to validate form input from the user.
43require_once 'codebase/lib/FormValidator.inc.php';
44$fv = new FormValidator();
45
46require_once 'codebase/lib/HTML.inc.php';
47
48/********************************************************************
49* MAIN
50********************************************************************/
51
52// If boomerang is set remember which page we came from so we can go back there.
53if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
54    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'reset_password');
55}
56
57$app->sslOn();
58
59switch (getFormData('op')) {
60case '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
80case 'form' :
81default :
82    $frm = array('username' => '');
83    break;
84}
85
86
87/********************************************************************
88* OUTPUT
89********************************************************************/
90
91$nav->add(_("Reset Password"));
92
93include 'header.ihtml';
94include 'reset_password.ihtml';
95include 'footer.ihtml';
96
Note: See TracBrowser for help on using the repository browser.