Skip to content

Instantly share code, notes, and snippets.

@lintaba
Last active March 17, 2017 00:34
Show Gist options
  • Save lintaba/602e7e12e430247384a6d6194ed5119b to your computer and use it in GitHub Desktop.
Save lintaba/602e7e12e430247384a6d6194ed5119b to your computer and use it in GitHub Desktop.
<?php
set_time_limit(-1);
define('KB',1024);
define('MB',KB*1024);
?>
<html><head><style>quote{border:1px solid gray;margin-left:5px;display:block;}</style></head><body>
<?php
if(!isset($_GET["to"])){die("paraméter(to) hiányzik (pl archive)");}
if(!isset($_GET["from"])){die("paraméter(from) hiányzik (pl ./");}
class Zipper extends ZipArchive {
public function addDir($path) {
print '<quote> <h2>' . $path . '</h2>';
$this->addEmptyDir($path);
$nodes = glob($path . '/*');
foreach ($nodes as $node) {
print $node . '<br>';
if (is_dir($node)) {
$this->addDir($node);
} else if (is_file($node)) {
$this->addFile($node);
}
}
print "</quote>";
}
}
$zip = new Zipper();
$filename = $_GET["to"].".zip";
touch($filename);
file_put_contents($filename,"PK\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
if ($zip->open($filename)!==TRUE) {
die("nem nyitható meg <$filename>\n");
}
$zip->addDir($_GET["from"]);
$zip->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment