Пример #1
0
 function processFieldInterface($name, $prefix = '')
 {
     switch ($name) {
         case 'password':
             if (!empty($_REQUEST[$prefix . $name . '1'])) {
                 $val = $_REQUEST[$prefix . $name . '1'];
                 if ($val != $_REQUEST[$prefix . $name . '2']) {
                     trigger_error('Password and password confirmation do not match; Password not saved.');
                 } else {
                     if (strlen($val) < $this->getMinPasswordLength()) {
                         trigger_error('Password is too short - must be at least ' . $this->getMinPasswordLength() . ' characters; Password not saved.');
                     } else {
                         if (!preg_match('/[0-9]+/', $val) || !preg_match('/[^0-9]+/', $val)) {
                             trigger_error('Password is too simple - it must contain letters and numbers; Password not saved.');
                         } else {
                             $this->setValue($name, jethro_password_hash($val));
                             $this->_tmp['raw_password'] = $val;
                             // only saved in this script execution
                         }
                     }
                 }
             }
             break;
         case 'permissions':
             if (!$GLOBALS['user_system']->havePerm(PERM_SYSADMIN)) {
                 return;
             }
             // fall through
         // fall through
         default:
             parent::processFieldInterface($name, $prefix);
     }
 }
 private function processSetPassword()
 {
     $db = $GLOBALS['db'];
     $val = $_REQUEST['password1'];
     if ($val != $_REQUEST['password2']) {
         $this->_error = 'Password and password confirmation do not match.  Try again.';
         require_once 'templates/set_password.template.php';
         exit;
     } else {
         if (strlen($val) < MEMBER_PASSWORD_MIN_LENGTH) {
             $this->_error = 'Password is too short - must be at least ' . MEMBER_PASSWORD_MIN_LENGTH . ' characters; Password not saved.';
             require_once 'templates/set_password.template.php';
             exit;
         } else {
             if (!preg_match('/[0-9]+/', $val) || !preg_match('/[^0-9]+/', $val)) {
                 $this->_error = 'Password is too simple - it must contain letters and numbers; Password not saved.';
                 require_once 'templates/set_password.template.php';
                 exit;
             } else {
                 $sql = 'UPDATE _person ' . 'SET `member_password` = ' . $db->quote(jethro_password_hash($val)) . ', ' . 'resethash = NULL, ' . 'resetexpires = NULL ' . 'WHERE id = ' . (int) $_SESSION['member']['id'];
                 $res = $db->exec($sql);
                 check_db_result($res);
                 if (!empty($_REQUEST['isreset'])) {
                     add_message('Your password has been successfully changed.');
                 } else {
                     add_message('Welcome!  Your account is complete and you are now logged in.');
                 }
             }
         }
     }
 }