source: trunk/services/reset_password.php @ 767

Last change on this file since 767 was 767, checked in by anonymous, 23 months ago

Add App param ‘template_ext’ used to inform services where to find header and footer templates. Minor fixes.

File size: 3.7 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
57switch (getFormData('op')) {
58case 'reset' :
59    $fv->notEmpty('username', sprintf(_("You must enter your %s."), _("Username")));
60    if (!$fv->anyErrors()) {
61        // Get the user id for this username, if it exists.
62        $qid = $db->query("
63            SELECT " . $db->escapeString($auth->getParam('db_primary_key')) . "
64            FROM " . $db->escapeString($auth->getParam('db_table')) . "
65            WHERE " . $db->escapeString($auth->getParam('db_username_column')) . " = '" . $db->escapeString(getFormData('username')) . "'
66        ");
67        if ((list($user_id) = mysql_fetch_row($qid)) && $auth->resetPassword($user_id, 'This was requested on the "I forgot my password" page.')) {
68            $app->raiseMsg(sprintf(_("Your password has been reset. Your new password has been sent to you in an email."), null), MSG_SUCCESS, __FILE__, __LINE__);
69            $app->dieURL($auth->getParam('login_url'));
70        } else {
71            $app->raiseMsg(sprintf(_("There was a problem resetting the password for <em>%s</em>. Please contact us if you need assistance."), oTxt(getFormData('username'))), MSG_WARNING, __FILE__, __LINE__);
72            $app->logMsg(sprintf('Password reset for %s failed.', getFormData('username')), LOG_NOTICE, __FILE__, __LINE__);
73            $frm = array('username' => getFormData('username'));
74        }
75    }
76    break;
77
78case 'form' :
79default :
80    $frm = array('username' => '');
81    break;
82}
83
84
85/********************************************************************
86* OUTPUT
87********************************************************************/
88
89$nav->add(_("Reset Password"));
90$nav->set('id', 'reset_password');
91
92include 'header.' . $app->getParam('template_ext');
93include 'reset_password.ihtml';
94include 'footer.' . $app->getParam('template_ext');
95
Note: See TracBrowser for help on using the repository browser.