Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use radio in export

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1160 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit e40612a46f194fd07ec788dc6a9aaa69563a5f5f 1 parent a8859fa
jakubvrana authored
View
5 adminer/dump.inc.php
@@ -143,9 +143,8 @@
$db_style[] = 'CREATE+ALTER';
$table_style[] = 'CREATE+ALTER';
}
-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('Compression') . "<td>" . ($dump_compress ? $dump_compress : lang('None of the supported PHP extensions (%s) are available.', 'zlib, bz2')) . "\n";
+echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data
+echo "<tr><th>" . lang('Format') . "<td>" . $adminer->dumpFormat(0) . "\n";
echo "<tr><th>" . lang('Database') . "<td><select name='db_style'>" . optionlist($db_style, (strlen(DB) ? '' : 'CREATE')) . "</select>\n";
if ($connection->server_info >= 5) {
$checked = strlen($_GET["dump"]);
View
24 adminer/include/adminer.inc.php
@@ -430,6 +430,30 @@ function processInput($field, $value, $function = "") {
return $return;
}
+ /** Returns export output options
+ * @param bool generate select (otherwise radio)
+ * @return string
+ */
+ function dumpOutput($select) {
+ $return = array('text' => lang('open'), 'file' => lang('save'));
+ if (function_exists('gzencode')) {
+ $return['gz'] = 'gzip';
+ }
+ if (function_exists('bzcompress')) {
+ $return['bz2'] = 'bzip2';
+ }
+ // ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
+ return html_select("output", $return, "text", $select);
+ }
+
+ /** Returns export format options
+ * @param bool generate select (otherwise radio)
+ * @return string
+ */
+ function dumpFormat($select) {
+ return html_select("format", array('sql' => 'SQL', 'csv' => 'CSV'), "sql", $select);
+ }
+
/** Prints navigation after Adminer title
* @param string can be "auth" if there is no database connection or "db" if there is no database selected
* @return null
View
28 adminer/include/export.inc.php
@@ -115,7 +115,8 @@ function dump_table($table, $style, $is_view = false) {
}
function dump_data($table, $style, $select = "") {
- global $connection, $max_packet;
+ global $connection;
+ $max_packet = 1048576; // default, minimum is 1024
if ($style) {
if ($_POST["format"] != "csv" && $style == "TRUNCATE+INSERT") {
dump("TRUNCATE " . idf_escape($table) . ";\n");
@@ -165,31 +166,18 @@ function dump_data($table, $style, $select = "") {
}
function dump_headers($identifier, $multi_table = false) {
- $compress = $_POST["compress"];
$filename = (strlen($identifier) ? friendly_url($identifier) : "dump");
+ $output = $_POST["output"];
$ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
header("Content-Type: " .
- ($compress == "bz2" ? "application/x-bzip" :
- ($compress == "gz" ? "application/x-gzip" :
+ ($output == "bz2" ? "application/x-bzip" :
+ ($output == "gz" ? "application/x-gzip" :
($ext == "tar" ? "application/x-tar" :
- ($ext == "sql" || $_POST["output"] != "file" ? "text/plain" : "text/csv") . "; charset=utf-8"
+ ($ext == "sql" || $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" : ""));
+ if ($output != "text") {
+ header("Content-Disposition: attachment; filename=$filename.$ext" . ($output != "file" && !ereg('[^0-9a-z]', $output) ? ".$output" : ""));
}
session_write_close();
return $ext;
}
-
-$compress = array();
-if (function_exists('gzencode')) {
- $compress['gz'] = 'gzip';
-}
-if (function_exists('bzcompress')) {
- $compress['bz2'] = 'bzip2';
-}
-// 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_format = "<select name='format'>" . optionlist(array('sql' => 'SQL', 'csv' => 'CSV')) . "</select>";
-$dump_compress = ($compress ? "<select name='compress'><option>" . optionlist($compress) . "</select>" : "");
-$max_packet = 1048576; // default, minimum is 1024
View
22 adminer/include/functions.inc.php
@@ -74,6 +74,24 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "") {
return (strlen($label) ? "<label for='checkbox-$id'>$return" . h($label) . "</label>" : $return);
}
+/** Generate HTML radio list
+* @param string
+* @param array
+* @param string
+* @param bool generate select (otherwise radio)
+* @return string
+*/
+function html_select($name, $options, $value, $select = true) {
+ if ($select) {
+ return "<select name='" . h($name) . "'>" . optionlist($options, $value) . "</select>";
+ }
+ $return = "";
+ foreach ($options as $key => $val) {
+ $return .= "<label><input type='radio' name='" . h($name) . "' value='" . h($key) . "'" . ($key == $value ? " checked" : "") . ">" . h($val) . "</label>";
+ }
+ return $return;
+}
+
/** Generate list of HTML options
* @param array array of strings or arrays (creates optgroup)
* @param mixed
@@ -457,10 +475,10 @@ function process_input($field) {
*/
function dump($string = null) { // null $string forces sending of buffer
static $buffer = ""; // used to improve compression and to allow GZ archives unpackable in Total Commander
- if ($_POST["compress"]) {
+ if (!ereg("text|file", $_POST["output"])) {
$buffer .= $string;
if (!isset($string) || strlen($buffer) > 1e6) {
- if ($_POST["compress"] == "bz2") {
+ if ($_POST["output"] == "bz2") {
echo bzcompress($buffer); // should not be called repeatedly but it would require whole buffer in memory or temporary file
} else {
echo gzencode($buffer);
View
1  adminer/lang/cs.inc.php
@@ -225,5 +225,4 @@
'Editor' => 'Editor',
'Webserver file %s' => 'Soubor %s na webovém serveru',
'File does not exist.' => 'Soubor neexistuje.',
- 'Compression' => 'Komprese',
);
View
1  adminer/lang/de.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Betreff',
'Send' => 'Abschicken',
'%d e-mail(s) have been sent.' => array('%d e-mail abgeschickt.', '%d e-mails abgeschickt.'),
- 'Compression' => 'Kompression',
'Webserver file %s' => 'Webserver Datei %s',
'File does not exist.' => 'Datei existiert nicht.',
);
View
1  adminer/lang/es.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Asunto',
'Send' => 'Enviar',
'%d e-mail(s) have been sent.' => array('%d email enviado.', '%d emails enviados.'),
- 'Compression' => 'Compresión',
'Webserver file %s' => 'Archivo de servidor web %s',
'File does not exist.' => 'Archivo no existe.',
);
View
1  adminer/lang/et.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Pealkiri',
'Send' => 'Saada',
'%d e-mail(s) have been sent.' => array('Saadetud kirju: %d.', 'Saadetud kirju: %d.'),
- 'Compression' => 'Kokkupakkimine',
'Webserver file %s' => 'Fail serveris: %s',
'File does not exist.' => 'Faili ei leitud.',
);
View
1  adminer/lang/fr.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Sujet',
'Send' => 'Envoyer',
'%d e-mail(s) have been sent.' => array('%d message a été envoyé.', '%d messages ont été envoyés.'),
- 'Compression' => 'Compression',
'Webserver file %s' => '%s fichier du serveur Web',
'File does not exist.' => 'Le fichier est introuvable.',
);
View
1  adminer/lang/it.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Oggetto',
'Send' => 'Invia',
'%d e-mail(s) have been sent.' => array('%d e-mail inviata.','%d e-mail inviate.'),
- 'Compression' => 'Compressione',
'Webserver file %s' => 'Webserver file %s',
'File does not exist.' => 'Il file non esiste.',
);
View
1  adminer/lang/nl.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Onderwerp',
'Send' => 'Verzenden',
'%d e-mail(s) have been sent.' => array('%d e-mail verzonden.', '%d e-mails verzonden.'),
- 'Compression' => 'Compressie',
'Webserver file %s' => 'Webserver bestand %s',
'File does not exist.' => 'Bestand niet gevonden.',
);
View
1  adminer/lang/ru.inc.php
@@ -223,7 +223,6 @@
'Subject' => 'Кому',
'Send' => 'Послать',
'%d e-mail(s) have been sent.' => array('Было отправлено %d письмо.', 'Было отправлено %d письма.', 'Было отправлено %d писем.'),
- 'Compression' => 'Сжатие',
'Webserver file %s' => 'Файл %s на вебсервере',
'File does not exist.' => 'Такого файла не существует.',
);
View
1  adminer/lang/sk.inc.php
@@ -223,7 +223,6 @@
'Maximum allowed file size is %sB.' => 'Maximálna povolená veľkosť súboru je %sB.',
'Clear' => 'Vyčistiť',
'Editor' => 'Editor',
- 'Compression' => 'Kompresia',
'Webserver file %s' => 'Súbor %s na webovom serveri',
'File does not exist.' => 'Súbor neexistuje.',
);
View
1  adminer/lang/zh-tw.inc.php
@@ -223,7 +223,6 @@
'Subject' => '主題',
'Send' => '發送',
'%d e-mail(s) have been sent.' => '已發送 %d 封郵件。',
- 'Compression' => '壓縮',
'Webserver file %s' => '網頁伺服器檔案 %s',
'File does not exist.' => '檔案不存在',
);
View
1  adminer/lang/zh.inc.php
@@ -223,7 +223,6 @@
'Subject' => '主题',
'Send' => '发送',
'%d e-mail(s) have been sent.' => '%d 封邮件已发送。',
- 'Compression' => '压缩',
'Webserver file %s' => 'Web服务器文件 %s',
'File does not exist.' => '文件不存在',
);
View
3  adminer/select.inc.php
@@ -262,7 +262,8 @@
echo (information_schema(DB) ? "" : "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' name='edit' value='" . lang('Edit') . "'> <input type='submit' name='clone' value='" . lang('Clone') . "'> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + (this.form['all'].checked ? $found_rows : form_checked(this, /check/)) + ')');\"></div></fieldset>\n");
print_fieldset("export", lang('Export'));
- echo "$dump_output $dump_format $dump_compress <input type='submit' name='export' value='" . lang('Export') . "'>\n";
+ echo $adminer->dumpOutput(1) . " " . $adminer->dumpFormat(1); // 1 - select
+ echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
echo "</div></fieldset>\n";
}
print_fieldset("import", lang('CSV Import'), !$result->num_rows);
View
2  adminer/sql.inc.php
@@ -48,7 +48,7 @@
$found = $match[0][0];
$offset = $match[0][1] + strlen($found);
if (!$found && $fp && !feof($fp)) {
- $query .= fread($fp, 1e6);
+ $query .= fread($fp, 1e5);
} else {
if (!$found && !strlen(rtrim($query))) {
break;
View
8 editor/include/adminer.inc.php
@@ -406,6 +406,14 @@ function processInput($field, $value, $function = "") {
return $return;
}
+ function dumpOutput($select) {
+ return "";
+ }
+
+ function dumpFormat($select) {
+ return "CSV";
+ }
+
function navigation($missing) {
global $VERSION;
?>
View
6 editor/include/export.inc.php
@@ -5,7 +5,7 @@ function dump_table($table) {
function dump_data($table, $style, $select = "") {
global $connection;
- $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)));
+ $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)), 1); // 1 - MYSQLI_USE_RESULT
if ($result) {
while ($row = $result->fetch_assoc()) {
dump_csv($row);
@@ -21,7 +21,3 @@ function dump_headers($identifier) {
session_write_close();
return $ext;
}
-
-$dump_output = "";
-$dump_format = "CSV";
-$dump_compress = "";
Please sign in to comment.
Something went wrong with that request. Please try again.