Simplify initializing post variables
This commit is contained in:
parent
e99463b295
commit
a09916737e
|
@ -14,9 +14,9 @@ if ($TABLE != "") {
|
||||||
$orig_fields = fields($TABLE);
|
$orig_fields = fields($TABLE);
|
||||||
$orig_status = table_status($TABLE);
|
$orig_status = table_status($TABLE);
|
||||||
}
|
}
|
||||||
if ($_POST && !$_POST["fields"]) {
|
|
||||||
$_POST["fields"] = array();
|
$row = $_POST;
|
||||||
}
|
$row["fields"] = (array) $row["fields"];
|
||||||
|
|
||||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
|
@ -26,18 +26,18 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||||
$all_fields = array();
|
$all_fields = array();
|
||||||
$use_all_fields = false;
|
$use_all_fields = false;
|
||||||
$foreign = array();
|
$foreign = array();
|
||||||
ksort($_POST["fields"]);
|
ksort($row["fields"]);
|
||||||
$orig_field = reset($orig_fields);
|
$orig_field = reset($orig_fields);
|
||||||
$after = " FIRST";
|
$after = " FIRST";
|
||||||
|
|
||||||
foreach ($_POST["fields"] as $key => $field) {
|
foreach ($row["fields"] as $key => $field) {
|
||||||
$foreign_key = $foreign_keys[$field["type"]];
|
$foreign_key = $foreign_keys[$field["type"]];
|
||||||
$type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type
|
$type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type
|
||||||
if ($field["field"] != "") {
|
if ($field["field"] != "") {
|
||||||
if (!$field["has_default"]) {
|
if (!$field["has_default"]) {
|
||||||
$field["default"] = null;
|
$field["default"] = null;
|
||||||
}
|
}
|
||||||
if ($key == $_POST["auto_increment_col"]) {
|
if ($key == $row["auto_increment_col"]) {
|
||||||
$field["auto_increment"] = true;
|
$field["auto_increment"] = true;
|
||||||
}
|
}
|
||||||
$process_field = process_field($field, $type_field);
|
$process_field = process_field($field, $type_field);
|
||||||
|
@ -65,17 +65,17 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||||
}
|
}
|
||||||
|
|
||||||
$partitioning = "";
|
$partitioning = "";
|
||||||
if (in_array($_POST["partition_by"], $partition_by)) {
|
if (in_array($row["partition_by"], $partition_by)) {
|
||||||
$partitions = array();
|
$partitions = array();
|
||||||
if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
|
if ($row["partition_by"] == 'RANGE' || $row["partition_by"] == 'LIST') {
|
||||||
foreach (array_filter($_POST["partition_names"]) as $key => $val) {
|
foreach (array_filter($row["partition_names"]) as $key => $val) {
|
||||||
$value = $_POST["partition_values"][$key];
|
$value = $row["partition_values"][$key];
|
||||||
$partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
|
$partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($row["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$partitioning .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
|
$partitioning .= "\nPARTITION BY $row[partition_by]($row[partition])" . ($partitions // $row["partition"] can be expression, not only column
|
||||||
? " (" . implode(",", $partitions) . "\n)"
|
? " (" . implode(",", $partitions) . "\n)"
|
||||||
: ($_POST["partitions"] ? " PARTITIONS " . (+$_POST["partitions"]) : "")
|
: ($row["partitions"] ? " PARTITIONS " . (+$row["partitions"]) : "")
|
||||||
);
|
);
|
||||||
} elseif (support("partitioning") && ereg("partitioned", $orig_status["Create_options"])) {
|
} elseif (support("partitioning") && ereg("partitioned", $orig_status["Create_options"])) {
|
||||||
$partitioning .= "\nREMOVE PARTITIONING";
|
$partitioning .= "\nREMOVE PARTITIONING";
|
||||||
|
@ -83,20 +83,20 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||||
|
|
||||||
$message = lang('Table has been altered.');
|
$message = lang('Table has been altered.');
|
||||||
if ($TABLE == "") {
|
if ($TABLE == "") {
|
||||||
cookie("adminer_engine", $_POST["Engine"]);
|
cookie("adminer_engine", $row["Engine"]);
|
||||||
$message = lang('Table has been created.');
|
$message = lang('Table has been created.');
|
||||||
}
|
}
|
||||||
$name = trim($_POST["name"]);
|
$name = trim($row["name"]);
|
||||||
|
|
||||||
queries_redirect(ME . "table=" . urlencode($name), $message, alter_table(
|
queries_redirect(ME . "table=" . urlencode($name), $message, alter_table(
|
||||||
$TABLE,
|
$TABLE,
|
||||||
$name,
|
$name,
|
||||||
($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields),
|
($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields),
|
||||||
$foreign,
|
$foreign,
|
||||||
$_POST["Comment"],
|
$row["Comment"],
|
||||||
($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? $_POST["Engine"] : ""),
|
($row["Engine"] && $row["Engine"] != $orig_status["Engine"] ? $row["Engine"] : ""),
|
||||||
($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? $_POST["Collation"] : ""),
|
($row["Collation"] && $row["Collation"] != $orig_status["Collation"] ? $row["Collation"] : ""),
|
||||||
($_POST["Auto_increment"] != "" ? +$_POST["Auto_increment"] : ""),
|
($row["Auto_increment"] != "" ? +$row["Auto_increment"] : ""),
|
||||||
$partitioning
|
$partitioning
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -104,14 +104,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||||
|
|
||||||
page_header(($TABLE != "" ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
|
page_header(($TABLE != "" ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
|
||||||
|
|
||||||
$row = array(
|
|
||||||
"Engine" => $_COOKIE["adminer_engine"],
|
|
||||||
"fields" => array(array("field" => "", "type" => (isset($types["int"]) ? "int" : (isset($types["integer"]) ? "integer" : "")))),
|
|
||||||
"partition_names" => array(""),
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$row = $_POST;
|
|
||||||
if ($row["auto_increment_col"]) {
|
if ($row["auto_increment_col"]) {
|
||||||
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
|
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +134,13 @@ if ($_POST) {
|
||||||
}
|
}
|
||||||
$row["partition_names"][] = "";
|
$row["partition_names"][] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$row = array(
|
||||||
|
"Engine" => $_COOKIE["adminer_engine"],
|
||||||
|
"fields" => array(array("field" => "", "type" => (isset($types["int"]) ? "int" : (isset($types["integer"]) ? "integer" : "")))),
|
||||||
|
"partition_names" => array(""),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$collations = collations();
|
$collations = collations();
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
|
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
|
||||||
restart_session();
|
restart_session();
|
||||||
$name = trim($_POST["name"]);
|
$name = trim($row["name"]);
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
$_GET["db"] = ""; // to save in global history
|
$_GET["db"] = ""; // to save in global history
|
||||||
queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
|
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
|
// create or rename database
|
||||||
if (DB != "") {
|
if (DB != "") {
|
||||||
$_GET["db"] = $name;
|
$_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 {
|
} else {
|
||||||
$databases = explode("\n", str_replace("\r", "", $name));
|
$databases = explode("\n", str_replace("\r", "", $name));
|
||||||
$success = true;
|
$success = true;
|
||||||
$last = "";
|
$last = "";
|
||||||
foreach ($databases as $db) {
|
foreach ($databases as $db) {
|
||||||
if (count($databases) == 1 || $db != "") { // ignore empty lines but always try to create single database
|
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;
|
$success = false;
|
||||||
}
|
}
|
||||||
$last = $db;
|
$last = $db;
|
||||||
|
@ -26,10 +28,10 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// alter database
|
// alter database
|
||||||
if (!$_POST["collation"]) {
|
if (!$row["collation"]) {
|
||||||
redirect(substr(ME, 0, -1));
|
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();
|
$collations = collations();
|
||||||
$name = DB;
|
$name = DB;
|
||||||
$collate = null;
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$name = $_POST["name"];
|
$name = $row["name"];
|
||||||
$collate = $_POST["collation"];
|
|
||||||
} elseif (DB != "") {
|
} elseif (DB != "") {
|
||||||
$collate = db_collation(DB, $collations);
|
$row["collation"] = db_collation(DB, $collations);
|
||||||
} elseif ($jush == "sql") {
|
} elseif ($jush == "sql") {
|
||||||
// propose database name with limited privileges
|
// propose database name with limited privileges
|
||||||
foreach (get_vals("SHOW GRANTS") as $grant) {
|
foreach (get_vals("SHOW GRANTS") as $grant) {
|
||||||
|
@ -60,7 +60,7 @@ if ($_POST) {
|
||||||
echo ($_POST["add_x"] || strpos($name, "\n")
|
echo ($_POST["add_x"] || strpos($name, "\n")
|
||||||
? '<textarea id="name" name="name" rows="10" cols="40">' . h($name) . '</textarea><br>'
|
? '<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">'
|
: '<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>
|
<script type='text/javascript'>focus(document.getElementById('name'));</script>
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
|
|
|
@ -2,32 +2,32 @@
|
||||||
$EVENT = $_GET["event"];
|
$EVENT = $_GET["event"];
|
||||||
$intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
|
$intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
|
||||||
$statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
|
$statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
|
query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
|
||||||
} elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
|
} elseif (in_array($row["INTERVAL_FIELD"], $intervals) && isset($statuses[$row["STATUS"]])) {
|
||||||
$schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
|
$schedule = "\nON SCHEDULE " . ($row["INTERVAL_VALUE"]
|
||||||
? "EVERY " . q($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
|
? "EVERY " . q($row["INTERVAL_VALUE"]) . " $row[INTERVAL_FIELD]"
|
||||||
. ($_POST["STARTS"] ? " STARTS " . q($_POST["STARTS"]) : "")
|
. ($row["STARTS"] ? " STARTS " . q($row["STARTS"]) : "")
|
||||||
. ($_POST["ENDS"] ? " ENDS " . q($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
|
. ($row["ENDS"] ? " ENDS " . q($row["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
|
||||||
: "AT " . q($_POST["STARTS"])
|
: "AT " . q($row["STARTS"])
|
||||||
) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
|
) . " ON COMPLETION" . ($row["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
|
||||||
;
|
;
|
||||||
|
|
||||||
queries_redirect(substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')), queries(($EVENT != ""
|
queries_redirect(substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')), queries(($EVENT != ""
|
||||||
? "ALTER EVENT " . idf_escape($EVENT) . $schedule
|
? "ALTER EVENT " . idf_escape($EVENT) . $schedule
|
||||||
. ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
|
. ($EVENT != $row["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($row["EVENT_NAME"]) : "")
|
||||||
: "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
|
: "CREATE EVENT " . idf_escape($row["EVENT_NAME"]) . $schedule
|
||||||
) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . q($_POST["EVENT_COMMENT"])
|
) . "\n" . $statuses[$row["STATUS"]] . " COMMENT " . q($row["EVENT_COMMENT"])
|
||||||
. rtrim(" DO\n$_POST[EVENT_DEFINITION]", ";") . ";"
|
. rtrim(" DO\n$row[EVENT_DEFINITION]", ";") . ";"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
|
page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
|
||||||
|
|
||||||
$row = $_POST;
|
|
||||||
if (!$row && $EVENT != "") {
|
if (!$row && $EVENT != "") {
|
||||||
$rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
|
$rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
|
||||||
$row = reset($rows);
|
$row = reset($rows);
|
||||||
|
|
|
@ -1,41 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
$TABLE = $_GET["foreign"];
|
$TABLE = $_GET["foreign"];
|
||||||
|
$name = $_GET["name"];
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
query_redirect("ALTER TABLE " . table($TABLE) . "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.'));
|
query_redirect("ALTER TABLE " . table($TABLE) . "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.'));
|
||||||
} else {
|
} else {
|
||||||
$source = array_filter($_POST["source"], 'strlen');
|
$source = array_filter($row["source"], 'strlen');
|
||||||
ksort($source); // enforce input order
|
ksort($source); // enforce input order
|
||||||
$target = array();
|
$target = array();
|
||||||
foreach ($source as $key => $val) {
|
foreach ($source as $key => $val) {
|
||||||
$target[$key] = $_POST["target"][$key];
|
$target[$key] = $row["target"][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
query_redirect("ALTER TABLE " . table($TABLE)
|
query_redirect("ALTER TABLE " . table($TABLE)
|
||||||
. ($_GET["name"] != "" ? "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($_GET["name"]) . "," : "")
|
. ($name != "" ? "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name) . "," : "")
|
||||||
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . table($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" //! reuse $_GET["name"] - check in older MySQL versions
|
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . table($row["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" //! reuse $name - check in older MySQL versions
|
||||||
. (ereg("^($on_actions)\$", $_POST["on_delete"]) ? " ON DELETE $_POST[on_delete]" : "")
|
. (ereg("^($on_actions)\$", $row["on_delete"]) ? " ON DELETE $row[on_delete]" : "")
|
||||||
. (ereg("^($on_actions)\$", $_POST["on_update"]) ? " ON UPDATE $_POST[on_update]" : "")
|
. (ereg("^($on_actions)\$", $row["on_update"]) ? " ON UPDATE $row[on_update]" : "")
|
||||||
, ME . "table=" . urlencode($TABLE), ($_GET["name"] != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
, ME . "table=" . urlencode($TABLE), ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||||
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
|
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header(lang('Foreign key'), $error, array("table" => $TABLE), $TABLE);
|
page_header(lang('Foreign key'), $error, array("table" => $TABLE), $TABLE);
|
||||||
|
|
||||||
$row = array("table" => $TABLE, "source" => array(""));
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$row = $_POST;
|
|
||||||
ksort($row["source"]);
|
ksort($row["source"]);
|
||||||
if ($_POST["add"]) {
|
if ($_POST["add"]) {
|
||||||
$row["source"][] = "";
|
$row["source"][] = "";
|
||||||
} elseif ($_POST["change"] || $_POST["change-js"]) {
|
} elseif ($_POST["change"] || $_POST["change-js"]) {
|
||||||
$row["target"] = array();
|
$row["target"] = array();
|
||||||
}
|
}
|
||||||
} elseif ($_GET["name"] != "") {
|
} elseif ($name != "") {
|
||||||
$foreign_keys = foreign_keys($TABLE);
|
$foreign_keys = foreign_keys($TABLE);
|
||||||
$row = $foreign_keys[$_GET["name"]];
|
$row = $foreign_keys[$name];
|
||||||
$row["source"][] = "";
|
$row["source"][] = "";
|
||||||
|
} else {
|
||||||
|
$row["table"] = $TABLE;
|
||||||
|
$row["source"] = array("");
|
||||||
}
|
}
|
||||||
|
|
||||||
$source = array_keys(fields($TABLE)); //! no text and blob
|
$source = array_keys(fields($TABLE)); //! no text and blob
|
||||||
|
@ -69,6 +73,6 @@ foreach ($row["source"] as $key => $val) {
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
<noscript><p><input type="submit" name="add" value="<?php echo lang('Add column'); ?>"></noscript>
|
<noscript><p><input type="submit" name="add" value="<?php echo lang('Add column'); ?>"></noscript>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($_GET["name"] != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
|
<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
|
||||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -10,10 +10,11 @@ if ($jush == "sqlite") { // doesn't support primary key
|
||||||
unset($index_types[0]);
|
unset($index_types[0]);
|
||||||
unset($indexes[""]);
|
unset($indexes[""]);
|
||||||
}
|
}
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error && !$_POST["add"]) {
|
if ($_POST && !$error && !$_POST["add"]) {
|
||||||
$alter = array();
|
$alter = array();
|
||||||
foreach ($_POST["indexes"] as $index) {
|
foreach ($row["indexes"] as $index) {
|
||||||
$name = $index["name"];
|
$name = $index["name"];
|
||||||
if (in_array($index["type"], $index_types)) {
|
if (in_array($index["type"], $index_types)) {
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
@ -58,9 +59,6 @@ if ($_POST && !$error && !$_POST["add"]) {
|
||||||
page_header(lang('Indexes'), $error, array("table" => $TABLE), $TABLE);
|
page_header(lang('Indexes'), $error, array("table" => $TABLE), $TABLE);
|
||||||
|
|
||||||
$fields = array_keys(fields($TABLE));
|
$fields = array_keys(fields($TABLE));
|
||||||
$row = array("indexes" => $indexes);
|
|
||||||
if ($_POST) {
|
|
||||||
$row = $_POST;
|
|
||||||
if ($_POST["add"]) {
|
if ($_POST["add"]) {
|
||||||
foreach ($row["indexes"] as $key => $index) {
|
foreach ($row["indexes"] as $key => $index) {
|
||||||
if ($index["columns"][count($index["columns"])] != "") {
|
if ($index["columns"][count($index["columns"])] != "") {
|
||||||
|
@ -72,12 +70,13 @@ if ($_POST) {
|
||||||
$row["indexes"][] = array("columns" => array(1 => ""));
|
$row["indexes"][] = array("columns" => array(1 => ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (!$row) {
|
||||||
foreach ($row["indexes"] as $key => $index) {
|
foreach ($indexes as $key => $index) {
|
||||||
$row["indexes"][$key]["name"] = $key;
|
$indexes[$key]["name"] = $key;
|
||||||
$row["indexes"][$key]["columns"][] = "";
|
$indexes[$key]["columns"][] = "";
|
||||||
}
|
}
|
||||||
$row["indexes"][] = array("columns" => array(1 => ""));
|
$indexes[] = array("columns" => array(1 => ""));
|
||||||
|
$row["indexes"] = $indexes;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
$link = preg_replace('~ns=[^&]*&~', '', ME) . "ns=";
|
$link = preg_replace('~ns=[^&]*&~', '', ME) . "ns=";
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
query_redirect("DROP SCHEMA " . idf_escape($_GET["ns"]), $link, lang('Schema has been dropped.'));
|
query_redirect("DROP SCHEMA " . idf_escape($_GET["ns"]), $link, lang('Schema has been dropped.'));
|
||||||
} else {
|
} else {
|
||||||
$name = trim($_POST["name"]);
|
$name = trim($row["name"]);
|
||||||
$link .= urlencode($name);
|
$link .= urlencode($name);
|
||||||
if ($_GET["ns"] == "") {
|
if ($_GET["ns"] == "") {
|
||||||
query_redirect("CREATE SCHEMA " . idf_escape($name), $link, lang('Schema has been created.'));
|
query_redirect("CREATE SCHEMA " . idf_escape($name), $link, lang('Schema has been created.'));
|
||||||
|
@ -18,9 +20,8 @@ if ($_POST && !$error) {
|
||||||
|
|
||||||
page_header($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema'), $error);
|
page_header($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema'), $error);
|
||||||
|
|
||||||
$row = $_POST;
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$row = array("name" => $_GET["ns"]);
|
$row["name"] = $_GET["ns"];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
$SEQUENCE = $_GET["sequence"];
|
$SEQUENCE = $_GET["sequence"];
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
$link = substr(ME, 0, -1);
|
$link = substr(ME, 0, -1);
|
||||||
$name = trim($_POST["name"]);
|
$name = trim($row["name"]);
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
query_redirect("DROP SEQUENCE " . idf_escape($SEQUENCE), $link, lang('Sequence has been dropped.'));
|
query_redirect("DROP SEQUENCE " . idf_escape($SEQUENCE), $link, lang('Sequence has been dropped.'));
|
||||||
} elseif ($SEQUENCE == "") {
|
} elseif ($SEQUENCE == "") {
|
||||||
|
@ -17,9 +18,8 @@ if ($_POST && !$error) {
|
||||||
|
|
||||||
page_header($SEQUENCE != "" ? lang('Alter sequence') . ": " . h($SEQUENCE) : lang('Create sequence'), $error);
|
page_header($SEQUENCE != "" ? lang('Alter sequence') . ": " . h($SEQUENCE) : lang('Create sequence'), $error);
|
||||||
|
|
||||||
$row = $_POST;
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$row = array("name" => $SEQUENCE);
|
$row["name"] = $SEQUENCE;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
$TYPE = $_GET["type"];
|
$TYPE = $_GET["type"];
|
||||||
|
$row = $_POST;
|
||||||
|
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
$link = substr(ME, 0, -1);
|
$link = substr(ME, 0, -1);
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
query_redirect("DROP TYPE " . idf_escape($TYPE), $link, lang('Type has been dropped.'));
|
query_redirect("DROP TYPE " . idf_escape($TYPE), $link, lang('Type has been dropped.'));
|
||||||
} else {
|
} else {
|
||||||
query_redirect("CREATE TYPE " . idf_escape(trim($_POST["name"])) . " $_POST[as]", $link, lang('Type has been created.'));
|
query_redirect("CREATE TYPE " . idf_escape(trim($row["name"])) . " $row[as]", $link, lang('Type has been created.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header($TYPE != "" ? lang('Alter type') . ": " . h($TYPE) : lang('Create type'), $error);
|
page_header($TYPE != "" ? lang('Alter type') . ": " . h($TYPE) : lang('Create type'), $error);
|
||||||
|
|
||||||
$row = $_POST;
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$row = array("as" => "AS ");
|
$row["as"] = "AS ";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue