From 823ab006aaa504aaaa9be5e9b5c27cbdf3df28cc Mon Sep 17 00:00:00 2001 From: Nick White Date: Sun, 23 Aug 2009 02:41:10 +0100 Subject: Initial commit of website code --- includes/tarball.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 includes/tarball.php (limited to 'includes/tarball.php') diff --git a/includes/tarball.php b/includes/tarball.php new file mode 100644 index 0000000..737aefa --- /dev/null +++ b/includes/tarball.php @@ -0,0 +1,41 @@ +. + */ + +function return_tarball($name, $contents) +{ + require("Archive/Tar.php"); + + $mimetype = "application/x-tar"; + $extension = "tar.bz2"; + + $timestamp = strftime('%F'); + + /* Use output buffering (ob_start and ob_end_flush) to ensure that the + * tarball data sent to stdout doesn't interfere with the headers. */ + ob_start(); + header('Content-Type: ' . $mimetype); + header('Content-Disposition: attachment; filename="' . $name . '-' . $timestamp . '.' . $extension . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_end_flush(); + + $tarball = new Archive_Tar("php://stdout", "bz2"); + + $tarball->create($contents); +} -- cgit v1.2.3