From 1810ce8b079204da2b7d8c65ab2e04422bcf59c8 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Wed, 15 Oct 2025 12:20:57 +0100 Subject: [PATCH 1/2] * removed rules removed in phpcs4 from phpcs.xml, * ran phpcs auto fix to correct violations, * added make commands from phpcs --- Makefile | 16 +++++++ adminer/call.inc.php | 1 + adminer/check.inc.php | 1 + adminer/create.inc.php | 1 + adminer/database.inc.php | 1 + adminer/db.inc.php | 1 + adminer/designs.php | 1 + adminer/download.inc.php | 1 + adminer/drivers/mssql.inc.php | 1 + adminer/drivers/mysql.inc.php | 1 + adminer/drivers/oracle.inc.php | 1 + adminer/drivers/pgsql.inc.php | 1 + adminer/drivers/sqlite.inc.php | 1 + adminer/dump.inc.php | 1 + adminer/edit.inc.php | 1 + adminer/elastic.php | 1 + adminer/event.inc.php | 1 + adminer/file.inc.php | 1 + adminer/foreign.inc.php | 1 + adminer/include/auth.inc.php | 1 + adminer/include/bootstrap.inc.php | 1 + adminer/include/connect.inc.php | 1 + adminer/include/coverage.inc.php | 1 + adminer/include/db.inc.php | 1 + adminer/include/design.inc.php | 73 ++++++++++++++++--------------- adminer/include/driver.inc.php | 1 + adminer/include/editing.inc.php | 1 + adminer/include/errors.inc.php | 1 + adminer/include/functions.inc.php | 1 + adminer/include/html.inc.php | 1 + adminer/include/lang.inc.php | 1 + adminer/include/pdo.inc.php | 1 + adminer/include/plugin.inc.php | 1 + adminer/include/plugins.inc.php | 1 + adminer/include/tmpfile.inc.php | 1 + adminer/include/version.inc.php | 1 + adminer/include/xxtea.inc.php | 1 + adminer/index.php | 2 + adminer/indexes.inc.php | 1 + adminer/lang/ar.inc.php | 1 + adminer/lang/bg.inc.php | 1 + adminer/lang/bn.inc.php | 1 + adminer/lang/bs.inc.php | 1 + adminer/lang/ca.inc.php | 1 + adminer/lang/cs.inc.php | 1 + adminer/lang/da.inc.php | 1 + adminer/lang/de.inc.php | 1 + adminer/lang/el.inc.php | 1 + adminer/lang/en.inc.php | 1 + adminer/lang/es.inc.php | 1 + adminer/lang/et.inc.php | 1 + adminer/lang/fa.inc.php | 1 + adminer/lang/fi.inc.php | 1 + adminer/lang/fr.inc.php | 1 + adminer/lang/gl.inc.php | 1 + adminer/lang/he.inc.php | 1 + adminer/lang/hi.inc.php | 1 + adminer/lang/hu.inc.php | 1 + adminer/lang/id.inc.php | 1 + adminer/lang/it.inc.php | 1 + adminer/lang/ja.inc.php | 1 + adminer/lang/ka.inc.php | 1 + adminer/lang/ko.inc.php | 1 + adminer/lang/lt.inc.php | 1 + adminer/lang/lv.inc.php | 1 + adminer/lang/ms.inc.php | 1 + adminer/lang/nl.inc.php | 1 + adminer/lang/no.inc.php | 1 + adminer/lang/pl.inc.php | 1 + adminer/lang/pt-br.inc.php | 1 + adminer/lang/pt.inc.php | 1 + adminer/lang/ro.inc.php | 1 + adminer/lang/ru.inc.php | 1 + adminer/lang/sk.inc.php | 1 + adminer/lang/sl.inc.php | 1 + adminer/lang/sr.inc.php | 1 + adminer/lang/sv.inc.php | 1 + adminer/lang/ta.inc.php | 1 + adminer/lang/th.inc.php | 1 + adminer/lang/tr.inc.php | 1 + adminer/lang/uk.inc.php | 1 + adminer/lang/uz.inc.php | 1 + adminer/lang/vi.inc.php | 1 + adminer/lang/xx.inc.php | 1 + adminer/lang/zh-tw.inc.php | 1 + adminer/lang/zh.inc.php | 1 + adminer/privileges.inc.php | 1 + adminer/procedure.inc.php | 1 + adminer/processlist.inc.php | 1 + adminer/schema.inc.php | 1 + adminer/scheme.inc.php | 1 + adminer/script.inc.php | 1 + adminer/select.inc.php | 1 + adminer/sequence.inc.php | 1 + adminer/sql.inc.php | 1 + adminer/sqlite.php | 1 + adminer/table.inc.php | 1 + adminer/trigger.inc.php | 1 + adminer/type.inc.php | 1 + adminer/user.inc.php | 1 + adminer/variables.inc.php | 1 + adminer/view.inc.php | 1 + editor/db.inc.php | 1 + editor/example.php | 1 + editor/include/connect.inc.php | 1 + editor/include/editing.inc.php | 1 + editor/index.php | 1 + editor/script.inc.php | 1 + editor/sqlite.php | 1 + phpcs.xml | 14 +----- plugins/drivers/clickhouse.php | 1 + plugins/drivers/elastic.php | 1 + plugins/drivers/firebird.php | 1 + plugins/drivers/imap.php | 1 + plugins/drivers/mongo.php | 1 + plugins/drivers/simpledb.php | 1 + plugins/file-upload.php | 1 + plugins/login-table.php | 1 + plugins/translation.php | 1 + 119 files changed, 171 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 8c5dcfbf6..7d6764439 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +PHPCS_BIN := $(HOME)/.composer/vendor/bin/phpcs +PHPCBF_BIN := $(HOME)/.composer/vendor/bin/phpcbf + ROOT_DIRECTORY = $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))") PHP := $(shell which php) PORT := 8000 @@ -37,3 +40,16 @@ clean: .PHONY: clean.all clean.all: clean + +.PHONY: get-phpcs +get-phpcs: + @echo "Global PHPCS path: $(PHPCS_BIN)" + @$(PHPCS_BIN) --version || echo "PHPCS not installed globally" + +.PHONY: phpcs +phpcs: + $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml + +.PHONY: phpcbf +phpcbf: + $(PHPCBF_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 4658e6619..bbedb3882 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -1,4 +1,5 @@ "MySQL / MariaDB") + SqlDriver::$drivers; diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 831effc9d..45a682240 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -1,4 +1,5 @@ css(); if (is_int(key($css))) { // legacy return value - $css = array_fill_keys($css, 'light'); + $css = array_fill_keys($css, 'light'); } $has_light = in_array('light', $css) || in_array('', $css); $has_dark = in_array('dark', $css) || in_array('', $css); @@ -40,7 +41,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s ); $media = " media='(prefers-color-scheme: dark)'"; if ($dark !== false) { - echo "\n"; + echo "\n"; } echo "\n"; @@ -48,23 +49,23 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo script_src("../adminer/static/functions.js"); echo script_src("static/editing.js"); if (adminer()->head($dark)) { - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; } foreach ($css as $url => $mode) { - $attrs = ($mode == 'dark' && !$dark - ? $media - : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") - ); - echo "\n"; + $attrs = ($mode == 'dark' && !$dark + ? $media + : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") +); +echo "\n"; } echo "\nbodyClass(); echo "'>\n"; $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 - $version = unserialize(file_get_contents($filename)); - $public = "-----BEGIN PUBLIC KEY----- + $version = unserialize(file_get_contents($filename)); + $public = "-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 @@ -74,9 +75,9 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s fQIDAQAB -----END PUBLIC KEY----- "; - if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { - $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser - } + if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { + $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser + } } echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick" . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") @@ -90,31 +91,31 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo "
\n"; echo "" . icon("move", "", "menu", "") . "" . script("qs('#menuopen').onclick = event => { qs('#foot').classList.toggle('foot'); event.stopPropagation(); }"); if ($breadcrumb !== null) { - $link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1); - echo '

$title_all

\n"; echo "\n"; @@ -122,7 +123,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s page_messages($error); $databases = &get_session("dbs"); if (DB != "" && $databases && !in_array(DB, $databases, true)) { - $databases = null; + $databases = null; } stop_session(); define('Adminer\PAGE_HEADER', 1); diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index 61a7d3953..ffac3be35 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -1,4 +1,5 @@ element */ diff --git a/adminer/include/lang.inc.php b/adminer/include/lang.inc.php index d648cea3c..4d5d24e30 100644 --- a/adminer/include/lang.inc.php +++ b/adminer/include/lang.inc.php @@ -1,4 +1,5 @@ select_db(adminer()->database()); diff --git a/editor/include/editing.inc.php b/editor/include/editing.inc.php index f0fdc494e..fb5659a70 100644 --- a/editor/include/editing.inc.php +++ b/editor/include/editing.inc.php @@ -1,4 +1,5 @@ /externals/ /designs/ /(adminer|editor)[-.] + /vendor @@ -79,7 +80,6 @@ - @@ -93,19 +93,7 @@ - - - - - - - - - - - - diff --git a/plugins/drivers/clickhouse.php b/plugins/drivers/clickhouse.php index 7fa1d5fc8..191ca2ff3 100644 --- a/plugins/drivers/clickhouse.php +++ b/plugins/drivers/clickhouse.php @@ -1,4 +1,5 @@ and link to the uploaded files from select diff --git a/plugins/login-table.php b/plugins/login-table.php index 3fa4a979f..cfe6f4ed5 100644 --- a/plugins/login-table.php +++ b/plugins/login-table.php @@ -1,4 +1,5 @@ Date: Wed, 15 Oct 2025 12:25:37 +0100 Subject: [PATCH 2/2] Small changes --- Makefile | 2 +- phpcs.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7d6764439..325d034be 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ get-phpcs: .PHONY: phpcs phpcs: - $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml + $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml --report=full .PHONY: phpcbf phpcbf: diff --git a/phpcs.xml b/phpcs.xml index 800ea242c..b438f5b00 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -52,6 +52,7 @@ adminer/include/pdo.inc.php adminer/plugins/foreign-system.php adminer/plugins/drivers/ + plugins/*