addFile( $filepath, $pathInZip ); } } if (count($files) == 0) { $za->addEmptyDir( substr($path, strlen($basePath)) ); } } // handle Zip if (isset($_REQUEST['zipit']) && $_REQUEST['zipit']) { if (!$p) { die('Path not found'); } set_time_limit(0); ini_set('error_reporting', 0); ini_set('display_errors', 'off'); // create temp-file $tmpfile = @tempnam('', 'zipit'); $filename = $_SERVER['HTTP_HOST'] . '-' . date('YmdHis') . '.zip'; header ('Content-Type: application/zip'); header ('Content-Disposition: attachment; filename="' . $filename . '"'); // zip it $za = new ZipArchive(); if ( !@$za->open( $tmpfile, ZipArchive::CREATE ) ) { die('Unable to open zip'); } add_to_ziparchive( $p, $za, $p ); $za->close(); readfile( $tmpfile ); exit; } // handle tar if (isset($_REQUEST['tarit']) && $_REQUEST['tarit']) { if (!$p) { die('Path not found'); } set_time_limit(0); ini_set('error_reporting', 0); ini_set('display_errors', 'off'); $filename = $_SERVER['HTTP_HOST'] . '-' . date('YmdHis') . '.tar.gz'; header ('Content-Type: application/octet-stream'); header ('Content-Disposition: attachment; filename="' . $filename . '"'); // tar it $cmd = "tar -zvcf - \"".$p."\""; system( $cmd ); exit; } // show files current path $files = list_files( $p ); ?>