. */ 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); }