mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 01:54:00 +02:00
Simplify initializing post variables
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
$row = $_POST;
|
||||
|
||||
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
|
||||
restart_session();
|
||||
$name = trim($_POST["name"]);
|
||||
$name = trim($row["name"]);
|
||||
if ($_POST["drop"]) {
|
||||
$_GET["db"] = ""; // to save in global history
|
||||
queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
|
||||
@@ -9,14 +11,14 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
|
||||
// create or rename database
|
||||
if (DB != "") {
|
||||
$_GET["db"] = $name;
|
||||
queries_redirect(preg_replace('~db=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $_POST["collation"]));
|
||||
queries_redirect(preg_replace('~db=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
|
||||
} else {
|
||||
$databases = explode("\n", str_replace("\r", "", $name));
|
||||
$success = true;
|
||||
$last = "";
|
||||
foreach ($databases as $db) {
|
||||
if (count($databases) == 1 || $db != "") { // ignore empty lines but always try to create single database
|
||||
if (!create_database($db, $_POST["collation"])) {
|
||||
if (!create_database($db, $row["collation"])) {
|
||||
$success = false;
|
||||
}
|
||||
$last = $db;
|
||||
@@ -26,10 +28,10 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
|
||||
}
|
||||
} else {
|
||||
// alter database
|
||||
if (!$_POST["collation"]) {
|
||||
if (!$row["collation"]) {
|
||||
redirect(substr(ME, 0, -1));
|
||||
}
|
||||
query_redirect("ALTER DATABASE " . idf_escape($name) . (eregi('^[a-z0-9_]+$', $_POST["collation"]) ? " COLLATE $_POST[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
|
||||
query_redirect("ALTER DATABASE " . idf_escape($name) . (eregi('^[a-z0-9_]+$', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +39,10 @@ page_header(DB != "" ? lang('Alter database') : lang('Create database'), $error,
|
||||
|
||||
$collations = collations();
|
||||
$name = DB;
|
||||
$collate = null;
|
||||
if ($_POST) {
|
||||
$name = $_POST["name"];
|
||||
$collate = $_POST["collation"];
|
||||
$name = $row["name"];
|
||||
} elseif (DB != "") {
|
||||
$collate = db_collation(DB, $collations);
|
||||
$row["collation"] = db_collation(DB, $collations);
|
||||
} elseif ($jush == "sql") {
|
||||
// propose database name with limited privileges
|
||||
foreach (get_vals("SHOW GRANTS") as $grant) {
|
||||
@@ -60,7 +60,7 @@ if ($_POST) {
|
||||
echo ($_POST["add_x"] || strpos($name, "\n")
|
||||
? '<textarea id="name" name="name" rows="10" cols="40">' . h($name) . '</textarea><br>'
|
||||
: '<input name="name" id="name" value="' . h($name) . '" maxlength="64" autocapitalize="off">'
|
||||
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $collate) : "");
|
||||
) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $row["collation"]) : "");
|
||||
?>
|
||||
<script type='text/javascript'>focus(document.getElementById('name'));</script>
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
|
Reference in New Issue
Block a user