mirror of
https://github.com/vrana/adminer.git
synced 2025-08-30 17:50:00 +02:00
Refactor opening adminer.sql[.gz] file
This commit is contained in:
@@ -941,9 +941,11 @@ class Adminer {
|
|||||||
return $ext;
|
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() {
|
function importServerPath() {
|
||||||
return "adminer.sql";
|
return "adminer.sql";
|
||||||
}
|
}
|
||||||
|
@@ -21,12 +21,18 @@ if (!$error && $_POST) {
|
|||||||
if (!isset($_GET["import"])) {
|
if (!isset($_GET["import"])) {
|
||||||
$query = $_POST["query"];
|
$query = $_POST["query"];
|
||||||
} elseif ($_POST["webfile"]) {
|
} elseif ($_POST["webfile"]) {
|
||||||
$sql_file_path = $adminer->importServerPath();
|
$import_file_path = $adminer->importServerPath();
|
||||||
$fp = @fopen((file_exists($sql_file_path)
|
if (!$import_file_path) {
|
||||||
? $sql_file_path
|
$fp = false;
|
||||||
: "compress.zlib://$sql_file_path.gz"
|
} elseif (file_exists($import_file_path)) {
|
||||||
), "rb");
|
$fp = fopen($import_file_path, "rb");
|
||||||
$query = ($fp ? fread($fp, 1e6) : false);
|
} 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 {
|
} else {
|
||||||
$query = get_file("sql_file", true);
|
$query = get_file("sql_file", true);
|
||||||
}
|
}
|
||||||
@@ -249,10 +255,10 @@ if (!isset($_GET["import"])) {
|
|||||||
: lang('File uploads are disabled.')
|
: lang('File uploads are disabled.')
|
||||||
);
|
);
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
$importServerPath = $adminer->importServerPath();
|
$import_file_path = $adminer->importServerPath();
|
||||||
if ($importServerPath) {
|
if ($import_file_path) {
|
||||||
echo "<fieldset><legend>" . lang('From server') . "</legend><div>";
|
echo "<fieldset><legend>" . lang('From server') . "</legend><div>";
|
||||||
echo lang('Webserver file %s', "<code>" . h($importServerPath) . "$gz</code>");
|
echo lang('Webserver file %s', "<code>" . h($import_file_path) . "$gz</code>");
|
||||||
echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
|
echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
@@ -582,6 +582,7 @@ qsl('div').onclick = whisperClick;", "")
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importServerPath() {
|
function importServerPath() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function homepage() {
|
function homepage() {
|
||||||
|
Reference in New Issue
Block a user