/** * Stats the given path. * * @param string $path * @param mixed $flags * @return array */ public function url_stat($path, $flags) { $realPath = self::initPath($path); $stat = @stat($realPath); $parts = AJXP_Utils::safeParseUrl($path); $repoObject = ConfService::getRepositoryById($parts["host"]); AbstractAccessDriver::fixPermissions($stat, $repoObject, array($this, "detectRemoteUserId")); return $stat; }
public function dir_opendir($url, $options) { $parts = $this->parseUrl($url); $link = $this->createFTPLink(); $serverPath = AJXP_Utils::securePath($this->path . "/" . $parts["path"]); $contents = $this->rawList($link, $serverPath); $folders = $files = array(); foreach ($contents as $entry) { $result = $this->rawListEntryToStat($entry); AbstractAccessDriver::fixPermissions($result["stat"], ConfService::getRepositoryById($this->repositoryId), array($this, "getRemoteUserId")); $isDir = $result["dir"]; $statValue = $result["stat"]; $file = $result["name"]; if ($isDir) { $folders[$file] = $statValue; } else { $files[$file] = $statValue; } } // Append all files keys to folders. Do not use array_merge. foreach ($files as $key => $value) { $folders[$key] = $value; } AJXP_Logger::debug(__CLASS__, __FUNCTION__, "OPENDIR ", $folders); self::$dirContentLoopPath = AJXP_Utils::safeDirname($url); self::$dirContent = $folders; //array_merge($folders, $files); self::$dirContentKeys = array_keys(self::$dirContent); self::$dirContentIndex = 0; return true; }
public function url_stat($path, $flags) { // We are in an opendir loop AJXP_Logger::debug("URL_STAT", $path); if (self::$dirContent != null) { $search = $this->safeBasename($path); //if($search == "") $search = "."; if (array_key_exists($search, self::$dirContent)) { return self::$dirContent[$search]; } } $parts = $this->parseUrl($path); $link = $this->createFTPLink(); $serverPath = AJXP_Utils::securePath($this->path . "/" . $parts["path"]); if ($parts["path"] == "/") { $basename = "."; } else { $basename = $this->safeBasename($serverPath); } $serverParent = $this->safeDirname($parts["path"]); $serverParent = AJXP_Utils::securePath($this->path . "/" . $serverParent); $testCd = @ftp_chdir($link, $serverPath); if ($testCd === true) { // DIR $contents = $this->rawList($link, $serverParent, 'd'); foreach ($contents as $entry) { $res = $this->rawListEntryToStat($entry); AJXP_Logger::debug("RAWLISTENTRY " . $res["name"] . " (searching " . $basename . ")", $res["stat"]); if ($res["name"] == $basename) { AbstractAccessDriver::fixPermissions($res["stat"], ConfService::getRepositoryById($this->repositoryId), array($this, "getRemoteUserId")); $statValue = $res["stat"]; return $statValue; } } } else { // FILE $contents = $this->rawList($link, $serverPath, 'f'); if (count($contents) == 1) { $res = $this->rawListEntryToStat($contents[0]); AbstractAccessDriver::fixPermissions($res["stat"], ConfService::getRepositoryById($this->repositoryId), array($this, "getRemoteUserId")); $statValue = $res["stat"]; AJXP_Logger::debug("STAT FILE {$serverPath}", $statValue); return $statValue; } } return null; }