/**
  * Initialize the stream from the given path.
  * Concretely, transform ajxp.webdav:// into webdav://
  *
  * @param string $path
  * @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
  */
 protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
 {
     $url = AJXP_Utils::safeParseUrl($path);
     $repoId = $url["host"];
     $repoObject = ConfService::getRepositoryById($repoId);
     if (!isset($repoObject)) {
         $e = new Exception("Cannot find repository with id " . $repoId);
         self::$lastException = $e;
         throw $e;
     }
     $path = $url["path"];
     $host = $repoObject->getOption("HOST");
     $hostParts = parse_url($host);
     if ($hostParts["scheme"] == "https" && !extension_loaded("openssl")) {
         $e = new Exception("Warning you must have the openssl PHP extension loaded to connect an https server!");
         self::$lastException = $e;
         throw $e;
     }
     $credentials = AJXP_Safe::tryLoadingCredentialsFromSources($hostParts, $repoObject);
     $user = $credentials["user"];
     $password = $credentials["password"];
     if ($user != null && $password != null) {
         $host = ($hostParts["scheme"] == "https" ? "webdavs" : "webdav") . "://{$user}:{$password}@" . $hostParts["host"];
         if (isset($hostParts["port"])) {
             $host .= ":" . $hostParts["port"];
         }
     } else {
         $host = str_replace(array("http", "https"), array("webdav", "webdavs"), $host);
     }
     // MAKE SURE THERE ARE NO // OR PROBLEMS LIKE THAT...
     $basePath = $repoObject->getOption("PATH");
     if ($basePath[strlen($basePath) - 1] == "/") {
         $basePath = substr($basePath, 0, -1);
     }
     if ($basePath[0] != "/") {
         $basePath = "/{$basePath}";
     }
     $path = AJXP_Utils::securePath($path);
     if ($path[0] == "/") {
         $path = substr($path, 1);
     }
     // SHOULD RETURN webdav://host_server/uri/to/webdav/folder
     AJXP_Logger::debug(__CLASS__, __FUNCTION__, $host . $basePath . "/" . $path);
     return $host . $basePath . "/" . $path;
 }