From 105999f62e4f40c70dcb96fa165afb60a9443e27 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 5 Mar 2025 15:01:05 +0100 Subject: [PATCH] Code style: Indent long statements --- adminer/drivers/mssql.inc.php | 9 +++++---- adminer/drivers/mysql.inc.php | 6 ++++-- adminer/drivers/oracle.inc.php | 3 ++- adminer/drivers/pgsql.inc.php | 3 ++- adminer/drivers/sqlite.inc.php | 3 ++- adminer/include/adminer.inc.php | 3 ++- adminer/include/auth.inc.php | 3 ++- adminer/indexes.inc.php | 3 ++- adminer/select.inc.php | 3 ++- adminer/user.inc.php | 3 ++- phpcs.xml | 2 -- plugins/drivers/elastic.php | 4 +--- 12 files changed, 26 insertions(+), 19 deletions(-) diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index c40a3c63..76b099df 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -493,10 +493,11 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row } else { $index[] = idf_escape($val[1]) . " ON " . table($table); } - } elseif (!queries(($val[0] != "PRIMARY" - ? "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) - : "ALTER TABLE " . table($table) . " ADD PRIMARY KEY" - ) . " (" . implode(", ", $val[2]) . ")") + } elseif ( + !queries(($val[0] != "PRIMARY" + ? "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) + : "ALTER TABLE " . table($table) . " ADD PRIMARY KEY" + ) . " (" . implode(", ", $val[2]) . ")") ) { return false; } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index d78bef82..3f634bb5 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -859,7 +859,8 @@ if (!defined("DRIVER")) { queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'"); foreach ($tables as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); - if (($_POST["overwrite"] && !queries("\nDROP TABLE IF EXISTS $name")) + if ( + ($_POST["overwrite"] && !queries("\nDROP TABLE IF EXISTS $name")) || !queries("CREATE TABLE $name LIKE " . table($table)) || !queries("INSERT INTO $name SELECT * FROM " . table($table)) ) { @@ -875,7 +876,8 @@ if (!defined("DRIVER")) { foreach ($views as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); $view = view($table); - if (($_POST["overwrite"] && !queries("DROP VIEW IF EXISTS $name")) + if ( + ($_POST["overwrite"] && !queries("DROP VIEW IF EXISTS $name")) || !queries("CREATE VIEW $name AS $view[select]") //! USE to avoid db.table ) { return false; diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index f9f5b6f0..d0847070 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -159,7 +159,8 @@ if (isset($_GET["oracle"])) { $where[] = "$key = $val"; } } - if (!(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) + if ( + !(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")")) ) { return false; diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 57b68d3e..d4ab7a95 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -208,7 +208,8 @@ if (isset($_GET["pgsql"])) { $where[] = "$key = $val"; } } - if (!(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) + if ( + !(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")")) ) { return false; diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 437c0299..8db3a762 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -541,7 +541,8 @@ if (isset($_GET["sqlite"])) { $triggers[] = "CREATE TRIGGER " . idf_escape($trigger_name) . " " . implode(" ", $timing_event) . " ON " . table($name) . "\n$trigger[Statement]"; } $auto_increment = $auto_increment ? 0 : $connection->result("SELECT seq FROM sqlite_sequence WHERE name = " . q($table)); // if $auto_increment is set then it will be updated later - if (!queries("DROP TABLE " . table($table)) // drop before creating indexes and triggers to allow using old names + if ( + !queries("DROP TABLE " . table($table)) // drop before creating indexes and triggers to allow using old names || ($table == $name && !queries("ALTER TABLE " . table($temp_name) . " RENAME TO " . table($name))) || !alter_indexes($name, $indexes) ) { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 8af053cb..8bbcc0a2 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -569,7 +569,8 @@ class Adminer { // find anywhere $cols = array(); foreach ($fields as $name => $field) { - if ((preg_match('~^[-\d.' . (preg_match('~IN$~', $val["op"]) ? ',' : '') . ']+$~', $val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"])) + if ( + (preg_match('~^[-\d.' . (preg_match('~IN$~', $val["op"]) ? ',' : '') . ']+$~', $val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"])) && (!preg_match("~[\x80-\xFF]~", $val["val"]) || preg_match('~char|text|enum|set~', $field["type"])) && (!preg_match('~date|timestamp~', $field["type"]) || preg_match('~^\d+-\d+-\d+~', $val["val"])) ) { diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 6cc2439d..7097cff3 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -66,7 +66,8 @@ if ($auth) { $permanent[$key] = "$key:" . base64_encode($private ? encrypt_string($password, $private) : ""); cookie("adminer_permanent", implode(" ", $permanent)); } - if (count($_POST) == 1 // 1 - auth + if ( + count($_POST) == 1 // 1 - auth || DRIVER != $vendor || SERVER != $server || $_GET["username"] !== $username // "0" == "00" diff --git a/adminer/indexes.inc.php b/adminer/indexes.inc.php index 64efbabb..1e91b514 100644 --- a/adminer/indexes.inc.php +++ b/adminer/indexes.inc.php @@ -47,7 +47,8 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) { ksort($existing["columns"]); ksort($existing["lengths"]); ksort($existing["descs"]); - if ($index["type"] == $existing["type"] + if ( + $index["type"] == $existing["type"] && array_values($existing["columns"]) === $columns && (!$existing["lengths"] || array_values($existing["lengths"]) === $lengths) && array_values($existing["descs"]) === $descs diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 4e2a6ab7..e8a494f1 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -228,7 +228,8 @@ $set = null; if (isset($rights["insert"]) || !support("table")) { $params = array(); foreach ((array) $_GET["where"] as $val) { - if (isset($foreign_keys[$val["col"]]) && count($foreign_keys[$val["col"]]) == 1 + if ( + isset($foreign_keys[$val["col"]]) && count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "=" || (!$val["op"] && (is_array($val["val"]) || !preg_match('~[_%]~', $val["val"])))) // LIKE in Editor ) { $params["set" . "[" . bracket_escape($val["col"]) . "]"] = $val["val"]; diff --git a/adminer/user.inc.php b/adminer/user.inc.php index 7cfbb517..1fb31ffb 100644 --- a/adminer/user.inc.php +++ b/adminer/user.inc.php @@ -86,7 +86,8 @@ if ($_POST && !$error) { $grant = array_diff($grant, $old_grant); unset($grants[$object]); } - if (preg_match('~^(.+)\s*(\(.*\))?$~U', $object, $match) && ( + if ( + preg_match('~^(.+)\s*(\(.*\))?$~U', $object, $match) && ( !grant("REVOKE", $revoke, $match[2], " ON $match[1] FROM $new_user") //! SQL injection || !grant("GRANT", $grant, $match[2], " ON $match[1] TO $new_user")) ) { diff --git a/phpcs.xml b/phpcs.xml index ede8b498..b2918f18 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -25,8 +25,6 @@ - - diff --git a/plugins/drivers/elastic.php b/plugins/drivers/elastic.php index 1595e5eb..f1603614 100644 --- a/plugins/drivers/elastic.php +++ b/plugins/drivers/elastic.php @@ -157,9 +157,7 @@ if (isset($_GET["elastic"])) { foreach ($parts as $part) { list($col, $op, $val) = explode(" ", $part, 3); $term = array($col => $val); - if (isset($fields[$col]) && $fields[$col]['full_type'] == 'boolean' - && $val !== 'true' && $val !== 'false' - ) { + if (isset($fields[$col]) && $fields[$col]['full_type'] == 'boolean' && $val !== 'true' && $val !== 'false') { continue; } if ($op == "=") {