Bzip2 compression
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1036 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
2f272b05e0
commit
702e949d30
|
@ -146,6 +146,7 @@ DROP PROCEDURE adminer_drop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dump();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +165,7 @@ if ($dbh->server_info >= 5) {
|
||||||
}
|
}
|
||||||
echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>$dump_output\n"; // token is not needed but checked in bootstrap for all POST data
|
echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>$dump_output\n"; // token is not needed but checked in bootstrap for all POST data
|
||||||
echo "<tr><th>" . lang('Format') . "<td>$dump_format\n";
|
echo "<tr><th>" . lang('Format') . "<td>$dump_format\n";
|
||||||
echo "<tr><th>" . lang('Compression') . "<td>" . ($dump_compress ? $dump_compress : lang('None of the supported PHP extensions (%s) are available.', 'zlib')) . "\n";
|
echo "<tr><th>" . lang('Compression') . "<td>" . ($dump_compress ? $dump_compress : lang('None of the supported PHP extensions (%s) are available.', 'zlib, bz2')) . "\n";
|
||||||
echo "<tr><th>" . lang('Database') . "<td><select name='db_style'>" . optionlist($db_style, (strlen($_GET["db"]) ? '' : 'CREATE')) . "</select>\n";
|
echo "<tr><th>" . lang('Database') . "<td><select name='db_style'>" . optionlist($db_style, (strlen($_GET["db"]) ? '' : 'CREATE')) . "</select>\n";
|
||||||
echo "<tr><th>" . lang('Tables') . "<td><select name='table_style'>" . optionlist($table_style, 'DROP+CREATE') . "</select>\n";
|
echo "<tr><th>" . lang('Tables') . "<td><select name='table_style'>" . optionlist($table_style, 'DROP+CREATE') . "</select>\n";
|
||||||
echo "<tr><th>" . lang('Data') . "<td><select name='data_style'>" . optionlist($data_style, 'INSERT') . "</select>\n";
|
echo "<tr><th>" . lang('Data') . "<td><select name='data_style'>" . optionlist($data_style, 'INSERT') . "</select>\n";
|
||||||
|
|
|
@ -127,39 +127,47 @@ function dump_data($table, $style, $select = "") {
|
||||||
$s = "\n($s)";
|
$s = "\n($s)";
|
||||||
if (!$buffer) {
|
if (!$buffer) {
|
||||||
$buffer = $insert . $s;
|
$buffer = $insert . $s;
|
||||||
|
} elseif (strlen($buffer) + 1 + strlen($s) < $max_packet) { // 1 - separator length
|
||||||
|
$buffer .= ",$s";
|
||||||
} else {
|
} else {
|
||||||
if (strlen($buffer) + 1 + strlen($s) < $max_packet) { // 1 - separator length
|
$buffer .= ";\n";
|
||||||
$buffer .= ",$s";
|
dump($buffer);
|
||||||
} else {
|
$buffer = $insert . $s;
|
||||||
dump("$buffer;\n");
|
|
||||||
$buffer = $insert . $s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_POST["format"] != "csv" && $style != "INSERT+UPDATE" && $buffer) {
|
if ($_POST["format"] != "csv" && $style != "INSERT+UPDATE" && $buffer) {
|
||||||
dump("$buffer;\n");
|
$buffer .= ";\n";
|
||||||
|
dump($buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dump_headers($identifier, $multi_table = false) {
|
function dump_headers($identifier, $multi_table = false) {
|
||||||
|
$compress = $_POST["compress"];
|
||||||
$filename = (strlen($identifier) ? friendly_url($identifier) : "dump");
|
$filename = (strlen($identifier) ? friendly_url($identifier) : "dump");
|
||||||
$ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
|
$ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
|
||||||
header("Content-Type: " . ($_POST["compress"] == "gz" ? "application/x-gzip" : ($ext == "tar" ? "application/x-tar" : ($ext == "sql" || $_POST["output"] != "file" ? "text/plain" : "text/csv")) . "; charset=utf-8"));
|
header("Content-Type: " .
|
||||||
if ($_POST["output"] == "file" || $_POST["compress"]) {
|
($compress == "bz2" ? "application/x-bzip" :
|
||||||
header("Content-Disposition: attachment; filename=$filename.$ext" . ($_POST["compress"] == "gz" ? ".gz" : ""));
|
($compress == "gz" ? "application/x-gzip" :
|
||||||
|
($ext == "tar" ? "application/x-tar" :
|
||||||
|
($ext == "sql" || $_POST["output"] != "file" ? "text/plain" : "text/csv") . "; charset=utf-8"
|
||||||
|
))));
|
||||||
|
if ($_POST["output"] == "file" || $compress) {
|
||||||
|
header("Content-Disposition: attachment; filename=$filename.$ext" . (ereg('[0-9a-z]', $compress) ? ".$compress" : ""));
|
||||||
}
|
}
|
||||||
return $ext;
|
return $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
$compress = array();
|
$compress = array();
|
||||||
if (function_exists('gzencode')) {
|
if (function_exists('gzencode')) {
|
||||||
$compress['gz'] = 'GZIP';
|
$compress['gz'] = 'gzip';
|
||||||
|
}
|
||||||
|
if (function_exists('bzcompress')) {
|
||||||
|
$compress['bz2'] = 'bzip2';
|
||||||
}
|
}
|
||||||
// bzcompress can't be called repetitively, bzopen requires temporary file
|
|
||||||
// ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
|
// ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
|
||||||
$dump_output = "<select name='output'>" . optionlist(array('text' => lang('open'), 'file' => lang('save'))) . "</select>";
|
$dump_output = "<select name='output'>" . optionlist(array('text' => lang('open'), 'file' => lang('save'))) . "</select>";
|
||||||
$dump_format = "<select name='format'>" . optionlist(array('sql' => 'SQL', 'csv' => 'CSV')) . "</select>";
|
$dump_format = "<select name='format'>" . optionlist(array('sql' => 'SQL', 'csv' => 'CSV')) . "</select>";
|
||||||
|
|
|
@ -360,9 +360,18 @@ function process_input($field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dump($string) {
|
function dump($string = null) { // null $string forces sending of buffer
|
||||||
if ($_POST["compress"] == "gz") {
|
static $buffer = ""; // used to improve compression and to allow GZ archives unpackable in Total Commander
|
||||||
echo gzencode($string);
|
if ($_POST["compress"]) {
|
||||||
|
$buffer .= $string;
|
||||||
|
if (!isset($string) || strlen($buffer) > 1e6) {
|
||||||
|
if ($_POST["compress"] == "bz2") {
|
||||||
|
echo bzcompress($buffer); // should not be called repeatedly but it would require whole buffer in memory or temporary file
|
||||||
|
} else {
|
||||||
|
echo gzencode($buffer);
|
||||||
|
}
|
||||||
|
$buffer = "";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
echo $string;
|
echo $string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
dump_data($_GET["select"], "INSERT", implode(" UNION ALL ", $union));
|
dump_data($_GET["select"], "INSERT", implode(" UNION ALL ", $union));
|
||||||
}
|
}
|
||||||
|
dump();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (!$adminer->selectEmailProcess($where)) {
|
if (!$adminer->selectEmailProcess($where)) {
|
||||||
|
|
Loading…
Reference in a new issue