/** * @param AJXP_Node $ajxpNode */ public function hideExtension(&$ajxpNode) { if ($ajxpNode->hasExtension("pad")) { $baseName = AJXP_Utils::safeBasename($ajxpNode->getPath()); $ajxpNode->setLabel(str_replace(".pad", "", $baseName)); } }
public static function translateURL($path) { $pydioScheme = false; self::$linkNode = null; $nodes = inboxAccessDriver::getNodes(false); $nodePath = basename(parse_url($path, PHP_URL_PATH)); $node = $nodes[ltrim($nodePath, '/')]; if (empty($node) || !isset($node['url'])) { return AJXP_Utils::getAjxpTmpDir(); } $url = $node['url']; $label = $node['label']; $scheme = parse_url($url, PHP_URL_SCHEME); if ($scheme == "pydio") { self::$linkNode = new AJXP_Node($path); $pydioScheme = true; } if (empty($nodePath)) { return AJXP_Utils::getAjxpTmpDir(); } if ($pydioScheme) { $node = new AJXP_Node($url); $node->setLabel($label); $node->getRepository()->driverInstance = null; try { ConfService::loadDriverForRepository($node->getRepository()); } catch (Exception $e) { } $node->getRepository()->detectStreamWrapper(true); } return $url; }
/** * @param AJXP_Node $ajxpNode * @param bool $parentNode * @param bool $details * @return void */ public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false) { $nodeName = basename($ajxpNode->getPath()); $metaData = $ajxpNode->metadata; if (!isset($metaData["is_file"])) { $isLeaf = is_file($ajxpNode->getUrl()) || AJXP_Utils::isBrowsableArchive($nodeName); $metaData["is_file"] = $isLeaf ? "1" : "0"; } else { $isLeaf = $metaData["is_file"] == "1" ? true : false; } $metaData["filename"] = $ajxpNode->getPath(); if (RecycleBinManager::recycleEnabled() && $ajxpNode->getPath() == RecycleBinManager::getRelativeRecycle()) { $mess = ConfService::getMessages(); $recycleIcon = $this->countFiles($ajxpNode->getUrl(), false, true) > 0 ? "trashcan_full.png" : "trashcan.png"; $metaData["icon"] = $recycleIcon; $metaData["mimestring"] = $mess[122]; $ajxpNode->setLabel($mess[122]); $metaData["ajxp_mime"] = "ajxp_recycle"; } else { $mimeData = AJXP_Utils::mimeData($ajxpNode->getUrl(), !$isLeaf); $metaData["mimestring_id"] = $mimeData[0]; //AJXP_Utils::mimetype($ajxpNode->getUrl(), "type", !$isLeaf); $metaData["icon"] = $mimeData[1]; //AJXP_Utils::mimetype($nodeName, "image", !$isLeaf); if ($metaData["icon"] == "folder.png") { $metaData["openicon"] = "folder_open.png"; } if (!$isLeaf) { $metaData["ajxp_mime"] = "ajxp_folder"; } } //if ($lsOptions["l"]) { $metaData["file_group"] = @filegroup($ajxpNode->getUrl()) || "unknown"; $metaData["file_owner"] = @fileowner($ajxpNode->getUrl()) || "unknown"; $crtPath = $ajxpNode->getPath(); $vRoots = $this->repository->listVirtualRoots(); if (!empty($crtPath)) { if (!@$this->isWriteable($ajxpNode->getUrl())) { $metaData["ajxp_readonly"] = "true"; } if (isset($vRoots[ltrim($crtPath, "/")])) { $metaData["ajxp_readonly"] = $vRoots[ltrim($crtPath, "/")]["right"] == "r" ? "true" : "false"; } } else { if (count($vRoots)) { $metaData["ajxp_readonly"] = "true"; } } $fPerms = @fileperms($ajxpNode->getUrl()); if ($fPerms !== false) { $fPerms = substr(decoct($fPerms), $isLeaf ? 2 : 1); } else { $fPerms = '0000'; } $metaData["file_perms"] = $fPerms; $datemodif = $this->date_modif($ajxpNode->getUrl()); $metaData["ajxp_modiftime"] = $datemodif ? $datemodif : "0"; $metaData["bytesize"] = 0; if ($isLeaf) { $metaData["bytesize"] = $this->filesystemFileSize($ajxpNode->getUrl()); } $metaData["filesize"] = AJXP_Utils::roundSize($metaData["bytesize"]); if (AJXP_Utils::isBrowsableArchive($nodeName)) { $metaData["ajxp_mime"] = "ajxp_browsable_archive"; } if ($details == "minimal") { $miniMeta = array("is_file" => $metaData["is_file"], "filename" => $metaData["filename"], "bytesize" => $metaData["bytesize"], "ajxp_modiftime" => $metaData["ajxp_modiftime"]); $ajxpNode->mergeMetadata($miniMeta); } else { $ajxpNode->mergeMetadata($metaData); } }
public static function getNodes($checkStats = false, $touch = true) { if (isset(self::$output)) { return self::$output; } $mess = ConfService::getMessages(); $repos = ConfService::getAccessibleRepositories(); $output = array(); $touchReposIds = array(); foreach ($repos as $repo) { if (!$repo->hasOwner() || !$repo->hasContentFilter()) { continue; } $repoId = $repo->getId(); if (strpos("ocs_remote_share_", $repoId) !== 0) { $touchReposIds[] = $repoId; } $url = "pydio://" . $repoId . "/"; $meta = array("shared_repository_id" => $repoId, "ajxp_description" => "File shared by " . $repo->getOwner() . " " . AJXP_Utils::relativeDate($repo->getOption("CREATION_TIME"), $mess), "share_meta_type" => 1); $cFilter = $repo->getContentFilter(); $filter = $cFilter instanceof ContentFilter ? array_keys($cFilter->filters)[0] : $cFilter; if (!is_array($filter)) { $label = basename($filter); } else { $label = $repo->getDisplay(); } if (strpos($repoId, "ocs_remote_share") !== 0) { // FOR REMOTE SHARES, DO NOT APPEND THE DOCUMENTNAME, WE STAT THE ROOT DIRECTLY $url .= $label; } $status = null; $remoteShare = null; $name = pathinfo($label, PATHINFO_FILENAME); $ext = pathinfo($label, PATHINFO_EXTENSION); $node = new AJXP_Node($url); $node->setLabel($label); if ($checkStats) { $node->getRepository()->driverInstance = null; try { ConfService::loadDriverForRepository($node->getRepository()); } catch (Exception $e) { $ext = "error"; $meta["ajxp_mime"] = "error"; } $node->getRepository()->detectStreamWrapper(true); $stat = @stat($url); if ($stat === false) { $ext = "error"; $meta["ajxp_mime"] = "error"; $meta["share_meta_type"] = 2; } else { if (strpos($repoId, "ocs_remote_share_") === 0) { // Check Status $linkId = str_replace("ocs_remote_share_", "", $repoId); $ocsStore = new \Pydio\OCS\Model\SQLStore(); $remoteShare = $ocsStore->remoteShareById($linkId); $status = $remoteShare->getStatus(); if ($status == OCS_INVITATION_STATUS_PENDING) { $stat = stat(AJXP_Utils::getAjxpTmpDir()); $ext = "invitation"; $meta["ajxp_mime"] = "invitation"; $meta["share_meta_type"] = 0; } else { $meta["remote_share_accepted"] = "true"; } $meta["remote_share_id"] = $remoteShare->getId(); } } if ($ext == "invitation") { $label .= " (" . $mess["inbox_driver.4"] . ")"; } else { if ($ext == "error") { $label .= " (" . $mess["inbox_driver.5"] . ")"; } } if (is_array($stat) && AuthService::getLoggedUser() != null) { $acl = AuthService::getLoggedUser()->mergedRole->getAcl($repoId); if ($acl == "r") { self::disableWriteInStat($stat); } } } $index = 0; $suffix = ""; while (isset($output[$name . $suffix . "." . $ext])) { $index++; $suffix = " ({$index})"; } $output[$name . $suffix . "." . $ext] = ["label" => $label, "url" => $url, "remote_share" => $remoteShare, "meta" => $meta]; if (isset($stat)) { $output[$name . $suffix . "." . $ext]['stat'] = $stat; } } ConfService::loadDriverForRepository(ConfService::getRepository()); self::$output = $output; if ($touch) { if (count($touchReposIds) && AuthService::getLoggedUser() != null) { $uPref = AuthService::getLoggedUser()->getPref("repository_last_connected"); if (empty($uPref)) { $uPref = array(); } foreach ($touchReposIds as $rId) { $uPref[$rId] = time(); } AuthService::getLoggedUser()->setPref("repository_last_connected", $uPref); } } return $output; }
/** * @param AJXP_Node $ajxpNode * @param AJXP_Node|bool $parentNode * @param bool $details */ public function filterENCFS(&$ajxpNode, $parentNode = false, $details = false) { if (substr($ajxpNode->getLabel(), 0, strlen("ENCFS_RAW_")) == "ENCFS_RAW_") { $ajxpNode->hidden = true; } else { if (substr($ajxpNode->getLabel(), 0, strlen("ENCFS_CLEAR_")) == "ENCFS_CLEAR_") { $ajxpNode->ENCFS_clear_folder = true; $ajxpNode->overlay_icon = "cypher.encfs/overlay_ICON_SIZE.png"; $ajxpNode->overlay_class = "icon-lock"; if (is_file($ajxpNode->getUrl() . "/.ajxp_mount")) { $ajxpNode->setLabel(substr($ajxpNode->getLabel(), strlen("ENCFS_CLEAR_"))); $ajxpNode->ENCFS_clear_folder_mounted = true; } else { $ajxpNode->setLabel(substr($ajxpNode->getLabel(), strlen("ENCFS_CLEAR_")) . " (encrypted)"); } } } }