本文整理汇总了PHP中ConfService::switchRootDir方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::switchRootDir方法的具体用法?PHP ConfService::switchRootDir怎么用?PHP ConfService::switchRootDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::switchRootDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($repository)
{
$repositoryId = $repository->isWriteable() ? $repository->getUniqueId() : $repository->getId();
ConfService::switchRootDir($repositoryId);
$this->repository = ConfService::getRepository();
$this->options = new ezcWebdavFileBackendOptions();
$this->options['noLock'] = false;
$this->options['waitForLock'] = 200000;
$this->options['lockTimeout'] = 2;
$this->options['lockFileName'] = '.ezc_lock';
$this->options['propertyStoragePath'] = '.ezc';
$this->options['directoryMode'] = 0755;
$this->options['fileMode'] = 0644;
$this->options['useMimeExts'] = false;
$this->options['hideDotFiles'] = true;
}
示例2: authenticate
public function authenticate(Sabre\DAV\Server $server, $realm)
{
//AJXP_Logger::debug("Try authentication on $realm", $server);
$success = parent::authenticate($server, $realm);
if ($success) {
$res = AuthService::logUser($this->currentUser, null, true);
if ($res < 1) {
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights(AuthService::getLoggedUser());
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
$webdavData = AuthService::getLoggedUser()->getPref("AJXP_WEBDAV_DATA");
AJXP_Safe::storeCredentials($this->currentUser, $this->_decodePassword($webdavData["PASS"], $this->currentUser));
}
}
if ($success === false) {
throw new Sabre\DAV\Exception\NotAuthenticated();
}
ConfService::switchRootDir($this->repositoryId);
return true;
}
示例3: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$xmlBuffer = "";
foreach ($httpVars as $getName => $getValue) {
${$getName} = Utils::securePath($getValue);
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// SWITCH THE ROOT REPOSITORY
//------------------------------------
case "switch_root_dir":
if (!isset($root_dir_index)) {
break;
}
$dirList = ConfService::getRootDirsList();
if (!isset($dirList[$root_dir_index])) {
$errorMessage = "Trying to switch to an unkown folder!";
break;
}
ConfService::switchRootDir($root_dir_index);
$logMessage = "Successfully Switched!";
AJXP_Logger::logAction("Switch Repository", array("rep. id" => $root_dir_index));
break;
//------------------------------------
// GET AN HTML TEMPLATE
//------------------------------------
//------------------------------------
// GET AN HTML TEMPLATE
//------------------------------------
case "get_template":
header("Content-type:text/html; charset:UTF-8");
if (isset($template_name) && is_file(CLIENT_RESOURCES_FOLDER . "/html/" . $template_name)) {
if ($template_name == "gui_tpl.html") {
include CLIENT_RESOURCES_FOLDER . "/html/usertemplate_top.html";
}
include CLIENT_RESOURCES_FOLDER . "/html/" . $template_name;
if ($template_name == "gui_tpl.html") {
include CLIENT_RESOURCES_FOLDER . "/html/usertemplate_bottom.html";
}
}
exit(0);
break;
//------------------------------------
// GET I18N MESSAGES
//------------------------------------
//------------------------------------
// GET I18N MESSAGES
//------------------------------------
case "get_i18n_messages":
header("Content-type:text/javascript");
HTMLWriter::writeI18nMessagesClass(ConfService::getMessages());
exit(0);
break;
//------------------------------------
// BOOKMARK BAR
//------------------------------------
//------------------------------------
// BOOKMARK BAR
//------------------------------------
case "get_bookmarks":
$bmUser = null;
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser = AuthService::getLoggedUser();
} else {
if (!AuthService::usersEnabled()) {
$confStorage = ConfService::getConfStorageImpl();
$bmUser = $confStorage->createUserObject("shared");
}
}
if ($bmUser == null) {
exit(1);
}
if (isset($_GET["bm_action"]) && isset($_GET["bm_path"])) {
if ($_GET["bm_action"] == "add_bookmark") {
$title = "";
if (isset($_GET["title"])) {
$title = $_GET["title"];
}
if ($title == "" && $_GET["bm_path"] == "/") {
$title = ConfService::getCurrentRootDirDisplay();
}
$bmUser->addBookMark($_GET["bm_path"], $title);
} else {
if ($_GET["bm_action"] == "delete_bookmark") {
$bmUser->removeBookmark($_GET["bm_path"]);
} else {
if ($_GET["bm_action"] == "rename_bookmark" && isset($_GET["bm_title"])) {
$bmUser->renameBookmark($_GET["bm_path"], $_GET["bm_title"]);
}
}
}
}
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
//.........这里部分代码省略.........
示例4: parseApplicationGetParameters
public static function parseApplicationGetParameters($parameters, &$output, &$session)
{
$output["EXT_REP"] = "/";
if (isset($parameters["repository_id"]) && isset($parameters["folder"])) {
require_once "server/classes/class.SystemTextEncoding.php";
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && $loggedUser->canSwitchTo($parameters["repository_id"])) {
$output["EXT_REP"] = SystemTextEncoding::toUTF8(urldecode($parameters["folder"]));
$loggedUser->setArrayPref("history", "last_repository", $parameters["repository_id"]);
$loggedUser->setPref("pending_folder", AJXP_Utils::decodeSecureMagic($parameters["folder"]));
$loggedUser->save();
AuthService::updateUser($loggedUser);
} else {
$session["PENDING_REPOSITORY_ID"] = $parameters["repository_id"];
$session["PENDING_FOLDER"] = AJXP_Utils::decodeSecureMagic($parameters["folder"]);
}
} else {
ConfService::switchRootDir($parameters["repository_id"]);
$output["EXT_REP"] = SystemTextEncoding::toUTF8(urldecode($parameters["folder"]));
}
}
if (isset($parameters["skipDebug"])) {
ConfService::setConf("JS_DEBUG", false);
}
if (ConfService::getConf("JS_DEBUG") && isset($parameters["compile"])) {
require_once SERVER_RESOURCES_FOLDER . "/class.AJXP_JSPacker.php";
AJXP_JSPacker::pack();
}
if (ConfService::getConf("JS_DEBUG") && isset($parameters["update_i18n"])) {
AJXP_Utils::updateI18nFiles(isset($parameters["plugin_path"]) ? $parameters["plugin_path"] : "");
}
if (isset($parameters["external_selector_type"])) {
$output["SELECTOR_DATA"] = array("type" => $parameters["external_selector_type"], "data" => $parameters);
}
}
示例5: switchAction
//.........这里部分代码省略.........
HTMLWriter::charsetHeader();
echo HTMLWriter::getDocFile(AJXP_Utils::securePath(htmlentities($_GET["doc_file"])));
break;
//------------------------------------
// GET BOOT GUI
//------------------------------------
//------------------------------------
// GET BOOT GUI
//------------------------------------
case "get_boot_gui":
HTMLWriter::internetExplorerMainDocumentHeader();
HTMLWriter::charsetHeader();
if (!is_file(TESTS_RESULT_FILE)) {
$outputArray = array();
$testedParams = array();
$passed = AJXP_Utils::runTests($outputArray, $testedParams);
if (!$passed && !isset($_GET["ignore_tests"])) {
AJXP_Utils::testResultsToTable($outputArray, $testedParams);
die;
} else {
AJXP_Utils::testResultsToFile($outputArray, $testedParams);
}
}
$START_PARAMETERS = array("BOOTER_URL" => "index.php?get_action=get_boot_conf", "MAIN_ELEMENT" => "ajxp_desktop");
if (AuthService::usersEnabled()) {
AuthService::preLogUser(isset($httpVars["remote_session"]) ? $httpVars["remote_session"] : "");
AuthService::bootSequence($START_PARAMETERS);
if (AuthService::getLoggedUser() != null || AuthService::logUser(null, null) == 1) {
if (AuthService::getDefaultRootId() == -1) {
AuthService::disconnect();
} else {
$loggedUser = AuthService::getLoggedUser();
if (!$loggedUser->canRead(ConfService::getCurrentRepositoryId()) && AuthService::getDefaultRootId() != ConfService::getCurrentRepositoryId()) {
ConfService::switchRootDir(AuthService::getDefaultRootId());
}
}
}
}
AJXP_Utils::parseApplicationGetParameters($_GET, $START_PARAMETERS, $_SESSION);
$confErrors = ConfService::getErrors();
if (count($confErrors)) {
$START_PARAMETERS["ALERT"] = implode(", ", array_values($confErrors));
}
// PRECOMPUTE BOOT CONF
if (!preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
$START_PARAMETERS["PRELOADED_BOOT_CONF"] = $this->computeBootConf();
}
// PRECOMPUTE REGISTRY
if (!isset($START_PARAMETERS["FORCE_REGISTRY_RELOAD"])) {
$regDoc = AJXP_PluginsService::getXmlRegistry();
$changes = AJXP_Controller::filterRegistryFromRole($regDoc);
if ($changes) {
AJXP_PluginsService::updateXmlRegistry($regDoc);
}
$clone = $regDoc->cloneNode(true);
$clonePath = new DOMXPath($clone);
$serverCallbacks = $clonePath->query("//serverCallback|hooks");
foreach ($serverCallbacks as $callback) {
$callback->parentNode->removeChild($callback);
}
$START_PARAMETERS["PRELOADED_REGISTRY"] = AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
}
$JSON_START_PARAMETERS = json_encode($START_PARAMETERS);
$crtTheme = $this->pluginConf["GUI_THEME"];
if (ConfService::getConf("JS_DEBUG")) {
if (!isset($mess)) {
示例6: catch
} catch (Exception $e) {
die("Severe error while loading plugins registry : " . $e->getMessage());
}
ConfService::start();
$confStorageDriver = ConfService::getConfStorageImpl();
require_once $confStorageDriver->getUserClassFileName();
//new AjxpSessionHandler();
if (!isset($OVERRIDE_SESSION)) {
session_name("AjaXplorer");
}
session_start();
if (isset($_GET["tmp_repository_id"])) {
ConfService::switchRootDir($_GET["tmp_repository_id"], true);
} else {
if (isset($_SESSION["SWITCH_BACK_REPO_ID"])) {
ConfService::switchRootDir($_SESSION["SWITCH_BACK_REPO_ID"]);
unset($_SESSION["SWITCH_BACK_REPO_ID"]);
}
}
$action = "ping";
if (preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
$action = "get_boot_gui";
} else {
$action = strpos($_SERVER["HTTP_ACCEPT"], "text/html") !== false ? "get_boot_gui" : "ping";
}
if (isset($_GET["action"]) || isset($_GET["get_action"])) {
$action = isset($_GET["get_action"]) ? $_GET["get_action"] : $_GET["action"];
} else {
if (isset($_POST["action"]) || isset($_POST["get_action"])) {
$action = isset($_POST["get_action"]) ? $_POST["get_action"] : $_POST["action"];
}
示例7: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$xmlBuffer = "";
foreach ($httpVars as $getName => $getValue) {
${$getName} = AJXP_Utils::securePath($getValue);
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// SWITCH THE ROOT REPOSITORY
//------------------------------------
case "switch_repository":
if (!isset($repository_id)) {
break;
}
$dirList = ConfService::getRepositoriesList();
/** @var $repository_id string */
if (!isset($dirList[$repository_id])) {
$errorMessage = "Trying to switch to an unkown repository!";
break;
}
ConfService::switchRootDir($repository_id);
// Load try to init the driver now, to trigger an exception
// if it's not loading right.
ConfService::loadRepositoryDriver();
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$user = AuthService::getLoggedUser();
$activeRepId = ConfService::getCurrentRepositoryId();
$user->setArrayPref("history", "last_repository", $activeRepId);
$user->save("user");
}
//$logMessage = "Successfully Switched!";
$this->logInfo("Switch Repository", array("rep. id" => $repository_id));
break;
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
case "get_xml_registry":
case "state":
$regDoc = AJXP_PluginsService::getXmlRegistry();
$changes = AJXP_Controller::filterRegistryFromRole($regDoc);
if ($changes) {
AJXP_PluginsService::updateXmlRegistry($regDoc);
}
$clone = $regDoc->cloneNode(true);
$clonePath = new DOMXPath($clone);
$serverCallbacks = $clonePath->query("//serverCallback|hooks");
foreach ($serverCallbacks as $callback) {
$callback->parentNode->removeChild($callback);
}
$xPath = '';
if (isset($httpVars["xPath"])) {
$xPath = ltrim(AJXP_Utils::securePath($httpVars["xPath"]), "/");
}
if (!empty($xPath)) {
$nodes = $clonePath->query($xPath);
if ($httpVars["format"] == "json") {
$data = AJXP_XMLWriter::xmlToArray($nodes->item(0));
HTMLWriter::charsetHeader("application/json");
echo json_encode($data);
} else {
AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $xPath));
if ($nodes->length) {
print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML($nodes->item(0)));
}
AJXP_XMLWriter::close("ajxp_registry_part");
}
} else {
AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
if ($httpVars["format"] == "json") {
$data = AJXP_XMLWriter::xmlToArray($clone);
HTMLWriter::charsetHeader("application/json");
echo json_encode($data);
} else {
header('Content-Type: application/xml; charset=UTF-8');
print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
}
}
break;
//------------------------------------
// BOOKMARK BAR
//------------------------------------
//------------------------------------
// BOOKMARK BAR
//------------------------------------
case "get_bookmarks":
$bmUser = null;
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser = AuthService::getLoggedUser();
} else {
if (!AuthService::usersEnabled()) {
//.........这里部分代码省略.........
示例8: isset
$cookieLogin = isset($_GET["cookie_login"]) ? true : false;
$loggingResult = AuthService::logUser($userId, $userPass, false, $cookieLogin, $_GET["login_seed"]);
if ($rememberMe && $loggingResult == 1) {
$rememberLogin = $userId;
$loggedUser = AuthService::getLoggedUser();
$rememberPass = $loggedUser->getCookieString();
}
} else {
AuthService::logUser(null, null);
}
// Check that current user can access current repository, try to switch otherwise.
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null) {
$currentRepo = ConfService::getRepositoryById(ConfService::getCurrentRootDirIndex());
if (!$loggedUser->canRead(ConfService::getCurrentRootDirIndex()) || $currentRepo->getAccessType() == "ajxp_conf" && ENABLE_USERS && !$loggedUser->isAdmin()) {
ConfService::switchRootDir(AuthService::getDefaultRootId());
}
}
if ($loggedUser == null) {
$requireAuth = true;
}
if (isset($loggingResult) || isset($_GET["get_action"]) && $_GET["get_action"] == "logged_user") {
AJXP_XMLWriter::header();
if (isset($loggingResult)) {
AJXP_XMLWriter::loggingResult($loggingResult, $rememberLogin, $rememberPass);
}
AJXP_XMLWriter::sendUserData();
AJXP_XMLWriter::close();
exit(1);
}
}
示例9: unset
if ($loggedUser != null) {
if (isset($_SESSION["PENDING_REPOSITORY_ID"]) && isset($_SESSION["PENDING_FOLDER"])) {
$loggedUser->setArrayPref("history", "last_repository", $_SESSION["PENDING_REPOSITORY_ID"]);
$loggedUser->setArrayPref("history", $_SESSION["PENDING_REPOSITORY_ID"], $_SESSION["PENDING_FOLDER"]);
$loggedUser->save();
unset($_SESSION["PENDING_REPOSITORY_ID"]);
unset($_SESSION["PENDING_FOLDER"]);
}
$currentRepoId = ConfService::getCurrentRootDirIndex();
$lastRepoId = $loggedUser->getArrayPref("history", "last_repository");
$defaultRepoId = AuthService::getDefaultRootId();
if ($lastRepoId != "" && $lastRepoId != $currentRepoId && !isset($_GET["tmp_repository_id"]) && $loggedUser->canSwitchTo($lastRepoId)) {
ConfService::switchRootDir($lastRepoId);
} else {
if (!$loggedUser->canSwitchTo($currentRepoId)) {
ConfService::switchRootDir($defaultRepoId);
}
}
}
if ($loggedUser == null) {
$requireAuth = true;
}
if (isset($loggingResult)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, $rememberLogin, $rememberPass);
AJXP_XMLWriter::close();
exit(1);
}
} else {
if (isset($_GET["get_action"]) && $_GET["get_action"] == "logged_user") {
AJXP_XMLWriter::header();
示例10: switchAction
function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$xmlBuffer = "";
foreach ($httpVars as $getName => $getValue) {
${$getName} = AJXP_Utils::securePath($getValue);
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// SWITCH THE ROOT REPOSITORY
//------------------------------------
case "switch_repository":
if (!isset($repository_id)) {
break;
}
$dirList = ConfService::getRootDirsList();
if (!isset($dirList[$repository_id])) {
$errorMessage = "Trying to switch to an unkown repository!";
break;
}
ConfService::switchRootDir($repository_id);
// Load try to init the driver now, to trigger an exception
// if it's not loading right.
ConfService::loadRepositoryDriver();
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$user = AuthService::getLoggedUser();
$activeRepId = ConfService::getCurrentRootDirIndex();
$user->setArrayPref("history", "last_repository", $activeRepId);
$user->save();
}
//$logMessage = "Successfully Switched!";
AJXP_Logger::logAction("Switch Repository", array("rep. id" => $repository_id));
break;
//------------------------------------
// BOOKMARK BAR
//------------------------------------
//------------------------------------
// BOOKMARK BAR
//------------------------------------
case "get_bookmarks":
$bmUser = null;
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser = AuthService::getLoggedUser();
} else {
if (!AuthService::usersEnabled()) {
$confStorage = ConfService::getConfStorageImpl();
$bmUser = $confStorage->createUserObject("shared");
}
}
if ($bmUser == null) {
exit(1);
}
if (isset($_GET["bm_action"]) && isset($_GET["bm_path"])) {
if ($_GET["bm_action"] == "add_bookmark") {
$title = "";
if (isset($_GET["bm_title"])) {
$title = $_GET["bm_title"];
}
if ($title == "" && $_GET["bm_path"] == "/") {
$title = ConfService::getCurrentRootDirDisplay();
}
$bmUser->addBookMark(SystemTextEncoding::magicDequote($_GET["bm_path"]), SystemTextEncoding::magicDequote($title));
} else {
if ($_GET["bm_action"] == "delete_bookmark") {
$bmUser->removeBookmark($_GET["bm_path"]);
} else {
if ($_GET["bm_action"] == "rename_bookmark" && isset($_GET["bm_title"])) {
$bmUser->renameBookmark($_GET["bm_path"], $_GET["bm_title"]);
}
}
}
}
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser->save();
AuthService::updateUser($bmUser);
} else {
if (!AuthService::usersEnabled()) {
$bmUser->save();
}
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks());
AJXP_XMLWriter::close();
exit(1);
break;
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
case "save_user_pref":
$userObject = AuthService::getLoggedUser();
$i = 0;
//.........这里部分代码省略.........
示例11: authenticate
public function authenticate(Sabre\DAV\Server $server, $realm)
{
$auth = new Sabre\HTTP\BasicAuth();
$auth->setHTTPRequest($server->httpRequest);
$auth->setHTTPResponse($server->httpResponse);
$auth->setRealm($realm);
$userpass = $auth->getUserPass();
if (!$userpass) {
$auth->requireLogin();
throw new Sabre\DAV\Exception\NotAuthenticated('No basic authentication headers were found');
}
// Authenticates the user
//AJXP_Logger::info(__CLASS__,"authenticate",$userpass[0]);
$confDriver = ConfService::getConfStorageImpl();
$userObject = $confDriver->createUserObject($userpass[0]);
$webdavData = $userObject->getPref("AJXP_WEBDAV_DATA");
if (empty($webdavData) || !isset($webdavData["ACTIVE"]) || $webdavData["ACTIVE"] !== true) {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => $userpass[0], "error" => "WebDAV user not found or disabled"));
throw new Sabre\DAV\Exception\NotAuthenticated();
}
// check if there are cached credentials. prevents excessive authentication calls to external
// auth mechanism.
$cachedPasswordValid = 0;
$secret = defined("AJXP_SECRET_KEY") ? AJXP_SECRET_KEY : "CDAFx¨op#";
$encryptedPass = md5($userpass[1] . $secret . date('YmdHi'));
if (isset($webdavData["TMP_PASS"]) && $encryptedPass == $webdavData["TMP_PASS"]) {
$cachedPasswordValid = true;
//AJXP_Logger::debug("Using Cached Password");
}
if (!$cachedPasswordValid && !$this->validateUserPass($userpass[0], $userpass[1])) {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => $userpass[0], "error" => "Invalid WebDAV user or password"));
$auth->requireLogin();
throw new Sabre\DAV\Exception\NotAuthenticated('Username or password does not match');
}
$this->currentUser = $userpass[0];
$res = AuthService::logUser($this->currentUser, $userpass[1], true);
if ($res < 1) {
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights(AuthService::getLoggedUser());
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
AJXP_Safe::storeCredentials($this->currentUser, $userpass[1]);
}
if (isset($this->repositoryId) && ConfService::getRepositoryById($this->repositoryId)->getOption("AJXP_WEBDAV_DISABLED") === true) {
throw new Sabre\DAV\Exception\NotAuthenticated('You are not allowed to access this workspace');
}
ConfService::switchRootDir($this->repositoryId);
// the method used here will invalidate the cached password every minute on the minute
if (!$cachedPasswordValid) {
$webdavData["TMP_PASS"] = $encryptedPass;
$userObject->setPref("AJXP_WEBDAV_DATA", $webdavData);
$userObject->save("user");
AuthService::updateUser($userObject);
}
return true;
}
示例12: loadMinisite
public static function loadMinisite($data, $hash = '', $error = null)
{
if (isset($data["SECURITY_MODIFIED"]) && $data["SECURITY_MODIFIED"] === true) {
$mess = ConfService::getMessages();
$error = $mess['share_center.164'];
}
$repository = $data["REPOSITORY"];
AJXP_PluginsService::getInstance()->initActivePlugins();
$shareCenter = AJXP_PluginsService::findPlugin("action", "share");
$confs = $shareCenter->getConfigs();
$minisiteLogo = "plugins/gui.ajax/PydioLogo250.png";
if (!empty($confs["CUSTOM_MINISITE_LOGO"])) {
$logoPath = $confs["CUSTOM_MINISITE_LOGO"];
if (strpos($logoPath, "plugins/") === 0 && is_file(AJXP_INSTALL_PATH . "/" . $logoPath)) {
$minisiteLogo = $logoPath;
} else {
$minisiteLogo = "index_shared.php?get_action=get_global_binary_param&binary_id=" . $logoPath;
}
}
// Default value
if (isset($data["AJXP_TEMPLATE_NAME"])) {
$templateName = $data["AJXP_TEMPLATE_NAME"];
if ($templateName == "ajxp_film_strip" && AJXP_Utils::userAgentIsMobile()) {
$templateName = "ajxp_shared_folder";
}
}
if (isset($repository)) {
$repoObject = ConfService::getRepositoryById($repository);
if (!is_object($repoObject)) {
$mess = ConfService::getMessages();
$error = $mess["share_center.166"];
$templateName = "ajxp_unique_strip";
$repoObject = null;
}
}
if (!isset($templateName) && isset($repoObject)) {
$filter = $repoObject->getContentFilter();
if (!empty($filter) && count($filter->virtualPaths) == 1) {
$templateName = "ajxp_unique_strip";
} else {
$templateName = "ajxp_shared_folder";
}
}
if (!isset($templateName) && isset($error)) {
$templateName = "ajxp_unique_strip";
}
// UPDATE TEMPLATE
$html = file_get_contents(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/action.share/res/minisite.php");
AJXP_Controller::applyHook("tpl.filter_html", array(&$html));
$html = AJXP_XMLWriter::replaceAjxpXmlKeywords($html);
$html = str_replace("AJXP_MINISITE_LOGO", $minisiteLogo, $html);
$html = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $html);
$html = str_replace("PYDIO_APP_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $html);
if (isset($repository) && isset($repoObject)) {
$html = str_replace("AJXP_START_REPOSITORY", $repository, $html);
$html = str_replace("AJXP_REPOSITORY_LABEL", ConfService::getRepositoryById($repository)->getDisplay(), $html);
}
$html = str_replace('AJXP_HASH_LOAD_ERROR', isset($error) ? $error : '', $html);
$html = str_replace("AJXP_TEMPLATE_NAME", $templateName, $html);
$html = str_replace("AJXP_LINK_HASH", $hash, $html);
$guiConfigs = AJXP_PluginsService::findPluginById("gui.ajax")->getConfigs();
$html = str_replace("AJXP_THEME", $guiConfigs["GUI_THEME"], $html);
if (isset($_GET["dl"]) && isset($_GET["file"])) {
AuthService::$useSession = false;
} else {
session_name("AjaXplorer_Shared" . str_replace(".", "_", $hash));
session_start();
AuthService::disconnect();
}
if (!empty($data["PRELOG_USER"])) {
AuthService::logUser($data["PRELOG_USER"], "", true);
$html = str_replace("AJXP_PRELOGED_USER", "ajxp_preloged_user", $html);
} else {
if (isset($data["PRESET_LOGIN"])) {
$_SESSION["PENDING_REPOSITORY_ID"] = $repository;
$_SESSION["PENDING_FOLDER"] = "/";
$html = str_replace("AJXP_PRELOGED_USER", $data["PRESET_LOGIN"], $html);
} else {
$html = str_replace("AJXP_PRELOGED_USER", "ajxp_legacy_minisite", $html);
}
}
if (isset($hash)) {
$_SESSION["CURRENT_MINISITE"] = $hash;
}
if (isset($_GET["dl"]) && isset($_GET["file"]) && (!isset($data["DOWNLOAD_DISABLED"]) || $data["DOWNLOAD_DISABLED"] === false)) {
ConfService::switchRootDir($repository);
ConfService::loadRepositoryDriver();
AJXP_PluginsService::deferBuildingRegistry();
AJXP_PluginsService::getInstance()->initActivePlugins();
AJXP_PluginsService::flushDeferredRegistryBuilding();
$errMessage = null;
try {
$params = $_GET;
$ACTION = "download";
if (isset($_GET["ct"])) {
$mime = pathinfo($params["file"], PATHINFO_EXTENSION);
$editors = AJXP_PluginsService::searchAllManifests("//editor[contains(@mimes,'{$mime}') and @previewProvider='true']", "node", true, true, false);
if (count($editors)) {
foreach ($editors as $editor) {
$xPath = new DOMXPath($editor->ownerDocument);
//.........这里部分代码省略.........
示例13: authenticate
public function authenticate(Sabre\DAV\Server $server, $realm)
{
//AJXP_Logger::debug("Try authentication on $realm", $server);
try {
$success = parent::authenticate($server, $realm);
} catch (Exception $e) {
$success = 0;
$errmsg = $e->getMessage();
if ($errmsg != "No digest authentication headers were found") {
$success = false;
}
}
if ($success) {
$res = AuthService::logUser($this->currentUser, null, true);
if ($res < 1) {
throw new Sabre\DAV\Exception\NotAuthenticated();
}
$this->updateCurrentUserRights(AuthService::getLoggedUser());
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
$webdavData = AuthService::getLoggedUser()->getPref("AJXP_WEBDAV_DATA");
AJXP_Safe::storeCredentials($this->currentUser, $this->_decodePassword($webdavData["PASS"], $this->currentUser));
}
} else {
if ($success === false) {
AJXP_Logger::warning(__CLASS__, "Login failed", array("user" => $this->currentUser, "error" => "Invalid WebDAV user or password"));
}
throw new Sabre\DAV\Exception\NotAuthenticated($errmsg);
}
ConfService::switchRootDir($this->repositoryId);
return true;
}
示例14: loadPubliclet
/**
* @static
* @param Array $data
* @return void
*/
static function loadPubliclet($data)
{
// create driver from $data
$className = $data["DRIVER"] . "AccessDriver";
$hash = md5(serialize($data));
if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"] || $data["DOWNLOAD_LIMIT"] && $data["DOWNLOAD_LIMIT"] > 0 && $data["DOWNLOAD_LIMIT"] <= PublicletCounter::getCount($hash)) {
// Remove the publiclet, it's done
if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]), realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) {
PublicletCounter::delete($hash);
unlink($_SERVER["SCRIPT_FILENAME"]);
}
echo "Link is expired, sorry.";
exit;
}
// Load language messages
$language = "en";
if (isset($_GET["lang"])) {
$language = $_GET["lang"];
}
$messages = array();
if (is_file(dirname(__FILE__) . "/res/i18n/" . $language . ".php")) {
include dirname(__FILE__) . "/res/i18n/" . $language . ".php";
$messages = $mess;
} else {
include dirname(__FILE__) . "/res/i18n/en.php";
}
$AJXP_LINK_HAS_PASSWORD = false;
$AJXP_LINK_BASENAME = SystemTextEncoding::toUTF8(basename($data["FILE_PATH"]));
// Check password
if (strlen($data["PASSWORD"])) {
if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) {
$AJXP_LINK_HAS_PASSWORD = true;
$AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"];
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
return;
}
} else {
if (!isset($_GET["dl"])) {
include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php";
return;
}
}
$filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
if (!is_file($filePath)) {
die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})");
}
require_once $filePath;
$driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
$driver->loadManifest();
$hash = md5(serialize($data));
PublicletCounter::increment($hash);
AuthService::logUser($data["OWNER_ID"], "", true);
if ($driver->hasMixin("credentials_consumer") && isset($data["SAFE_USER"]) && isset($data["SAFE_PASS"])) {
// FORCE SESSION MODE
AJXP_Safe::getInstance()->forceSessionCredentialsUsage();
AJXP_Safe::storeCredentials($data["SAFE_USER"], $data["SAFE_PASS"]);
}
$repoObject = $data["REPOSITORY"];
ConfService::switchRootDir($repoObject->getId());
ConfService::loadRepositoryDriver();
ConfService::initActivePlugins();
try {
$params = array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"]));
if (isset($data["PLUGINS_DATA"])) {
$params["PLUGINS_DATA"] = $data["PLUGINS_DATA"];
}
AJXP_Controller::findActionAndApply($data["ACTION"], $params, null);
} catch (Exception $e) {
die($e->getMessage());
}
}
示例15: md5
}
if (AuthService::usersEnabled() && !empty($optUser)) {
$seed = AuthService::generateSeed();
if ($seed != -1) {
$optPass = md5(md5($optPass) . $seed);
}
$loggingResult = AuthService::logUser($optUser, $optPass, isset($optToken), false, $seed);
// Check that current user can access current repository, try to switch otherwise.
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && $detectedUser !== false && $loggedUser->isAdmin()) {
AuthService::disconnect();
AuthService::logUser($detectedUser, "empty", true, false, "");
$loggedUser = AuthService::getLoggedUser();
}
if ($loggedUser != null) {
ConfService::switchRootDir($optRepoId, true);
/*
$res = ConfService::switchUserToActiveRepository($loggedUser, $optRepoId);
if (!$res) {
AuthService::disconnect();
$requireAuth = true;
}
*/
}
if (isset($loggingResult) && $loggingResult != 1) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, false, false, "");
AJXP_XMLWriter::close();
if ($optStatusFile) {
file_put_contents($optStatusFile, "ERROR:No user logged");
}