/** * Creates a table filled with the sessions currently registered. * Returned structure: * <sessions> * <session> * <username></username> * <loginstatus></loginstatus> * <releasetime></releasetime> * <activity></activity> * </session> * </sessions> * * @return string * @permissions right1 */ protected function actionSystemSessions() { $strReturn = ""; //check needed rights $arrSessions = class_module_system_session::getAllActiveSessions(); $strReturn .= "<sessions>"; foreach ($arrSessions as $objOneSession) { $strReturn .= "<session>"; $strUsername = ""; if ($objOneSession->getStrUserid() != "") { $objUser = new class_module_user_user($objOneSession->getStrUserid()); $strUsername = $objUser->getStrUsername(); } $strLoginStatus = ""; if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $strLoginStatus = $this->getLang("session_loggedin"); } else { $strLoginStatus = $this->getLang("session_loggedout"); } //find out what the user is doing... $strLastUrl = $objOneSession->getStrLasturl(); if (uniStrpos($strLastUrl, "?") !== false) { $strLastUrl = uniSubstr($strLastUrl, uniStrpos($strLastUrl, "?")); } $strActivity = ""; if (uniStrpos($strLastUrl, "admin=1") !== false) { $strActivity .= $this->getLang("session_admin"); foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "module") { $strActivity .= $arrUrlParam[1]; } } } else { $strActivity .= $this->getLang("session_portal"); if ($strLastUrl == "") { $strActivity .= class_module_system_setting::getConfigValue("_pages_indexpage_"); } else { foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "page") { $strActivity .= $arrUrlParam[1]; } } if ($strActivity == $this->getLang("session_portal") && uniSubstr($strLastUrl, 0, 5) == "image") { $strActivity .= $this->getLang("session_portal_imagegeneration"); } } } $strReturn .= "<username>" . xmlSafeString($strUsername) . "</username>"; $strReturn .= "<loginstatus>" . xmlSafeString($strLoginStatus) . "</loginstatus>"; $strReturn .= "<releasetime>" . xmlSafeString(timeToString($objOneSession->getIntReleasetime())) . "</releasetime>"; $strReturn .= "<activity>" . xmlSafeString($strActivity) . "</activity>"; $strReturn .= "</session>"; } $strReturn .= "</sessions>"; return $strReturn; }
/** * Returns, if available, the internal session-object for the passed internal session-id * * @param string $strSessionid * * @return class_module_system_session */ public static function getSessionById($strSessionid) { $objSession = new class_module_system_session($strSessionid); if ($objSession->isSessionValid()) { return $objSession; } else { return null; } }
/** * Creates a table filled with the sessions currently registered * * @autoTestable * @return string * @permissions right1 */ protected function actionSystemSessions() { $strReturn = ""; //react on commands? if ($this->getParam("logout") == "true") { $objSession = new class_module_system_session($this->getSystemid()); $objSession->setStrLoginstatus(class_module_system_session::$LOGINSTATUS_LOGGEDOUT); $objSession->updateObjectToDb(); class_carrier::getInstance()->getObjDB()->flushQueryCache(); } //showing a list using the pageview $objArraySectionIterator = new class_array_section_iterator(class_module_system_session::getNumberOfActiveSessions()); $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objArraySectionIterator->setArraySection(class_module_system_session::getAllActiveSessions($objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos())); $arrData = array(); $arrHeader = array(); $arrHeader[0] = ""; $arrHeader[1] = $this->getLang("session_username"); $arrHeader[2] = $this->getLang("session_valid"); $arrHeader[3] = $this->getLang("session_status"); $arrHeader[4] = $this->getLang("session_activity"); $arrHeader[5] = ""; /** @var $objOneSession class_module_system_session */ foreach ($objArraySectionIterator as $objOneSession) { $arrRowData = array(); $strUsername = ""; if ($objOneSession->getStrUserid() != "") { $objUser = new class_module_user_user($objOneSession->getStrUserid()); $strUsername = $objUser->getStrUsername(); } $arrRowData[0] = class_adminskin_helper::getAdminImage("icon_user"); $arrRowData[1] = $strUsername; $arrRowData[2] = timeToString($objOneSession->getIntReleasetime()); if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $arrRowData[3] = $this->getLang("session_loggedin"); } else { $arrRowData[3] = $this->getLang("session_loggedout"); } //find out what the user is doing... $strLastUrl = $objOneSession->getStrLasturl(); if (uniStrpos($strLastUrl, "?") !== false) { $strLastUrl = uniSubstr($strLastUrl, uniStrpos($strLastUrl, "?")); } $strActivity = ""; if (uniStrpos($strLastUrl, "admin=1") !== false) { $strActivity .= $this->getLang("session_admin"); foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "module") { $strActivity .= $arrUrlParam[1]; } } } else { $strActivity .= $this->getLang("session_portal"); if ($strLastUrl == "") { $strActivity .= class_module_system_setting::getConfigValue("_pages_indexpage_") != "" ? class_module_system_setting::getConfigValue("_pages_indexpage_") : ""; } else { foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "page") { $strActivity .= $arrUrlParam[1]; } } if ($strActivity == $this->getLang("session_portal") && uniSubstr($strLastUrl, 0, 5) == "image") { $strActivity .= $this->getLang("session_portal_imagegeneration"); } } } $arrRowData[4] = $strActivity; if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $arrRowData[5] = class_link::getLinkAdmin("system", "systemSessions", "&logout=true&systemid=" . $objOneSession->getSystemid(), "", $this->getLang("session_logout"), "icon_delete"); } else { $arrRowData[5] = class_adminskin_helper::getAdminImage("icon_deleteDisabled"); } $arrData[] = $arrRowData; } $strReturn .= $this->objToolkit->dataTable($arrHeader, $arrData); $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, "system", "systemSessions"); return $strReturn; }
/** * Initializes the internal kajona session * @return void */ public function initInternalSession() { $arrTables = $this->objDB->getTables(); if (!in_array(_dbprefix_ . "session", $arrTables) || class_module_system_setting::getConfigValue("_guests_group_id_") === null) { return; } $this->bitLazyLoaded = true; if ($this->getSession("KAJONA_INTERNAL_SESSID") !== false) { $this->objInternalSession = class_module_system_session::getSessionById($this->getSession("KAJONA_INTERNAL_SESSID")); if ($this->objInternalSession != null && $this->objInternalSession->isSessionValid()) { $this->objInternalSession->setIntReleasetime(time() + (int) class_module_system_setting::getConfigValue("_system_release_time_")); $this->objInternalSession->setStrLasturl(getServer("QUERY_STRING")); } else { $this->objInternalSession = null; } if ($this->objInternalSession != null) { return; } } //try to load the matching groups $strGroups = class_module_system_setting::getConfigValue("_guests_group_id_"); if (validateSystemid($this->getUserID())) { $this->objUser = new class_module_user_user($this->getUserID()); $strGroups = implode(",", $this->objUser->getArrGroupIds()); } $objSession = new class_module_system_session(); $objSession->setStrPHPSessionId($this->getSessionId()); $objSession->setStrUserid($this->getUserID()); $objSession->setStrGroupids($strGroups); $objSession->setIntReleasetime(time() + (int) class_module_system_setting::getConfigValue("_system_release_time_")); $objSession->setStrLasturl(getServer("QUERY_STRING")); $objSession->setSystemid(generateSystemid()); //this update is removed. the internal session validates on destruct, if an update or an insert is required //$objSession->updateObjectToDb(); $this->setSession("KAJONA_INTERNAL_SESSID", $objSession->getSystemid()); $this->objInternalSession = $objSession; }