1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-17 20:01:25 +02:00

Centralize dump_headers

This commit is contained in:
Jakub Vrana
2011-02-17 11:43:21 +01:00
parent b1d8bfba36
commit 8ab6fffe74
6 changed files with 22 additions and 14 deletions

View File

@@ -670,7 +670,6 @@ DROP PROCEDURE adminer_alter;
* @return string extension
*/
function dumpHeaders($identifier, $multi_table = false) {
$filename = ($identifier != "" ? friendly_url($identifier) : "adminer");
$output = $_POST["output"];
$ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
header("Content-Type: " .
@@ -679,14 +678,10 @@ DROP PROCEDURE adminer_alter;
($ext == "tar" ? "application/x-tar" :
($ext == "sql" || $output != "file" ? "text/plain" : "text/csv") . "; charset=utf-8"
))));
if ($output != "text") {
header("Content-Disposition: attachment; filename=$filename.$ext" . ($output != "file" && !ereg('[^0-9a-z]', $output) ? ".$output" : ""));
}
session_write_close();
if ($_POST["output"] == "bz2") {
if ($output == "bz2") {
ob_start('bzcompress', 1e6);
}
if ($_POST["output"] == "gz") {
if ($output == "gz") {
ob_start('gzencode', 1e6);
}
return $ext;

View File

@@ -754,6 +754,22 @@ function search_tables() {
echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
}
/** Send headers for export
* @param string
* @param bool
* @return string extension
*/
function dump_headers($identifier, $multi_table = false) {
global $adminer;
$return = $adminer->dumpHeaders($identifier, $multi_table);
$output = $_POST["output"];
if ($output != "text") {
header("Content-Disposition: attachment; filename=" . ($identifier != "" ? friendly_url($identifier) : "dump") . ".$return" . ($output != "file" && !ereg('[^0-9a-z]', $output) ? ".$output" : ""));
}
session_write_close();
return $return;
}
/** Print CSV row
* @param array
* @return null