From 696244c8caa95982e90875132d4aaf154a4b6c59 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 4 Mar 2021 17:46:36 +0100 Subject: fix: init config script - update default values returned by get_class_vars, otherwise domain is never correctly set - use more robust scheme detection --- app/class/Config.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/class/Config.php b/app/class/Config.php index 7b2b50c..bfe0f08 100644 --- a/app/class/Config.php +++ b/app/class/Config.php @@ -91,6 +91,10 @@ abstract class Config public static function tojson() { $arr = get_class_vars(get_class()); + // get_class_vars returns default values, we need to update each of them with the current one + foreach ($arr as $key => $value) { + $arr[$key] = self::$$key; + } $json = json_encode($arr, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT); return $json; } @@ -106,7 +110,7 @@ abstract class Config */ public static function getdomain() { - self::$domain = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']; + self::$domain = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST']; } /** @@ -114,7 +118,7 @@ abstract class Config */ public static function checkdomain() { - return (self::$domain === $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']); + return (self::$domain === (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST']); } /** -- cgit v1.2.3