コード例 #1
0
ファイル: H5ai.php プロジェクト: rsertelon/h5ai
 public function getAbsPath($absHref = null)
 {
     if ($absHref === null) {
         return $this->absPath;
     }
     $absHref = substr($absHref, strlen($this->rootAbsHref));
     return H5ai::normalize_path($this->rootAbsPath . "/" . rawurldecode($absHref));
 }
コード例 #2
0
ファイル: Archive.php プロジェクト: rsertelon/h5ai
 private function add_hrefs($hrefs)
 {
     foreach ($hrefs as $href) {
         $d = H5ai::normalize_path(dirname($href), true);
         $n = basename($href);
         $code = $this->h5ai->getHttpCode($d);
         if ($code == 401) {
             $this->sc401 = true;
         }
         if ($code == "h5ai" && !$this->h5ai->is_ignored($n)) {
             $realFile = $this->h5ai->getAbsPath($href);
             $archivedFile = preg_replace("!^" . H5ai::normalize_path($this->h5ai->getRootAbsPath(), true) . "!", "", $realFile);
             if (is_dir($realFile)) {
                 $this->add_dir($realFile, $archivedFile);
             } else {
                 $this->add_file($realFile, $archivedFile);
             }
         }
     }
 }
コード例 #3
0
ファイル: Entry.php プロジェクト: nvdnkpr/h5ai
 private function __construct($h5ai, $absPath, $absHref)
 {
     $this->h5ai = $h5ai;
     $this->absPath = H5ai::normalize_path($absPath);
     $this->isFolder = is_dir($this->absPath);
     $this->absHref = H5ai::normalize_path($absHref, $this->isFolder);
     $this->date = filemtime($this->absPath);
     if ($this->isFolder) {
         $this->size = null;
         $options = $h5ai->getOptions();
         if ($options["foldersize"]["enabled"]) {
             $cmd = str_replace("[DIR]", $this->absPath, Entry::$FOLDER_SIZE_CMD);
             $this->size = intval(preg_replace("/\\s.*\$/", "", `{$cmd}`), 10);
         }
     } else {
         $this->size = filesize($this->absPath);
     }
     $this->parent = null;
     if ($this->absHref !== "/") {
         $this->parent = Entry::get($this->h5ai, H5ai::normalize_path(dirname($this->absPath)), H5ai::normalize_path(dirname($this->absHref), true));
     }
     $this->isContentFetched = false;
     Entry::$cache[$this->absHref] = $this;
 }
コード例 #4
0
ファイル: api.php プロジェクト: nvdnkpr/h5ai
     json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
     list($execution, $format, $hrefs) = check_keys(array("execution", "format", "hrefs"));
     H5ai::req_once("/php/inc/Archive.php");
     $archive = new Archive($h5ai);
     $hrefs = explode(":", trim($hrefs));
     $target = $archive->create($execution, $format, $hrefs);
     if (!is_string($target)) {
         json_fail($target, "package creation failed");
     }
     json_exit(array("id" => basename($target), "size" => filesize($target)));
 } else {
     if ($action === "getarchive") {
         json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
         list($id, $as) = check_keys(array("id", "as"));
         json_fail(2, "file not found", !preg_match("/^h5ai-selection-/", $id));
         $target = H5ai::normalize_path(sys_get_temp_dir(), true) . $id;
         json_fail(3, "file not found", !file_exists($target));
         header("Content-Type: application/octet-stream");
         header("Content-Length: " . filesize($target));
         header("Content-Disposition: attachment; filename=\"{$as}\"");
         header("Connection: close");
         readfile($target);
     } else {
         if ($action === "getchecks") {
             $php = version_compare(PHP_VERSION, "5.2.1") >= 0;
             $archive = class_exists("PharData");
             $gd = false;
             if (function_exists("gd_info")) {
                 $gdinfo = gd_info();
                 $gd = array_key_exists("JPG Support", $gdinfo) && $gdinfo["JPG Support"] || array_key_exists("JPEG Support", $gdinfo) && $gdinfo["JPEG Support"];
             }