mirror of
https://github.com/vrana/adminer.git
synced 2025-08-17 20:01:25 +02:00
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:
@@ -71,8 +71,7 @@ class Adminer {
|
||||
* @return string
|
||||
*/
|
||||
function selectLinks($tableStatus) {
|
||||
global $SELF;
|
||||
return '<a href="' . h($SELF) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
|
||||
return '<a href="' . h(ME) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
|
||||
}
|
||||
|
||||
/** Find backward keys for table
|
||||
@@ -88,9 +87,8 @@ class Adminer {
|
||||
* @return string
|
||||
*/
|
||||
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
|
||||
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
|
||||
@@ -337,10 +335,9 @@ class Adminer {
|
||||
* @return string
|
||||
*/
|
||||
function messageQuery($query) {
|
||||
global $SELF;
|
||||
$id = "sql-" . count($_SESSION["messages"]);
|
||||
$_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
|
||||
@@ -416,14 +413,14 @@ class Adminer {
|
||||
* @return null
|
||||
*/
|
||||
function navigation($missing) {
|
||||
global $SELF, $dbh;
|
||||
global $dbh;
|
||||
if ($missing != "auth") {
|
||||
$databases = get_databases();
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<p>
|
||||
<a href="<?php echo h($SELF); ?>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); ?>sql="><?php echo lang('SQL command'); ?></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="submit" name="logout" value="<?php echo lang('Logout'); ?>">
|
||||
</p>
|
||||
@@ -449,12 +446,12 @@ class Adminer {
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
while ($row = $result->fetch_row()) {
|
||||
echo '<a href="' . h($SELF) . '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) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
|
||||
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();
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ if (isset($_POST["server"])) {
|
||||
foreach (array("usernames", "passwords", "databases", "tokens", "history") as $val) {
|
||||
unset($_SESSION[$val][$_GET["server"]]);
|
||||
}
|
||||
redirect(substr($SELF, 0, -1), lang('Logout successful.'));
|
||||
redirect(substr(ME, 0, -1), lang('Logout successful.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,10 @@ if (isset($_GET["file"])) {
|
||||
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")) {
|
||||
// use specific session name to get own namespace
|
||||
session_name("adminer_sid");
|
||||
@@ -64,10 +68,7 @@ if (get_magic_quotes_gpc()) {
|
||||
}
|
||||
set_magic_quotes_runtime(false);
|
||||
|
||||
if (!isset($_SERVER["REQUEST_URI"])) {
|
||||
$_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"]) . '&' : '');
|
||||
define("ME", 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()
|
||||
|
||||
include "../adminer/include/version.inc.php";
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
function connect_error() {
|
||||
global $dbh, $SELF, $VERSION;
|
||||
global $dbh, $VERSION;
|
||||
if (strlen($_GET["db"])) {
|
||||
page_header(lang('Database') . ": " . h($_GET["db"]), lang('Invalid database.'), false);
|
||||
} else {
|
||||
@@ -11,7 +11,7 @@ function connect_error() {
|
||||
'processlist' => lang('Process list'),
|
||||
'variables' => lang('Variables'),
|
||||
) 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('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n";
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
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");
|
||||
?>
|
||||
<!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">
|
||||
<?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="editing.js"></script>
|
||||
|
||||
<div id="content">
|
||||
<?php
|
||||
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> » ';
|
||||
if (is_array($breadcrumb)) {
|
||||
if (strlen($_GET["db"])) {
|
||||
echo '<a href="' . h(substr($SELF, 0, -1)) . '">' . h($_GET["db"]) . '</a> » ';
|
||||
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["db"]) . '</a> » ';
|
||||
}
|
||||
foreach ($breadcrumb as $key => $val) {
|
||||
$desc = (is_array($val) ? $val[1] : $val);
|
||||
if (strlen($desc)) {
|
||||
echo '<a href="' . h("$SELF$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> » ';
|
||||
echo '<a href="' . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> » ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,4 @@
|
||||
<?php
|
||||
function get_self() {
|
||||
// can be used in customization, $SELF is minified
|
||||
global $SELF;
|
||||
return $SELF;
|
||||
}
|
||||
|
||||
function get_dbh() {
|
||||
// can be used in customization, $dbh is minified
|
||||
global $dbh;
|
||||
@@ -116,7 +110,7 @@ function redirect($location, $message = null) {
|
||||
}
|
||||
|
||||
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
|
||||
global $dbh, $error, $SELF, $adminer;
|
||||
global $dbh, $error, $adminer;
|
||||
$sql = "";
|
||||
if ($query) {
|
||||
$sql = $adminer->messageQuery($query);
|
||||
@@ -178,7 +172,6 @@ function odd($s = ' class="odd"') {
|
||||
}
|
||||
|
||||
function select($result, $dbh2 = null) {
|
||||
global $SELF;
|
||||
if (!$result->num_rows) {
|
||||
echo "<p class='message'>" . lang('No rows.') . "\n";
|
||||
} else {
|
||||
@@ -238,9 +231,9 @@ function select($result, $dbh2 = null) {
|
||||
if (isset($links[$key]) && !$columns[$links[$key]]) {
|
||||
$link = "edit=" . urlencode($links[$key]);
|
||||
foreach ($indexes[$links[$key]] as $col => $j) {
|
||||
$link .= "&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";
|
||||
@@ -310,7 +303,7 @@ function input($field, $value, $function) {
|
||||
$functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
|
||||
$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;\"" : "");
|
||||
echo (count($functions) > 1 ? "<select name='function[$name]'>" . optionlist($functions, $function) . "</select>" : " ") . '<td>';
|
||||
echo (count($functions) > 1 ? "<select name='function[$name]'>" . optionlist($functions, $function) . "</select>" : (strlen($functions[0]) ? $functions[0] : " ")) . '<td>';
|
||||
$input = $adminer->editInput($_GET["edit"], $field, " name='fields[$name]'$onchange", $value); // usage in call is without a table
|
||||
if (strlen($input)) {
|
||||
echo $input;
|
||||
|
Reference in New Issue
Block a user