]> git.joonet.de Git - adminer.git/commitdiff
Split SQL command and import
authorJakub Vrana <jakub@vrana.cz>
Fri, 2 Aug 2013 18:45:55 +0000 (11:45 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 2 Aug 2013 18:56:10 +0000 (11:56 -0700)
adminer/include/adminer.inc.php
adminer/include/connect.inc.php
adminer/sql.inc.php
changes.txt

index dcb98aa8178dfab22ed4057da77cdd8469c9cdcf..d5a9b7630a8987ec9c7f36a83ff73d5add139376 100644 (file)
@@ -769,7 +769,7 @@ username.form['auth[driver]'].onchange();
                } else {
                        $this->databasesPrint($missing);
                        if (DB == "" || !$missing) {
-                               echo "<p class='links'>" . (support("sql") ? "<a href='" . h(ME) . "sql='" . bold(isset($_GET["sql"])) . " title='" . lang('Import') . "'>" . lang('SQL command') . "</a>\n" : "") . "";
+                               echo "<p class='links'>" . (support("sql") ? "<a href='" . h(ME) . "sql='" . bold(isset($_GET["sql"]) && !isset($_GET["import"])) . ">" . lang('SQL command') . "</a>\n<a href='" . h(ME) . "import='" . bold(isset($_GET["import"])) . ">" . lang('Import') . "</a>\n" : "") . "";
                                if (support("dump")) {
                                        echo "<a href='" . h(ME) . "dump=" . urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]) . "' id='dump'" . bold(isset($_GET["dump"])) . ">" . lang('Dump') . "</a>\n";
                                }
index 907900ee11bd17a4838e68d7c7218d0789965d5e..d50dc8fa51f0e1f8bbdfcfdc747286fbf777b106 100644 (file)
@@ -67,6 +67,10 @@ function connect_error() {
 if (isset($_GET["status"])) {
        $_GET["variables"] = $_GET["status"];
 }
+if (isset($_GET["import"])) {
+       $_GET["sql"] = $_GET["import"];
+}
+
 if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]) || $_GET["script"] == "connect" || $_GET["script"] == "kill")) {
        if (DB != "" || $_GET["refresh"]) {
                restart_session();
index 4a5548f4deffe45b86d34fec9b40face2235f434..e58131549178f91f746987e40a71f0ab5403923c 100644 (file)
@@ -14,18 +14,19 @@ if (!$error && $_POST["clear"]) {
        redirect(remove_from_uri("history"));
 }
 
-page_header(lang('SQL command'), $error);
+page_header((isset($_GET["import"]) ? lang('Import') : lang('SQL command')), $error);
 
 if (!$error && $_POST) {
        $fp = false;
-       $query = $_POST["query"];
-       if ($_POST["webfile"]) {
+       if (!isset($_GET["import"])) {
+               $query = $_POST["query"];
+       } elseif ($_POST["webfile"]) {
                $fp = @fopen((file_exists("adminer.sql")
                        ? "adminer.sql"
                        : "compress.zlib://adminer.sql.gz"
                ), "rb");
                $query = ($fp ? fread($fp, 1e6) : false);
-       } elseif ($_FILES && $_FILES["sql_file"]["error"][0] != 4) { // 4 - UPLOAD_ERR_NO_FILE
+       } else {
                $query = get_file("sql_file", true);
        }
 
@@ -184,38 +185,41 @@ if (!$error && $_POST) {
 ?>
 
 <form action="" method="post" enctype="multipart/form-data" id="form">
-<p><?php
-$q = $_GET["sql"]; // overwrite $q from if ($_POST) to save memory
-if ($_POST) {
-       $q = $_POST["query"];
-} elseif ($_GET["history"] == "all") {
-       $q = $history;
-} elseif ($_GET["history"] != "") {
-       $q = $history[$_GET["history"]][0];
+<?php
+$execute = "<input type='submit' value='" . lang('Execute') . "' title='Ctrl+Enter'>";
+if (!isset($_GET["import"])) {
+       $q = $_GET["sql"]; // overwrite $q from if ($_POST) to save memory
+       if ($_POST) {
+               $q = $_POST["query"];
+       } elseif ($_GET["history"] == "all") {
+               $q = $history;
+       } elseif ($_GET["history"] != "") {
+               $q = $history[$_GET["history"]][0];
+       }
+       echo "<p>";
+       textarea("query", $q, 20);
+       echo ($_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n");
+       echo "<p>$execute\n";
+       
+} else {
+       echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
+       echo (ini_bool("file_uploads")
+               ? '<input type="file" name="sql_file[]" multiple> (&lt; ' . ini_get("upload_max_filesize") . 'B)' // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
+               : lang('File uploads are disabled.')
+       );
+       echo "\n$execute";
+       echo "</div></fieldset>\n";
+       echo "<fieldset><legend>" . lang('From server') . "</legend><div>";
+       echo lang('Webserver file %s', "<code>adminer.sql" . (extension_loaded("zlib") ? "[.gz]" : "") . "</code>");
+       echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
+       echo "</div></fieldset>\n";
+       echo "<p>";
 }
-textarea("query", $q, 20);
 
-echo ($_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n");
-?>
-<p>
-<input type="submit" value="<?php echo lang('Execute'); ?>" title="Ctrl+Enter">
-<?php
-echo checkbox("error_stops", 1, $_POST["error_stops"], lang('Stop on error')) . "\n";
+echo checkbox("error_stops", 1, ($_POST ? $_POST["error_stops"] : isset($_GET["import"])), lang('Stop on error')) . "\n";
 echo checkbox("only_errors", 1, $_POST["only_errors"], lang('Show only errors')) . "\n";
 
-echo "<p>" . (ini_bool("file_uploads")
-       ? lang('File upload') . ': <input type="file" name="sql_file[]" multiple'
-               . ($_FILES && $_FILES["sql_file"]["error"][0] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') // 4 - UPLOAD_ERR_NO_FILE
-               . '> (&lt; ' . ini_get("upload_max_filesize") . 'B)' // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
-       : lang('File uploads are disabled.')
-);
-
-print_fieldset("webfile", lang('From server'), $_POST["webfile"], "document.getElementById('form')['only_errors'].checked = true; ");
-echo lang('Webserver file %s', "<code>adminer.sql" . (extension_loaded("zlib") ? "[.gz]" : "") . "</code>");
-echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
-echo "</div></fieldset>\n";
-
-if ($history) {
+if (!isset($_GET["import"]) && $history) {
        print_fieldset("history", lang('History'), $_GET["history"] != "");
        for ($val = end($history); $val; $val = prev($history)) { // not array_reverse() to save memory
                $key = key($history);
index e9b030a29b2bcdd00284d42aac9e4f9970197047..94082215925d75234f350456ffad86060707caae 100644 (file)
@@ -1,6 +1,7 @@
 Adminer 4.0.0-dev:
 Driver for SimpleDB and Elasticsearch
 Save and continue edit by AJAX
+Split SQL command and import
 Add a new column in alter table on key press
 Mark length as required for strings
 Add label to database selection