Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Centralize dump_headers

  • Loading branch information...
commit 8ab6fffe7484133d635ba1c292b479bbf64e93e7 1 parent b1d8bfb
@vrana authored
View
2  adminer/dump.inc.php
@@ -7,7 +7,7 @@
$cookie .= "&$key=" . urlencode($_POST[$key]);
}
cookie("adminer_export", substr($cookie, 1));
- $ext = $adminer->dumpHeaders(($TABLE != "" ? $TABLE : DB), (DB == "" || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
+ $ext = dump_headers(($TABLE != "" ? $TABLE : DB), (DB == "" || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
$is_sql = ($_POST["format"] == "sql");
if ($is_sql) {
echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump
View
9 adminer/include/adminer.inc.php
@@ -670,7 +670,6 @@ function dumpData($table, $style, $query) {
* @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 @@ function dumpHeaders($identifier, $multi_table = false) {
($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
16 adminer/include/functions.inc.php
@@ -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
View
2  adminer/select.inc.php
@@ -54,7 +54,7 @@
}
}
if ($_POST["export"]) {
- $adminer->dumpHeaders($TABLE);
+ dump_headers($TABLE);
$adminer->dumpTable($TABLE, "");
if (!is_array($_POST["check"]) || $unselected === array()) {
$where2 = $where;
View
2  adminer/sql.inc.php
@@ -1,6 +1,6 @@
<?php
if (!$error && $_POST["export"]) {
- $adminer->dumpHeaders("sql");
+ dump_headers("sql");
$adminer->dumpTable("", "");
$adminer->dumpData("", "table", $_POST["query"]);
exit;
View
5 editor/include/adminer.inc.php
@@ -463,12 +463,9 @@ function dumpData($table, $style, $query) {
}
}
- function dumpHeaders($identifier) {
- $filename = ($identifier != "" ? friendly_url($identifier) : "dump");
+ function dumpHeaders($identifier, $multi_table = false) {
$ext = "csv";
header("Content-Type: text/csv; charset=utf-8");
- header("Content-Disposition: attachment; filename=$filename.$ext");
- session_write_close();
return $ext;
}
Please sign in to comment.
Something went wrong with that request. Please try again.