/**
  * Save user account settings
  * @return 
  */
 public function saveGeneralSettingsObject()
 {
     global $ilUser, $ilSetting;
     $this->initFormGeneralSettings();
     if ($this->form->checkInput()) {
         $valid = true;
         if (!strlen($this->form->getInput('loginname_change_blocking_time'))) {
             $valid = false;
             $this->form->getItemByPostVar('loginname_change_blocking_time')->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
         }
         include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
         $security = ilSecuritySettings::_getInstance();
         // account security settings
         $security->setPasswordCharsAndNumbersEnabled((bool) $_POST["password_chars_and_numbers_enabled"]);
         $security->setPasswordSpecialCharsEnabled((bool) $_POST["password_special_chars_enabled"]);
         $security->setPasswordMinLength((int) $_POST["password_min_length"]);
         $security->setPasswordMaxLength((int) $_POST["password_max_length"]);
         $security->setPasswordNumberOfUppercaseChars((int) $_POST['password_ucase_chars_num']);
         $security->setPasswordNumberOfLowercaseChars((int) $_POST['password_lowercase_chars_num']);
         $security->setPasswordMaxAge((int) $_POST["password_max_age"]);
         $security->setLoginMaxAttempts((int) $_POST["login_max_attempts"]);
         $security->setPreventionOfSimultaneousLogins((bool) $_POST['ps_prevent_simultaneous_logins']);
         $security->setPasswordChangeOnFirstLoginEnabled((bool) $_POST['password_change_on_first_login_enabled']);
         $security->setPasswordMustNotContainLoginnameStatus((int) $_POST['password_must_not_contain_loginame']);
         if (!$security->validate($this->form)) {
             $valid = false;
         }
         if ($valid) {
             $security->save();
             include_once './Services/User/classes/class.ilUserAccountSettings.php';
             ilUserAccountSettings::getInstance()->enableLocalUserAdministration($this->form->getInput('lua'));
             ilUserAccountSettings::getInstance()->restrictUserAccess($this->form->getInput('lrua'));
             ilUserAccountSettings::getInstance()->update();
             // TODO: move to user account settings
             $save_blocking_time_in_seconds = (int) $ilSetting->get('loginname_change_blocking_time') * 86400;
             $ilSetting->set('allow_change_loginname', (int) $this->form->getInput('allow_change_loginname'));
             $ilSetting->set('create_history_loginname', (int) $this->form->getInput('create_history_loginname'));
             $ilSetting->set('reuse_of_loginnames', (int) $this->form->getInput('reuse_of_loginnames'));
             $ilSetting->set('loginname_change_blocking_time', (int) $save_blocking_time_in_seconds);
             $ilSetting->set('user_adm_alpha_nav', (int) $this->form->getInput('user_adm_alpha_nav'));
             $ilSetting->set('user_reactivate_code', (int) $this->form->getInput('user_reactivate_code'));
             $ilSetting->set('user_delete_own_account', (int) $this->form->getInput('user_own_account'));
             $ilSetting->set('user_delete_own_account_email', $this->form->getInput('user_own_account_email'));
             $ilSetting->set("passwd_auto_generate", $this->form->getInput("passwd_auto_generate"));
             $ilSetting->set("password_assistance", $this->form->getInput("password_assistance"));
             // BEGIN SESSION SETTINGS
             $ilSetting->set('session_handling_type', (int) $this->form->getInput('session_handling_type'));
             if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_FIXED) {
                 $ilSetting->set('session_reminder_enabled', $this->form->getInput('session_reminder_enabled'));
             } else {
                 if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_LOAD_DEPENDENT) {
                     require_once 'Services/Authentication/classes/class.ilSessionControl.php';
                     if ($ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
                         // has to be done BEFORE updating the setting!
                         include_once "Services/Authentication/classes/class.ilSessionStatistics.php";
                         ilSessionStatistics::updateLimitLog((int) $this->form->getInput('session_max_count'));
                         $ilSetting->set('session_max_count', (int) $this->form->getInput('session_max_count'));
                         $ilSetting->set('session_min_idle', (int) $this->form->getInput('session_min_idle'));
                         $ilSetting->set('session_max_idle', (int) $this->form->getInput('session_max_idle'));
                         $ilSetting->set('session_max_idle_after_first_request', (int) $this->form->getInput('session_max_idle_after_first_request'));
                     }
                 }
             }
             // END SESSION SETTINGS
             ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
         } else {
             ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
         }
     } else {
         ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
     }
     $this->form->setValuesByPost();
     $this->tpl->setContent($this->form->getHTML());
 }
Ejemplo n.º 2
0
 /**
  * Destroy session
  *
  * @param	string|array		session id|s
  * @param	int					closing context
  * @param	int|bool			expired at timestamp
  */
 static function _destroy($a_session_id, $a_closing_context = null, $a_expired_at = null)
 {
     global $ilDB;
     if (!$a_closing_context) {
         $a_closing_context = self::$closing_context;
     }
     ilSessionStatistics::closeRawEntry($a_session_id, $a_closing_context, $a_expired_at);
     if (!is_array($a_session_id)) {
         $q = "DELETE FROM usr_session WHERE session_id = " . $ilDB->quote($a_session_id, "text");
     } else {
         // array: id => timestamp - so we get rid of timestamps
         if ($a_expired_at) {
             $a_session_id = array_keys($a_session_id);
         }
         $q = "DELETE FROM usr_session WHERE " . $ilDB->in("session_id", $a_session_id, "", "text");
     }
     ilSessionIStorage::destroySession($a_session_id);
     $ilDB->manipulate($q);
     return true;
 }
Ejemplo n.º 3
0
 /**
  * checks wether the current session exhaust the limit of sessions
  * when limit is reached it deletes "firstRequestAbidencer" and checks again
  * when limit is still reached it deletes "oneMinIdleSession" and checks again
  * when limit is still reached the current session will be logged out
  *
  * @global ilSetting $ilSetting
  * @global ilAppEventHandler $ilAppEventHandler
  * @param Auth $a_auth
  */
 private static function checkCurrentSessionIsAllowed(Auth $a_auth, $a_user_id)
 {
     global $ilSetting;
     $max_sessions = (int) $ilSetting->get('session_max_count', DEFAULT_MAX_COUNT);
     if ($max_sessions > 0) {
         // get total number of sessions
         $num_sessions = self::getExistingSessionCount(self::$session_types_controlled);
         self::debug(__METHOD__ . "--> total existing sessions (" . $num_sessions . ")");
         if ($num_sessions + 1 > $max_sessions) {
             self::debug(__METHOD__ . ' --> limit for session pool reached, but try kicking some first request abidencer');
             self::kickFirstRequestAbidencer(self::$session_types_controlled);
             // get total number of sessions again
             $num_sessions = self::getExistingSessionCount(self::$session_types_controlled);
             if ($num_sessions + 1 > $max_sessions) {
                 self::debug(__METHOD__ . ' --> limit for session pool still reached so try kick one min idle session');
                 self::kickOneMinIdleSession(self::$session_types_controlled);
                 // get total number of sessions again
                 $num_sessions = self::getExistingSessionCount(self::$session_types_controlled);
                 if ($num_sessions + 1 > $max_sessions) {
                     self::debug(__METHOD__ . ' --> limit for session pool still reached so logout session (' . session_id() . ') and trigger event');
                     ilSession::setClosingContext(ilSession::SESSION_CLOSE_LIMIT);
                     // as the session is opened and closed in one request, there
                     // is no proper session yet and we have to do this ourselves
                     ilSessionStatistics::createRawEntry(session_id(), $_SESSION['SessionType'], time(), $a_user_id);
                     $a_auth->logout();
                     // Trigger reachedSessionPoolLimit Event
                     global $ilAppEventHandler;
                     $ilAppEventHandler->raise('Services/Authentication', 'reachedSessionPoolLimit', array());
                     // auth won't do this, we need to close session properly
                     session_destroy();
                     ilUtil::redirect('login.php?reached_session_limit=true');
                 } else {
                     self::debug(__METHOD__ . ' --> limit of session pool not reached anymore after kicking one min idle session');
                 }
             } else {
                 self::debug(__METHOD__ . ' --> limit of session pool not reached anymore after kicking some first request abidencer');
             }
         } else {
             self::debug(__METHOD__ . ' --> limit for session pool not reached yet');
         }
     } else {
         self::debug(__METHOD__ . ' --> limit for session pool not set so check is bypassed');
     }
 }
 protected function adminSync()
 {
     global $ilCtrl, $lng;
     // see ilSession::_writeData()
     $now = time();
     ilSession::_destroyExpiredSessions();
     ilSessionStatistics::aggretateRaw($now);
     ilUtil::sendSuccess($lng->txt("trac_sync_session_stats_success"), true);
     $ilCtrl->redirect($this);
 }
 /**
  * Save basic settings form
  *
  */
 public function saveBasicSettingsObject()
 {
     global $tpl, $lng, $ilCtrl, $ilSetting, $rbacsystem;
     if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     $this->initBasicSettingsForm();
     if ($this->form->checkInput()) {
         $ilSetting->set("short_inst_name", $_POST["short_inst_name"]);
         $ilSetting->set("pub_section", $_POST["pub_section"]);
         $ilSetting->set("open_google", $_POST["open_google"]);
         $ilSetting->set("default_repository_view", $_POST["default_rep_view"]);
         $ilSetting->set("links_dynamic", $_POST["links_dynamic"]);
         $ilSetting->set("enable_trash", $_POST["enable_trash"]);
         $ilSetting->set("password_assistance", $_POST["password_assistance"]);
         $ilSetting->set("passwd_auto_generate", $_POST["passwd_auto_generate"]);
         $ilSetting->set("locale", $_POST["locale"]);
         $ilSetting->set('preview_learner', (int) $_POST['preview_learner']);
         $ilSetting->set('comments_tagging_in_lists', (int) $_POST['comments_tagging_in_lists']);
         $ilSetting->set('activate_captcha_anonym', (int) $_POST['activate_captcha_anonym']);
         //			$ilSetting->set('rep_cache',(int) $_POST['rep_cache']);
         $ilSetting->set('item_cmd_asynch', (int) $_POST['item_cmd_asynch']);
         $ilSetting->set("repository_tree_pres", $_POST["tree_pres"]);
         if ($_POST["tree_pres"] == "") {
             $_POST["rep_tree_limit_grp_crs"] = "";
         }
         if ($_POST["rep_tree_limit_grp_crs"] && !$ilSetting->get("rep_tree_limit_grp_crs")) {
             $_POST["rep_tree_synchronize"] = true;
         } else {
             if (!$_POST["rep_tree_synchronize"] && $ilSetting->get("rep_tree_synchronize")) {
                 $_POST["rep_tree_limit_grp_crs"] = false;
             }
         }
         $ilSetting->set("rep_tree_limit_grp_crs", $_POST["rep_tree_limit_grp_crs"]);
         $ilSetting->set("rep_tree_synchronize", $_POST["rep_tree_synchronize"]);
         // BEGIN SESSION SETTINGS
         $ilSetting->set('session_handling_type', (int) $this->form->getInput('session_handling_type'));
         if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_FIXED) {
             $ilSetting->set('session_reminder_enabled', $this->form->getInput('session_reminder_enabled'));
         } else {
             if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_LOAD_DEPENDENT) {
                 require_once 'Services/Authentication/classes/class.ilSessionControl.php';
                 if ($ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
                     // has to be done BEFORE updating the setting!
                     include_once "Services/Authentication/classes/class.ilSessionStatistics.php";
                     ilSessionStatistics::updateLimitLog((int) $this->form->getInput('session_max_count'));
                     $ilSetting->set('session_max_count', (int) $this->form->getInput('session_max_count'));
                     $ilSetting->set('session_min_idle', (int) $this->form->getInput('session_min_idle'));
                     $ilSetting->set('session_max_idle', (int) $this->form->getInput('session_max_idle'));
                     $ilSetting->set('session_max_idle_after_first_request', (int) $this->form->getInput('session_max_idle_after_first_request'));
                 }
             }
         }
         // END SESSION SETTINGS
         $global_profiles = $_POST["pub_section"] ? (int) $_POST['enable_global_profiles'] : 0;
         $ilSetting->set('enable_global_profiles', $global_profiles);
         $ilSetting->set("rep_shorten_description", $this->form->getInput('rep_shorten_description'));
         $ilSetting->set("rep_shorten_description_length", (int) $this->form->getInput('rep_shorten_description_length'));
         include_once "Services/User/classes/class.ilUserUtil.php";
         ilUserUtil::setStartingPoint($this->form->getInput('usr_start'), $this->form->getInput('usr_start_ref_id'));
         ilUserUtil::togglePersonalStartingPoint($this->form->getInput('usr_start_pers'));
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "showBasicSettings");
     }
     $this->setGeneralSettingsSubTabs("basic_settings");
     $this->form->setValuesByPost();
     $tpl->setContent($this->form->getHtml());
 }