$newconf_PP['PPVersion'] = $version; $newconf_PP['PASSWORDENF'] = isset($_POST['PP_Password_Enforced']) ? $_POST['PP_Password_Enforced'] : 'false'; $newconf_PP['PASSWORD_SCORE'] = isset($_POST['PP_Password_Score']) ? $_POST['PP_Password_Score'] : '100'; $newconf_PP['ADMINPASSWENF'] = isset($_POST['PP_AdminPassword_Enforced']) ? $_POST['PP_AdminPassword_Enforced'] : 'false'; $newconf_PP['PWDRESET'] = isset($_POST['PP_PwdReset']) ? $_POST['PP_PwdReset'] : 'false'; $newconf_PP['LOGFAILBLOCK'] = isset($_POST['PP_LogFailedPassw']) ? $_POST['PP_LogFailedPassw'] : 'false'; $newconf_PP['NBLOGFAIL'] = isset($_POST['PP_NbFailedPassw']) ? $_POST['PP_NbFailedPassw'] : '0'; $newconf_PP['USRLOCKEDTXT'] = isset($_POST['PP_CustomLockMsg']) ? $_POST['PP_CustomLockMsg'] : l10n('PP_User_Account_Locked_Txt'); $conf['PasswordPolicy'] = serialize($newconf_PP); conf_update_param('PasswordPolicy', pwg_db_real_escape_string($conf['PasswordPolicy'])); array_push($page['infos'], l10n('PP_save_config')); } // Testing password enforcement // ---------------------------- if (isset($_POST['PasswordTest']) and isset($_POST['PP_Password_Test']) and !empty($_POST['PP_Password_Test'])) { $PP_Password_Test_Score = PP_testpassword($_POST['PP_Password_Test']); } else { if (isset($_POST['PasswordTest']) and empty($_POST['PP_Password_Test'])) { array_push($page['errors'], l10n('PP_Error_Password_Mandatory')); } } $conf_PP = unserialize($conf['PasswordPolicy']); $template->assign(array('PP_VERSION' => $version, 'PP_PATH' => PP_PATH, 'PP_PASSWORDENF_TRUE' => $conf_PP['PASSWORDENF'] == 'true' ? 'checked="checked"' : '', 'PP_PASSWORDENF_FALSE' => $conf_PP['PASSWORDENF'] == 'false' ? 'checked="checked"' : '', 'PP_PASSWORD_SCORE' => $conf_PP['PASSWORD_SCORE'], 'PP_ADMINPASSWENF_TRUE' => $conf_PP['ADMINPASSWENF'] == 'true' ? 'checked="checked"' : '', 'PP_ADMINPASSWENF_FALSE' => $conf_PP['ADMINPASSWENF'] == 'false' ? 'checked="checked"' : '', 'PP_PWDRESET_TRUE' => $conf_PP['PWDRESET'] == 'true' ? 'checked="checked"' : '', 'PP_PWDRESET_FALSE' => $conf_PP['PWDRESET'] == 'false' ? 'checked="checked"' : '', 'PP_PASSWORD_TEST_SCORE' => $PP_Password_Test_Score, 'PP_LOGFAILEDPASSW_TRUE' => $conf_PP['LOGFAILBLOCK'] == 'true' ? 'checked="checked"' : '', 'PP_LOGFAILEDPASSW_FALSE' => $conf_PP['LOGFAILBLOCK'] == 'false' ? 'checked="checked"' : '', 'PP_NBLOGFAIL' => $conf_PP['NBLOGFAIL'], 'PP_USRLOCKEDTXT' => $conf_PP['USRLOCKEDTXT'])); // +-----------------------------------------------------------------------+ // | errors display | // +-----------------------------------------------------------------------+ if (isset($errors) and count($errors) != 0) { $template->assign('errors', array()); foreach ($errors as $error) { array_push($page['errors'], $error); }
/** * Triggered on loc_begin_profile */ function PP_Profile_Init() { global $conf, $user, $template; load_language('plugin.lang', PP_PATH); $conf_PP = unserialize($conf['PasswordPolicy']); // Special message display for password reset // ------------------------------------------ if (isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET'] == 'true') { if (PP_check_pwdreset($user['id'])) { $template->append('errors', l10n('PP_Password_Reset_Msg')); } } // Controls on profile page submission // ----------------------------------- if (isset($_POST['validate']) and !is_admin()) { // Password reset control // ---------------------- if (isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET'] == 'true' and PP_check_pwdreset($user['id'])) { // if password not changed then pwdreset field = true else pwdreset field = false // ------------------------------------------------------------------------------ if (!empty($_POST['use_new_pwd'])) { $query = ' UPDATE ' . USERS_TABLE . ' SET PP_pwdreset = "false" WHERE id = ' . $user['id'] . ' LIMIT 1 ;'; pwg_query($query); } } if (!empty($_POST['use_new_pwd'])) { // Password enforcement control // ---------------------------- if (isset($conf_PP['PASSWORDENF']) and $conf_PP['PASSWORDENF'] == 'true' and !empty($conf_PP['PASSWORD_SCORE'])) { $PasswordCheck = PP_testpassword($_POST['use_new_pwd']); if ($PasswordCheck < $conf_PP['PASSWORD_SCORE']) { $message = get_l10n_args('PP_Error_Password_Need_Enforcement_%s', $PasswordCheck); $template->append('errors', l10n_args($message) . $conf_PP['PASSWORD_SCORE']); unset($_POST['use_new_pwd']); unset($_POST['validate']); } } } } }