Ejemplo n.º 1
0
     }
 } else {
     if ($action === "tree") {
         list($href) = checkKeys(array("href"));
         require_once "inc/Tree.php";
         $absHref = trim($href);
         $absPath = $h5ai->getAbsPath($absHref);
         $tree = new TreeEntry($h5ai, $absPath, $absHref);
         $tree->loadContent();
         echo $tree->contentToHtml();
     } else {
         if ($action === "zip") {
             fail(0, "zipped download is disabled", !$options["zippedDownload"]);
             list($hrefs) = checkKeys(array("hrefs"));
             require_once "inc/ZipIt.php";
             $zipit = new ZipIt($h5ai);
             $hrefs = explode(":", trim($hrefs));
             $zipFile = $zipit->zip($hrefs);
             if ($zipFile === false) {
                 fail(2, "something went wrong while building the zip");
             }
             header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\"");
             header("Content-Type: application/force-download");
             header("Content-Length: " . filesize($zipFile));
             header("Connection: close");
             readfile($zipFile);
         } else {
             fail(1, "unsupported 'action' specified");
         }
     }
 }
Ejemplo n.º 2
0
function Zip($dir, $source, $name)
{
    $zip = new ZipIt();
    $res = $zip->open($dir . '.zip', ZipArchive::CREATE);
    if ($res === TRUE) {
        $zip->addDir($source, basename($source));
        $zip->close();
    }
}