From 574e13cc4ba4c67c870d62271b3c5db880695f8f Mon Sep 17 00:00:00 2001 From: Lionel Laffineur Date: Mon, 11 Dec 2023 21:44:25 +0100 Subject: [PATCH] Fixed warnings related to Pgsql driver --- adminer/create.inc.php | 8 ++++---- adminer/drivers/pgsql.inc.php | 7 +++++-- adminer/include/adminer.inc.php | 6 +++--- adminer/include/auth.inc.php | 2 +- adminer/include/connect.inc.php | 14 +++++++------- adminer/include/design.inc.php | 2 +- adminer/include/editing.inc.php | 8 ++++---- adminer/indexes.inc.php | 10 +++++----- adminer/sql.inc.php | 14 +++++++------- adminer/trigger.inc.php | 14 +++++++------- 10 files changed, 44 insertions(+), 41 deletions(-) diff --git a/adminer/create.inc.php b/adminer/create.inc.php index 206a7066..db5c317d 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -61,7 +61,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) { if (isset($field["has_default"]) === false || !$field["has_default"]) { $field["default"] = null; } - if ($key == $row["auto_increment_col"]) { + if (isset($row["auto_increment_col"]) && $key == $row["auto_increment_col"]) { $field["auto_increment"] = true; } $process_field = process_field($field, $type_field); @@ -178,7 +178,7 @@ foreach ($engines as $engine) {

-: " autocapitalize="off"> +: " autocapitalize="off"> " . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "" . on_help("getTarget(event).value", 1) . script("qsl('select').onchange = helpClose;") : ""); ?> "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?> @@ -201,9 +201,9 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys); $comments = ($_POST ? $_POST["comments"] : adminer_setting("comments")); echo (support("comment") ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly") - . ' ' . (preg_match('~\n~', $row["Comment"]) + . ' ' . (preg_match('~\n~', isset($row["Comment"]) ? $row["Comment"] : null) ? "" - : '' + : '' ) : '') ; diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 4c6f61d4..902182d8 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -234,7 +234,10 @@ if (isset($_GET["pgsql"])) { "information_schema" => "infoschema", "pg_catalog" => "catalog", ); - $link = $links[$_GET["ns"]]; + $link = null; + if (isset($_GET["ns"]) && isset($links[$_GET["ns"]])) { + $links[$_GET["ns"]]; + } if ($link) { return "$link-" . str_replace("_", "-", $name) . ".html"; } @@ -467,7 +470,7 @@ ORDER BY connamespace, conname") as $row) { global $connection; $return = h($connection->error); if (preg_match('~^(.*\n)?([^\n]*)\n( *)\^(\n.*)?$~s', $return, $match)) { - $return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\1\2', $match[2]) . $match[4]; + $return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\1\2', $match[2]) . (isset($match[4]) ? $match[4] : null); } return nl_br($return); } diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 081ef936..d789ce95 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -318,7 +318,7 @@ class Adminer { echo "" . lang('Column') . "" . lang('Type') . (support("comment") ? "" . lang('Comment') : "") . "\n"; foreach ($fields as $field) { echo "" . h($field["field"]); - echo "" . h($field["full_type"]) . ""; + echo "" . h(isset($field["full_type"]) ? $field["full_type"] : null) . ""; echo ($field["null"] ? " NULL" : ""); echo ($field["auto_increment"] ? " " . lang('Auto Increment') . "" : ""); echo (isset($field["default"]) ? " [" . h($field["default"]) . "]" : ""); @@ -340,8 +340,8 @@ class Adminer { $print = array(); foreach ($index["columns"] as $key => $val) { $print[] = "" . h($val) . "" - . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "") - . ($index["descs"][$key] ? " DESC" : "") + . (isset($index["lengths"][$key]) && $index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "") + . (isset($index["descs"][$key]) && $index["descs"][$key] ? " DESC" : "") ; } echo "$index[type]" . implode(", ", $print) . "\n"; diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 49abf0d0..630e49e1 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -119,7 +119,7 @@ function auth_error($error) { $session_name = session_name(); if (isset($_GET["username"])) { 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.'); } else { restart_session(); diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index 7dd73950..904e4c88 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -5,7 +5,7 @@ function connect_error() { header("HTTP/1.1 404 Not Found"); page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true); } 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"])); } @@ -42,17 +42,17 @@ function connect_error() { . "\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) { $root = h(ME) . "db=" . urlencode($db); $id = h("Db-" . $db); - echo "" . (support("database") ? "" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]), "", "", "", $id) : ""); + echo "" . (support("database") ? "" . checkbox("db[]", $db, in_array($db, (array) (isset($_POST["db"]) ? $_POST["db"] : [])), "", "", "", $id) : ""); echo "" . h($db) . ""; $collation = h(db_collation($db, $collations)); echo "" . (support("database") ? "$collation" : $collation); - echo "" . ($_GET["dbsize"] ? $tables : "?") . ""; - echo "" . ($_GET["dbsize"] ? db_size($db) : "?"); + echo "" . (isset($_GET["dbsize"]) && $_GET["dbsize"] ? $tables : "?") . ""; + echo "" . (isset($_GET["dbsize"]) && $_GET["dbsize"] ? db_size($db) : "?"); echo "\n"; } @@ -82,8 +82,8 @@ if (isset($_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 != "" || $_GET["refresh"]) { +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 != "" || (isset($_GET["refresh"]) && $_GET["refresh"])) { restart_session(); set_session("dbs", null); } diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 70d79e5a..63e4c674 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -35,7 +35,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { 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)); $public = "-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 8c559ffe..9ced5b17 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -104,7 +104,7 @@ function referencable_primary($self) { foreach (table_status('', true) as $table_name => $table) { if ($table_name != $self && fk_support($table)) { 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 unset($return[$table_name]); break; @@ -185,7 +185,7 @@ if ($foreign_keys) { $structured_types[lang('Foreign keys')] = $foreign_keys; } echo optionlist(array_merge($extra_types, $structured_types), $type); -?>" size="3" aria-labelledby="label-length">" size="3" aria-labelledby="label-length">

"; 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 "

$execute\n"; - echo lang('Limit rows') . ": \n"; + echo lang('Limit rows') . ": \n"; } else { echo "

" . lang('File upload') . "
"; @@ -245,8 +245,8 @@ if (!isset($_GET["import"])) { echo "

"; } -echo checkbox("error_stops", 1, ($_POST ? $_POST["error_stops"] : isset($_GET["import"]) || $_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("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, (isset($_POST["only_errors"]) ? $_POST["only_errors"] : isset($_GET["import"]) || (isset($_GET["only_errors"]) && $_GET["only_errors"])), lang('Show only errors')) . "\n"; echo "\n"; if (!isset($_GET["import"]) && $history) { diff --git a/adminer/trigger.inc.php b/adminer/trigger.inc.php index 4c780cb0..078fed30 100644 --- a/adminer/trigger.inc.php +++ b/adminer/trigger.inc.php @@ -1,6 +1,6 @@ $TABLE . "_bi"); @@ -10,7 +10,7 @@ if ($_POST) { $on = " ON " . table($TABLE); $drop = "DROP TRIGGER " . idf_escape($name) . ($jush == "pgsql" ? $on : ""); $location = ME . "table=" . urlencode($TABLE); - if ($_POST["drop"]) { + if (isset($_POST["drop"]) && $_POST["drop"]) { query_redirect($drop, $location, lang('Trigger has been dropped.')); } else { if ($name != "") { @@ -34,10 +34,10 @@ page_header(($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Creat -
-
-": ""); ?> -
+
+
+": ""); ?> +

: " data-maxlength="64" autocapitalize="off">