From: Marc MAURICE Date: Sat, 17 Aug 2013 20:09:18 +0000 (+0200) Subject: Tar plugin disabled by default X-Git-Tag: v1.7~6 X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=commitdiff_plain;h=4a74e0085e76653319bfa9da56e6abf394fe8729 Tar plugin disabled by default --- diff --git a/plugins/_disabled/tar/after_content.php b/plugins/_disabled/tar/after_content.php new file mode 100644 index 0000000..1bc535a --- /dev/null +++ b/plugins/_disabled/tar/after_content.php @@ -0,0 +1,5 @@ + +
+">Download all files in this directory +
+ diff --git a/plugins/_disabled/tar/tar.php b/plugins/_disabled/tar/tar.php new file mode 100644 index 0000000..9d3a46f --- /dev/null +++ b/plugins/_disabled/tar/tar.php @@ -0,0 +1,73 @@ +. +*/ + +# do not enable recursive tars by default +$TAR_FLAGS = "--no-recursion"; + +# send content length for browsers to display the progress bar +# note : won't work if the http server uses Chunked transfer encoding (http://en.wikipedia.org/wiki/Chunked_transfer_encoding) +# probably the case with gzip content-encoding. +# For this we need to tar files to /dev/null before the real tar +$SEND_CONTENT_LENGTH = true; + +######################## +$bizouRootFromHere = '../..'; +require "$bizouRootFromHere/config.php"; + +if (isset($_SERVER["PATH_INFO"])) { + $simplePath = $_SERVER["PATH_INFO"]; +} else { + $simplePath = '/'; +} + +if (strpos($simplePath, '..') !== false) die(".. found in url"); + +$realDir = "$bizouRootFromHere/".IMAGES_DIR.$simplePath; + +if ( ! is_dir($realDir) ) { + header("HTTP/1.1 404 Not Found"); + die("Directory Not Found"); +} + +# change to the parent directory +chdir(dirname($realDir)); + +$filesarg = basename($realDir); +# same as escapeshellarg function but this supports utf8 regardless of locale +$filesarg = "'".str_replace("'", "'\\''", $filesarg)."'"; +$filesarg = "$filesarg/*"; + +# compute and send content-length header +if ($SEND_CONTENT_LENGTH) { + $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1", $output, $ret); + preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); + $totalsize = $matches[1]; + + ($totalsize > 1000 and $ret === 0) or die("Could not tar: $filesarg. Try checking permissions."); + + 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 $TAR_FLAGS -c $filesarg"); + +?> diff --git a/plugins/tar/after_content.php b/plugins/tar/after_content.php deleted file mode 100644 index 1bc535a..0000000 --- a/plugins/tar/after_content.php +++ /dev/null @@ -1,5 +0,0 @@ - -
-">Download all files in this directory -
- diff --git a/plugins/tar/tar.php b/plugins/tar/tar.php deleted file mode 100644 index 9d3a46f..0000000 --- a/plugins/tar/tar.php +++ /dev/null @@ -1,73 +0,0 @@ -. -*/ - -# do not enable recursive tars by default -$TAR_FLAGS = "--no-recursion"; - -# send content length for browsers to display the progress bar -# note : won't work if the http server uses Chunked transfer encoding (http://en.wikipedia.org/wiki/Chunked_transfer_encoding) -# probably the case with gzip content-encoding. -# For this we need to tar files to /dev/null before the real tar -$SEND_CONTENT_LENGTH = true; - -######################## -$bizouRootFromHere = '../..'; -require "$bizouRootFromHere/config.php"; - -if (isset($_SERVER["PATH_INFO"])) { - $simplePath = $_SERVER["PATH_INFO"]; -} else { - $simplePath = '/'; -} - -if (strpos($simplePath, '..') !== false) die(".. found in url"); - -$realDir = "$bizouRootFromHere/".IMAGES_DIR.$simplePath; - -if ( ! is_dir($realDir) ) { - header("HTTP/1.1 404 Not Found"); - die("Directory Not Found"); -} - -# change to the parent directory -chdir(dirname($realDir)); - -$filesarg = basename($realDir); -# same as escapeshellarg function but this supports utf8 regardless of locale -$filesarg = "'".str_replace("'", "'\\''", $filesarg)."'"; -$filesarg = "$filesarg/*"; - -# compute and send content-length header -if ($SEND_CONTENT_LENGTH) { - $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1", $output, $ret); - preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); - $totalsize = $matches[1]; - - ($totalsize > 1000 and $ret === 0) or die("Could not tar: $filesarg. Try checking permissions."); - - 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 $TAR_FLAGS -c $filesarg"); - -?>