mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
Use radio in export
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1160 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -143,9 +143,8 @@ if ($connection->server_info >= 5) {
|
||||
$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"]);
|
||||
|
@@ -430,6 +430,30 @@ class Adminer {
|
||||
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
|
||||
|
@@ -115,7 +115,8 @@ DROP PROCEDURE adminer_alter;
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -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);
|
||||
|
@@ -225,5 +225,4 @@ $translations = array(
|
||||
'Editor' => 'Editor',
|
||||
'Webserver file %s' => 'Soubor %s na webovém serveru',
|
||||
'File does not exist.' => 'Soubor neexistuje.',
|
||||
'Compression' => 'Komprese',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'Subject' => 'Кому',
|
||||
'Send' => 'Послать',
|
||||
'%d e-mail(s) have been sent.' => array('Было отправлено %d письмо.', 'Было отправлено %d письма.', 'Было отправлено %d писем.'),
|
||||
'Compression' => 'Сжатие',
|
||||
'Webserver file %s' => 'Файл %s на вебсервере',
|
||||
'File does not exist.' => 'Такого файла не существует.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'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.',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'Subject' => '主題',
|
||||
'Send' => '發送',
|
||||
'%d e-mail(s) have been sent.' => '已發送 %d 封郵件。',
|
||||
'Compression' => '壓縮',
|
||||
'Webserver file %s' => '網頁伺服器檔案 %s',
|
||||
'File does not exist.' => '檔案不存在',
|
||||
);
|
||||
|
@@ -223,7 +223,6 @@ $translations = array(
|
||||
'Subject' => '主题',
|
||||
'Send' => '发送',
|
||||
'%d e-mail(s) have been sent.' => '%d 封邮件已发送。',
|
||||
'Compression' => '压缩',
|
||||
'Webserver file %s' => 'Web服务器文件 %s',
|
||||
'File does not exist.' => '文件不存在',
|
||||
);
|
||||
|
@@ -262,7 +262,8 @@ if (!$columns) {
|
||||
|
||||
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);
|
||||
|
@@ -48,7 +48,7 @@ if (!$error && $_POST) {
|
||||
$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;
|
||||
|
@@ -406,6 +406,14 @@ ORDER BY ORDINAL_POSITION");
|
||||
return $return;
|
||||
}
|
||||
|
||||
function dumpOutput($select) {
|
||||
return "";
|
||||
}
|
||||
|
||||
function dumpFormat($select) {
|
||||
return "CSV";
|
||||
}
|
||||
|
||||
function navigation($missing) {
|
||||
global $VERSION;
|
||||
?>
|
||||
|
@@ -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 = "";
|
||||
|
Reference in New Issue
Block a user