diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index a03689d7..9f1c46e4 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -941,9 +941,11 @@ class Adminer { return $ext; } - /** Set the path of the file for webserver load - * @return string path of the sql dump file - */ + /** + * Gets the path of the file for webserver load. + * + * @return string Path of the sql import file. + */ function importServerPath() { return "adminer.sql"; } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 6828ce28..3470c6bd 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -21,12 +21,18 @@ if (!$error && $_POST) { if (!isset($_GET["import"])) { $query = $_POST["query"]; } elseif ($_POST["webfile"]) { - $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); + $import_file_path = $adminer->importServerPath(); + if (!$import_file_path) { + $fp = false; + } elseif (file_exists($import_file_path)) { + $fp = fopen($import_file_path, "rb"); + } elseif (file_exists("$import_file_path.gz")) { + $fp = fopen("compress.zlib://$import_file_path.gz", "rb"); + } else { + $fp = false; + } + + $query = $fp ? fread($fp, 1e6) : false; } else { $query = get_file("sql_file", true); } @@ -249,10 +255,10 @@ if (!isset($_GET["import"])) { : lang('File uploads are disabled.') ); echo "\n"; - $importServerPath = $adminer->importServerPath(); - if ($importServerPath) { + $import_file_path = $adminer->importServerPath(); + if ($import_file_path) { echo "
" . lang('From server') . "
"; - echo lang('Webserver file %s', "" . h($importServerPath) . "$gz"); + echo lang('Webserver file %s', "" . h($import_file_path) . "$gz"); echo ' '; echo "
\n"; } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index dd6ae607..5856b717 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -582,6 +582,7 @@ qsl('div').onclick = whisperClick;", "") } function importServerPath() { + return null; } function homepage() {