Function verify_version doesn't use version parameter

Don't preselect first option in foreign key edit
Prefill insert by foreign key searches
REQUEST_URI is used earlier
Change variable $SELF to constant ME
Denote required fields in Editor


git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@944 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-07-30 08:12:54 +00:00
parent 940d5ecbd3
commit 98507da3ea
27 changed files with 100 additions and 100 deletions

View file

@ -69,7 +69,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
} elseif ($dbh->server_info >= 5.1 && strlen($_GET["create"])) { } elseif ($dbh->server_info >= 5.1 && strlen($_GET["create"])) {
$status .= "\nREMOVE PARTITIONING"; $status .= "\nREMOVE PARTITIONING";
} }
$location = $SELF . "table=" . urlencode($_POST["name"]); $location = ME . "table=" . urlencode($_POST["name"]);
if (strlen($_GET["create"])) { 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.')); query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
} else { } else {

View file

@ -2,7 +2,7 @@
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
if ($_POST["drop"]) { if ($_POST["drop"]) {
unset($_SESSION["databases"][$_GET["server"]]); unset($_SESSION["databases"][$_GET["server"]]);
query_redirect("DROP DATABASE " . idf_escape($_GET["db"]), substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1), lang('Database has been dropped.')); query_redirect("DROP DATABASE " . idf_escape($_GET["db"]), substr(preg_replace('~db=[^&]*&~', '', ME), 0, -1), lang('Database has been dropped.'));
} elseif ($_GET["db"] !== $_POST["name"]) { } elseif ($_GET["db"] !== $_POST["name"]) {
// create or rename database // create or rename database
unset($_SESSION["databases"][$_GET["server"]]); // clear cache unset($_SESSION["databases"][$_GET["server"]]); // clear cache
@ -17,7 +17,7 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
$last = $db; $last = $db;
} }
} }
if (query_redirect(queries(), $SELF . "db=" . urlencode($last), lang('Database has been created.'), !strlen($_GET["db"]), false, $failed)) { if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), !strlen($_GET["db"]), false, $failed)) {
$result = $dbh->query("SHOW TABLES"); $result = $dbh->query("SHOW TABLES");
while ($row = $result->fetch_row()) { while ($row = $result->fetch_row()) {
if (!queries("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) { if (!queries("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) {
@ -28,14 +28,14 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
if (!$row) { if (!$row) {
queries("DROP DATABASE " . idf_escape($_GET["db"])); queries("DROP DATABASE " . idf_escape($_GET["db"]));
} }
query_redirect(queries(), preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'), !$row, false, $row); query_redirect(queries(), preg_replace('~db=[^&]*&~', '', ME) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'), !$row, false, $row);
} }
} else { } else {
// alter database // alter database
if (!$_POST["collation"]) { if (!$_POST["collation"]) {
redirect(substr($SELF, 0, -1)); redirect(substr(ME, 0, -1));
} }
query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $dbh->quote($_POST["collation"]), substr($SELF, 0, -1), lang('Database has been altered.')); query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $dbh->quote($_POST["collation"]), substr(ME, 0, -1), lang('Database has been altered.'));
} }
} }

View file

@ -35,12 +35,12 @@ if ($tables_views && !$error) {
} }
} }
} }
query_redirect(queries(), substr($SELF, 0, -1), $message, $result, false, !$result); query_redirect(queries(), substr(ME, 0, -1), $message, $result, false, !$result);
} }
page_header(lang('Database') . ": " . h($_GET["db"]), $error, false); page_header(lang('Database') . ": " . h($_GET["db"]), $error, false);
echo '<p><a href="' . h($SELF) . 'database=">' . lang('Alter database') . "</a>\n"; echo '<p><a href="' . h(ME) . 'database=">' . lang('Alter database') . "</a>\n";
echo '<p><a href="' . h($SELF) . 'schema=">' . lang('Database schema') . "</a>\n"; echo '<p><a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
echo "<h3>" . lang('Tables and views') . "</h3>\n"; echo "<h3>" . lang('Tables and views') . "</h3>\n";
$table_status = table_status(); $table_status = table_status();
@ -54,16 +54,16 @@ if (!$table_status) {
$name = $row["Name"]; $name = $row["Name"];
table_comment($row); table_comment($row);
echo '<tr' . odd() . '><td><input type="checkbox" name="' . (isset($row["Rows"]) ? 'tables' : 'views') . '[]" value="' . h($name) . '"' . (in_array($name, $tables_views, true) ? ' checked' : '') . ' onclick="form_uncheck(\'check-all\');">'; echo '<tr' . odd() . '><td><input type="checkbox" name="' . (isset($row["Rows"]) ? 'tables' : 'views') . '[]" value="' . h($name) . '"' . (in_array($name, $tables_views, true) ? ' checked' : '') . ' onclick="form_uncheck(\'check-all\');">';
echo '<th><a href="' . h($SELF) . 'table=' . urlencode($name) . '">' . h($name) . '</a>'; echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
if (isset($row["Rows"])) { if (isset($row["Rows"])) {
echo "<td>$row[Engine]<td>$row[Collation]"; echo "<td>$row[Engine]<td>$row[Collation]";
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) { foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) {
$val = number_format($row[$key], 0, '.', lang(',')); $val = number_format($row[$key], 0, '.', lang(','));
echo '<td align="right">' . (strlen($row[$key]) ? '<a href="' . h("$SELF$link=") . urlencode($name) . '">' . str_replace(" ", "&nbsp;", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '</a>' : '&nbsp;'); echo '<td align="right">' . (strlen($row[$key]) ? '<a href="' . h(ME . "$link=") . urlencode($name) . '">' . str_replace(" ", "&nbsp;", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '</a>' : '&nbsp;');
} }
echo "<td>" . (strlen(trim($row["Comment"])) ? h($row["Comment"]) : "&nbsp;"); echo "<td>" . (strlen(trim($row["Comment"])) ? h($row["Comment"]) : "&nbsp;");
} else { } else {
echo '<td colspan="8"><a href="' . h($SELF) . "select=" . urlencode($name) . '">' . lang('View') . '</a>'; echo '<td colspan="8"><a href="' . h(ME) . "select=" . urlencode($name) . '">' . lang('View') . '</a>';
} }
} }
echo "</table>\n"; echo "</table>\n";
@ -77,7 +77,7 @@ if (!$table_status) {
} }
if ($dbh->server_info >= 5) { if ($dbh->server_info >= 5) {
echo '<p><a href="' . h($SELF) . 'view=">' . lang('Create view') . "</a>\n"; echo '<p><a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
echo "<h3>" . lang('Routines') . "</h3>\n"; echo "<h3>" . lang('Routines') . "</h3>\n";
$result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $dbh->quote($_GET["db"])); $result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $dbh->quote($_GET["db"]));
if ($result->num_rows) { if ($result->num_rows) {
@ -85,13 +85,13 @@ if ($dbh->server_info >= 5) {
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
echo "<tr>"; echo "<tr>";
echo "<td>" . h($row["ROUTINE_TYPE"]); echo "<td>" . h($row["ROUTINE_TYPE"]);
echo '<th><a href="' . h($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>'; echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
echo '<td><a href="' . h($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>"; echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
} }
echo "</table>\n"; echo "</table>\n";
} }
$result->free(); $result->free();
echo '<p><a href="' . h($SELF) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h($SELF) . 'function=">' . lang('Create function') . "</a>\n"; echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
} }
if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) { if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) {
@ -101,12 +101,12 @@ if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) {
echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n"; echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
echo "<tr>"; echo "<tr>";
echo '<th><a href="' . h($SELF) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>"; echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]"); echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
echo "<td>$row[Ends]"; echo "<td>$row[Ends]";
} }
echo "</table>\n"; echo "</table>\n";
} }
$result->free(); $result->free();
echo '<p><a href="' . h($SELF) . 'event=">' . lang('Create event') . "</a>\n"; echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
} }

View file

@ -8,7 +8,10 @@ foreach ($fields as $name => $field) {
} }
} }
if ($_POST && !$error && !isset($_GET["select"])) { if ($_POST && !$error && !isset($_GET["select"])) {
$location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); // "insert" to continue edit or insert $location = ($_POST["insert"] // continue edit or insert
? $_SERVER["REQUEST_URI"]
: ME . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]) //! append &set converted to &where
);
$set = array(); $set = array();
foreach ($fields as $name => $field) { foreach ($fields as $name => $field) {
$val = process_input($field); $val = process_input($field);
@ -70,9 +73,10 @@ if ($fields) {
echo "<table cellspacing='0'>\n"; echo "<table cellspacing='0'>\n";
foreach ($fields as $name => $field) { foreach ($fields as $name => $field) {
echo "<tr><th>" . $adminer->fieldName($field); echo "<tr><th>" . $adminer->fieldName($field);
$default = $_GET["set"][bracket_escape($name)];
$value = (isset($row) $value = (isset($row)
? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name]) ? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
: ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $field["default"])) : ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : (isset($default) ? $default : $field["default"])))
); );
if (!$_POST["save"] && is_string($value)) { if (!$_POST["save"] && is_string($value)) {
$value = $adminer->editVal($value, $field); $value = $adminer->editVal($value, $field);

View file

@ -4,7 +4,7 @@ $statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DIS
if ($_POST && !$error) { if ($_POST && !$error) {
if ($_POST["drop"]) { if ($_POST["drop"]) {
query_redirect("DROP EVENT " . idf_escape($_GET["event"]), substr($SELF, 0, -1), lang('Event has been dropped.')); query_redirect("DROP EVENT " . idf_escape($_GET["event"]), substr(ME, 0, -1), lang('Event has been dropped.'));
} elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) { } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
$schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"] $schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]" ? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
@ -19,7 +19,7 @@ if ($_POST && !$error) {
: "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"]) ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"])
. " DO\n$_POST[EVENT_DEFINITION]" . " DO\n$_POST[EVENT_DEFINITION]"
, substr($SELF, 0, -1), (strlen($_GET["event"]) ? lang('Event has been altered.') : lang('Event has been created.'))); , substr(ME, 0, -1), (strlen($_GET["event"]) ? lang('Event has been altered.') : lang('Event has been created.')));
} }
} }

View file

@ -1,7 +1,7 @@
<?php <?php
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 " . idf_escape($_GET["foreign"]) . "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]), $SELF . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.')); 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.'));
} else { } else {
$source = array_filter($_POST["source"], 'strlen'); $source = array_filter($_POST["source"], 'strlen');
ksort($source); // enforce input order ksort($source); // enforce input order
@ -14,7 +14,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . idf_escape($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" . "\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_delete"], $on_actions) ? " ON DELETE $_POST[on_delete]" : "")
. (in_array($_POST["on_update"], $on_actions) ? " ON UPDATE $_POST[on_update]" : "") . (in_array($_POST["on_update"], $on_actions) ? " ON UPDATE $_POST[on_update]" : "")
, $SELF . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))); , ME . "table=" . urlencode($_GET["foreign"]), (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 exists.') . "<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 exists.') . "<br>$error"; //! no partitioning
} }
} }

View file

@ -6,7 +6,7 @@ function toggle(id) {
return true; return true;
} }
function verify_version(version) { function verify_version() {
document.cookie = 'adminer_version=0'; document.cookie = 'adminer_version=0';
var script = document.createElement('script'); var script = document.createElement('script');
script.src = 'https://adminer.svn.sourceforge.net/svnroot/adminer/trunk/released.js'; script.src = 'https://adminer.svn.sourceforge.net/svnroot/adminer/trunk/released.js';

View file

@ -71,8 +71,7 @@ class Adminer {
* @return string * @return string
*/ */
function selectLinks($tableStatus) { function selectLinks($tableStatus) {
global $SELF; return '<a href="' . h(ME) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
return '<a href="' . h($SELF) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
} }
/** Find backward keys for table /** Find backward keys for table
@ -88,9 +87,8 @@ class Adminer {
* @return string * @return string
*/ */
function selectQuery($query) { function selectQuery($query) {
global $SELF;
// it would be nice if $query can be passed by reference and printed value would be returned but call_user() doesn't allow reference parameters // it would be nice if $query can be passed by reference and printed value would be returned but call_user() doesn't allow reference parameters
return "<p><code class='jush-sql'>" . h($query) . "</code> <a href='" . h($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n"; return "<p><code class='jush-sql'>" . h($query) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
} }
/** Description of a row in a table /** Description of a row in a table
@ -337,10 +335,9 @@ class Adminer {
* @return string * @return string
*/ */
function messageQuery($query) { function messageQuery($query) {
global $SELF;
$id = "sql-" . count($_SESSION["messages"]); $id = "sql-" . count($_SESSION["messages"]);
$_SESSION["history"][$_GET["server"]][$_GET["db"]][] = $query; $_SESSION["history"][$_GET["server"]][$_GET["db"]][] = $query;
return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . h($query) . '</pre><a href="' . h($SELF . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>'; return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . h($query) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
} }
/** Functions displayed in edit form /** Functions displayed in edit form
@ -416,14 +413,14 @@ class Adminer {
* @return null * @return null
*/ */
function navigation($missing) { function navigation($missing) {
global $SELF, $dbh; global $dbh;
if ($missing != "auth") { if ($missing != "auth") {
$databases = get_databases(); $databases = get_databases();
?> ?>
<form action="" method="post"> <form action="" method="post">
<p> <p>
<a href="<?php echo h($SELF); ?>sql="><?php echo lang('SQL command'); ?></a> <a href="<?php echo h(ME); ?>sql="><?php echo lang('SQL command'); ?></a>
<a href="<?php echo h($SELF); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a> <a href="<?php echo h(ME); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
<input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>"> <input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
<input type="submit" name="logout" value="<?php echo lang('Logout'); ?>"> <input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
</p> </p>
@ -449,12 +446,12 @@ class Adminer {
} else { } else {
echo "<p>\n"; echo "<p>\n";
while ($row = $result->fetch_row()) { while ($row = $result->fetch_row()) {
echo '<a href="' . h($SELF) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> '; echo '<a href="' . h(ME) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
echo '<a href="' . h($SELF) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status echo '<a href="' . h(ME) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status
} }
} }
$result->free(); $result->free();
echo '<p><a href="' . h($SELF) . 'create=">' . lang('Create new table') . "</a>\n"; echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
} }
} }
} }

View file

@ -32,7 +32,7 @@ if (isset($_POST["server"])) {
foreach (array("usernames", "passwords", "databases", "tokens", "history") as $val) { foreach (array("usernames", "passwords", "databases", "tokens", "history") as $val) {
unset($_SESSION[$val][$_GET["server"]]); unset($_SESSION[$val][$_GET["server"]]);
} }
redirect(substr($SELF, 0, -1), lang('Logout successful.')); redirect(substr(ME, 0, -1), lang('Logout successful.'));
} }
} }

View file

@ -39,6 +39,10 @@ if (isset($_GET["file"])) {
exit; exit;
} }
if (!isset($_SERVER["REQUEST_URI"])) {
$_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"] . (strlen($_SERVER["QUERY_STRING"]) ? "?$_SERVER[QUERY_STRING]" : "");
}
if (!ini_get("session.auto_start")) { if (!ini_get("session.auto_start")) {
// use specific session name to get own namespace // use specific session name to get own namespace
session_name("adminer_sid"); session_name("adminer_sid");
@ -64,10 +68,7 @@ if (get_magic_quotes_gpc()) {
} }
set_magic_quotes_runtime(false); set_magic_quotes_runtime(false);
if (!isset($_SERVER["REQUEST_URI"])) { define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?' . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen($_GET["db"]) ? 'db=' . urlencode($_GET["db"]) . '&' : ''));
$_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"] . (strlen($_SERVER["QUERY_STRING"]) ? "?$_SERVER[QUERY_STRING]" : "");
}
$SELF = preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?' . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen($_GET["db"]) ? 'db=' . urlencode($_GET["db"]) . '&' : '');
$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); // used in foreign_keys() $on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); // used in foreign_keys()
include "../adminer/include/version.inc.php"; include "../adminer/include/version.inc.php";

View file

@ -1,6 +1,6 @@
<?php <?php
function connect_error() { function connect_error() {
global $dbh, $SELF, $VERSION; global $dbh, $VERSION;
if (strlen($_GET["db"])) { if (strlen($_GET["db"])) {
page_header(lang('Database') . ": " . h($_GET["db"]), lang('Invalid database.'), false); page_header(lang('Database') . ": " . h($_GET["db"]), lang('Invalid database.'), false);
} else { } else {
@ -11,7 +11,7 @@ function connect_error() {
'processlist' => lang('Process list'), 'processlist' => lang('Process list'),
'variables' => lang('Variables'), 'variables' => lang('Variables'),
) as $key => $val) { ) as $key => $val) {
echo '<p><a href="' . h($SELF) . "$key=\">$val</a>\n"; echo '<p><a href="' . h(ME) . "$key=\">$val</a>\n";
} }
echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($dbh->server_info < 4.1 ? " class='binary'" : "") . ">$dbh->server_info</b>", "<b>$dbh->extension</b>") . "\n"; echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($dbh->server_info < 4.1 ? " class='binary'" : "") . ">$dbh->server_info</b>", "<b>$dbh->extension</b>") . "\n";
echo "<p>" . lang('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n"; echo "<p>" . lang('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n";

View file

@ -1,6 +1,6 @@
<?php <?php
function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
global $SELF, $LANG, $VERSION, $adminer; global $LANG, $VERSION, $adminer;
header("Content-Type: text/html; charset=utf-8"); header("Content-Type: text/html; charset=utf-8");
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
@ -15,23 +15,23 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<link rel="stylesheet" type="text/css" href="adminer.css"> <link rel="stylesheet" type="text/css" href="adminer.css">
<?php } ?> <?php } ?>
<body onload="body_load();<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verify_version('$VERSION');"); ?>"> <body onload="body_load();<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verify_version();"); ?>">
<script type="text/javascript" src="../adminer/functions.js"></script> <script type="text/javascript" src="../adminer/functions.js"></script>
<script type="text/javascript" src="editing.js"></script> <script type="text/javascript" src="editing.js"></script>
<div id="content"> <div id="content">
<?php <?php
if (isset($breadcrumb)) { if (isset($breadcrumb)) {
$link = substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1); $link = substr(preg_replace('~db=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . (strlen($link) ? h($link) : ".") . '">' . (isset($_GET["server"]) ? h($_GET["server"]) : lang('Server')) . '</a> &raquo; '; echo '<p id="breadcrumb"><a href="' . (strlen($link) ? h($link) : ".") . '">' . (isset($_GET["server"]) ? h($_GET["server"]) : lang('Server')) . '</a> &raquo; ';
if (is_array($breadcrumb)) { if (is_array($breadcrumb)) {
if (strlen($_GET["db"])) { if (strlen($_GET["db"])) {
echo '<a href="' . h(substr($SELF, 0, -1)) . '">' . h($_GET["db"]) . '</a> &raquo; '; echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["db"]) . '</a> &raquo; ';
} }
foreach ($breadcrumb as $key => $val) { foreach ($breadcrumb as $key => $val) {
$desc = (is_array($val) ? $val[1] : $val); $desc = (is_array($val) ? $val[1] : $val);
if (strlen($desc)) { if (strlen($desc)) {
echo '<a href="' . h("$SELF$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; '; echo '<a href="' . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; ';
} }
} }
} }

View file

@ -1,10 +1,4 @@
<?php <?php
function get_self() {
// can be used in customization, $SELF is minified
global $SELF;
return $SELF;
}
function get_dbh() { function get_dbh() {
// can be used in customization, $dbh is minified // can be used in customization, $dbh is minified
global $dbh; global $dbh;
@ -116,7 +110,7 @@ function redirect($location, $message = null) {
} }
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) { function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
global $dbh, $error, $SELF, $adminer; global $dbh, $error, $adminer;
$sql = ""; $sql = "";
if ($query) { if ($query) {
$sql = $adminer->messageQuery($query); $sql = $adminer->messageQuery($query);
@ -178,7 +172,6 @@ function odd($s = ' class="odd"') {
} }
function select($result, $dbh2 = null) { function select($result, $dbh2 = null) {
global $SELF;
if (!$result->num_rows) { if (!$result->num_rows) {
echo "<p class='message'>" . lang('No rows.') . "\n"; echo "<p class='message'>" . lang('No rows.') . "\n";
} else { } else {
@ -238,9 +231,9 @@ function select($result, $dbh2 = null) {
if (isset($links[$key]) && !$columns[$links[$key]]) { if (isset($links[$key]) && !$columns[$links[$key]]) {
$link = "edit=" . urlencode($links[$key]); $link = "edit=" . urlencode($links[$key]);
foreach ($indexes[$links[$key]] as $col => $j) { foreach ($indexes[$links[$key]] as $col => $j) {
$link .= "&amp;where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]); $link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
} }
$val = "<a href='" . h($SELF) . "$link'>$val</a>"; $val = "<a href='" . h(ME . $link) . "'>$val</a>";
} }
} }
echo "<td>$val"; echo "<td>$val";
@ -310,7 +303,7 @@ function input($field, $value, $function) {
$functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field); $functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
$first = array_search("", $functions) + (isset($_GET["select"]) ? 1 : 0); $first = array_search("", $functions) + (isset($_GET["select"]) ? 1 : 0);
$onchange = ($first ? " onchange=\"var f = this.form['function[" . addcslashes($name, "\r\n'\\") . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : ""); $onchange = ($first ? " onchange=\"var f = this.form['function[" . addcslashes($name, "\r\n'\\") . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : "");
echo (count($functions) > 1 ? "<select name='function[$name]'>" . optionlist($functions, $function) . "</select>" : "&nbsp;") . '<td>'; echo (count($functions) > 1 ? "<select name='function[$name]'>" . optionlist($functions, $function) . "</select>" : (strlen($functions[0]) ? $functions[0] : "&nbsp;")) . '<td>';
$input = $adminer->editInput($_GET["edit"], $field, " name='fields[$name]'$onchange", $value); // usage in call is without a table $input = $adminer->editInput($_GET["edit"], $field, " name='fields[$name]'$onchange", $value); // usage in call is without a table
if (strlen($input)) { if (strlen($input)) {
echo $input; echo $input;

View file

@ -34,9 +34,9 @@ if ($_POST && !$error && !$_POST["add"]) {
$alter[] = "\nDROP INDEX " . idf_escape($name); $alter[] = "\nDROP INDEX " . idf_escape($name);
} }
if (!$alter) { if (!$alter) {
redirect($SELF . "table=" . urlencode($_GET["indexes"])); redirect(ME . "table=" . urlencode($_GET["indexes"]));
} }
query_redirect("ALTER TABLE " . idf_escape($_GET["indexes"]) . implode(",", $alter), $SELF . "table=" . urlencode($_GET["indexes"]), lang('Indexes has been altered.')); query_redirect("ALTER TABLE " . idf_escape($_GET["indexes"]) . implode(",", $alter), ME . "table=" . urlencode($_GET["indexes"]), lang('Indexes has been altered.'));
} }
page_header(lang('Indexes'), $error, array("table" => $_GET["indexes"]), $_GET["indexes"]); page_header(lang('Indexes'), $error, array("table" => $_GET["indexes"]), $_GET["indexes"]);

View file

@ -1,6 +1,6 @@
<?php <?php
page_header(lang('Privileges')); page_header(lang('Privileges'));
echo '<p><a href="' . h($SELF) . 'user=">' . lang('Create user') . "</a>"; echo '<p><a href="' . h(ME) . 'user=">' . lang('Create user') . "</a>";
$result = $dbh->query("SELECT User, Host FROM mysql.user ORDER BY Host, User"); $result = $dbh->query("SELECT User, Host FROM mysql.user ORDER BY Host, User");
if (!$result) { if (!$result) {
@ -19,7 +19,7 @@ if (!$result) {
echo "<table cellspacing='0'>\n"; echo "<table cellspacing='0'>\n";
echo "<thead><tr><th>&nbsp;<th>" . lang('Username') . "<th>" . lang('Server') . "</thead>\n"; echo "<thead><tr><th>&nbsp;<th>" . lang('Username') . "<th>" . lang('Server') . "</thead>\n";
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
echo '<tr' . odd() . '><td><a href="' . h($SELF . 'user=' . urlencode($row["User"]) . '&host=' . urlencode($row["Host"])) . '">' . lang('edit') . '</a><td>' . h($row["User"]) . "<td>" . h($row["Host"]) . "\n"; echo '<tr' . odd() . '><td><a href="' . h(ME . 'user=' . urlencode($row["User"]) . '&host=' . urlencode($row["Host"])) . '">' . lang('edit') . '</a><td>' . h($row["User"]) . "<td>" . h($row["Host"]) . "\n";
} }
echo "</table>\n"; echo "</table>\n";
$result->free(); $result->free();

View file

@ -4,7 +4,7 @@ $routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
$dropped = false; $dropped = false;
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 (strlen($_GET["procedure"])) { if (strlen($_GET["procedure"])) {
$dropped = query_redirect("DROP $routine " . idf_escape($_GET["procedure"]), substr($SELF, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]); $dropped = query_redirect("DROP $routine " . idf_escape($_GET["procedure"]), substr(ME, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
} }
if (!$_POST["drop"]) { if (!$_POST["drop"]) {
$set = array(); $set = array();
@ -19,7 +19,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
. " (" . implode(", ", $set) . ")" . " (" . implode(", ", $set) . ")"
. (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "")
. "\n$_POST[definition]" . "\n$_POST[definition]"
, substr($SELF, 0, -1), (strlen($_GET["procedure"]) ? lang('Routine has been altered.') : lang('Routine has been created.'))); , substr(ME, 0, -1), (strlen($_GET["procedure"]) ? lang('Routine has been altered.') : lang('Routine has been created.')));
} }
} }

View file

@ -6,7 +6,7 @@ if ($_POST && !$error) {
$killed++; $killed++;
} }
} }
query_redirect(queries(), $SELF . "processlist=", lang('%d process(es) has been killed.', $killed), $killed || !$_POST["kill"], false, !$killed && $_POST["kill"]); query_redirect(queries(), ME . "processlist=", lang('%d process(es) has been killed.', $killed), $killed || !$_POST["kill"], false, !$killed && $_POST["kill"]);
} }
page_header(lang('Process list'), $error); page_header(lang('Process list'), $error);

View file

@ -60,7 +60,7 @@ document.onmouseup = schema_mouseup;
<?php <?php
foreach ($schema as $name => $table) { foreach ($schema as $name => $table) {
echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;' onmousedown='schema_mousedown(this, event);'>"; echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;' onmousedown='schema_mousedown(this, event);'>";
echo '<a href="' . h($SELF) . 'table=' . urlencode($name) . '"><strong>' . h($name) . "</strong></a><br>\n"; echo '<a href="' . h(ME) . 'table=' . urlencode($name) . '"><strong>' . h($name) . "</strong></a><br>\n";
foreach ($table["fields"] as $field) { foreach ($table["fields"] as $field) {
$val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " " . lang('NULL') : '')) . '">' . h($field["field"]) . '</span>'; $val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " " . lang('NULL') : '')) . '">' . h($field["field"]) . '</span>';
echo ($field["primary"] ? "<em>$val</em>" : $val) . "<br>\n"; echo ($field["primary"] ? "<em>$val</em>" : $val) . "<br>\n";

View file

@ -116,10 +116,18 @@ if ($_POST && !$error) {
page_header(lang('Select') . ": " . $adminer->tableName($table_status), $error); page_header(lang('Select') . ": " . $adminer->tableName($table_status), $error);
$foreign_keys = column_foreign_keys($_GET["select"]);
echo "<p>"; echo "<p>";
if (isset($rights["insert"])) { if (isset($rights["insert"])) {
//! pass search values forth and back $set = "";
echo '<a href="' . h($SELF) . 'edit=' . urlencode($_GET['select']) . '">' . lang('New item') . '</a> '; foreach ((array) $_GET["where"] as $val) {
if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
|| ($val["op"] == "" && !ereg('[_%]', $val["val"])) // LIKE in Editor
)) {
$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 $adminer->selectLinks($table_status); echo $adminer->selectLinks($table_status);
@ -163,7 +171,6 @@ if (!$columns) {
: count($rows) : count($rows)
); );
$foreign_keys = column_foreign_keys($_GET["select"]);
$descriptions = $adminer->rowDescriptions($rows, $foreign_keys); $descriptions = $adminer->rowDescriptions($rows, $foreign_keys);
$backward_keys = $adminer->backwardKeys($_GET["select"]); $backward_keys = $adminer->backwardKeys($_GET["select"]);
@ -191,7 +198,7 @@ if (!$columns) {
echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n"; echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n";
foreach ($descriptions as $n => $row) { foreach ($descriptions as $n => $row) {
$unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes)); $unique_idf = implode('&amp;', 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($_GET["db"]) ? '' : " <a href='" . h($SELF) . "edit=" . urlencode($_GET['select']) . "&amp;$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($_GET["db"]) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($_GET['select']) . "&amp;$unique_idf" . "'>" . lang('edit') . "</a>");
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
if (isset($names[$key])) { if (isset($names[$key])) {
if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) { if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
@ -203,7 +210,7 @@ if (!$columns) {
$val = "<i>NULL</i>"; $val = "<i>NULL</i>";
} else { } else {
if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) { if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
$link = h($SELF . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf; $link = h(ME . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&') . $unique_idf;
} }
if (!strlen(trim($val, " \t"))) { if (!strlen(trim($val, " \t"))) {
$val = "&nbsp;"; $val = "&nbsp;";
@ -219,7 +226,7 @@ if (!$columns) {
foreach ($foreign_key["source"] as $i => $source) { foreach ($foreign_key["source"] as $i => $source) {
$link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]); $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
} }
$link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), $SELF) : $SELF) . 'select=' . urlencode($foreign_key["table"])) . $link; // InnoDB supports non-UNIQUE keys $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"])) . $link; // InnoDB supports non-UNIQUE keys
break; break;
} }
} }
@ -235,7 +242,7 @@ if (!$columns) {
echo "<td>"; echo "<td>";
foreach ($table_names as $table => $name) { foreach ($table_names as $table => $name) {
foreach ($backward_keys[$table] as $columns) { foreach ($backward_keys[$table] as $columns) {
echo " <a href='" . h($SELF) . 'select=' . urlencode($table); echo " <a href='" . h(ME) . 'select=' . urlencode($table);
$i = 0; $i = 0;
foreach ($columns as $column => $val) { foreach ($columns as $column => $val) {
echo where_link($i, $column, $rows[$n][$val]); echo where_link($i, $column, $rows[$n][$val]);

View file

@ -96,7 +96,7 @@ if ($history) {
echo "<fieldset><legend>" . lang('History') . "</legend>\n"; echo "<fieldset><legend>" . lang('History') . "</legend>\n";
foreach ($history as $key => $val) { foreach ($history as $key => $val) {
//! save and display timestamp //! save and display timestamp
echo '<a href="' . h($SELF . "sql=&history=$key") . '">' . lang('Edit') . '</a> <code class="jush-sql">' . shorten_utf8(ltrim(str_replace("\n", " ", preg_replace('~^(#|-- ).*~m', '', $val))), 80, "</code>") . "<br>\n"; echo '<a href="' . h(ME . "sql=&history=$key") . '">' . lang('Edit') . '</a> <code class="jush-sql">' . shorten_utf8(ltrim(str_replace("\n", " ", preg_replace('~^(#|-- ).*~m', '', $val))), 80, "</code>") . "<br>\n";
} }
echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n"; echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n";
echo "</fieldset>\n"; echo "</fieldset>\n";

View file

@ -22,13 +22,13 @@ if ($result) {
echo "<p>"; echo "<p>";
if ($is_view) { if ($is_view) {
echo '<a href="' . h($SELF) . 'view=' . urlencode($_GET["table"]) . '">' . lang('Alter view') . '</a>'; echo '<a href="' . h(ME) . 'view=' . urlencode($_GET["table"]) . '">' . lang('Alter view') . '</a>';
} else { } else {
echo '<a href="' . h($SELF) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . '</a>'; echo '<a href="' . h(ME) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . '</a>';
echo ($auto_increment_only ? '' : ' <a href="' . h($SELF) . 'default=' . urlencode($_GET["table"]) . '">' . lang('Default values') . '</a>'); echo ($auto_increment_only ? '' : ' <a href="' . h(ME) . 'default=' . urlencode($_GET["table"]) . '">' . lang('Default values') . '</a>');
} }
echo ' <a href="' . h($SELF) . 'select=' . urlencode($_GET["table"]) . '">' . lang('Select table') . '</a>'; echo ' <a href="' . h(ME) . 'select=' . urlencode($_GET["table"]) . '">' . lang('Select table') . '</a>';
echo ' <a href="' . h($SELF) . 'edit=' . urlencode($_GET["table"]) . '">' . lang('New item') . '</a>'; echo ' <a href="' . h(ME) . 'edit=' . urlencode($_GET["table"]) . '">' . lang('New item') . '</a>';
if (!$is_view) { if (!$is_view) {
echo "<h3>" . lang('Indexes') . "</h3>\n"; echo "<h3>" . lang('Indexes') . "</h3>\n";
@ -45,7 +45,7 @@ if ($result) {
} }
echo "</table>\n"; echo "</table>\n";
} }
echo '<p><a href="' . h($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a>\n"; echo '<p><a href="' . h(ME) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a>\n";
if ($table_status["Engine"] == "InnoDB") { if ($table_status["Engine"] == "InnoDB") {
echo "<h3>" . lang('Foreign keys') . "</h3>\n"; echo "<h3>" . lang('Foreign keys') . "</h3>\n";
@ -56,13 +56,13 @@ if ($result) {
$link = (strlen($foreign_key["db"]) ? "<strong>" . h($foreign_key["db"]) . "</strong>." : "") . h($foreign_key["table"]); $link = (strlen($foreign_key["db"]) ? "<strong>" . h($foreign_key["db"]) . "</strong>." : "") . h($foreign_key["table"]);
echo "<tr>"; echo "<tr>";
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>"; 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"]), $SELF) : $SELF) . "table=" . urlencode($foreign_key["table"]) . "'>$link</a>"; 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 "(<em>" . implode("</em>, <em>", array_map('h', $foreign_key["target"])) . "</em>)";
echo "<td>" . (!strlen($foreign_key["db"]) ? '<a href="' . h($SELF) . 'foreign=' . urlencode($_GET["table"]) . '&amp;name=' . urlencode($name) . '">' . lang('Alter') . '</a>' : '&nbsp;'); echo "<td>" . (!strlen($foreign_key["db"]) ? '<a href="' . h(ME) . 'foreign=' . urlencode($_GET["table"]) . '&amp;name=' . urlencode($name) . '">' . lang('Alter') . '</a>' : '&nbsp;');
} }
echo "</table>\n"; echo "</table>\n";
} }
echo '<p><a href="' . h($SELF) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a>\n"; echo '<p><a href="' . h(ME) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a>\n";
} }
if ($dbh->server_info >= 5) { if ($dbh->server_info >= 5) {
@ -71,12 +71,12 @@ if ($result) {
if ($result->num_rows) { if ($result->num_rows) {
echo "<table cellspacing='0'>\n"; echo "<table cellspacing='0'>\n";
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
echo "<tr valign='top'><td>$row[Timing]<td>$row[Event]<th>" . h($row["Trigger"]) . "<td><a href=\"" . h($SELF) . 'trigger=' . urlencode($_GET["table"]) . '&amp;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($_GET["table"]) . '&amp;name=' . urlencode($row["Trigger"]) . '">' . lang('Alter') . "</a>\n";
} }
echo "</table>\n"; echo "</table>\n";
} }
$result->free(); $result->free();
echo '<p><a href="' . h($SELF) . 'trigger=' . urlencode($_GET["table"]) . '">' . lang('Add trigger') . "</a>\n"; echo '<p><a href="' . h(ME) . 'trigger=' . urlencode($_GET["table"]) . '">' . lang('Add trigger') . "</a>\n";
} }
} }
} }

View file

@ -5,11 +5,11 @@ $trigger_event = array("INSERT", "UPDATE", "DELETE");
$dropped = false; $dropped = false;
if ($_POST && !$error) { if ($_POST && !$error) {
if (strlen($_GET["name"])) { if (strlen($_GET["name"])) {
$dropped = query_redirect("DROP TRIGGER " . idf_escape($_GET["name"]), $SELF . "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($_GET["trigger"]), lang('Trigger has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
} }
if (!$_POST["drop"]) { if (!$_POST["drop"]) {
if (in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) { 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]", $SELF . "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($_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.')));
} }
} }
} }

View file

@ -63,7 +63,7 @@ if ($_POST && !$error) {
$new_user = $dbh->quote($_POST["user"]) . "@" . $dbh->quote($_POST["host"]); // if $_GET["host"] is not set then $new_user is always different $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"]); $pass = $dbh->quote($_POST["pass"]);
if ($_POST["drop"]) { if ($_POST["drop"]) {
query_redirect("DROP USER $old_user", $SELF . "privileges=", lang('User has been dropped.')); query_redirect("DROP USER $old_user", ME . "privileges=", lang('User has been dropped.'));
} else { } else {
if ($old_user == $new_user) { if ($old_user == $new_user) {
queries("SET PASSWORD FOR $new_user = " . ($_POST["hashed"] ? $pass : "PASSWORD($pass)")); queries("SET PASSWORD FOR $new_user = " . ($_POST["hashed"] ? $pass : "PASSWORD($pass)"));
@ -106,7 +106,7 @@ if ($_POST && !$error) {
} }
} }
} }
query_redirect(queries(), $SELF . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error, false, $error); query_redirect(queries(), ME . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error, false, $error);
if ($old_user != $new_user) { if ($old_user != $new_user) {
// delete new user in case of an error // delete new user in case of an error
$dbh->query("DROP USER $new_user"); $dbh->query("DROP USER $new_user");

View file

@ -2,9 +2,9 @@
$dropped = false; $dropped = false;
if ($_POST && !$error) { if ($_POST && !$error) {
if (strlen($_GET["view"])) { if (strlen($_GET["view"])) {
$dropped = query_redirect("DROP VIEW " . idf_escape($_GET["view"]), substr($SELF, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]); $dropped = query_redirect("DROP VIEW " . idf_escape($_GET["view"]), substr(ME, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]);
} }
query_redirect("CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]", $SELF . "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($_GET["view"]) ? 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($_GET["view"]) ? lang('Alter view') : lang('Create view')), $error, array("table" => $_GET["view"]), $_GET["view"]);

View file

@ -12,6 +12,7 @@ Link e-mails in select
Show type in field name title (thanks to Jakub Sochor) Show type in field name title (thanks to Jakub Sochor)
Preselect now() for timestamp columns (thanks to paranoiq) Preselect now() for timestamp columns (thanks to paranoiq)
Clear history (thanks to paranoiq) Clear history (thanks to paranoiq)
Prefill insert by foreign key searches
Remove Delete button from Edit page - use mass operation for it Remove Delete button from Edit page - use mass operation for it
Faster multiple update, clone and delete Faster multiple update, clone and delete
Faster table list in navigation Faster table list in navigation

View file

@ -285,7 +285,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
} }
function editFunctions($field) { function editFunctions($field) {
return array(""); return array($field["null"] || $field["auto_increment"] ? "" : "*");
} }
function editInput($table, $field, $attrs, $value) { function editInput($table, $field, $attrs, $value) {
@ -296,11 +296,8 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
$id = idf_escape($foreign_key["target"][0]); $id = idf_escape($foreign_key["target"][0]);
$name = $this->rowDescription($foreign_key["table"]); $name = $this->rowDescription($foreign_key["table"]);
if (strlen($name) && $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big if (strlen($name) && $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big
$return = array(); $return = array("" => "");
$result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2"); $result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2");
if ($field["null"] || !$result->num_rows) { // empty <select> is not HTML-valid
$return[""] = "";
}
while ($row = $result->fetch_row()) { while ($row = $result->fetch_row()) {
$return[$row[0]] = $row[1]; $return[$row[0]] = $row[1];
} }
@ -327,7 +324,6 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
} }
function navigation($missing) { function navigation($missing) {
global $SELF;
if ($missing != "auth") { if ($missing != "auth") {
?> ?>
<form action="" method="post"> <form action="" method="post">
@ -346,7 +342,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
foreach ($table_status as $row) { foreach ($table_status as $row) {
$name = $this->tableName($row); $name = $this->tableName($row);
if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name
echo "<a href='" . h($SELF) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n"; echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n";
} }
} }
} }

View file

@ -1 +1,2 @@
// downloaded from repository by version_checker()
document.cookie = 'adminer_version=1.11.1'; document.cookie = 'adminer_version=1.11.1';