Simple Zip Archive Given Folder And Download Using PHP On Linux Server

<?php

// zip
$file = $_GET['folder'];
exec("zip -r $file.zip $file");

// download
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename("$file.zip").'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize("$file.zip"));
flush(); // Flush system output buffer
readfile("$file.zip");

// clean
exec("rm $file.zip");

?>