diff --git a/core/src/core/classes/class.AuthService.php b/core/src/core/classes/class.AuthService.php index 1c5d44da6b..523fb07cee 100644 --- a/core/src/core/classes/class.AuthService.php +++ b/core/src/core/classes/class.AuthService.php @@ -375,8 +375,8 @@ public static function logUser($user_id, $pwd, $bypass_pwd = false, $cookieLogin else self::$currentUser = $user; if ($user->isAdmin()) { - $user = self::updateAdminRights($user); - self::updateUser($user); + //$user = self::updateAdminRights($user); + //self::updateUser($user); } if ($authDriver->autoCreateUser() && !$user->storageExists()) { diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index 7ea7d7b35a..753c460ff0 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -28,9 +28,14 @@ class ConfService { private static $instance; + public static $useSession = true; + private $errors = array(); private $configs = array(); + private $contextRepositoryId; + private $contextCharset; + /** * @param AJXP_PluginsService $ajxpPluginService * @return AbstractConfDriver @@ -121,6 +126,35 @@ public static function getErrors() return self::getInstance()->errors; } + public static function getContextCharset(){ + if(self::$useSession) { + if(isSet($_SESSION["AJXP_CHARSET"])) return $_SESSION["AJXP_CHARSET"]; + else return null; + }else { + return self::getInstance()->contextCharset; + } + } + + public static function setContextCharset($value){ + if(self::$useSession){ + $_SESSION["AJXP_CHARSET"] = $value; + }else{ + self::getInstance()->contextCharset = $value; + } + } + + public static function clearContextCharset(){ + if(self::$useSession && isSet($_SESSION["AJXP_CHARSET"])){ + unset($_SESSION["AJXP_CHARSET"]); + }else{ + self::getInstance()->contextCharset = null; + } + } + + private function getContextRepositoryId(){ + return self::$useSession ? $_SESSION["REPO_ID"] : $this->contextRepositoryId; + } + /** * @static * @param $globalsArray @@ -289,8 +323,8 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) { if ($rootDirIndex == -1) { $ok = false; - if (isSet($_SESSION['REPO_ID'])) { - $sessionId = $_SESSION['REPO_ID']; + if (isSet($_SESSION['REPO_ID']) || $this->contextRepositoryId != null) { + $sessionId = self::$useSession ? $_SESSION['REPO_ID'] : $this->contextRepositoryId; $object = self::getRepositoryById($sessionId); if($object != null && self::repositoryIsAccessible($sessionId, $object)){ $this->configs["REPOSITORY"] = $object; @@ -301,7 +335,11 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) $currentRepos = $this->getLoadedRepositories(); $keys = array_keys($currentRepos); $this->configs["REPOSITORY"] = $currentRepos[$keys[0]]; - $_SESSION['REPO_ID'] = $keys[0]; + if(self::$useSession){ + $_SESSION['REPO_ID'] = $keys[0]; + }else{ + $this->contextRepositoryId = $keys[0]; + } } } else { /* @@ -309,14 +347,14 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) return; } */ - if ($temporary && isSet($_SESSION['REPO_ID'])) { - $crtId = $_SESSION['REPO_ID']; + if ($temporary && (isSet($_SESSION['REPO_ID']) || $this->contextRepositoryId != null)) { + $crtId = self::$useSession ? $_SESSION['REPO_ID'] : $this->contextRepositoryId; if ($crtId != $rootDirIndex && !isSet($_SESSION['SWITCH_BACK_REPO_ID'])) { $_SESSION['SWITCH_BACK_REPO_ID'] = $crtId; //AJXP_Logger::debug("switching to $rootDirIndex, registering $crtId"); } } else { - $crtId = $_SESSION['REPO_ID']; + $crtId = self::$useSession ? $_SESSION['REPO_ID'] : $this->contextRepositoryId; $_SESSION['PREVIOUS_REPO_ID'] = $crtId; //AJXP_Logger::debug("switching back to $rootDirIndex"); } @@ -325,16 +363,18 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) } else { $this->configs["REPOSITORY"] = ConfService::getRepositoryById($rootDirIndex); } - $_SESSION['REPO_ID'] = $rootDirIndex; + if(self::$useSession){ + $_SESSION['REPO_ID'] = $rootDirIndex; + }else{ + $this->contextRepositoryId = $rootDirIndex; + } if(isSet($this->configs["ACCESS_DRIVER"])) unset($this->configs["ACCESS_DRIVER"]); } if (isSet($this->configs["REPOSITORY"]) && $this->configs["REPOSITORY"]->getOption("CHARSET")!="") { - $_SESSION["AJXP_CHARSET"] = $this->configs["REPOSITORY"]->getOption("CHARSET"); + self::setContextCharset($this->configs["REPOSITORY"]->getOption("CHARSET")); } else { - if (isSet($_SESSION["AJXP_CHARSET"])) { - unset($_SESSION["AJXP_CHARSET"]); - } + self::clearContextCharset(); } @@ -518,10 +558,11 @@ public static function getCurrentRepositoryId() */ public function getCurrentRepositoryIdInst() { - if(isSet($_SESSION['REPO_ID'])){ - $object = self::getRepositoryById($_SESSION['REPO_ID']); - if($object != null && self::repositoryIsAccessible($_SESSION['REPO_ID'], $object)){ - return $_SESSION['REPO_ID']; + $ctxId = $this->getContextRepositoryId(); + if(!empty($ctxId)){ + $object = self::getRepositoryById($ctxId); + if($object != null && self::repositoryIsAccessible($ctxId, $object)){ + return $ctxId; } } $currentRepos = $this->getLoadedRepositories(); @@ -542,8 +583,9 @@ public static function getCurrentRootDirDisplay() public function getCurrentRootDirDisplayInst() { $currentRepos = $this->getLoadedRepositories(); - if (isSet($currentRepos[$_SESSION['REPO_ID']])) { - $repo = $currentRepos[$_SESSION['REPO_ID']]; + $ctxId = $this->getContextRepositoryId(); + if (isSet($currentRepos[$ctxId])) { + $repo = $currentRepos[$ctxId]; return $repo->getDisplay(); } return ""; @@ -1266,8 +1308,9 @@ public static function getRepository() */ public function getRepositoryInst() { - if (isSet($_SESSION['REPO_ID']) && isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$_SESSION['REPO_ID']])) { - return $this->configs["REPOSITORIES"][$_SESSION['REPO_ID']]; + $ctxId = $this->getContextRepositoryId(); + if (!empty($ctxId) && isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$ctxId])) { + return $this->configs["REPOSITORIES"][$ctxId]; } return $this->configs["REPOSITORY"]; } @@ -1467,9 +1510,10 @@ public function loadRepositoryDriverREST(&$repository) } $repository->driverInstance = $plugInstance; - if (isSet($_SESSION["REPO_ID"]) && $_SESSION["REPO_ID"] == $repository->getId()) { + $ctxId = $this->getContextRepositoryId(); + if (!empty($ctxId) && $ctxId == $repository->getId()) { $this->configs["REPOSITORY"] = $repository; - $this->cacheRepository($_SESSION['REPO_ID'], $repository); + $this->cacheRepository($ctxId, $repository); } return $plugInstance; } diff --git a/core/src/core/classes/class.SystemTextEncoding.php b/core/src/core/classes/class.SystemTextEncoding.php index ebc72c90c4..07d82b451f 100644 --- a/core/src/core/classes/class.SystemTextEncoding.php +++ b/core/src/core/classes/class.SystemTextEncoding.php @@ -78,12 +78,12 @@ public static function parseCharset($locale) public static function getEncoding() { if (self::$currentCharsetValue == null) { - global $_SESSION; - if (isset($_SESSION["AJXP_CHARSET"]) && strlen($_SESSION["AJXP_CHARSET"])) { - // Check if the session get an assigned charset encoding (it's the case for remote SSH for example) - self::$currentCharsetValue = $_SESSION["AJXP_CHARSET"]; + $charset = ConfService::getContextCharset(); + if (!empty($charset)) { + // Check if the session get an assigned charset encoding (it's the case for remote SSH for example) + self::$currentCharsetValue = $charset; } else { - // Get the current locale (expecting the filesystem is in the same locale, as the standard says) + // Get the current locale (expecting the filesystem is in the same locale, as the standard says) self::$currentCharsetValue = self::parseCharset(setlocale(LC_CTYPE, 0)); } } diff --git a/core/src/plugins/access.ftp/class.ftpAccessWrapper.php b/core/src/plugins/access.ftp/class.ftpAccessWrapper.php index b1aef4f30a..4de6de2668 100644 --- a/core/src/plugins/access.ftp/class.ftpAccessWrapper.php +++ b/core/src/plugins/access.ftp/class.ftpAccessWrapper.php @@ -440,8 +440,13 @@ protected function parseUrl($url, $forceLogin = false) $cacheKey = $repository->getId()."_ftpCharset"; if (!isset($_SESSION[$cacheKey]) || !strlen($_SESSION[$cacheKey]) || $forceLogin) { $features = $this->getServerFeatures(); - if(!isSet($_SESSION["AJXP_CHARSET"]) || $_SESSION["AJXP_CHARSET"] == "") $_SESSION["AJXP_CHARSET"] = $features["charset"]; - $_SESSION[$cacheKey] = $_SESSION["AJXP_CHARSET"]; + $ctxCharset = ConfService::getContextCharset(); + if(empty($ctxCharset)) { + ConfService::setContextCharset($features["charset"]); + $_SESSION[$cacheKey] = $features["charset"]; + }else{ + $_SESSION[$cacheKey] = $ctxCharset; + } } return $urlParts; } diff --git a/core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php b/core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php index 353ee9a93b..bee5a6240d 100644 --- a/core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php +++ b/core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php @@ -233,7 +233,7 @@ public function switchAction($action, $httpVars, $fileVars) } if (preg_match('/MSIE 7/',$_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/',$_SERVER['HTTP_USER_AGENT'])) { // TODO: OFFICIALLY DROP IE7 SUPPORT? - //$content = str_replace("ajaxplorer_boot.js", "ajaxplorer_boot_protolegacy.js", $content); + // $content = str_replace("ajaxplorer_boot.js", "ajaxplorer_boot_protolegacy.js", $content); } $content = str_replace("AJXP_ADDITIONAL_JS_FRAMEWORKS", $ADDITIONAL_FRAMEWORKS, $content); $content = AJXP_XMLWriter::replaceAjxpXmlKeywords($content, false); diff --git a/core/src/rest.php b/core/src/rest.php index bcb86f1b6e..60e6dc7e9e 100644 --- a/core/src/rest.php +++ b/core/src/rest.php @@ -26,15 +26,18 @@ set_exception_handler(array("AJXP_XMLWriter", "catchException")); $pServ = AJXP_PluginsService::getInstance(); +ConfService::$useSession = false; +AuthService::$useSession = false; + ConfService::init(); $confPlugin = ConfService::getInstance()->confPluginSoftLoad($pServ); $pServ->loadPluginsRegistry(AJXP_INSTALL_PATH."/plugins", $confPlugin); ConfService::start(); $confStorageDriver = ConfService::getConfStorageImpl(); require_once($confStorageDriver->getUserClassFileName()); -session_name("AjaXplorer"); -session_start(); -AuthService::$useSession = false; +//session_name("AjaXplorer"); +//session_start(); + AJXP_PluginsService::getInstance()->initActivePlugins(); AuthService::preLogUser(array_merge($_GET, $_POST));