diff --git a/download.php b/download.php new file mode 100644 index 0000000..cd913d2 --- /dev/null +++ b/download.php @@ -0,0 +1,66 @@ +open($zip_path, ZipArchive::CREATE) === TRUE) { + $files = scandir($icons_path); + foreach ($files as $file) { + $file_path = $icons_path."/$file"; + if (substr($file, -4, 4) == ".svg") { + touch($file_path); + $zip->addFile($file_path, $file); + } + } + $zip->close(); + } else { + echo "Oops"; + exit; + } + } + + if (is_file($zip_path)) { + header('Content-Type: application/zip'); + $quoted = sprintf('"%s"', addcslashes(basename($zip_path), '"\\')); + $size = filesize($zip_path); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename=' . $quoted); + header('Content-Transfer-Encoding: binary'); + header('Connection: Keep-Alive'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . $size); + readfile($zip_path); + } + +} else { + $file = $icons_path . "/$request"; + if (!is_file($file)) exit; + + header('Content-Type: image/svg+xml'); + $quoted = sprintf('"%s"', addcslashes(basename($file), '"\\')); + $size = filesize($file); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename=' . $quoted); + header('Content-Transfer-Encoding: binary'); + header('Connection: Keep-Alive'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: ' . $size); + readfile($file); +}