]> git.joonet.de Git - adminer.git/commitdiff
Move $HTTPS to HTTPS
authorJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 17:29:05 +0000 (18:29 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 17:39:30 +0000 (18:39 +0100)
adminer/include/bootstrap.inc.php
adminer/include/functions.inc.php
phpstan.neon

index 050e6a455d8bfbbb3ad3cf420ddeeba83c28bca8..9fd82101467dfae03337a6cf48bb3295665594ff 100644 (file)
@@ -39,7 +39,7 @@ if ($_GET["script"] == "version") {
        exit;
 }
 
-global $adminer, $connection, $driver, $drivers, $error, $HTTPS, $permanent, $has_token, $token, $translations; // allows including Adminer inside a function
+global $adminer, $connection, $driver, $drivers, $error, $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"];
@@ -50,13 +50,13 @@ if (!strpos($_SERVER["REQUEST_URI"], '?') && $_SERVER["QUERY_STRING"] != "") { /
 if ($_SERVER["HTTP_X_FORWARDED_PREFIX"]) {
        $_SERVER["REQUEST_URI"] = $_SERVER["HTTP_X_FORWARDED_PREFIX"] . $_SERVER["REQUEST_URI"];
 }
-$HTTPS = ($_SERVER["HTTPS"] && strcasecmp($_SERVER["HTTPS"], "off")) || ini_bool("session.cookie_secure"); // session.cookie_secure could be set on HTTP if we are behind a reverse proxy
+define('Adminer\HTTPS', ($_SERVER["HTTPS"] && strcasecmp($_SERVER["HTTPS"], "off")) || ini_bool("session.cookie_secure")); // session.cookie_secure could be set on HTTP if we are behind a reverse proxy
 
 @ini_set("session.use_trans_sid", '0'); // protect links in export, @ - may be disabled
 if (!defined("SID")) {
        session_cache_limiter(""); // to allow restarting session
        session_name("adminer_sid"); // use specific session name to get own namespace
-       session_set_cookie_params(0, preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"]), "", $HTTPS, true); // ini_set() may be disabled
+       session_set_cookie_params(0, preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"]), "", HTTPS, true); // ini_set() may be disabled
        session_start();
 }
 
index 52f97b8ed584775280276cbd83489012ceffcb8d..615717e609b6f22030bcef6545979a6e44e7b814 100644 (file)
@@ -323,12 +323,11 @@ function convert_fields(array $columns, array $fields, array $select = array()):
 * @param int $lifetime number of seconds, 0 for session cookie, 2592000 - 30 days
 */
 function cookie(string $name, ?string $value, int $lifetime = 2592000): void {
-       global $HTTPS;
        header(
                "Set-Cookie: $name=" . urlencode($value)
                        . ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
                        . "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
-                       . ($HTTPS ? "; secure" : "")
+                       . (HTTPS ? "; secure" : "")
                        . "; HttpOnly; SameSite=lax",
                false
        );
index 5b5195507d4ee2d24996ec96a215bdd0247b3929..2b16c4b095fd4fdbfb7f0c3600a8a6938a2e688e 100644 (file)
@@ -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|permanent|has_token|token|translations) might not be defined~" # declared in bootstrap.inc.php
+               - "~^Variable \\$(adminer|connection|driver|drivers|error|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