From: Jakub Vrana Date: Tue, 28 May 2013 17:28:47 +0000 (-0700) Subject: Add Bzip2 export plugin X-Git-Tag: v3.7.1~31 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=5eb3eaa06e7e21cab3318f68cf44516487a5d7b6;p=adminer.git Add Bzip2 export plugin --- diff --git a/adminer/plugin.php b/adminer/plugin.php index d6a7f9a3..d948600f 100644 --- a/adminer/plugin.php +++ b/adminer/plugin.php @@ -12,6 +12,7 @@ function adminer_object() { // specify enabled plugins here new AdminerDatabaseHide(array('information_schema')), new AdminerDumpJson, + new AdminerDumpBz2, new AdminerDumpZip, new AdminerDumpXml, new AdminerDumpAlter, diff --git a/plugins/dump-bz2.php b/plugins/dump-bz2.php new file mode 100644 index 00000000..9fa03ca2 --- /dev/null +++ b/plugins/dump-bz2.php @@ -0,0 +1,41 @@ + 'bzip2'); + } + + function _bz2($string, $state) { + bzwrite($this->fp, $string); + if ($state & PHP_OUTPUT_HANDLER_END) { + bzclose($this->fp); + $return = file_get_contents($this->filename); + unlink($this->filename); + return $return; + } + return ""; + } + + function dumpHeaders($identifier, $multi_table = false) { + if ($_POST["output"] == "bz2") { + $this->filename = tempnam("", "bz2"); + $this->fp = bzopen($this->filename, 'w'); + header("Content-Type: application/x-bzip"); + ob_start(array($this, '_bz2'), 1e6); + } + } + +} diff --git a/plugins/dump-zip.php b/plugins/dump-zip.php index 07f39e96..e317deaa 100644 --- a/plugins/dump-zip.php +++ b/plugins/dump-zip.php @@ -35,8 +35,8 @@ class AdminerDumpZip { } function dumpHeaders($identifier, $multi_table = false) { - $this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]); if ($_POST["output"] == "zip") { + $this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]); header("Content-Type: application/zip"); ob_start(array($this, '_zip')); }