1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Zip dump only if requested

This commit is contained in:
Jakub Vrana
2012-06-29 14:09:44 -07:00
parent 5b57706890
commit f158d5e392

View File

@@ -8,7 +8,7 @@
*/
class AdminerDumpZip {
/** @access protected */
var $filename;
var $filename, $data;
function dumpOutput() {
if (!class_exists('ZipArchive')) {
@@ -18,13 +18,12 @@ class AdminerDumpZip {
}
function _zip($string, $state) {
static $data = "";
$data .= $string;
$this->data .= $string;
if ($state & PHP_OUTPUT_HANDLER_END) {
$zip = new ZipArchive;
$zipFile = tempnam("", "zip");
$zip->open($zipFile, ZipArchive::OVERWRITE); // php://output is not supported
$zip->addFromString($this->filename, $data);
$zip->addFromString($this->filename, $this->data);
$zip->close();
$return = file_get_contents($zipFile);
unlink($zipFile);
@@ -37,8 +36,8 @@ class AdminerDumpZip {
$this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]);
if ($_POST["output"] == "zip") {
header("Content-Type: application/zip");
ob_start(array($this, '_zip'));
}
ob_start(array($this, '_zip'));
}
}