Ignore:
Timestamp:
Sep 15, 2014 9:44:27 PM (10 years ago)
Author:
anonymous
Message:

Beginning the process of adapting codebase to foundation styles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/services/password.php

    r468 r497  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2525 */
    2626
    27 // require_once dirname(__FILE__) . '/_config.inc.php';
     27// Redefine include_path including the codebase/services but allow local templates override global ones.
     28ini_set('include_path', join(PATH_SEPARATOR, array(
     29    get_include_path(),
     30    dirname(__FILE__) . '/templates'
     31)));
    2832
    2933$auth->requireLogin();
    3034
    3135require_once 'codebase/lib/FormValidator.inc.php';
     36require_once 'codebase/lib/HTML.inc.php';
    3237
    3338/******************************************************************************
     
    3641
    3742// Titles and navigation header.
    38 $nav->add(_("Change password"));
     43$nav->add(sprintf(_("Change password for <em>%s</em>"), $auth->get('username')));
    3944
    4045// The object to validate form input from the user.
     
    5863
    5964    // Validate the posted data.
    60 //  $fv->isEmpty('oldpassword', _("You did not specify the <strong>old password</strong>."));
    61     $fv->checkRegex('oldpassword', '/^[[:alnum:][:punct:]]{0,128}$/i', true, _("The <strong>Old password</strong> specified is not valid."));
    62     if (!$fv->isEmpty('newpassword', _("You did not specify the <strong>New password</strong>."))) {
    63         $fv->checkRegex('newpassword', '/^[[:alnum:][:punct:]]{6,128}$/i', true, _("The <strong>New password</strong> specified is not valid. A password must be 6 or more characters."));
    64         if ($frm['newpassword'] != $frm['newpassword2'] && !$fv->isEmpty('newpassword2', _("You need to type the <strong>New password</strong> twice."))) {
    65             $fv->addError('newpassword', _("The <strong>New passwords</strong> do not match."));
    66             $fv->addError('newpassword2');
     65    if ($fv->notEmpty('oldpassword', _("You did not specify the <strong>old password</strong>."))) {
     66        $fv->checkRegex('oldpassword', '/^\S{0,128}$/i', true, _("The <strong>old password</strong> specified is not valid."));
     67    }
     68    if ($fv->notEmpty('newpassword', _("You did not specify the <strong>new password</strong>."))) {
     69        if ($fv->checkRegex('newpassword', '/^\S{8,128}$/i', true, _("The <strong>new password</strong> specified is not valid. A password must be eight or more characters."))) {
     70            if ($fv->notEmpty('newpassword2', _("You need to type the <strong>new password</strong> twice.")) && $frm['newpassword'] != $frm['newpassword2']) {
     71                $fv->addError('newpassword', _("The <strong>new passwords</strong> do not match."));
     72                $fv->addError('newpassword2');
     73            }
    6774        }
    6875    }
    6976
    7077    if (!$fv->anyErrors() && false === $auth->authenticate($auth->get('username'), $frm['oldpassword'])) {
    71         $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication."));
     78        $fv->addError('oldpassword', _("Your <strong>old password</strong> failed authentication."));
    7279        $app->logMsg(sprintf('Password change failed for %s, using (md5ed) password: %s', $auth->get('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);
    7380    }
     
    8491// Templates.
    8592include 'header.ihtml';
    86 include 'codebase/services/templates/password.ihtml';
     93include 'password.ihtml';
    8794include 'footer.ihtml';
    8895
Note: See TracChangeset for help on using the changeset viewer.