Fixed warnings related to Pgsql driver

This commit is contained in:
Lionel Laffineur 2023-12-11 21:44:25 +01:00
parent 4f4f2d3069
commit 574e13cc4b
10 changed files with 44 additions and 41 deletions

View file

@ -61,7 +61,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
if (isset($field["has_default"]) === false || !$field["has_default"]) { if (isset($field["has_default"]) === false || !$field["has_default"]) {
$field["default"] = null; $field["default"] = null;
} }
if ($key == $row["auto_increment_col"]) { if (isset($row["auto_increment_col"]) && $key == $row["auto_increment_col"]) {
$field["auto_increment"] = true; $field["auto_increment"] = true;
} }
$process_field = process_field($field, $type_field); $process_field = process_field($field, $type_field);
@ -178,7 +178,7 @@ foreach ($engines as $engine) {
<form action="" method="post" id="form"> <form action="" method="post" id="form">
<p> <p>
<?php if (support("columns") || $TABLE == "") { ?> <?php if (support("columns") || $TABLE == "") { ?>
<?php echo lang('Table name'); ?>: <input name="name" data-maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off"> <?php echo lang('Table name'); ?>: <input name="name" data-maxlength="64" value="<?php echo h(isset($row["name"]) ? $row["name"] : null); ?>" autocapitalize="off">
<?php if ($TABLE == "" && !$_POST) { echo script("focus(qs('#form')['name']);"); } ?> <?php if ($TABLE == "" && !$_POST) { echo script("focus(qs('#form')['name']);"); } ?>
<?php echo ($engines ? "<select name='Engine'>" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" . on_help("getTarget(event).value", 1) . script("qsl('select').onchange = helpClose;") : ""); ?> <?php echo ($engines ? "<select name='Engine'>" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" . on_help("getTarget(event).value", 1) . script("qsl('select').onchange = helpClose;") : ""); ?>
<?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?> <?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
@ -201,9 +201,9 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
$comments = ($_POST ? $_POST["comments"] : adminer_setting("comments")); $comments = ($_POST ? $_POST["comments"] : adminer_setting("comments"));
echo (support("comment") echo (support("comment")
? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly") ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
. ' ' . (preg_match('~\n~', $row["Comment"]) . ' ' . (preg_match('~\n~', isset($row["Comment"]) ? $row["Comment"] : null)
? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>" ? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>"
: '<input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>' : '<input name="Comment" value="' . h(isset($row["Comment"]) ? $row["Comment"] : null) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>'
) )
: '') : '')
; ;

View file

@ -234,7 +234,10 @@ if (isset($_GET["pgsql"])) {
"information_schema" => "infoschema", "information_schema" => "infoschema",
"pg_catalog" => "catalog", "pg_catalog" => "catalog",
); );
$link = $links[$_GET["ns"]]; $link = null;
if (isset($_GET["ns"]) && isset($links[$_GET["ns"]])) {
$links[$_GET["ns"]];
}
if ($link) { if ($link) {
return "$link-" . str_replace("_", "-", $name) . ".html"; return "$link-" . str_replace("_", "-", $name) . ".html";
} }
@ -467,7 +470,7 @@ ORDER BY connamespace, conname") as $row) {
global $connection; global $connection;
$return = h($connection->error); $return = h($connection->error);
if (preg_match('~^(.*\n)?([^\n]*)\n( *)\^(\n.*)?$~s', $return, $match)) { if (preg_match('~^(.*\n)?([^\n]*)\n( *)\^(\n.*)?$~s', $return, $match)) {
$return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\1<b>\2</b>', $match[2]) . $match[4]; $return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\1<b>\2</b>', $match[2]) . (isset($match[4]) ? $match[4] : null);
} }
return nl_br($return); return nl_br($return);
} }

View file

@ -318,7 +318,7 @@ class Adminer {
echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . (support("comment") ? "<td>" . lang('Comment') : "") . "</thead>\n"; echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . (support("comment") ? "<td>" . lang('Comment') : "") . "</thead>\n";
foreach ($fields as $field) { foreach ($fields as $field) {
echo "<tr" . odd() . "><th>" . h($field["field"]); echo "<tr" . odd() . "><th>" . h($field["field"]);
echo "<td><span title='" . h($field["collation"]) . "'>" . h($field["full_type"]) . "</span>"; echo "<td><span title='" . h(isset($field["collation"]) ? $field["collation"] : null) . "'>" . h(isset($field["full_type"]) ? $field["full_type"] : null) . "</span>";
echo ($field["null"] ? " <i>NULL</i>" : ""); echo ($field["null"] ? " <i>NULL</i>" : "");
echo ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : ""); echo ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : "");
echo (isset($field["default"]) ? " <span title='" . lang('Default value') . "'>[<b>" . h($field["default"]) . "</b>]</span>" : ""); echo (isset($field["default"]) ? " <span title='" . lang('Default value') . "'>[<b>" . h($field["default"]) . "</b>]</span>" : "");
@ -340,8 +340,8 @@ class Adminer {
$print = array(); $print = array();
foreach ($index["columns"] as $key => $val) { foreach ($index["columns"] as $key => $val) {
$print[] = "<i>" . h($val) . "</i>" $print[] = "<i>" . h($val) . "</i>"
. ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "") . (isset($index["lengths"][$key]) && $index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
. ($index["descs"][$key] ? " DESC" : "") . (isset($index["descs"][$key]) && $index["descs"][$key] ? " DESC" : "")
; ;
} }
echo "<tr title='" . h($name) . "'><th>$index[type]<td>" . implode(", ", $print) . "\n"; echo "<tr title='" . h($name) . "'><th>$index[type]<td>" . implode(", ", $print) . "\n";

View file

@ -119,7 +119,7 @@ function auth_error($error) {
$session_name = session_name(); $session_name = session_name();
if (isset($_GET["username"])) { if (isset($_GET["username"])) {
header("HTTP/1.1 403 Forbidden"); // 401 requires sending WWW-Authenticate header header("HTTP/1.1 403 Forbidden"); // 401 requires sending WWW-Authenticate header
if (($_COOKIE[$session_name] || $_GET[$session_name]) && !$has_token) { if (((isset($_COOKIE[$session_name]) && $_COOKIE[$session_name]) || (isset($_GET[$session_name]) && $_GET[$session_name])) && !$has_token) {
$error = lang('Session expired, please login again.'); $error = lang('Session expired, please login again.');
} else { } else {
restart_session(); restart_session();

View file

@ -5,7 +5,7 @@ function connect_error() {
header("HTTP/1.1 404 Not Found"); header("HTTP/1.1 404 Not Found");
page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true); page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true);
} else { } else {
if ($_POST["db"] && !$error) { if (isset($_POST["db"]) && $_POST["db"] && !$error) {
queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"])); queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"]));
} }
@ -42,17 +42,17 @@ function connect_error() {
. "</thead>\n" . "</thead>\n"
; ;
$databases = ($_GET["dbsize"] ? count_tables($databases) : array_flip($databases)); $databases = (isset($_GET["dbsize"]) && $_GET["dbsize"] ? count_tables($databases) : array_flip($databases));
foreach ($databases as $db => $tables) { foreach ($databases as $db => $tables) {
$root = h(ME) . "db=" . urlencode($db); $root = h(ME) . "db=" . urlencode($db);
$id = h("Db-" . $db); $id = h("Db-" . $db);
echo "<tr" . odd() . ">" . (support("database") ? "<td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]), "", "", "", $id) : ""); echo "<tr" . odd() . ">" . (support("database") ? "<td>" . checkbox("db[]", $db, in_array($db, (array) (isset($_POST["db"]) ? $_POST["db"] : [])), "", "", "", $id) : "");
echo "<th><a href='$root' id='$id'>" . h($db) . "</a>"; echo "<th><a href='$root' id='$id'>" . h($db) . "</a>";
$collation = h(db_collation($db, $collations)); $collation = h(db_collation($db, $collations));
echo "<td>" . (support("database") ? "<a href='$root" . ($scheme ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>$collation</a>" : $collation); echo "<td>" . (support("database") ? "<a href='$root" . ($scheme ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>$collation</a>" : $collation);
echo "<td align='right'><a href='$root&amp;schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>" . ($_GET["dbsize"] ? $tables : "?") . "</a>"; echo "<td align='right'><a href='$root&amp;schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>" . (isset($_GET["dbsize"]) && $_GET["dbsize"] ? $tables : "?") . "</a>";
echo "<td align='right' id='size-" . h($db) . "'>" . ($_GET["dbsize"] ? db_size($db) : "?"); echo "<td align='right' id='size-" . h($db) . "'>" . (isset($_GET["dbsize"]) && $_GET["dbsize"] ? db_size($db) : "?");
echo "\n"; echo "\n";
} }
@ -82,8 +82,8 @@ if (isset($_GET["import"])) {
$_GET["sql"] = $_GET["import"]; $_GET["sql"] = $_GET["import"];
} }
if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]) || $_GET["script"] == "connect" || $_GET["script"] == "kill")) { if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]) || (isset($_GET["script"]) && $_GET["script"] == "connect") || (isset($_GET["script"]) && $_GET["script"] == "kill"))) {
if (DB != "" || $_GET["refresh"]) { if (DB != "" || (isset($_GET["refresh"]) && $_GET["refresh"])) {
restart_session(); restart_session();
set_session("dbs", null); set_session("dbs", null);
} }

View file

@ -35,7 +35,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<body class="<?php echo lang('ltr'); ?> nojs <?php echo $GLOBALS['project']; ?>"> <body class="<?php echo lang('ltr'); ?> nojs <?php echo $GLOBALS['project']; ?>">
<?php <?php
$filename = get_temp_dir() . "/adminer.version"; $filename = get_temp_dir() . "/adminer.version";
if (!$_COOKIE["adminer_version"] && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds if ((isset($_COOKIE["adminer_version"]) === false || !$_COOKIE["adminer_version"]) && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds
$version = unserialize(file_get_contents($filename)); $version = unserialize(file_get_contents($filename));
$public = "-----BEGIN PUBLIC KEY----- $public = "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK

View file

@ -104,7 +104,7 @@ function referencable_primary($self) {
foreach (table_status('', true) as $table_name => $table) { foreach (table_status('', true) as $table_name => $table) {
if ($table_name != $self && fk_support($table)) { if ($table_name != $self && fk_support($table)) {
foreach (fields($table_name) as $field) { foreach (fields($table_name) as $field) {
if ($field["primary"]) { if (isset($field["primary"]) && $field["primary"]) {
if (isset($return[$table_name]) && $return[$table_name]) { // multi column primary key if (isset($return[$table_name]) && $return[$table_name]) { // multi column primary key
unset($return[$table_name]); unset($return[$table_name]);
break; break;
@ -185,7 +185,7 @@ if ($foreign_keys) {
$structured_types[lang('Foreign keys')] = $foreign_keys; $structured_types[lang('Foreign keys')] = $foreign_keys;
} }
echo optionlist(array_merge($extra_types, $structured_types), $type); echo optionlist(array_merge($extra_types, $structured_types), $type);
?></select><td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?> aria-labelledby="label-length"><td class="options"><?php ?></select><td><input name="<?php echo h($key); ?>[length]" value="<?php echo h(isset($field["length"]) ? $field["length"] : null); ?>" size="3"<?php echo ((isset($field["length"]) === false || !$field["length"]) && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); //! type="number" with enabled JavaScript ?> aria-labelledby="label-length"><td class="options"><?php
echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, (isset($field["collation"]) ? $field["collation"] : null)) . '</select>'; echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, (isset($field["collation"]) ? $field["collation"] : null)) . '</select>';
echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, (isset($field["unsigned"]) ? $field["unsigned"] : null)) . '</select>' : ''); echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, (isset($field["unsigned"]) ? $field["unsigned"] : null)) . '</select>' : '');
echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), (preg_match('~^CURRENT_TIMESTAMP~i', (isset($field["on_update"]) ? $field["on_update"] : null)) ? "CURRENT_TIMESTAMP" : $field["on_update"])) . '</select>' : ''); echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), (preg_match('~^CURRENT_TIMESTAMP~i', (isset($field["on_update"]) ? $field["on_update"] : null)) ? "CURRENT_TIMESTAMP" : $field["on_update"])) . '</select>' : '');
@ -310,7 +310,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?> <th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
<input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?> <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
<?php if ($type == "TABLE") { ?> <?php if ($type == "TABLE") { ?>
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?> <td><?php echo checkbox("fields[$i][null]", 1, isset($field["null"]) ? $field["null"] : null, "", "", "block", "label-null"); ?>
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php <td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php
echo (support("comment") ? "<td$comment_class><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : ""); echo (support("comment") ? "<td$comment_class><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : "");
@ -548,7 +548,7 @@ function doc_link($paths, $text = "<sup>?</sup>") {
$urls['sql'] = "https://mariadb.com/kb/en/library/"; $urls['sql'] = "https://mariadb.com/kb/en/library/";
$paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql'])); $paths['sql'] = (isset($paths['mariadb']) ? $paths['mariadb'] : str_replace(".html", "/", $paths['sql']));
} }
return ($paths[$jush] ? "<a href='" . h($urls[$jush] . $paths[$jush]) . "'" . target_blank() . ">$text</a>" : ""); return (isset($paths[$jush]) && $paths[$jush] ? "<a href='" . h($urls[$jush] . $paths[$jush]) . "'" . target_blank() . ">$text</a>" : "");
} }
/** Wrap gzencode() for usage in ob_start() /** Wrap gzencode() for usage in ob_start()

View file

@ -72,7 +72,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
page_header(lang('Indexes'), $error, array("table" => $TABLE), h($TABLE)); page_header(lang('Indexes'), $error, array("table" => $TABLE), h($TABLE));
$fields = array_keys(fields($TABLE)); $fields = array_keys(fields($TABLE));
if ($_POST["add"]) { if (isset($_POST["add"]) && $_POST["add"]) {
foreach ($row["indexes"] as $key => $index) { foreach ($row["indexes"] as $key => $index) {
if ($index["columns"][count($index["columns"])] != "") { if ($index["columns"][count($index["columns"])] != "") {
$row["indexes"][$key]["columns"][] = ""; $row["indexes"][$key]["columns"][] = "";
@ -113,8 +113,8 @@ if ($primary) {
} }
$j = 1; $j = 1;
foreach ($row["indexes"] as $index) { foreach ($row["indexes"] as $index) {
if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) { if (isset($_POST["drop_col"]) === false || !$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : 1), "label-type"); echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, isset($index["type"]) ? $index["type"] : null, ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : 1), "label-type");
echo "<td>"; echo "<td>";
ksort($index["columns"]); ksort($index["columns"]);
@ -127,12 +127,12 @@ foreach ($row["indexes"] as $index) {
"partial(" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . ", '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "')" "partial(" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . ", '" . js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "')"
); );
echo ($jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "' title='" . lang('Length') . "'>" : ""); echo ($jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[$j][lengths][$i]' class='size' value='" . h($index["lengths"][$key]) . "' title='" . lang('Length') . "'>" : "");
echo (support("descidx") ? checkbox("indexes[$j][descs][$i]", 1, $index["descs"][$key], lang('descending')) : ""); echo (support("descidx") ? checkbox("indexes[$j][descs][$i]", 1, isset($index["descs"][$key]) ? $index["descs"][$key] : null, lang('descending')) : "");
echo " </span>"; echo " </span>";
$i++; $i++;
} }
echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off' aria-labelledby='label-name'>\n"; echo "<td><input name='indexes[$j][name]' value='" . h(isset($index["name"]) ? $index["name"] : null) . "' autocapitalize='off' aria-labelledby='label-name'>\n";
echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" . script("qsl('input').onclick = partial(editingRemoveRow, 'indexes\$1[type]');"); echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" . script("qsl('input').onclick = partial(editingRemoveRow, 'indexes\$1[type]');");
} }
$j++; $j++;

View file

@ -1,5 +1,5 @@
<?php <?php
if (!$error && $_POST["export"]) { if (!$error && isset($_POST["export"]) && $_POST["export"]) {
dump_headers("sql"); dump_headers("sql");
$adminer->dumpTable("", ""); $adminer->dumpTable("", "");
$adminer->dumpData("", "table", $_POST["query"]); $adminer->dumpData("", "table", $_POST["query"]);
@ -9,7 +9,7 @@ if (!$error && $_POST["export"]) {
restart_session(); restart_session();
$history_all = &get_session("queries"); $history_all = &get_session("queries");
$history = &$history_all[DB]; $history = &$history_all[DB];
if (!$error && $_POST["clear"]) { if (!$error && isset($_POST["clear"]) && $_POST["clear"]) {
$history = array(); $history = array();
redirect(remove_from_uri("history")); redirect(remove_from_uri("history"));
} }
@ -216,16 +216,16 @@ if (!isset($_GET["import"])) {
$q = $_GET["sql"]; // overwrite $q from if ($_POST) to save memory $q = $_GET["sql"]; // overwrite $q from if ($_POST) to save memory
if ($_POST) { if ($_POST) {
$q = $_POST["query"]; $q = $_POST["query"];
} elseif ($_GET["history"] == "all") { } elseif (isset($_GET["history"]) && $_GET["history"] == "all") {
$q = $history; $q = $history;
} elseif ($_GET["history"] != "") { } elseif (isset($_GET["history"]) && $_GET["history"] != "") {
$q = $history[$_GET["history"]][0]; $q = $history[$_GET["history"]][0];
} }
echo "<p>"; echo "<p>";
textarea("query", $q, 20); textarea("query", $q, 20);
echo script(($_POST ? "" : "qs('textarea').focus();\n") . "qs('#form').onsubmit = partial(sqlSubmit, qs('#form'), '" . js_escape(remove_from_uri("sql|limit|error_stops|only_errors|history")) . "');"); echo script(($_POST ? "" : "qs('textarea').focus();\n") . "qs('#form').onsubmit = partial(sqlSubmit, qs('#form'), '" . js_escape(remove_from_uri("sql|limit|error_stops|only_errors|history")) . "');");
echo "<p>$execute\n"; echo "<p>$execute\n";
echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n"; echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h(isset($_POST["limit"]) ? $_POST["limit"] : (isset($_GET["limit"]) ? $_GET["limit"] : null)) . "'>\n";
} else { } else {
echo "<fieldset><legend>" . lang('File upload') . "</legend><div>"; echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
@ -245,8 +245,8 @@ if (!isset($_GET["import"])) {
echo "<p>"; echo "<p>";
} }
echo checkbox("error_stops", 1, ($_POST ? $_POST["error_stops"] : isset($_GET["import"]) || $_GET["error_stops"]), lang('Stop on error')) . "\n"; echo checkbox("error_stops", 1, (isset($_POST["error_stops"]) ? $_POST["error_stops"] : isset($_GET["import"]) || (isset($_GET["error_stops"]) && $_GET["error_stops"])), lang('Stop on error')) . "\n";
echo checkbox("only_errors", 1, ($_POST ? $_POST["only_errors"] : isset($_GET["import"]) || $_GET["only_errors"]), lang('Show only errors')) . "\n"; echo checkbox("only_errors", 1, (isset($_POST["only_errors"]) ? $_POST["only_errors"] : isset($_GET["import"]) || (isset($_GET["only_errors"]) && $_GET["only_errors"])), lang('Show only errors')) . "\n";
echo "<input type='hidden' name='token' value='$token'>\n"; echo "<input type='hidden' name='token' value='$token'>\n";
if (!isset($_GET["import"]) && $history) { if (!isset($_GET["import"]) && $history) {

View file

@ -1,6 +1,6 @@
<?php <?php
$TABLE = $_GET["trigger"]; $TABLE = isset($_GET["trigger"]) ? $_GET["trigger"] : null;
$name = $_GET["name"]; $name = isset($_GET["name"]) ? $_GET["name"] : null;
$trigger_options = trigger_options(); $trigger_options = trigger_options();
$row = (array) trigger($name, $TABLE) + array("Trigger" => $TABLE . "_bi"); $row = (array) trigger($name, $TABLE) + array("Trigger" => $TABLE . "_bi");
@ -10,7 +10,7 @@ if ($_POST) {
$on = " ON " . table($TABLE); $on = " ON " . table($TABLE);
$drop = "DROP TRIGGER " . idf_escape($name) . ($jush == "pgsql" ? $on : ""); $drop = "DROP TRIGGER " . idf_escape($name) . ($jush == "pgsql" ? $on : "");
$location = ME . "table=" . urlencode($TABLE); $location = ME . "table=" . urlencode($TABLE);
if ($_POST["drop"]) { if (isset($_POST["drop"]) && $_POST["drop"]) {
query_redirect($drop, $location, lang('Trigger has been dropped.')); query_redirect($drop, $location, lang('Trigger has been dropped.'));
} else { } else {
if ($name != "") { if ($name != "") {
@ -34,10 +34,10 @@ page_header(($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Creat
<form action="" method="post" id="form"> <form action="" method="post" id="form">
<table cellspacing="0" class="layout"> <table cellspacing="0" class="layout">
<tr><th><?php echo lang('Time'); ?><td><?php echo html_select("Timing", $trigger_options["Timing"], $row["Timing"], "triggerChange(/^" . preg_quote($TABLE, "/") . "_[ba][iud]$/, '" . js_escape($TABLE) . "', this.form);"); ?> <tr><th><?php echo lang('Time'); ?><td><?php echo html_select("Timing", isset($trigger_options["Timing"]) ? $trigger_options["Timing"] : null, isset($row["Timing"]) ? $row["Timing"] : null, "triggerChange(/^" . preg_quote($TABLE, "/") . "_[ba][iud]$/, '" . js_escape($TABLE) . "', this.form);"); ?>
<tr><th><?php echo lang('Event'); ?><td><?php echo html_select("Event", $trigger_options["Event"], $row["Event"], "this.form['Timing'].onchange();"); ?> <tr><th><?php echo lang('Event'); ?><td><?php echo html_select("Event", isset($trigger_options["Event"]) ? $trigger_options["Event"] : null, isset($row["Event"]) ? $row["Event"] : null, "this.form['Timing'].onchange();"); ?>
<?php echo (in_array("UPDATE OF", $trigger_options["Event"]) ? " <input name='Of' value='" . h($row["Of"]) . "' class='hidden'>": ""); ?> <?php echo (in_array("UPDATE OF", $trigger_options["Event"]) ? " <input name='Of' value='" . h(isset($row["Of"]) ? $row["Of"] : null) . "' class='hidden'>": ""); ?>
<tr><th><?php echo lang('Type'); ?><td><?php echo html_select("Type", $trigger_options["Type"], $row["Type"]); ?> <tr><th><?php echo lang('Type'); ?><td><?php echo html_select("Type", isset($trigger_options["Type"]) ? $trigger_options["Type"] : null, isset($row["Type"]) ? $row["Type"] : null); ?>
</table> </table>
<p><?php echo lang('Name'); ?>: <input name="Trigger" value="<?php echo h($row["Trigger"]); ?>" data-maxlength="64" autocapitalize="off"> <p><?php echo lang('Name'); ?>: <input name="Trigger" value="<?php echo h($row["Trigger"]); ?>" data-maxlength="64" autocapitalize="off">
<?php echo script("qs('#form')['Timing'].onchange();"); ?> <?php echo script("qs('#form')['Timing'].onchange();"); ?>