protected function initDirAndSelection($httpVars, $additionnalPathes = array(), $testRecycle = false) { $userSelection = new UserSelection(); $userSelection->initFromHttpVars($httpVars); $repo = $this->accessDriver->repository; $repo->detectStreamWrapper(); $wrapperData = $repo->streamData; $urlBase = $wrapperData["protocol"] . "://" . $repo->getId(); $result = array(); if ($testRecycle) { $recycle = $repo->getOption("RECYCLE_BIN"); if ($recycle != "") { RecycleBinManager::init($urlBase, "/" . $recycle); $result["RECYCLE"] = RecycleBinManager::filterActions($httpVars["get_action"], $userSelection, $httpVars["dir"], $httpVars); // if necessary, check recycle was checked. // We could use a hook instead here? Maybe the full recycle system // could be turned into a plugin $sessionKey = "AJXP_SVN_" . $repo->getId() . "_RECYCLE_CHECKED"; if (isset($_SESSION[$sessionKey])) { $file = RecycleBinManager::getRelativeRecycle() . "/" . RecycleBinManager::getCacheFileName(); $realFile = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . $file); $this->addIfNotVersionned($file, $realFile); $_SESSION[$sessionKey] = true; } } } $result["DIR"] = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . AJXP_Utils::decodeSecureMagic($httpVars["dir"])); $result["ORIGINAL_SELECTION"] = $userSelection; $result["SELECTION"] = array(); if (!$userSelection->isEmpty()) { $files = $userSelection->getFiles(); foreach ($files as $selected) { $result["SELECTION"][] = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . $selected); } } foreach ($additionnalPathes as $parameter => $path) { $result[$parameter] = call_user_func(array($wrapperData["classname"], "getRealFSReference"), $urlBase . $path); } return $result; }
function listing($nom_rep, $dir_only = false, $offset = 0, $limit = 0) { $mess = ConfService::getMessages(); $size_unit = $mess["byte_unit_symbol"]; $orderDir = 0; $orderBy = "filename"; $handle = opendir($nom_rep); $recycle = $this->repository->getOption("RECYCLE_BIN"); $cursor = 0; while (strlen($file = readdir($handle)) > 0) { if ($file != "." && $file != ".." && !(Utils::isHidden($file) && !$this->driverConf["SHOW_HIDDEN_FILES"])) { if ($offset > 0 && $cursor < $offset) { $cursor++; continue; } if ($limit > 0 && $cursor - $offset >= $limit) { break; } $cursor++; if ($recycle != "" && $nom_rep == $this->repository->getOption("PATH") . "/" . $recycle && $file == RecycleBinManager::getCacheFileName()) { continue; } $poidsfic = @filesize("{$nom_rep}/{$file}") or 0; if (is_dir("{$nom_rep}/{$file}")) { if ($this->filterFolder($file)) { continue; } if ($recycle != "" && $this->getPath() . "/" . $recycle == "{$nom_rep}/{$file}") { continue; } if ($orderBy == "mod") { $liste_rep[$file] = filemtime("{$nom_rep}/{$file}"); } else { $liste_rep[$file] = $file; } } else { if ($this->filterFile($file)) { continue; } if (!$dir_only) { if ($orderBy == "filename") { $liste_fic[$file] = Utils::mimetype("{$nom_rep}/{$file}", "image", is_dir("{$nom_rep}/{$file}")); } else { if ($orderBy == "filesize") { $liste_fic[$file] = $poidsfic; } else { if ($orderBy == "mod") { $liste_fic[$file] = filemtime("{$nom_rep}/{$file}"); } else { if ($orderBy == "filetype") { $liste_fic[$file] = Utils::mimetype("{$nom_rep}/{$file}", "type", is_dir("{$nom_rep}/{$file}")); } else { $liste_fic[$file] = Utils::mimetype("{$nom_rep}/{$file}", "image", is_dir("{$nom_rep}/{$file}")); } } } } } else { if (preg_match("/\\.zip\$/", $file) && ConfService::zipEnabled()) { if (!isset($liste_zip)) { $liste_zip = array(); } $liste_zip[$file] = $file; } } } } } closedir($handle); if (isset($liste_fic) && is_array($liste_fic)) { if ($orderBy == "filename") { if ($orderDir == 0) { Utils::natksort($liste_fic); } else { Utils::natkrsort($liste_fic); } } else { if ($orderBy == "mod") { if ($orderDir == 0) { arsort($liste_fic); } else { asort($liste_fic); } } else { if ($orderBy == "filesize" || $orderBy == "filetype") { if ($orderDir == 0) { asort($liste_fic); } else { arsort($liste_fic); } } else { if ($orderDir == 0) { Utils::natksort($liste_fic); } else { Utils::natkrsort($liste_fic); } } } } if ($orderBy != "filename") { foreach ($liste_fic as $index => $value) { $liste_fic[$index] = Utils::mimetype($index, "image", false); } } } else { $liste_fic = array(); } if (isset($liste_rep) && is_array($liste_rep)) { if ($orderBy == "mod") { if ($orderDir == 0) { arsort($liste_rep); } else { asort($liste_rep); } } else { if ($orderDir == 0) { Utils::natksort($liste_rep); } else { Utils::natkrsort($liste_rep); } } if ($orderBy != "filename") { foreach ($liste_rep as $index => $value) { $liste_rep[$index] = $index; } } } else { $liste_rep = array(); } $liste = Utils::mergeArrays($liste_rep, $liste_fic); if (isset($liste_zip)) { $liste = Utils::mergeArrays($liste, $liste_zip); } return $liste; }
public function filterNodeName($nodePath, $nodeName, &$isLeaf, $lsOptions) { $showHiddenFiles = $this->getFilteredOption("SHOW_HIDDEN_FILES", $this->repository->getId()); $isLeaf = is_file($nodePath . "/" . $nodeName) || AJXP_Utils::isBrowsableArchive($nodeName); if (AJXP_Utils::isHidden($nodeName) && !$showHiddenFiles) { return false; } $nodeType = "d"; if ($isLeaf) { if (AJXP_Utils::isBrowsableArchive($nodeName)) { $nodeType = "z"; } else { $nodeType = "f"; } } if (!$lsOptions[$nodeType]) { return false; } if ($nodeType == "d") { if (RecycleBinManager::recycleEnabled() && $nodePath . "/" . $nodeName == RecycleBinManager::getRecyclePath()) { return false; } return !$this->filterFolder($nodeName); } else { if ($nodeName == "." || $nodeName == "..") { return false; } if (RecycleBinManager::recycleEnabled() && $nodePath == RecycleBinManager::getRecyclePath() && $nodeName == RecycleBinManager::getCacheFileName()) { return false; } return !$this->filterFile($nodeName); } }
function filterNodeName($nodePath, $nodeName, $isLeaf, $lsOptions) { if (AJXP_Utils::isHidden($nodeName) && !$this->driverConf["SHOW_HIDDEN_FILES"]) { return false; } $nodeType = "d"; if ($isLeaf) { if (AJXP_Utils::isBrowsableArchive($nodeName)) { $nodeType = "z"; } else { $nodeType = "f"; } } if (!$lsOptions[$nodeType]) { return false; } if ($nodeType == "d") { if (RecycleBinManager::recycleEnabled() && $nodePath . "/" . $nodeName == RecycleBinManager::getRecyclePath()) { return false; } return !$this->filterFolder($nodeName); } else { if ($nodeName == "." || $nodeName == "..") { return false; } if (RecycleBinManager::recycleEnabled() && $nodePath == RecycleBinManager::getRecyclePath() && $nodeName == RecycleBinManager::getCacheFileName()) { return false; } return !$this->filterFile($nodeName); } }
function listing($nom_rep, $dir_only = false) { $mess = ConfService::getMessages(); $size_unit = $mess["byte_unit_symbol"]; $sens = 0; $ordre = "nom"; $poidstotal = 0; $contents = @ftp_rawlist($this->connect, $nom_rep); if (!is_array($contents)) { // We might have timed out, so let's go passive if not done yet global $_SESSION; if ($_SESSION["ftpPasv"] == "true") { return array(); } @ftp_pasv($this->connect, TRUE); $_SESSION["ftpPasv"] = "true"; $contents = @ftp_rawlist($this->connect, $nom_rep); if (!is_array($contents)) { return array(); } } foreach ($contents as $entry) { $info = array(); $vinfo = preg_split("/[\\s]+/", $entry, 9); if ($vinfo[0] !== "total") { $info['chmod'] = $vinfo[0]; $info['num'] = $vinfo[1]; $info['owner'] = $vinfo[2]; $info['group'] = $vinfo[3]; $info['size'] = $vinfo[4]; $info['month'] = $vinfo[5]; $info['day'] = $vinfo[6]; $info['timeOrYear'] = $vinfo[7]; $info['name'] = $vinfo[8]; } $file = trim($info['name']); $filetaille = trim($info['size']); if (strstr($info["timeOrYear"], ":")) { $info["time"] = $info["timeOrYear"]; $info["year"] = date("Y"); } else { $info["time"] = '09:00'; $info["year"] = $info["timeOrYear"]; } $filedate = trim($info['day']) . " " . trim($info['month']) . " " . trim($info['year']) . " " . trim($info['time']); $filedate = strtotime($filedate); $fileperms = trim($info['chmod']); $info['chmod1'] = $this->convertingChmod(trim($info['chmod'])); $isDir = false; $info['modifTime'] = $filedate; $info['isDir'] = false; //gestion des Simbolic Link pour la navigation if (strpos($fileperms, "d") !== FALSE || strpos($fileperms, "l") !== FALSE) { if (strpos($fileperms, "l") !== FALSE) { $test = explode(" ->", $file); $file = $test[0]; $info['name'] = $file; } $isDir = true; $info['isDir'] = true; } if ($file != "." && $file != "..") { if (RecycleBinManager::recycleEnabled() && $nom_rep == $this->repository->getOption("PATH") . "/" . $this->repository->getOption("RECYCLE_BIN") && $file == RecycleBinManager::getCacheFileName()) { continue; } $poidstotal += $filetaille; if ($isDir) { if (RecycleBinManager::recycleEnabled() && $this->repository->getOption("PATH") . "/" . $this->repository->getOption("RECYCLE_BIN") == "{$nom_rep}/{$file}") { continue; } $liste_rep[$file] = $info; $liste_rep[$file]['icon'] = Utils::mimetype("{$nom_rep}/{$file}", "image", $isDir); $liste_rep[$file]['type'] = Utils::mimetype("{$nom_rep}/{$file}", "type", $isDir); } else { if (!$dir_only) { $liste_fic[$file] = $info; $liste_fic[$file]['icon'] = Utils::mimetype("{$nom_rep}/{$file}", "image", $isDir); $liste_fic[$file]['type'] = Utils::mimetype("{$nom_rep}/{$file}", "type", $isDir); } else { if (preg_match("/\\.zip\$/", $file) && ConfService::zipEnabled()) { if (!isset($liste_zip)) { $liste_zip = array(); } $liste_zip[$file] = $file; } } } } } if (isset($liste_fic) && is_array($liste_fic)) { if ($ordre == "nom") { if ($sens == 0) { ksort($liste_fic); } else { krsort($liste_fic); } } else { if ($ordre == "mod") { if ($sens == 0) { arsort($liste_fic); } else { asort($liste_fic); } } else { if ($ordre == "taille" || $ordre == "type") { if ($sens == 0) { asort($liste_fic); } else { arsort($liste_fic); } } else { if ($sens == 0) { ksort($liste_fic); } else { krsort($liste_fic); } } } } if ($ordre != "nom") { foreach ($liste_fic as $index => $value) { $liste_fic[$index] = Utils::mimetype($index, "image", false); } } } else { $liste_fic = array(); } if (isset($liste_rep) && is_array($liste_rep)) { if ($ordre == "mod") { if ($sens == 0) { arsort($liste_rep); } else { asort($liste_rep); } } else { if ($sens == 0) { ksort($liste_rep); } else { krsort($liste_rep); } } if ($ordre != "nom") { foreach ($liste_rep as $index => $value) { $liste_rep[$index] = $index; } } } else { $liste_rep = array(); } $liste = Utils::mergeArrays($liste_rep, $liste_fic); if (isset($liste_zip)) { $liste = Utils::mergeArrays($liste, $liste_zip); } if ($poidstotal >= 1073741824) { $poidstotal = round($poidstotal / 1073741824 * 100) / 100 . " G" . $size_unit; } elseif ($poidstotal >= 1048576) { $poidstotal = round($poidstotal / 1048576 * 100) / 100 . " M" . $size_unit; } elseif ($poidstotal >= 1024) { $poidstotal = round($poidstotal / 1024 * 100) / 100 . " K" . $size_unit; } else { $poidstotal = $poidstotal . " " . $size_unit; } return array($liste, $poidstotal); }
function saveCache($value) { if (!RecycleBinManager::recycleEnabled()) { return null; } $cachePath = RecycleBinManager::getRecyclePath() . "/" . RecycleBinManager::getCacheFileName(); $fp = fopen($cachePath, "w"); if ($fp) { fwrite($fp, serialize($value)); fflush($fp); fclose($fp); } }