true)); $getMode = admFuncVariableIsValid($_GET, 'mode', 'string', array('defaultValue' => 'html', 'validValues' => array('html', 'change'))); // in ajax mode only return simple text on error if($getMode === 'change') { $gMessage->showHtmlTextOnly(true); } else { $gMessage->showInModalWindow(); } $user = new User($gDb, $gProfileFields, $getUserId); $currUsrId = (int) $gCurrentUser->getValue('usr_id'); // only the own password could be individual set. // Administrator could only send a generated password or set a password if no password was set before if((int) $gCurrentUser->getValue('usr_id') !== $getUserId && (!isMember($getUserId) || (!$gCurrentUser->isAdministrator() && $currUsrId !== $getUserId) || ($gCurrentUser->isAdministrator() && $user->getValue('EMAIL') !== '' && $gSettingsManager->getBool('enable_system_mails')))) { $gMessage->show($gL10n->get('SYS_NO_RIGHTS')); // => EXIT } if($getMode === 'change') { if($gCurrentUser->isAdministrator() && $currUsrId !== $getUserId) { $oldPassword = ''; } else { $oldPassword = $_POST['old_password']; } $newPassword = $_POST['new_password']; $newPasswordConfirm = $_POST['new_password_confirm']; /***********************************************************************/ /* Handle form input */ /***********************************************************************/ if(($oldPassword !== '' || $gCurrentUser->isAdministrator()) && $newPassword !== '' && $newPasswordConfirm !== '') { if(strlen($newPassword) >= PASSWORD_MIN_LENGTH) { if (PasswordHashing::passwordStrength($newPassword, $user->getPasswordUserData()) >= $gSettingsManager->getInt('password_min_strength')) { if ($newPassword === $newPasswordConfirm) { // check if old password is correct. // Administrator could change password of other users without this verification. if (PasswordHashing::verify($oldPassword, $user->getValue('usr_password')) || ($gCurrentUser->isAdministrator() && $currUsrId !== $getUserId)) { $user->saveChangesWithoutRights(); $user->setPassword($newPassword); $user->save(); // if password of current user changed, then update value in current session if ($currUsrId === (int) $user->getValue('usr_id')) { $gCurrentUser->setPassword($newPassword); } $phrase = 'success'; } else { $phrase = $gL10n->get('PRO_PASSWORD_OLD_WRONG'); } } else { $phrase = $gL10n->get('PRO_PASSWORDS_NOT_EQUAL'); } } else { $phrase = $gL10n->get('PRO_PASSWORD_NOT_STRONG_ENOUGH'); } } else { $phrase = $gL10n->get('PRO_PASSWORD_LENGTH'); } } else { $phrase = $gL10n->get('SYS_FIELDS_EMPTY'); } echo $phrase; } elseif($getMode === 'html') { /***********************************************************************/ /* Show password form */ /***********************************************************************/ $zxcvbnUserInputs = json_encode($user->getPasswordUserData(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $passwordStrengthLevel = 1; if ($gSettingsManager->getInt('password_min_strength')) { $passwordStrengthLevel = $gSettingsManager->getInt('password_min_strength'); } echo ' '; }