mirror of
https://github.com/vrana/adminer.git
synced 2025-08-17 20:01:25 +02:00
Shortcut for htmlspecialchars
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@936 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -33,8 +33,8 @@ class Adminer {
|
||||
function loginForm($username) {
|
||||
?>
|
||||
<table cellspacing="0">
|
||||
<tr><th><?php echo lang('Server'); ?><td><input name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>">
|
||||
<tr><th><?php echo lang('Username'); ?><td><input name="username" value="<?php echo htmlspecialchars($username); ?>">
|
||||
<tr><th><?php echo lang('Server'); ?><td><input name="server" value="<?php echo h($_GET["server"]); ?>">
|
||||
<tr><th><?php echo lang('Username'); ?><td><input name="username" value="<?php echo h($username); ?>">
|
||||
<tr><th><?php echo lang('Password'); ?><td><input type="password" name="password">
|
||||
</table>
|
||||
<?php
|
||||
@@ -54,7 +54,7 @@ class Adminer {
|
||||
* @return string
|
||||
*/
|
||||
function tableName($tableStatus) {
|
||||
return htmlspecialchars($tableStatus["Name"]);
|
||||
return h($tableStatus["Name"]);
|
||||
}
|
||||
|
||||
/** Field caption used in select and edit
|
||||
@@ -63,7 +63,7 @@ class Adminer {
|
||||
* @return string
|
||||
*/
|
||||
function fieldName($field, $order = 0) {
|
||||
return '<span title="' . htmlspecialchars($field["full_type"]) . '">' . htmlspecialchars($field["field"]) . '</span>';
|
||||
return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>';
|
||||
}
|
||||
|
||||
/** Links after select heading
|
||||
@@ -72,7 +72,7 @@ class Adminer {
|
||||
*/
|
||||
function selectLinks($tableStatus) {
|
||||
global $SELF;
|
||||
return '<a href="' . htmlspecialchars($SELF) . '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
|
||||
@@ -90,7 +90,7 @@ class Adminer {
|
||||
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'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
|
||||
return "<p><code class='jush-sql'>" . h($query) . "</code> <a href='" . h($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
|
||||
}
|
||||
|
||||
/** Description of a row in a table
|
||||
@@ -163,8 +163,8 @@ class Adminer {
|
||||
echo '<fieldset><legend><a href="#fieldset-search" onclick="return !toggle(\'fieldset-search\');">' . lang('Search') . "</a></legend><div id='fieldset-search'" . ($where ? "" : " class='hidden'") . ">\n";
|
||||
foreach ($indexes as $i => $index) {
|
||||
if ($index["type"] == "FULLTEXT") {
|
||||
echo "(<i>" . implode("</i>, <i>", array_map('htmlspecialchars', $index["columns"])) . "</i>) AGAINST";
|
||||
echo ' <input name="fulltext[' . $i . ']" value="' . htmlspecialchars($_GET["fulltext"][$i]) . '">';
|
||||
echo "(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
|
||||
echo " <input name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
|
||||
echo "<label><input type='checkbox' name='boolean[$i]' value='1'" . (isset($_GET["boolean"][$i]) ? " checked='checked'" : "") . ">" . lang('BOOL') . "</label>";
|
||||
echo "<br>\n";
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class Adminer {
|
||||
if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) {
|
||||
echo "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . optionlist($columns, $val["col"], true) . "</select>";
|
||||
echo "<select name='where[$i][op]'>" . optionlist($this->operators, $val["op"]) . "</select>";
|
||||
echo "<input name='where[$i][val]' value=\"" . htmlspecialchars($val["val"]) . "\"></div>\n";
|
||||
echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class Adminer {
|
||||
*/
|
||||
function selectLimitPrint($limit) {
|
||||
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
|
||||
echo "<input name='limit' size='3' value=\"" . htmlspecialchars($limit) . "\">";
|
||||
echo "<input name='limit' size='3' value='" . h($limit) . "'>";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ class Adminer {
|
||||
function selectLengthPrint($text_length) {
|
||||
if (isset($text_length)) {
|
||||
echo "<fieldset><legend>" . lang('Text length') . "</legend><div>";
|
||||
echo '<input name="text_length" size="3" value="' . htmlspecialchars($text_length) . '">';
|
||||
echo '<input name="text_length" size="3" value="' . h($text_length) . '">';
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,7 @@ class Adminer {
|
||||
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'>" . htmlspecialchars($query) . '</pre><a href="' . htmlspecialchars($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($SELF . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
|
||||
}
|
||||
|
||||
/** Functions displayed in edit form
|
||||
@@ -422,18 +422,18 @@ class Adminer {
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<p>
|
||||
<a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
|
||||
<a href="<?php echo htmlspecialchars($SELF); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
|
||||
<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>
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
|
||||
<input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
|
||||
</p>
|
||||
</form>
|
||||
<form action="">
|
||||
<p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>"><?php } ?>
|
||||
<p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
|
||||
<?php if ($databases) { ?>
|
||||
<select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)<?php echo optionlist($databases, $_GET["db"]); ?></select>
|
||||
<?php } else { ?>
|
||||
<input name="db" value="<?php echo htmlspecialchars($_GET["db"]); ?>">
|
||||
<input name="db" value="<?php echo h($_GET["db"]); ?>">
|
||||
<?php } ?>
|
||||
<?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
|
||||
<?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
|
||||
@@ -449,12 +449,12 @@ class Adminer {
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
while ($row = $result->fetch_row()) {
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
|
||||
echo '<a href="' . htmlspecialchars($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($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
|
||||
}
|
||||
}
|
||||
$result->free();
|
||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a>\n";
|
||||
echo '<p><a href="' . h($SELF) . 'create=">' . lang('Create new table') . "</a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,13 +40,13 @@ function auth_error($exception = null) {
|
||||
global $ignore, $dbh, $adminer;
|
||||
$username = $_SESSION["usernames"][$_GET["server"]];
|
||||
unset($_SESSION["usernames"][$_GET["server"]]);
|
||||
page_header(lang('Login'), (isset($username) ? htmlspecialchars($exception ? $exception->getMessage() : (is_string($dbh) ? $dbh : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Sessions must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
|
||||
page_header(lang('Login'), (isset($username) ? h($exception ? $exception->getMessage() : (is_string($dbh) ? $dbh : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Sessions must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
|
||||
echo "<form action='' method='post'>\n";
|
||||
$adminer->loginForm($username);
|
||||
echo "<p>\n";
|
||||
hidden_fields($_POST, $ignore); // expired session
|
||||
foreach ($_FILES as $key => $val) {
|
||||
echo '<input type="hidden" name="files[' . htmlspecialchars($key) . ']" value="' . ($val["error"] ? $val["error"] : base64_encode(file_get_contents($val["tmp_name"]))) . '">';
|
||||
echo '<input type="hidden" name="files[' . h($key) . ']" value="' . ($val["error"] ? $val["error"] : base64_encode(file_get_contents($val["tmp_name"]))) . '">';
|
||||
}
|
||||
echo "<input type='submit' value='" . lang('Login') . "'>\n</form>\n";
|
||||
page_footer("auth");
|
||||
|
@@ -2,7 +2,7 @@
|
||||
function connect_error() {
|
||||
global $dbh, $SELF, $VERSION;
|
||||
if (strlen($_GET["db"])) {
|
||||
page_header(lang('Database') . ": " . htmlspecialchars($_GET["db"]), lang('Invalid database.'), false);
|
||||
page_header(lang('Database') . ": " . h($_GET["db"]), lang('Invalid database.'), false);
|
||||
} else {
|
||||
page_header(lang('Select database'), "", null);
|
||||
foreach (array(
|
||||
@@ -11,10 +11,10 @@ function connect_error() {
|
||||
'processlist' => lang('Process list'),
|
||||
'variables' => lang('Variables'),
|
||||
) as $key => $val) {
|
||||
echo '<p><a href="' . htmlspecialchars($SELF) . "$key=\">$val</a>\n";
|
||||
echo '<p><a href="' . h($SELF) . "$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>" . htmlspecialchars($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n";
|
||||
echo "<p>" . lang('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n";
|
||||
}
|
||||
page_footer("db");
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript">
|
||||
<meta name="robots" content="noindex">
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? htmlspecialchars("- $_GET[server]") : "") . " - " . $adminer->name(); ?></title>
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . h($title2) : "") . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? h("- $_GET[server]") : "") . " - " . $adminer->name(); ?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="../adminer/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../adminer/default.css<?php // Ondrej Valka, http://valka.info ?>">
|
||||
<?php if (file_exists("adminer.css")) { ?>
|
||||
@@ -23,21 +23,21 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||
<?php
|
||||
if (isset($breadcrumb)) {
|
||||
$link = substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1);
|
||||
echo '<p id="breadcrumb"><a href="' . (strlen($link) ? htmlspecialchars($link) : ".") . '">' . (isset($_GET["server"]) ? htmlspecialchars($_GET["server"]) : lang('Server')) . '</a> » ';
|
||||
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="' . htmlspecialchars(substr($SELF, 0, -1)) . '">' . htmlspecialchars($_GET["db"]) . '</a> » ';
|
||||
echo '<a href="' . h(substr($SELF, 0, -1)) . '">' . h($_GET["db"]) . '</a> » ';
|
||||
}
|
||||
foreach ($breadcrumb as $key => $val) {
|
||||
$desc = (is_array($val) ? $val[1] : $val);
|
||||
if (strlen($desc)) {
|
||||
echo '<a href="' . htmlspecialchars("$SELF$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . htmlspecialchars($desc) . '</a> » ';
|
||||
echo '<a href="' . h("$SELF$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> » ';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "$title\n";
|
||||
}
|
||||
echo "<h2>$title" . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . "</h2>\n";
|
||||
echo "<h2>$title" . (strlen($title2) ? ": " . h($title2) : "") . "</h2>\n";
|
||||
if ($_SESSION["messages"]) {
|
||||
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $_SESSION["messages"]) . "</div>\n";
|
||||
$_SESSION["messages"] = array();
|
||||
@@ -63,7 +63,7 @@ function page_footer($missing = false) {
|
||||
<?php switch_lang(); ?>
|
||||
<div id="menu">
|
||||
<h1><a href="http://www.adminer.org/" class="h1"><?php echo $adminer->name(); ?></a> <?php echo $VERSION; ?>
|
||||
<a href='http://www.adminer.org/#download' id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? htmlspecialchars($_COOKIE["adminer_version"]) : ""); ?></a>
|
||||
<a href='http://www.adminer.org/#download' id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
|
||||
</h1>
|
||||
<?php $adminer->navigation($missing); ?>
|
||||
</div>
|
||||
|
@@ -21,7 +21,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
|
||||
global $structured_types, $unsigned, $inout;
|
||||
?>
|
||||
<td><select name="<?php echo $key; ?>[type]" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
|
||||
<td><input name="<?php echo $key; ?>[length]" value="<?php echo htmlspecialchars($field["length"]); ?>" size="3">
|
||||
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3">
|
||||
<td><?php
|
||||
echo "<select name=\"$key" . '[collation]"' . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
||||
echo ($unsigned ? " <select name=\"$key" . '[unsigned]"' . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
||||
@@ -84,12 +84,12 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
|
||||
?>
|
||||
<tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
|
||||
<?php if ($type == "PROCEDURE") { ?><td><select name="fields[<?php echo $i; ?>][inout]"><?php echo optionlist($inout, $field["inout"]); ?></select><?php } ?>
|
||||
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>" onchange="<?php echo (strlen($field["field"]) || count($fields) > 1 ? "" : "editing_add_row(this, $allowed); "); ?>editing_name_change(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>">
|
||||
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo (strlen($field["field"]) || count($fields) > 1 ? "" : "editing_add_row(this, $allowed); "); ?>editing_name_change(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($field[($_POST ? "orig" : "field")]); ?>">
|
||||
<?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
|
||||
<?php if ($type == "TABLE") { ?>
|
||||
<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?>>
|
||||
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?>>
|
||||
<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255">
|
||||
<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo h($field["comment"]); ?>" maxlength="255">
|
||||
<?php } ?>
|
||||
<?php
|
||||
echo "<td class='nowrap'><input type='image' name='add[$i]' src='../adminer/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='var x = editing_add_row(this, $allowed); if (x) { x.focus(); x.onchange = function () { }; } return !x;'>";
|
||||
|
@@ -25,14 +25,18 @@ function bracket_escape($idf, $back = false) {
|
||||
return strtr($idf, ($back ? array_flip($trans) : $trans));
|
||||
}
|
||||
|
||||
function h($string) {
|
||||
return htmlspecialchars($string, ENT_QUOTES);
|
||||
}
|
||||
|
||||
function optionlist($options, $selected = null, $use_keys = false) {
|
||||
$return = "";
|
||||
foreach ($options as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$return .= '<optgroup label="' . htmlspecialchars($k) . '">';
|
||||
$return .= '<optgroup label="' . h($k) . '">';
|
||||
}
|
||||
foreach ((is_array($v) ? $v : array($k => $v)) as $key => $val) {
|
||||
$return .= '<option' . ($use_keys || is_string($key) ? ' value="' . htmlspecialchars($key) . '"' : '') . (($use_keys || is_string($key) ? (string) $key : $val) === $selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($val);
|
||||
$return .= '<option' . ($use_keys || is_string($key) ? ' value="' . h($key) . '"' : '') . (($use_keys || is_string($key) ? (string) $key : $val) === $selected ? ' selected="selected"' : '') . '>' . h($val);
|
||||
}
|
||||
if (is_array($v)) {
|
||||
$return .= '</optgroup>';
|
||||
@@ -121,7 +125,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
||||
$failed = !$dbh->query($query);
|
||||
}
|
||||
if ($failed) {
|
||||
$error = htmlspecialchars($dbh->error) . $sql;
|
||||
$error = h($dbh->error) . $sql;
|
||||
return false;
|
||||
}
|
||||
if ($redirect) {
|
||||
@@ -147,7 +151,7 @@ function remove_from_uri($param = "") {
|
||||
}
|
||||
|
||||
function pagination($page) {
|
||||
return " " . ($page == $_GET["page"] ? $page + 1 : '<a href="' . htmlspecialchars(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
|
||||
return " " . ($page == $_GET["page"] ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
|
||||
}
|
||||
|
||||
function get_file($key) {
|
||||
@@ -212,7 +216,7 @@ function select($result, $dbh2 = null) {
|
||||
$blobs[$j] = true;
|
||||
}
|
||||
$types[$j] = $field->type;
|
||||
echo "<th>" . htmlspecialchars($field->name);
|
||||
echo "<th>" . h($field->name);
|
||||
}
|
||||
echo "</thead>\n";
|
||||
}
|
||||
@@ -226,7 +230,7 @@ function select($result, $dbh2 = null) {
|
||||
} elseif (!strlen(trim($val, " \t"))) {
|
||||
$val = " "; // some content to print a border
|
||||
} else {
|
||||
$val = nl2br(htmlspecialchars($val));
|
||||
$val = nl2br(h($val));
|
||||
if ($types[$key] == 254) {
|
||||
$val = "<code>$val</code>";
|
||||
}
|
||||
@@ -236,7 +240,7 @@ function select($result, $dbh2 = null) {
|
||||
foreach ($indexes[$links[$key]] as $col => $j) {
|
||||
$link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
|
||||
}
|
||||
$val = '<a href="' . htmlspecialchars($SELF) . $link . '">' . $val . '</a>';
|
||||
$val = "<a href='" . h($SELF) . "$link'>$val</a>";
|
||||
}
|
||||
}
|
||||
echo "<td>$val";
|
||||
@@ -254,7 +258,7 @@ function is_utf8($val) {
|
||||
|
||||
function shorten_utf8($string, $length = 80, $suffix = "") {
|
||||
preg_match("~^((?:.|\n){0,$length})(.|\n)?~u", $string, $match); // ~s causes trash in $match[2] under some PHP versions
|
||||
return htmlspecialchars($match[1]) . $suffix . ($match[2] ? "<em>...</em>" : "");
|
||||
return h($match[1]) . $suffix . ($match[2] ? "<em>...</em>" : "");
|
||||
}
|
||||
|
||||
function friendly_url($val) {
|
||||
@@ -269,7 +273,7 @@ function hidden_fields($process, $ignore = array()) {
|
||||
$process[$key . "[$k]"] = $v;
|
||||
}
|
||||
} elseif (!in_array($key, $ignore)) {
|
||||
echo '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($val) . '">';
|
||||
echo '<input type="hidden" name="' . h($key) . '" value="' . h($val) . '">';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,28 +290,28 @@ function column_foreign_keys($table) {
|
||||
|
||||
function input($field, $value, $function) {
|
||||
global $types, $adminer;
|
||||
$name = htmlspecialchars(bracket_escape($field["field"]));
|
||||
$name = h(bracket_escape($field["field"]));
|
||||
echo "<td class='function'>";
|
||||
if ($field["type"] == "enum") {
|
||||
echo " <td>" . (isset($_GET["select"]) ? ' <label><input type="radio" name="fields[' . $name . ']" value="-1" checked="checked"><em>' . lang('original') . '</em></label>' : "");
|
||||
echo " <td>" . (isset($_GET["select"]) ? " <label><input type='radio' name='fields[$name]' value='-1' checked='checked'><em>" . lang('original') . "</em></label>" : "");
|
||||
if ($field["null"] || isset($_GET["default"])) {
|
||||
echo ' <label><input type="radio" name="fields[' . $name . ']" value=""' . (($field["null"] ? isset($value) : strlen($value)) || isset($_GET["select"]) ? '' : ' checked="checked"') . '>' . ($field["null"] ? '<em>NULL</em>' : '') . '</label>';
|
||||
echo " <label><input type='radio' name='fields[$name]' value=''" . (($field["null"] ? isset($value) : strlen($value)) || isset($_GET["select"]) ? '' : ' checked="checked"') . '>' . ($field["null"] ? '<em>NULL</em>' : '') . '</label>';
|
||||
}
|
||||
if (!isset($_GET["default"])) {
|
||||
echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . '>';
|
||||
echo "<input type='radio' name='fields[$name]' value='0'" . ($value === 0 ? ' checked="checked"' : '') . '>';
|
||||
}
|
||||
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
|
||||
foreach ($matches[1] as $i => $val) {
|
||||
$val = stripcslashes(str_replace("''", "'", $val));
|
||||
$checked = (is_int($value) ? $value == $i+1 : $value === $val);
|
||||
echo ' <label><input type="radio" name="fields[' . $name . ']" value="' . (isset($_GET["default"]) ? (strlen($val) ? htmlspecialchars($val) : " ") : $i+1) . '"' . ($checked ? ' checked="checked"' : '') . '>' . htmlspecialchars($val) . '</label>';
|
||||
echo " <label><input type='radio' name='fields[$name]' value='" . (isset($_GET["default"]) ? (strlen($val) ? h($val) : " ") : $i+1) . "'" . ($checked ? ' checked="checked"' : '') . '>' . h($val) . '</label>';
|
||||
}
|
||||
} else {
|
||||
$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>';
|
||||
$input = $adminer->editInput($_GET["edit"], $field, ' name="fields[' . $name . ']"' . $onchange, $value); // usage in call is without a table
|
||||
$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>';
|
||||
$input = $adminer->editInput($_GET["edit"], $field, " name='fields[$name]'$onchange", $value); // usage in call is without a table
|
||||
if (strlen($input)) {
|
||||
echo $input;
|
||||
} elseif ($field["type"] == "set") { //! 64 bits
|
||||
@@ -315,16 +319,16 @@ function input($field, $value, $function) {
|
||||
foreach ($matches[1] as $i => $val) {
|
||||
$val = stripcslashes(str_replace("''", "'", $val));
|
||||
$checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
|
||||
echo ' <label><input type="checkbox" name="fields[' . $name . '][' . $i . ']" value="' . (isset($_GET["default"]) ? htmlspecialchars($val) : 1 << $i) . '"' . ($checked ? ' checked="checked"' : '') . "$onchange>" . htmlspecialchars($val) . '</label>';
|
||||
echo " <label><input type='checkbox' name='fields[$name][$i]' value='" . (isset($_GET["default"]) ? h($val) : 1 << $i) . "'" . ($checked ? ' checked="checked"' : '') . "$onchange>" . h($val) . '</label>';
|
||||
}
|
||||
} elseif (strpos($field["type"], "text") !== false) {
|
||||
echo '<textarea name="fields[' . $name . ']" cols="50" rows="12"' . "$onchange>" . htmlspecialchars($value) . '</textarea>';
|
||||
echo "<textarea name='fields[$name]' cols='50' rows='12'$onchange>" . h($value) . '</textarea>';
|
||||
} elseif (ereg('binary|blob', $field["type"])) {
|
||||
echo (ini_get("file_uploads") ? '<input type="file" name="' . $name . '"' . "$onchange>" : lang('File uploads are disabled.'));
|
||||
echo (ini_get("file_uploads") ? "<input type='file' name='$name'$onchange>" : lang('File uploads are disabled.'));
|
||||
} else {
|
||||
// int(3) is only a display hint
|
||||
$maxlength = (!ereg('int', $field["type"]) && preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
|
||||
echo '<input name="fields[' . $name . ']" value="' . htmlspecialchars($value) . '"' . ($maxlength ? " maxlength='$maxlength'" : "") . "$onchange>";
|
||||
echo "<input name='fields[$name]' value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . "$onchange>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user