mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-30 06:55:16 -04:00
Adds support for zipped download of htaccess restricted files.
This commit is contained in:
parent
08cc2834df
commit
041c172a55
8 changed files with 258 additions and 52 deletions
|
@ -24,11 +24,19 @@ class ZipIt {
|
|||
foreach ($hrefs as $href) {
|
||||
$d = safe_dirname($href, true);
|
||||
$n = basename($href);
|
||||
if ($this->h5ai->getHttpCode($d) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) {
|
||||
$code = $this->h5ai->getHttpCode($d);
|
||||
if ($code == 401) {
|
||||
return $code;
|
||||
}
|
||||
|
||||
if ($code == "h5ai" && !$this->h5ai->ignoreThisFile($n)) {
|
||||
$localFile = $this->h5ai->getAbsPath($href);
|
||||
$file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile);
|
||||
if (is_dir($localFile)) {
|
||||
$this->zipDir($zip, $localFile, $file);
|
||||
$rcode = $this->zipDir($zip, $localFile, $file);
|
||||
if ($rcode == 401) {
|
||||
return $rcode;
|
||||
}
|
||||
} else {
|
||||
$this->zipFile($zip, $localFile, $file);
|
||||
}
|
||||
|
@ -50,19 +58,25 @@ class ZipIt {
|
|||
|
||||
private function zipDir($zip, $localDir, $dir) {
|
||||
|
||||
if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") {
|
||||
$code = $this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir));
|
||||
|
||||
if ($code == 'h5ai') {
|
||||
$zip->addEmptyDir($dir);
|
||||
$files = $this->h5ai->readDir($localDir);
|
||||
foreach ($files as $file) {
|
||||
$localFile = $localDir . "/" . $file;
|
||||
$file = $dir . "/" . $file;
|
||||
if (is_dir($localFile)) {
|
||||
$this->zipDir($zip, $localFile, $file);
|
||||
$rcode = $this->zipDir($zip, $localFile, $file);
|
||||
if ($rcode == 401) {
|
||||
return $rcode;
|
||||
}
|
||||
} else {
|
||||
$this->zipFile($zip, $localFile, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue