Substitute table name to $TABLE
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1047 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
e43156e863
commit
79d1902812
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
page_header(lang('Call') . ": " . h($_GET["call"]), $error);
|
||||
$PROCEDURE = $_GET["call"];
|
||||
page_header(lang('Call') . ": " . h($PROCEDURE), $error);
|
||||
|
||||
$routine = routine($_GET["call"], (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
|
||||
$routine = routine($PROCEDURE, (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
|
||||
$in = array();
|
||||
$out = array();
|
||||
foreach ($routine["fields"] as $i => $field) {
|
||||
|
@ -27,7 +28,7 @@ if (!$error && $_POST) {
|
|||
}
|
||||
$call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
|
||||
}
|
||||
$result = $dbh->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($_GET["call"]) . "(" . implode(", ", $call) . ")");
|
||||
$result = $dbh->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")");
|
||||
if (!$result) {
|
||||
echo "<p class='error'>" . h($dbh->error) . "\n";
|
||||
} else {
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
<?php
|
||||
$TABLE = $_GET["create"];
|
||||
$partition_by = array('HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY', 'RANGE', 'LIST');
|
||||
|
||||
$referencable_primary = referencable_primary($_GET["create"]);
|
||||
$referencable_primary = referencable_primary($TABLE);
|
||||
$foreign_keys = array();
|
||||
foreach ($referencable_primary as $table_name => $field) {
|
||||
$foreign_keys[idf_escape($table_name) . "." . idf_escape($field["field"])] = $table_name;
|
||||
}
|
||||
|
||||
if (strlen($_GET["create"])) {
|
||||
$orig_fields = fields($_GET["create"]);
|
||||
if (strlen($TABLE)) {
|
||||
$orig_fields = fields($TABLE);
|
||||
}
|
||||
|
||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||
$auto_increment_index = " PRIMARY KEY";
|
||||
// don't overwrite primary key by auto_increment
|
||||
if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment_col"]]["orig"])) {
|
||||
foreach (indexes($_GET["create"]) as $index) {
|
||||
if (strlen($TABLE) && strlen($_POST["fields"][$_POST["auto_increment_col"]]["orig"])) {
|
||||
foreach (indexes($TABLE) as $index) {
|
||||
foreach ($index["columns"] as $column) {
|
||||
if ($column === $_POST["fields"][$_POST["auto_increment_col"]]["orig"]) {
|
||||
$auto_increment_index = "";
|
||||
|
@ -33,17 +34,17 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||
foreach ($_POST["fields"] as $key => $field) {
|
||||
$type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
|
||||
if (strlen($field["field"]) && $type_field) {
|
||||
$fields[] = "\n" . (strlen($_GET["create"]) ? (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ") : " ")
|
||||
$fields[] = "\n" . (strlen($TABLE) ? (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ") : " ")
|
||||
. idf_escape($field["field"]) . process_type($type_field)
|
||||
. ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
|
||||
. (!$field["has_default"] || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $field["default"]) ? $field["default"] : $dbh->quote($field["default"])))
|
||||
. ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
|
||||
. " COMMENT " . $dbh->quote($field["comment"])
|
||||
. (strlen($_GET["create"]) ? " $after" : "")
|
||||
. (strlen($TABLE) ? " $after" : "")
|
||||
;
|
||||
$after = "AFTER " . idf_escape($field["field"]);
|
||||
if (!isset($types[$field["type"]])) {
|
||||
$fields[] = (strlen($_GET["create"]) ? " ADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")";
|
||||
$fields[] = (strlen($TABLE) ? " ADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")";
|
||||
}
|
||||
} elseif (strlen($field["orig"])) {
|
||||
$fields[] = "\nDROP " . idf_escape($field["orig"]);
|
||||
|
@ -66,12 +67,12 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||
? " (" . implode(",", $partitions) . "\n)"
|
||||
: ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
|
||||
);
|
||||
} elseif ($dbh->server_info >= 5.1 && strlen($_GET["create"])) {
|
||||
} elseif ($dbh->server_info >= 5.1 && strlen($TABLE)) {
|
||||
$status .= "\nREMOVE PARTITIONING";
|
||||
}
|
||||
$location = ME . "table=" . urlencode($_POST["name"]);
|
||||
if (strlen($_GET["create"])) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
||||
if (strlen($TABLE)) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
||||
} else {
|
||||
$path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
|
||||
setcookie("adminer_engine", $_POST["Engine"], gmmktime(0, 0, 0, gmdate("n") + 1), $path);
|
||||
|
@ -79,7 +80,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||
}
|
||||
}
|
||||
|
||||
page_header((strlen($_GET["create"]) ? lang('Alter table') : lang('Create table')), $error, array("table" => $_GET["create"]), $_GET["create"]);
|
||||
page_header((strlen($TABLE) ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
|
||||
|
||||
$engines = array();
|
||||
$result = $dbh->query("SHOW ENGINES");
|
||||
|
@ -100,9 +101,9 @@ if ($_POST) {
|
|||
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
|
||||
}
|
||||
process_fields($row["fields"]);
|
||||
} elseif (strlen($_GET["create"])) {
|
||||
$row = table_status($_GET["create"]);
|
||||
$row["name"] = $_GET["create"];
|
||||
} elseif (strlen($TABLE)) {
|
||||
$row = table_status($TABLE);
|
||||
$row["name"] = $TABLE;
|
||||
$row["fields"] = array();
|
||||
foreach ($orig_fields as $field) {
|
||||
$field["has_default"] = isset($field["default"]);
|
||||
|
@ -112,7 +113,7 @@ if ($_POST) {
|
|||
$row["fields"][] = $field;
|
||||
}
|
||||
if ($dbh->server_info >= 5.1) {
|
||||
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $dbh->quote(DB) . " AND TABLE_NAME = " . $dbh->quote($_GET["create"]);
|
||||
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $dbh->quote(DB) . " AND TABLE_NAME = " . $dbh->quote($TABLE);
|
||||
$result = $dbh->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
|
||||
list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
|
||||
$row["partition_names"] = array();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
$TABLE = $_GET["download"];
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Disposition: attachment; filename=" . friendly_url("$_GET[download]-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
|
||||
echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($_GET["download"]) . " WHERE " . where($_GET) . " LIMIT 1"));
|
||||
header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
|
||||
echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($TABLE) . " WHERE " . where($_GET) . " LIMIT 1"));
|
||||
exit; // don't output footer
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
$TABLE = $_GET["dump"];
|
||||
function tar_file($filename, $contents) {
|
||||
$return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
|
||||
$checksum = 8*32; // space for checksum itself
|
||||
|
@ -25,7 +26,7 @@ function dump_triggers($table, $style) {
|
|||
}
|
||||
|
||||
if ($_POST) {
|
||||
$ext = dump_headers((strlen($_GET["dump"]) ? $_GET["dump"] : DB), (!strlen(DB) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
|
||||
$ext = dump_headers((strlen($TABLE) ? $TABLE : DB), (!strlen(DB) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
|
||||
if ($_POST["format"] == "sql") {
|
||||
dump("SET NAMES utf8;
|
||||
SET foreign_key_checks = 0;
|
||||
|
@ -176,14 +177,14 @@ echo "<tr><th>" . lang('Data') . "<td><select name='data_style'>" . optionlist($
|
|||
<table cellspacing="0">
|
||||
<?php
|
||||
if (strlen(DB)) {
|
||||
$checked = (strlen($_GET["dump"]) ? "" : " checked");
|
||||
$checked = (strlen($TABLE) ? "" : " checked");
|
||||
echo "<thead><tr>";
|
||||
echo "<th style='text-align: left;'><label><input type='checkbox' id='check-tables'$checked onclick='form_check(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
|
||||
echo "<th style='text-align: right;'><label>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='form_check(this, /^data\\[/);'></label>";
|
||||
echo "</thead>\n";
|
||||
$views = "";
|
||||
foreach (table_status() as $row) {
|
||||
$checked = (strlen($_GET["dump"]) && $row["Name"] != $_GET["dump"] ? '' : " checked");
|
||||
$checked = (strlen($TABLE) && $row["Name"] != $TABLE ? '' : " checked");
|
||||
$print = "<tr><td><label><input type='checkbox' name='tables[]' value='" . h($row["Name"]) . "'$checked onclick=\"form_uncheck('check-tables');\">" . h($row["Name"]) . "</label>";
|
||||
if (!$row["Engine"]) {
|
||||
$views .= "$print\n";
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
$TABLE = $_GET["edit"];
|
||||
$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : "") : where($_GET));
|
||||
$update = (isset($_GET["select"]) ? $_POST["edit"] : $where);
|
||||
$fields = fields($_GET["edit"]);
|
||||
$fields = fields($TABLE);
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!isset($field["privileges"][$update ? "update" : "insert"]) || !strlen($adminer->fieldName($field))) {
|
||||
unset($fields[$name]);
|
||||
|
@ -10,7 +11,7 @@ foreach ($fields as $name => $field) {
|
|||
if ($_POST && !$error && !isset($_GET["select"])) {
|
||||
$location = $_SERVER["REQUEST_URI"]; // continue edit or insert
|
||||
if (!$_POST["insert"]) {
|
||||
$location = ME . "select=" . urlencode($_GET["edit"]);
|
||||
$location = ME . "select=" . urlencode($TABLE);
|
||||
$i = 0; // append &set converted to &where
|
||||
foreach ((array) $_GET["set"] as $key => $val) {
|
||||
if ($val == $_POST["fields"][$key]) {
|
||||
|
@ -29,17 +30,17 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
|||
redirect($location);
|
||||
}
|
||||
if ($update) {
|
||||
query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set) . "\nWHERE $where\nLIMIT 1", $location, lang('Item has been updated.'));
|
||||
query_redirect("UPDATE " . idf_escape($TABLE) . " SET" . implode(",", $set) . "\nWHERE $where\nLIMIT 1", $location, lang('Item has been updated.'));
|
||||
} else {
|
||||
query_redirect("INSERT INTO " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set), $location, lang('Item has been inserted.'));
|
||||
query_redirect("INSERT INTO " . idf_escape($TABLE) . " SET" . implode(",", $set), $location, lang('Item has been inserted.'));
|
||||
}
|
||||
}
|
||||
|
||||
$table_name = $adminer->tableName(table_status($_GET["edit"]));
|
||||
$table_name = $adminer->tableName(table_status($TABLE));
|
||||
page_header(
|
||||
($update ? lang('Edit') : lang('Insert')),
|
||||
$error,
|
||||
array("select" => array($_GET["edit"], $table_name)),
|
||||
array("select" => array($TABLE, $table_name)),
|
||||
$table_name
|
||||
);
|
||||
|
||||
|
@ -55,7 +56,7 @@ if ($_POST["save"]) {
|
|||
}
|
||||
$row = array();
|
||||
if ($select) {
|
||||
$result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($_GET["edit"]) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1"));
|
||||
$result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1"));
|
||||
$row = $result->fetch_assoc();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
$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");
|
||||
$statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
|
||||
|
||||
if ($_POST && !$error) {
|
||||
if ($_POST["drop"]) {
|
||||
query_redirect("DROP EVENT " . idf_escape($_GET["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"]])) {
|
||||
$schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
|
||||
? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
|
||||
|
@ -13,23 +14,23 @@ if ($_POST && !$error) {
|
|||
: "AT " . $dbh->quote($_POST["STARTS"])
|
||||
) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
|
||||
;
|
||||
query_redirect((strlen($_GET["event"])
|
||||
? "ALTER EVENT " . idf_escape($_GET["event"]) . $schedule
|
||||
. ($_GET["event"] != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
|
||||
query_redirect((strlen($EVENT)
|
||||
? "ALTER EVENT " . idf_escape($EVENT) . $schedule
|
||||
. ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
|
||||
: "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
|
||||
) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"])
|
||||
. " DO\n$_POST[EVENT_DEFINITION]"
|
||||
, substr(ME, 0, -1), (strlen($_GET["event"]) ? lang('Event has been altered.') : lang('Event has been created.')));
|
||||
, substr(ME, 0, -1), (strlen($EVENT) ? lang('Event has been altered.') : lang('Event has been created.')));
|
||||
}
|
||||
}
|
||||
|
||||
page_header((strlen($_GET["event"]) ? lang('Alter event') . ": " . h($_GET["event"]) : lang('Create event')), $error);
|
||||
page_header((strlen($EVENT) ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
|
||||
|
||||
$row = array();
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
} elseif (strlen($_GET["event"])) {
|
||||
$result = $dbh->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $dbh->quote(DB) . " AND EVENT_NAME = " . $dbh->quote($_GET["event"]));
|
||||
} elseif (strlen($EVENT)) {
|
||||
$result = $dbh->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $dbh->quote(DB) . " AND EVENT_NAME = " . $dbh->quote($EVENT));
|
||||
$row = $result->fetch_assoc();
|
||||
}
|
||||
?>
|
||||
|
@ -48,5 +49,5 @@ if ($_POST) {
|
|||
<p>
|
||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
<?php if (strlen($_GET["event"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
||||
<?php if (strlen($EVENT)) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
||||
</form>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
$TABLE = $_GET["foreign"];
|
||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
|
||||
if ($_POST["drop"]) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["foreign"]) . "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]), ME . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.'));
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.'));
|
||||
} else {
|
||||
$source = array_filter($_POST["source"], 'strlen');
|
||||
ksort($source); // enforce input order
|
||||
|
@ -9,19 +10,19 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
|
|||
foreach ($source as $key => $val) {
|
||||
$target[$key] = $_POST["target"][$key];
|
||||
}
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["foreign"])
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE)
|
||||
. (strlen($_GET["name"]) ? "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]) . "," : "")
|
||||
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . idf_escape($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")"
|
||||
. (in_array($_POST["on_delete"], $on_actions) ? " ON DELETE $_POST[on_delete]" : "")
|
||||
. (in_array($_POST["on_update"], $on_actions) ? " ON UPDATE $_POST[on_update]" : "")
|
||||
, ME . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||
, ME . "table=" . urlencode($TABLE), (strlen($_GET["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
|
||||
}
|
||||
}
|
||||
|
||||
page_header(lang('Foreign key'), $error, array("table" => $_GET["foreign"]), $_GET["foreign"]);
|
||||
page_header(lang('Foreign key'), $error, array("table" => $TABLE), $TABLE);
|
||||
|
||||
$row = array("table" => $_GET["foreign"], "source" => array(""));
|
||||
$row = array("table" => $TABLE, "source" => array(""));
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
ksort($row["source"]);
|
||||
|
@ -31,13 +32,13 @@ if ($_POST) {
|
|||
$row["target"] = array();
|
||||
}
|
||||
} elseif (strlen($_GET["name"])) {
|
||||
$foreign_keys = foreign_keys($_GET["foreign"]);
|
||||
$foreign_keys = foreign_keys($TABLE);
|
||||
$row = $foreign_keys[$_GET["name"]];
|
||||
$row["source"][] = "";
|
||||
}
|
||||
|
||||
$source = get_vals("SHOW COLUMNS FROM " . idf_escape($_GET["foreign"])); //! no text and blob
|
||||
$target = ($_GET["foreign"] === $row["table"] ? $source : get_vals("SHOW COLUMNS FROM " . idf_escape($row["table"])));
|
||||
$source = get_vals("SHOW COLUMNS FROM " . idf_escape($TABLE)); //! no text and blob
|
||||
$target = ($TABLE === $row["table"] ? $source : get_vals("SHOW COLUMNS FROM " . idf_escape($row["table"])));
|
||||
?>
|
||||
|
||||
<form action="" method="post">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
$TABLE = $_GET["indexes"];
|
||||
$index_types = array("PRIMARY", "UNIQUE", "INDEX", "FULLTEXT");
|
||||
$indexes = indexes($_GET["indexes"]);
|
||||
$indexes = indexes($TABLE);
|
||||
if ($_POST && !$error && !$_POST["add"]) {
|
||||
$alter = array();
|
||||
foreach ($_POST["indexes"] as $index) {
|
||||
|
@ -34,14 +35,14 @@ if ($_POST && !$error && !$_POST["add"]) {
|
|||
$alter[] = "\nDROP INDEX " . idf_escape($name);
|
||||
}
|
||||
if (!$alter) {
|
||||
redirect(ME . "table=" . urlencode($_GET["indexes"]));
|
||||
redirect(ME . "table=" . urlencode($TABLE));
|
||||
}
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["indexes"]) . implode(",", $alter), ME . "table=" . urlencode($_GET["indexes"]), lang('Indexes have been altered.'));
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . implode(",", $alter), ME . "table=" . urlencode($TABLE), lang('Indexes have been altered.'));
|
||||
}
|
||||
|
||||
page_header(lang('Indexes'), $error, array("table" => $_GET["indexes"]), $_GET["indexes"]);
|
||||
page_header(lang('Indexes'), $error, array("table" => $TABLE), $TABLE);
|
||||
|
||||
$fields = array_keys(fields($_GET["indexes"]));
|
||||
$fields = array_keys(fields($TABLE));
|
||||
$row = array("indexes" => $indexes);
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
$PROCEDURE = $_GET["procedure"];
|
||||
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
||||
|
||||
$dropped = false;
|
||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||
if (strlen($_GET["procedure"])) {
|
||||
$dropped = query_redirect("DROP $routine " . idf_escape($_GET["procedure"]), substr(ME, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
||||
if (strlen($PROCEDURE)) {
|
||||
$dropped = query_redirect("DROP $routine " . idf_escape($PROCEDURE), substr(ME, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
||||
}
|
||||
if (!$_POST["drop"]) {
|
||||
$set = array();
|
||||
|
@ -19,11 +20,11 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||
. " (" . implode(", ", $set) . ")"
|
||||
. (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "")
|
||||
. "\n$_POST[definition]"
|
||||
, substr(ME, 0, -1), (strlen($_GET["procedure"]) ? lang('Routine has been altered.') : lang('Routine has been created.')));
|
||||
, substr(ME, 0, -1), (strlen($PROCEDURE) ? lang('Routine has been altered.') : lang('Routine has been created.')));
|
||||
}
|
||||
}
|
||||
|
||||
page_header((strlen($_GET["procedure"]) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($_GET["procedure"]) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
|
||||
page_header((strlen($PROCEDURE) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
|
||||
|
||||
$collations = get_vals("SHOW CHARACTER SET");
|
||||
sort($collations);
|
||||
|
@ -32,9 +33,9 @@ if ($_POST) {
|
|||
$row = $_POST;
|
||||
$row["fields"] = (array) $row["fields"];
|
||||
process_fields($row["fields"]);
|
||||
} elseif (strlen($_GET["procedure"])) {
|
||||
$row = routine($_GET["procedure"], $routine);
|
||||
$row["name"] = $_GET["procedure"];
|
||||
} elseif (strlen($PROCEDURE)) {
|
||||
$row = routine($PROCEDURE, $routine);
|
||||
$row["name"] = $PROCEDURE;
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -49,5 +50,5 @@ if ($_POST) {
|
|||
<?php if ($dropped) { ?><input type="hidden" name="dropped" value="1"><?php } ?>
|
||||
<?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" maxlength="64">
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
<?php if (strlen($_GET["procedure"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
||||
<?php if (strlen($PROCEDURE)) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
||||
</form>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
$table_status = table_status($_GET["select"]);
|
||||
$indexes = indexes($_GET["select"]);
|
||||
$fields = fields($_GET["select"]);
|
||||
$TABLE = $_GET["select"];
|
||||
$table_status = table_status($TABLE);
|
||||
$indexes = indexes($TABLE);
|
||||
$fields = fields($TABLE);
|
||||
$rights = array(); // privilege => 0
|
||||
$columns = array(); // selectable columns
|
||||
unset($text_length);
|
||||
|
@ -20,7 +21,7 @@ list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes);
|
|||
$where = $adminer->selectSearchProcess($fields, $indexes);
|
||||
$order = $adminer->selectOrderProcess($fields, $indexes);
|
||||
$limit = $adminer->selectLimitProcess();
|
||||
$from = ($select ? implode(", ", $select) : "*") . " FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "");
|
||||
$from = ($select ? implode(", ", $select) : "*") . " FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "");
|
||||
$group_by = ($group && count($group) < count($select) ? " GROUP BY " . implode(", ", $group) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "");
|
||||
|
||||
if ($_POST && !$error) {
|
||||
|
@ -33,20 +34,20 @@ if ($_POST && !$error) {
|
|||
}
|
||||
}
|
||||
if ($_POST["export"]) {
|
||||
dump_headers($_GET["select"]);
|
||||
dump_table($_GET["select"], "");
|
||||
dump_headers($TABLE);
|
||||
dump_table($TABLE, "");
|
||||
if ($_POST["format"] != "sql") { // Editor doesn't send format
|
||||
dump_csv($select ? $select : array_keys($fields));
|
||||
}
|
||||
if (!is_array($_POST["check"]) || $primary === array()) {
|
||||
dump_data($_GET["select"], "INSERT", "SELECT $from" . (is_array($_POST["check"]) ? ($where ? " AND " : " WHERE ") . "($where_check)" : "") . $group_by);
|
||||
dump_data($TABLE, "INSERT", "SELECT $from" . (is_array($_POST["check"]) ? ($where ? " AND " : " WHERE ") . "($where_check)" : "") . $group_by);
|
||||
} else {
|
||||
$union = array();
|
||||
foreach ($_POST["check"] as $val) {
|
||||
// where is not unique so OR can't be used
|
||||
$union[] = "(SELECT $from " . ($where ? "AND " : "WHERE ") . where_check($val) . $group_by . " LIMIT 1)";
|
||||
}
|
||||
dump_data($_GET["select"], "INSERT", implode(" UNION ALL ", $union));
|
||||
dump_data($TABLE, "INSERT", implode(" UNION ALL ", $union));
|
||||
}
|
||||
dump();
|
||||
exit;
|
||||
|
@ -55,7 +56,7 @@ if ($_POST && !$error) {
|
|||
if (!$_POST["import"]) { // edit
|
||||
$result = true;
|
||||
$affected = 0;
|
||||
$command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($_GET["select"]);
|
||||
$command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($TABLE);
|
||||
$set = array();
|
||||
if (!$_POST["delete"]) {
|
||||
foreach ($columns as $name => $val) { //! should check also for edit or insert privileges
|
||||
|
@ -66,7 +67,7 @@ if ($_POST && !$error) {
|
|||
$set[] = idf_escape($name) . " = $val";
|
||||
}
|
||||
}
|
||||
$command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . "\nFROM " . idf_escape($_GET["select"]) : " SET\n" . implode(",\n", $set));
|
||||
$command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . "\nFROM " . idf_escape($TABLE) : " SET\n" . implode(",\n", $set));
|
||||
}
|
||||
if ($_POST["delete"] || $set) {
|
||||
if ($_POST["all"] || ($primary === array() && $_POST["check"])) {
|
||||
|
@ -91,7 +92,7 @@ if ($_POST && !$error) {
|
|||
$length = 0;
|
||||
$result = true;
|
||||
$dbh->query("SET foreign_key_checks = 0");
|
||||
$query = "REPLACE " . idf_escape($_GET["select"]); // ON DUPLICATE KEY UPDATE would require one query per record
|
||||
$query = "REPLACE " . idf_escape($TABLE); // ON DUPLICATE KEY UPDATE would require one query per record
|
||||
$packet_size = $dbh->result($dbh->query("SELECT @@max_allowed_packet"));
|
||||
$rows = array();
|
||||
preg_match_all('~("[^"]*"|[^"\\n])+~', $file, $matches);
|
||||
|
@ -136,7 +137,7 @@ if ($_POST && !$error) {
|
|||
|
||||
page_header(lang('Select') . ": " . $adminer->tableName($table_status), $error);
|
||||
|
||||
$foreign_keys = column_foreign_keys($_GET["select"]);
|
||||
$foreign_keys = column_foreign_keys($TABLE);
|
||||
echo "<p>";
|
||||
if (isset($rights["insert"])) {
|
||||
$set = "";
|
||||
|
@ -147,7 +148,7 @@ if (isset($rights["insert"])) {
|
|||
$set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
|
||||
}
|
||||
}
|
||||
echo '<a href="' . h(ME . 'edit=' . urlencode($_GET['select']) . $set) . '">' . lang('New item') . '</a> ';
|
||||
echo '<a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . '</a> ';
|
||||
}
|
||||
echo $adminer->selectLinks($table_status);
|
||||
|
||||
|
@ -158,7 +159,7 @@ if (!$columns) {
|
|||
echo "<div style='display: none;'>";
|
||||
echo (strlen($_GET["server"]) ? '<input type="hidden" name="server" value="' . h($_GET["server"]) . '">' : "");
|
||||
echo (strlen(DB) ? '<input type="hidden" name="db" value="' . h(DB) . '">' : ""); // not used in Editor
|
||||
echo '<input type="hidden" name="select" value="' . h($_GET["select"]) . '">';
|
||||
echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
|
||||
echo "</div>\n";
|
||||
$adminer->selectColumnsPrint($select, $columns);
|
||||
$adminer->selectSearchPrint($where, $columns, $indexes);
|
||||
|
@ -192,7 +193,7 @@ if (!$columns) {
|
|||
|
||||
$descriptions = $adminer->rowDescriptions($rows, $foreign_keys);
|
||||
|
||||
$backward_keys = $adminer->backwardKeys($_GET["select"]);
|
||||
$backward_keys = $adminer->backwardKeys($TABLE);
|
||||
$table_names = array();
|
||||
if ($backward_keys) {
|
||||
foreach ($backward_keys as $key => $val) {
|
||||
|
@ -222,7 +223,7 @@ if (!$columns) {
|
|||
echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
||||
foreach ($descriptions as $n => $row) {
|
||||
$unique_idf = implode('&', unique_idf($rows[$n], $indexes));
|
||||
echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf' onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($_GET['select']) . "&$unique_idf'>" . lang('edit') . "</a>");
|
||||
echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf' onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($TABLE) . "&$unique_idf'>" . lang('edit') . "</a>");
|
||||
foreach ($row as $key => $val) {
|
||||
if (isset($names[$key])) {
|
||||
if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
|
||||
|
@ -234,7 +235,7 @@ if (!$columns) {
|
|||
$val = "<i>NULL</i>";
|
||||
} else {
|
||||
if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
|
||||
$link = h(ME . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
|
||||
$link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . '&') . $unique_idf;
|
||||
}
|
||||
if (!strlen(trim($val, " \t"))) {
|
||||
$val = " ";
|
||||
|
@ -284,7 +285,7 @@ if (!$columns) {
|
|||
// slow with big tables
|
||||
ob_flush();
|
||||
flush();
|
||||
$found_rows = $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
|
||||
$found_rows = $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
|
||||
}
|
||||
echo "<p>";
|
||||
if (intval($limit) && $found_rows > $limit) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
$result = $dbh->query("SHOW FULL COLUMNS FROM " . idf_escape($_GET["table"]));
|
||||
$TABLE = $_GET["table"];
|
||||
$result = $dbh->query("SHOW FULL COLUMNS FROM " . idf_escape($TABLE));
|
||||
if (!$result) {
|
||||
$error = h($dbh->error);
|
||||
}
|
||||
$table_status = ($result ? table_status($_GET["table"]) : array());
|
||||
$table_status = ($result ? table_status($TABLE) : array());
|
||||
$is_view = !isset($table_status["Rows"]);
|
||||
|
||||
page_header(($result && $is_view ? lang('View') : lang('Table')) . ": " . h($_GET["table"]), $error);
|
||||
page_header(($result && $is_view ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
|
||||
|
||||
if ($result) {
|
||||
echo "<table cellspacing='0'>\n";
|
||||
|
@ -21,16 +22,16 @@ if ($result) {
|
|||
|
||||
echo "<p>";
|
||||
if ($is_view) {
|
||||
echo '<a href="' . h(ME) . 'view=' . urlencode($_GET["table"]) . '">' . lang('Alter view') . '</a>';
|
||||
echo '<a href="' . h(ME) . 'view=' . urlencode($TABLE) . '">' . lang('Alter view') . '</a>';
|
||||
} else {
|
||||
echo '<a href="' . h(ME) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . '</a>';
|
||||
echo '<a href="' . h(ME) . 'create=' . urlencode($TABLE) . '">' . lang('Alter table') . '</a>';
|
||||
}
|
||||
echo ' <a href="' . h(ME) . 'select=' . urlencode($_GET["table"]) . '">' . lang('Select table') . '</a>';
|
||||
echo ' <a href="' . h(ME) . 'edit=' . urlencode($_GET["table"]) . '">' . lang('New item') . '</a>';
|
||||
echo ' <a href="' . h(ME) . 'select=' . urlencode($TABLE) . '">' . lang('Select table') . '</a>';
|
||||
echo ' <a href="' . h(ME) . 'edit=' . urlencode($TABLE) . '">' . lang('New item') . '</a>';
|
||||
|
||||
if (!$is_view) {
|
||||
echo "<h3>" . lang('Indexes') . "</h3>\n";
|
||||
$indexes = indexes($_GET["table"]);
|
||||
$indexes = indexes($TABLE);
|
||||
if ($indexes) {
|
||||
echo "<table cellspacing='0'>\n";
|
||||
foreach ($indexes as $index) {
|
||||
|
@ -43,11 +44,11 @@ if ($result) {
|
|||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo '<p><a href="' . h(ME) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a>\n";
|
||||
echo '<p><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
|
||||
|
||||
if ($table_status["Engine"] == "InnoDB") {
|
||||
echo "<h3>" . lang('Foreign keys') . "</h3>\n";
|
||||
$foreign_keys = foreign_keys($_GET["table"]);
|
||||
$foreign_keys = foreign_keys($TABLE);
|
||||
if ($foreign_keys) {
|
||||
echo "<table cellspacing='0'>\n";
|
||||
foreach ($foreign_keys as $name => $foreign_key) {
|
||||
|
@ -56,24 +57,24 @@ if ($result) {
|
|||
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
|
||||
echo "<td><a href='" . h(strlen($foreign_key["db"]) ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ME) . "table=" . urlencode($foreign_key["table"]) . "'>$link</a>";
|
||||
echo "(<em>" . implode("</em>, <em>", array_map('h', $foreign_key["target"])) . "</em>)";
|
||||
echo "<td>" . (!strlen($foreign_key["db"]) ? '<a href="' . h(ME . 'foreign=' . urlencode($_GET["table"]) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>' : ' ');
|
||||
echo "<td>" . (!strlen($foreign_key["db"]) ? '<a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>' : ' ');
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo '<p><a href="' . h(ME) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a>\n";
|
||||
echo '<p><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
|
||||
}
|
||||
|
||||
if ($dbh->server_info >= 5) {
|
||||
echo "<h3>" . lang('Triggers') . "</h3>\n";
|
||||
$result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($_GET["table"], "%_")));
|
||||
$result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($TABLE, "%_")));
|
||||
if ($result->num_rows) {
|
||||
echo "<table cellspacing='0'>\n";
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<tr valign='top'><td>$row[Timing]<td>$row[Event]<th>" . h($row["Trigger"]) . "<td><a href='" . h(ME . 'trigger=' . urlencode($_GET["table"]) . '&name=' . urlencode($row["Trigger"])) . "'>" . lang('Alter') . "</a>\n";
|
||||
echo "<tr valign='top'><td>$row[Timing]<td>$row[Event]<th>" . h($row["Trigger"]) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($row["Trigger"])) . "'>" . lang('Alter') . "</a>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo '<p><a href="' . h(ME) . 'trigger=' . urlencode($_GET["table"]) . '">' . lang('Add trigger') . "</a>\n";
|
||||
echo '<p><a href="' . h(ME) . 'trigger=' . urlencode($TABLE) . '">' . lang('Add trigger') . "</a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
<?php
|
||||
$TABLE = $_GET["trigger"];
|
||||
$trigger_time = array("BEFORE", "AFTER");
|
||||
$trigger_event = array("INSERT", "UPDATE", "DELETE");
|
||||
|
||||
$dropped = false;
|
||||
if ($_POST && !$error) {
|
||||
if (strlen($_GET["name"])) {
|
||||
$dropped = query_redirect("DROP TRIGGER " . idf_escape($_GET["name"]), ME . "table=" . urlencode($_GET["trigger"]), lang('Trigger has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
||||
$dropped = query_redirect("DROP TRIGGER " . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Trigger has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
||||
}
|
||||
if (!$_POST["drop"]) {
|
||||
if (in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) {
|
||||
query_redirect("CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($_GET["trigger"]) . " FOR EACH ROW\n$_POST[Statement]", ME . "table=" . urlencode($_GET["trigger"]), (strlen($_GET["name"]) ? lang('Trigger has been altered.') : lang('Trigger has been created.')));
|
||||
query_redirect("CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($TABLE) . " FOR EACH ROW\n$_POST[Statement]", ME . "table=" . urlencode($TABLE), (strlen($_GET["name"]) ? lang('Trigger has been altered.') : lang('Trigger has been created.')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $_GET["trigger"]));
|
||||
page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE));
|
||||
|
||||
$row = array("Trigger" => "$_GET[trigger]_bi");
|
||||
$row = array("Trigger" => $TABLE . "_bi");
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
} elseif (strlen($_GET["name"])) {
|
||||
|
@ -27,7 +28,7 @@ if ($_POST) {
|
|||
|
||||
<form action="" method="post" id="form">
|
||||
<table cellspacing="0">
|
||||
<tr><th><?php echo lang('Time'); ?><td><select name="Timing" onchange="if (/^<?php echo h(preg_quote($_GET["trigger"], "/")); ?>_[ba][iud]$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '<?php echo h(addcslashes($_GET["trigger"], "\r\n'\\")); ?>_' + this.value.charAt(0).toLowerCase() + this.form['Event'].value.charAt(0).toLowerCase();"><?php echo optionlist($trigger_time, $row["Timing"]); ?></select>
|
||||
<tr><th><?php echo lang('Time'); ?><td><select name="Timing" onchange="if (/^<?php echo h(preg_quote($TABLE, "/")); ?>_[ba][iud]$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '<?php echo h(addcslashes($TABLE, "\r\n'\\")); ?>_' + this.value.charAt(0).toLowerCase() + this.form['Event'].value.charAt(0).toLowerCase();"><?php echo optionlist($trigger_time, $row["Timing"]); ?></select>
|
||||
<tr><th><?php echo lang('Event'); ?><td><select name="Event" onchange="this.form['Timing'].onchange();"><?php echo optionlist($trigger_event, $row["Event"]); ?></select>
|
||||
<tr><th><?php echo lang('Name'); ?><td><input name="Trigger" value="<?php echo h($row["Trigger"]); ?>" maxlength="64">
|
||||
</table>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
$USER = $_GET["user"];
|
||||
$privileges = array("" => array("All privileges" => ""));
|
||||
$result = $dbh->query("SHOW PRIVILEGES");
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
|
@ -40,7 +41,7 @@ if ($_POST) {
|
|||
}
|
||||
$grants = array();
|
||||
$old_pass = "";
|
||||
if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->quote($_GET["user"]) . "@" . $dbh->quote($_GET["host"])))) { //! use information_schema for MySQL 5 - column names in column privileges are not escaped
|
||||
if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->quote($USER) . "@" . $dbh->quote($_GET["host"])))) { //! use information_schema for MySQL 5 - column names in column privileges are not escaped
|
||||
while ($row = $result->fetch_row()) {
|
||||
if (preg_match('~GRANT (.*) ON (.*) TO ~', $row[0], $match) && preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~', $match[1], $matches, PREG_SET_ORDER)) { //! escape the part between ON and TO
|
||||
foreach ($matches as $val) {
|
||||
|
@ -57,7 +58,7 @@ if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->qu
|
|||
}
|
||||
|
||||
if ($_POST && !$error) {
|
||||
$old_user = (isset($_GET["host"]) ? $dbh->quote($_GET["user"]) . "@" . $dbh->quote($_GET["host"]) : "''");
|
||||
$old_user = (isset($_GET["host"]) ? $dbh->quote($USER) . "@" . $dbh->quote($_GET["host"]) : "''");
|
||||
$new_user = $dbh->quote($_POST["user"]) . "@" . $dbh->quote($_POST["host"]); // if $_GET["host"] is not set then $new_user is always different
|
||||
$pass = $dbh->quote($_POST["pass"]);
|
||||
if ($_POST["drop"]) {
|
||||
|
@ -112,7 +113,7 @@ if ($_POST && !$error) {
|
|||
}
|
||||
}
|
||||
|
||||
page_header((isset($_GET["host"]) ? lang('Username') . ": " . h("$_GET[user]@$_GET[host]") : lang('Create user')), $error, array("privileges" => array('', lang('Privileges'))));
|
||||
page_header((isset($_GET["host"]) ? lang('Username') . ": " . h("$USER@$_GET[host]") : lang('Create user')), $error, array("privileges" => array('', lang('Privileges'))));
|
||||
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
$TABLE = $_GET["view"];
|
||||
$dropped = false;
|
||||
if ($_POST && !$error) {
|
||||
if (strlen($_GET["view"])) {
|
||||
$dropped = query_redirect("DROP VIEW " . idf_escape($_GET["view"]), substr(ME, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]);
|
||||
if (strlen($TABLE)) {
|
||||
$dropped = query_redirect("DROP VIEW " . idf_escape($TABLE), substr(ME, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]);
|
||||
}
|
||||
query_redirect("CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]", ME . "table=" . urlencode($_POST["name"]), (strlen($_GET["view"]) ? lang('View has been altered.') : lang('View has been created.')));
|
||||
query_redirect("CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]", ME . "table=" . urlencode($_POST["name"]), (strlen($TABLE) ? lang('View has been altered.') : lang('View has been created.')));
|
||||
}
|
||||
|
||||
page_header((strlen($_GET["view"]) ? lang('Alter view') : lang('Create view')), $error, array("table" => $_GET["view"]), $_GET["view"]);
|
||||
page_header((strlen($TABLE) ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
|
||||
|
||||
$row = array();
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
} elseif (strlen($_GET["view"])) {
|
||||
$row = view($_GET["view"]);
|
||||
$row["name"] = $_GET["view"];
|
||||
} elseif (strlen($TABLE)) {
|
||||
$row = view($TABLE);
|
||||
$row["name"] = $TABLE;
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
2
todo.txt
2
todo.txt
|
@ -12,7 +12,7 @@ IE6 - <label for>
|
|||
Offer enum and set items in search - whisperer
|
||||
Use event $intervals + microseconds in relative date functions
|
||||
? Column and table names auto-completition in SQL textarea
|
||||
? Aliasing of built-in functions can save 7 KB, function minification can save 7 KB, substitution of $_GET and friends can save 2 KB, remove of base64_decode() + using chars 127-255 in minification can save 1 KB, JS packer can save 1 KB, not enclosing attribute values can save 1.2 KB
|
||||
? Aliasing of built-in functions can save 7 KB, function minification can save 7 KB, substitution of repetitive $a["a"] can save 4 KB, substitution of $_GET and friends can save 2 KB, remove of base64_decode() + using chars 127-255 in minification can save 1 KB, JS packer can save 1 KB, not enclosing HTML attribute values can save 1.2 KB
|
||||
? AJAX editing - select page has all data to display edit form
|
||||
|
||||
Editor:
|
||||
|
|
Loading…
Reference in a new issue