diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-03-04 17:46:36 +0100 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-03-04 17:46:36 +0100 |
commit | 696244c8caa95982e90875132d4aaf154a4b6c59 (patch) | |
tree | c9447406ed849fc01a9355c11eb9e6dc34929479 | |
parent | f30ec46d410f4c0bf986929e132f8a9efd4d0530 (diff) | |
download | wcms-696244c8caa95982e90875132d4aaf154a4b6c59.tar.gz wcms-696244c8caa95982e90875132d4aaf154a4b6c59.zip |
fix: init config script
- update default values returned by get_class_vars,
otherwise domain is never correctly set
- use more robust scheme detection
-rw-r--r-- | app/class/Config.php | 8 |
1 files 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']); } /** |