From ce885a485d6459acbbcd0a6af128f2a0bfff8f9c Mon Sep 17 00:00:00 2001 From: Marc MAURICE Date: Mon, 13 Jun 2011 21:04:29 +0200 Subject: [PATCH] Added variables to enable/disable tar recursion and content-length header --- plugins/tar/tar.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/plugins/tar/tar.php b/plugins/tar/tar.php index add078d..3554622 100644 --- a/plugins/tar/tar.php +++ b/plugins/tar/tar.php @@ -1,5 +1,15 @@ &1"); -preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); -$totalsize = $matches[1]; +# compute and send content-length header +if ($SEND_CONTENT_LENGTH) { + $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1"); + preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); + $totalsize = $matches[1]; + + header("Content-Length: $totalsize"); +} -header("Content-Length: $totalsize"); +# final step : stream the directory content via tar header('Content-Type: application/x-tar'); header('Content-Disposition: attachment; filename="'.basename($realDir).'.tar"'); -passthru("tar --no-recursion -c $filesarg"); +passthru("tar $TAR_FLAGS -c $filesarg"); ?> -- 1.7.10.4