]> git.joonet.de Git - adminer.git/commitdiff
Add ability to override file name (path) when loading dump from webserver
authorAndrea Giacobino <no.andrea@gmail.com>
Wed, 27 Sep 2017 16:09:14 +0000 (18:09 +0200)
committerJakub Vrana <jakub@vrana.cz>
Tue, 23 Jan 2018 08:24:57 +0000 (09:24 +0100)
adminer/include/adminer.inc.php
adminer/sql.inc.php
editor/include/adminer.inc.php
plugins/plugin.php

index 720be4cc12046959bb78c24a7acb907fa01fa750..20e144631e3a9f5a814601c23bfabf6f64c6206b 100644 (file)
@@ -850,6 +850,13 @@ class Adminer {
                return $ext;
        }
 
+       /** Set the path of the file for webserver load
+       * @return string path of the sql dump file
+       */
+       function importServerPath() {
+               return "adminer.sql";
+       }
+
        /** Print homepage
        * @return bool whether to print default homepage
        */
index f218dc93ffa0939e764ff01369edaec9b30195e1..7f8e5d954bda61fdccb5ac0104d8e4a6f5d1449c 100644 (file)
@@ -21,9 +21,10 @@ if (!$error && $_POST) {
        if (!isset($_GET["import"])) {
                $query = $_POST["query"];
        } elseif ($_POST["webfile"]) {
-               $fp = @fopen((file_exists("adminer.sql")
-                       ? "adminer.sql"
-                       : "compress.zlib://adminer.sql.gz"
+               $sql_file_path = $adminer->importServerPath();
+               $fp = @fopen((file_exists($sql_file_path)
+                       ? $sql_file_path
+                       : "compress.zlib://{$sql_file_path}.gz"
                ), "rb");
                $query = ($fp ? fread($fp, 1e6) : false);
        } else {
@@ -220,7 +221,7 @@ if (!isset($_GET["import"])) {
        );
        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 lang('Webserver file %s', "<code>" . h($adminer->importServerPath()) . (extension_loaded("zlib") ? "[.gz]" : "") . "</code>");
        echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
        echo "</div></fieldset>\n";
        echo "<p>";
index 9131dba0f8bf082d8c9b2dae0bac1182506f0786..81907bcabba1a4e732fed5b6c3ab5baa937b2ce0 100644 (file)
@@ -549,6 +549,9 @@ qsl('div').onclick = whisperClick;", "")
                return $ext;
        }
 
+       function importServerPath() {
+       }
+
        function homepage() {
                return true;
        }
index a8bc0144c9b1f418bafaa0c89f75f8be44008176..0b1d1c329a5f90ee891391f97cade1ab9b04b7da 100644 (file)
@@ -347,6 +347,11 @@ class AdminerPlugin extends Adminer {
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
 
+       function importServerPath() {
+               $args = func_get_args();
+               return $this->_applyPlugin(__FUNCTION__, $args);
+       }
+
        function homepage() {
                $args = func_get_args();
                return $this->_applyPlugin(__FUNCTION__, $args);