Fixes include problems as well as Win path problems.

This commit is contained in:
Lars Jung 2012-02-15 18:41:13 +01:00
parent d72ea22fb0
commit 9f10e92175
13 changed files with 158 additions and 70 deletions

View file

@ -1,13 +1,16 @@
<?php
class ZipIt {
private $h5ai;
public function __construct($h5ai) {
$this->h5ai = $h5ai;
}
public function zip($hrefs) {
$zipFile = tempnam("/tmp", "h5ai-download");
@ -18,11 +21,11 @@ class ZipIt {
}
foreach ($hrefs as $href) {
$d = dirname($href);
$d = safe_dirname($href, true);
$n = basename($href);
if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) {
$localFile = $this->h5ai->getAbsPath($href);
$file = preg_replace("!^" . $this->h5ai->getDocRoot() . "!", "", $localFile);
$file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile);
if (is_dir($localFile)) {
$this->zipDir($zip, $localFile, $file);
} else {
@ -35,6 +38,7 @@ class ZipIt {
return $zipFile;
}
private function zipFile($zip, $localFile, $file) {
if (is_readable($localFile)) {
@ -42,6 +46,7 @@ class ZipIt {
}
}
private function zipDir($zip, $localDir, $dir) {
if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") {