diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index 0284c655..dc9eae27 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -16,7 +16,7 @@ if ($_POST && !$error) { $is_sql = preg_match('~sql~', $_POST["format"]); if ($is_sql) { - echo "-- Adminer $VERSION " . $drivers[DRIVER] . " " . str_replace("\n", " ", $connection->server_info) . " dump\n\n"; + echo "-- Adminer " . VERSION . " " . $drivers[DRIVER] . " " . str_replace("\n", " ", $connection->server_info) . " dump\n\n"; if (JUSH == "sql") { echo "SET NAMES utf8; SET time_zone = '+00:00'; diff --git a/adminer/file.inc.php b/adminer/file.inc.php index 4ae73a5c..01b917c5 100644 --- a/adminer/file.inc.php +++ b/adminer/file.inc.php @@ -1,7 +1,7 @@ " . $adminer->name() . " $VERSION"; + global $drivers, $connection, $adminer; + echo "

" . $adminer->name() . " " . VERSION; $new_version = $_COOKIE["adminer_version"]; - echo " " . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . ""; + echo " " . (version_compare(VERSION, $new_version) < 0 ? h($new_version) : "") . ""; echo "

\n"; // this is matched by compile.php switch_lang(); diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 3fdf2266..f77d2461 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -39,7 +39,7 @@ if ($_GET["script"] == "version") { exit; } -global $adminer, $connection, $driver, $drivers, $error, $HTTPS, $LANG, $langs, $permanent, $has_token, $token, $translations, $VERSION; // allows including Adminer inside a function +global $adminer, $connection, $driver, $drivers, $error, $HTTPS, $LANG, $langs, $permanent, $has_token, $token, $translations; // allows including Adminer inside a function if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"]; diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index a2a125e2..2c20b48c 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -7,7 +7,7 @@ namespace Adminer; * @param string $title2 used after colon in title and heading, should be HTML escaped */ function page_header(string $title, string $error = "", $breadcrumb = array(), string $title2 = ""): void { - global $LANG, $VERSION, $adminer, $drivers; + global $LANG, $adminer, $drivers; page_headers(); if (is_ajax() && $error) { page_messages($error); @@ -77,7 +77,7 @@ fQIDAQAB } } echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick" - . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '$VERSION', '" . js_escape(ME) . "', '" . get_token() . "')") // $token may be empty in auth.inc.php + . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") // $token may be empty in auth.inc.php . "}); document.body.classList.replace('nojs', 'js'); const offlineMessage = '" . js_escape(lang('You are offline.')) . "'; diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 947d0775..52f97b8e 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -26,12 +26,6 @@ function driver() { return $driver; } -/** Get Adminer version */ -function version(): string { - global $VERSION; - return $VERSION; -} - /** Unescape database identifier * @param string $idf text inside `` */ diff --git a/adminer/include/version.inc.php b/adminer/include/version.inc.php index bc07b271..456c8bf2 100644 --- a/adminer/include/version.inc.php +++ b/adminer/include/version.inc.php @@ -1,4 +1,4 @@ ''); // used in support() $features = array("check", "call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "sql", "status", "trigger", "type", "user" => "privileges", "variables", "view"); $lang_ids = array(); // global variable simplifies usage in a callback function $file = file_get_contents(__DIR__ . "/$project/index.php"); -$file = preg_replace('~\*/~', "* @version $VERSION\n*/", $file, 1); +$file = preg_replace('~\*/~', "* @version " . Adminer\VERSION . "\n*/", $file, 1); if ($vendor) { $_GET[$vendor] = true; // to load the driver include_once __DIR__ . $driver_path; @@ -357,7 +357,7 @@ if (function_exists('stripTypes')) { $file = stripTypes($file); } $file = preg_replace_callback("~compile_file\\('([^']+)'(?:, '([^']*)')?\\)~", 'compile_file', $file); // integrate static files -$replace = 'preg_replace("~\\\\\\\\?.*~", "", ME) . "?file=\1&version=' . $VERSION . '"'; +$replace = 'preg_replace("~\\\\\\\\?.*~", "", ME) . "?file=\1&version=' . Adminer\VERSION . '"'; $file = preg_replace('~\.\./adminer/static/(default\.css)~', '', $file); $file = preg_replace('~"\.\./adminer/static/(functions\.js)"~', $replace, $file); $file = preg_replace('~\.\./adminer/static/([^\'"]*)~', '" . h(' . $replace . ') . "', $file); @@ -366,6 +366,6 @@ if (function_exists('phpShrink')) { $file = phpShrink($file); } -$filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($vendor ? "-$vendor" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; +$filename = $project . (preg_match('~-dev$~', Adminer\VERSION) ? "" : "-" . Adminer\VERSION) . ($vendor ? "-$vendor" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; file_put_contents($filename, $file); echo "$filename created (" . strlen($file) . " B).\n"; diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index c23c0428..60a88ffb 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -596,10 +596,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row } function navigation($missing) { - global $VERSION, $adminer; - echo "

" . $adminer->name() . " $VERSION"; + global $adminer; + echo "

" . $adminer->name() . " " . VERSION; $new_version = $_COOKIE["adminer_version"]; - echo " " . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . ""; + echo " " . (version_compare(VERSION, $new_version) < 0 ? h($new_version) : "") . ""; echo "

\n"; switch_lang(); if ($missing == "auth") { diff --git a/phpstan.neon b/phpstan.neon index 80deae6b..60a27664 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -12,7 +12,7 @@ parameters: - identifier: includeOnce.fileNotFound # ./adminer-plugins.php - "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions - "~an unknown class OCI-?Lob~" # this looks like PHPStan bug - - "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations|VERSION) might not be defined~" # declared in bootstrap.inc.php + - "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations) might not be defined~" # declared in bootstrap.inc.php - "~expects int, float given~" # this will work - "~expects bool~" # truthy values - "~fread expects int<1, max>, 100000~" # 1e6