From: Marc MAURICE Date: Mon, 13 Jun 2011 19:04:29 +0000 (+0200) Subject: Added variables to enable/disable tar recursion and content-length header X-Git-Tag: v1.5~2 X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=commitdiff_plain;h=ce885a485d6459acbbcd0a6af128f2a0bfff8f9c Added variables to enable/disable tar recursion and content-length header --- 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"); ?>