From 4f4f2d3069b6f782d3af49a66625d393b00bc3eb Mon Sep 17 00:00:00 2001 From: Lionel Laffineur Date: Sat, 9 Dec 2023 15:07:04 +0100 Subject: [PATCH] Fixed warnings of editor edit / save / clone / delete --- adminer/edit.inc.php | 2 +- adminer/include/adminer.inc.php | 2 +- adminer/include/auth.inc.php | 2 +- adminer/include/functions.inc.php | 2 +- adminer/select.inc.php | 20 ++++++++++---------- editor/include/adminer.inc.php | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index 867be10a..846882c9 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -2,7 +2,7 @@ $TABLE = $_GET["edit"]; $fields = fields($TABLE); $where = (isset($_GET["select"]) ? ($_POST["check"] && count($_POST["check"]) == 1 ? where_check($_POST["check"][0], $fields) : "") : where($_GET, $fields)); -$update = (isset($_GET["select"]) ? $_POST["edit"] : $where); +$update = (isset($_GET["select"]) ? (isset($_POST["edit"]) ? $_POST["edit"] : null) : $where); foreach ($fields as $name => $field) { if (!isset($field["privileges"][$update ? "update" : "insert"]) || $adminer->fieldName($field) == "" || $field["generated"]) { unset($fields[$name]); diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 76e175c5..081ef936 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -126,7 +126,7 @@ class Adminer { echo $this->loginFormField('db', '' . lang('Database') . '', '' . "\n"); echo "\n"; echo "

\n"; - echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n"; + echo checkbox("auth[permanent]", 1, isset($_COOKIE["adminer_permanent"]) ? $_COOKIE["adminer_permanent"] : null, lang('Permanent login')) . "\n"; } /** Get login form field diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 9b62f84a..49abf0d0 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -134,7 +134,7 @@ function auth_error($error) { unset_permanent(); } } - if (!$_COOKIE[$session_name] && $_GET[$session_name] && ini_bool("session.use_only_cookies")) { + if ((isset($_COOKIE[$session_name]) === false || !$_COOKIE[$session_name]) && (isset($_GET[$session_name]) && $_GET[$session_name]) && ini_bool("session.use_only_cookies")) { $error = lang('Session support must be enabled.'); } $params = session_get_cookie_params(); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index db85899a..05749bee 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -1568,7 +1568,7 @@ function edit_form($table, $fields, $row, $update) { : ($_POST || !$fields ? "" : script("focus(qsa('td', qs('#form'))[1].firstChild);")) ); if (isset($_GET["select"])) { - hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"])); + hidden_fields(array("check" => (array) isset($_POST["check"]) ? $_POST["check"] : null, "clone" => isset($_POST["clone"]) ? $_POST["clone"] : null, "all" => isset($_POST["all"]) ? $_POST["all"] : null)); } ?> "> diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 237ed709..98a03c80 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -65,7 +65,7 @@ if ($oid && !$primary) { if ($_POST && !$error) { $where_check = $where; - if (!$_POST["all"] && is_array($_POST["check"])) { + if ((isset($_POST["all"]) === false || !$_POST["all"]) && (isset($_POST["check"]) && is_array($_POST["check"]))) { $checks = array(); foreach ($_POST["check"] as $check) { $checks[] = where_check($check, $fields); @@ -73,7 +73,7 @@ if ($_POST && !$error) { $where_check[] = "((" . implode(") OR (", $checks) . "))"; } $where_check = ($where_check ? "\nWHERE " . implode(" AND ", $where_check) : ""); - if ($_POST["export"]) { + if (isset($_POST["export"]) && $_POST["export"]) { cookie("adminer_import", "output=" . urlencode($_POST["output"]) . "&format=" . urlencode($_POST["format"])); dump_headers($TABLE); $adminer->dumpTable($TABLE, ""); @@ -96,11 +96,11 @@ if ($_POST && !$error) { } if (!$adminer->selectEmailProcess($where, $foreign_keys)) { - if ($_POST["save"] || $_POST["delete"]) { // edit + if ((isset($_POST["save"]) && $_POST["save"]) || (isset($_POST["delete"]) && $_POST["delete"])) { // edit $result = true; $affected = 0; $set = array(); - if (!$_POST["delete"]) { + if (isset($_POST["delete"]) === false || !$_POST["delete"]) { foreach ($columns as $name => $val) { //! should check also for edit or insert privileges $val = process_input($fields[$name]); if ($val !== null && ($_POST["clone"] || $val !== false)) { @@ -108,11 +108,11 @@ if ($_POST && !$error) { } } } - if ($_POST["delete"] || $set) { - if ($_POST["clone"]) { + if ((isset($_POST["delete"]) && $_POST["delete"]) || $set) { + if (isset($_POST["clone"]) && $_POST["clone"]) { $query = "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE); } - if ($_POST["all"] || ($primary && is_array($_POST["check"])) || $is_group) { + if ((isset($_POST["all"]) && $_POST["all"]) || ($primary && isset($_POST["check"]) && is_array($_POST["check"])) || $is_group) { $result = ($_POST["delete"] ? $driver->delete($TABLE, $where_check) : ($_POST["clone"] @@ -125,7 +125,7 @@ if ($_POST && !$error) { foreach ((array) $_POST["check"] as $val) { // where is not unique so OR can't be used $where2 = "\nWHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($val, $fields); - $result = ($_POST["delete"] + $result = (isset($_POST["delete"]) && $_POST["delete"] ? $driver->delete($TABLE, $where2, 1) : ($_POST["clone"] ? queries("INSERT" . limit1($TABLE, $query, $where2)) @@ -140,13 +140,13 @@ if ($_POST && !$error) { } } $message = lang('%d item(s) have been affected.', $affected); - if ($_POST["clone"] && $result && $affected == 1) { + if (isset($_POST["clone"]) && $_POST["clone"] && $result && $affected == 1) { $last_id = last_id(); if ($last_id) { $message = lang('Item%s has been inserted.', " $last_id"); } } - queries_redirect(remove_from_uri($_POST["all"] && $_POST["delete"] ? "page" : ""), $message, $result); + queries_redirect(remove_from_uri(isset($_POST["all"]) && $_POST["all"] && isset($_POST["delete"]) && $_POST["delete"] ? "page" : ""), $message, $result); if (!$_POST["delete"]) { edit_form($TABLE, $fields, (array) $_POST["fields"], !$_POST["clone"]); page_footer(); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index f6bb0d18..3e932856 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -418,10 +418,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 } function selectEmailProcess($where, $foreignKeys) { - if ($_POST["email_append"]) { + if (isset($_POST["email_append"]) && $_POST["email_append"]) { return true; } - if ($_POST["email"]) { + if (isset($_POST["email"]) && $_POST["email"]) { $sent = 0; if ($_POST["all"] || $_POST["check"]) { $field = idf_escape($_POST["email_field"]);