コード例 #1
0
 /**
  * @param $idOrAlias
  * @return null|Repository
  */
 public static function findRepositoryByIdOrAlias($idOrAlias)
 {
     $repository = ConfService::getRepositoryById($idOrAlias);
     if ($repository != null) {
         return $repository;
     }
     $repository = ConfService::getRepositoryByAlias($idOrAlias);
     if ($repository != null) {
         return $repository;
     }
     return null;
 }
コード例 #2
0
ファイル: dav.php プロジェクト: biggtfish/cms
if (ConfService::getCoreConf("WEBDAV_BASEHOST") != "") {
    $baseURL = ConfService::getCoreConf("WEBDAV_BASEHOST");
} else {
    $baseURL = AJXP_Utils::detectServerURL();
}
$baseURI = ConfService::getCoreConf("WEBDAV_BASEURI");
$requestUri = $_SERVER["REQUEST_URI"];
$end = trim(substr($requestUri, strlen($baseURI . "/")));
$rId = null;
if ((!empty($end) || $end === "0") && $end[0] != "?") {
    $parts = explode("/", $end);
    $pathBase = $parts[0];
    $repositoryId = $pathBase;
    $repository = ConfService::getRepositoryById($repositoryId);
    if ($repository == null) {
        $repository = ConfService::getRepositoryByAlias($repositoryId);
        if ($repository != null) {
            $repositoryId = $repository->getId();
        }
    }
    if ($repository == null) {
        AJXP_Logger::debug("not found, dying {$repositoryId}");
        die('You are not allowed to access this service');
    }
    $rId = $repositoryId;
    $rootDir = new AJXP_Sabre_Collection("/", $repository, null);
    $server = new Sabre\DAV\Server($rootDir);
    $server->setBaseUri($baseURI . "/" . $pathBase);
} else {
    $rootDir = new AJXP_Sabre_RootCollection("root");
    $server = new Sabre\DAV\Server($rootDir);
コード例 #3
0
 /**
  * Authenticates the user based on the current request.
  *
  * If authentication is successful, true must be returned.
  * If authentication fails, an exception must be thrown.
  *
  * @param DAV\Server $server
  * @param string $realm
  * @throws DAV\Exception\NotAuthenticated
  * @return bool
  */
 public function authenticate(DAV\Server $server, $realm)
 {
     $auth = new BasicAuthNoPass();
     $auth->setHTTPRequest($server->httpRequest);
     $auth->setHTTPResponse($server->httpResponse);
     $auth->setRealm($realm);
     $userpass = $auth->getUserPass();
     if (!$userpass) {
         $auth->requireLogin();
         throw new DAV\Exception\NotAuthenticated('No basic authentication headers were found');
     }
     // Authenticates the user
     $token = $userpass[0];
     $shareStore = new \ShareStore(\ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"));
     $shareData = $shareStore->loadShare($token);
     if (is_array($shareData)) {
         $this->shareData = $shareData;
     } else {
         $auth->requireLogin();
         throw new DAV\Exception\NotAuthenticated('Username or password does not match');
     }
     if (!$this->validateUserPass($userpass[0], $userpass[1])) {
         $auth->requireLogin();
         throw new DAV\Exception\NotAuthenticated('Username or password does not match');
     }
     $repositoryId = $this->shareData["REPOSITORY"];
     $repository = \ConfService::getRepositoryById($repositoryId);
     if ($repository == null) {
         $repository = \ConfService::getRepositoryByAlias($repositoryId);
     }
     if ($repository == null) {
         throw new DAV\Exception\NotAuthenticated('Username cannot access any repository');
     } else {
         $this->rootCollection->updateRepository($repository);
     }
     $this->currentUser = $userpass[0];
     return true;
 }
コード例 #4
0
 /**
  * Utilitary to pass some parameters directly at startup :
  * + repository_id / folder
  * + compile & skipDebug
  * + update_i18n, extract, create
  * + external_selector_type
  * + skipIOS
  * + gui
  * @static
  * @param $parameters
  * @param $output
  * @param $session
  * @return void
  */
 public static function parseApplicationGetParameters($parameters, &$output, &$session)
 {
     $output["EXT_REP"] = "/";
     if (isset($parameters["repository_id"]) && isset($parameters["folder"]) || isset($parameters["goto"])) {
         if (isset($parameters["goto"])) {
             $explode = explode("/", ltrim($parameters["goto"], "/"));
             $repoId = array_shift($explode);
             $parameters["folder"] = str_replace($repoId, "", ltrim($parameters["goto"], "/"));
         } else {
             $repoId = $parameters["repository_id"];
         }
         $repository = ConfService::getRepositoryById($repoId);
         if ($repository == null) {
             $repository = ConfService::getRepositoryByAlias($repoId);
             if ($repository != null) {
                 $parameters["repository_id"] = $repository->getId();
             }
         } else {
             $parameters["repository_id"] = $repository->getId();
         }
         require_once AJXP_BIN_FOLDER . "/class.SystemTextEncoding.php";
         if (AuthService::usersEnabled()) {
             $loggedUser = AuthService::getLoggedUser();
             if ($loggedUser != null && $loggedUser->canSwitchTo($parameters["repository_id"])) {
                 $output["FORCE_REGISTRY_RELOAD"] = true;
                 $output["EXT_REP"] = SystemTextEncoding::toUTF8(urldecode($parameters["folder"]));
                 $loggedUser->setArrayPref("history", "last_repository", $parameters["repository_id"]);
                 $loggedUser->setPref("pending_folder", SystemTextEncoding::toUTF8(AJXP_Utils::decodeSecureMagic($parameters["folder"])));
                 $loggedUser->save("user");
                 AuthService::updateUser($loggedUser);
             } else {
                 $session["PENDING_REPOSITORY_ID"] = $parameters["repository_id"];
                 $session["PENDING_FOLDER"] = SystemTextEncoding::toUTF8(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 AJXP_BIN_FOLDER . "/class.AJXP_JSPacker.php";
         AJXP_JSPacker::pack();
     }
     if (ConfService::getConf("JS_DEBUG") && isset($parameters["update_i18n"])) {
         if (isset($parameters["extract"])) {
             self::extractConfStringsFromManifests();
         }
         self::updateAllI18nLibraries(isset($parameters["create"]) ? $parameters["create"] : "");
     }
     if (ConfService::getConf("JS_DEBUG") && isset($parameters["clear_plugins_cache"])) {
         @unlink(AJXP_PLUGINS_CACHE_FILE);
         @unlink(AJXP_PLUGINS_REQUIRES_FILE);
     }
     if (AJXP_SERVER_DEBUG && isset($parameters["extract_application_hooks"])) {
         self::extractHooksToDoc();
     }
     if (isset($parameters["external_selector_type"])) {
         $output["SELECTOR_DATA"] = array("type" => $parameters["external_selector_type"], "data" => $parameters);
     }
     if (isset($parameters["skipIOS"])) {
         setcookie("SKIP_IOS", "true");
     }
     if (isset($parameters["skipANDROID"])) {
         setcookie("SKIP_ANDROID", "true");
     }
     if (isset($parameters["gui"])) {
         setcookie("AJXP_GUI", $parameters["gui"]);
         if ($parameters["gui"] == "light") {
             $session["USE_EXISTING_TOKEN_IF_EXISTS"] = true;
         }
     } else {
         if (isset($session["USE_EXISTING_TOKEN_IF_EXISTS"])) {
             unset($session["USE_EXISTING_TOKEN_IF_EXISTS"]);
         }
         setcookie("AJXP_GUI", null);
     }
     if (isset($session["OVERRIDE_GUI_START_PARAMETERS"])) {
         $output = array_merge($output, $session["OVERRIDE_GUI_START_PARAMETERS"]);
     }
 }
コード例 #5
0
 public function downloadFile($nodeName)
 {
     $nodeName = urldecode($nodeName);
     //ob_start();
     $alreadyInstanciated = true;
     if (AuthService::getLoggedUser() == null) {
         AuthService::logUser($this->authLogin, $this->authPwd, true);
         $alreadyInstanciated = false;
     }
     $parts = explode("/", trim($nodeName, "/"));
     $repoAlias = array_shift($parts);
     $fileName = implode("/", $parts);
     $nbRep = ConfService::getRepositoryByAlias($repoAlias);
     $defaultRepoId = $nbRep->getId();
     ConfService::switchRootDir($defaultRepoId);
     ConfService::getConfStorageImpl();
     ConfService::loadRepositoryDriver();
     if (!$alreadyInstanciated) {
         AJXP_PluginsService::getInstance()->initActivePlugins();
     }
     //ob_end_clean();
     AJXP_Controller::findActionAndApply("download", array("file" => "/" . $fileName), array());
     exit;
 }