From 79a31aab21ad335a40b238b09c4db8d57c0f6b59 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Thu, 6 Apr 2017 19:18:51 +0200 Subject: [PATCH] Add config helper --- helpers/config.php | 102 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 helpers/config.php diff --git a/helpers/config.php b/helpers/config.php new file mode 100644 index 0000000..a3a6433 --- /dev/null +++ b/helpers/config.php @@ -0,0 +1,102 @@ +setFromFile(); + $this->setFromCookies(); + } + + private function setFromFile() { + $configFile = self::$rootDir . "/config.php"; + if (self::$fileLoaded || !file_exists($configFile)) { + return; + } + self::$fileLoaded = true; + include_once($configFile); + + if (isset($mapapi)) { self::$mapapi = $mapapi; } + if (isset($layer_ocm)) { self::$layer_ocm = $layer_ocm; } + if (isset($layer_mq)) { self::$layer_mq = $layer_mq; } + if (isset($layer_osmapa)) { self::$layer_osmapa = $layer_osmapa; } + if (isset($layer_ump)) { self::$layer_ump = $layer_ump; } + if (isset($init_latitude)) { self::$init_latitude = $init_latitude; } + if (isset($init_longitude)) { self::$init_longitude = $init_longitude; } + if (isset($dbhost)) { self::$dbhost = $dbhost; } + if (isset($dbuser)) { self::$dbuser = $dbuser; } + if (isset($dbpass)) { self::$dbpass = $dbpass; } + if (isset($dbname)) { self::$dbname = $dbname; } + if (isset($require_authentication)) { self::$require_authentication = (bool) $require_authentication; } + if (isset($public_tracks)) { self::$public_tracks = $public_tracks; } + if (isset($admin_user)) { self::$admin_user = $admin_user; } + if (isset($interval)) { self::$interval = $interval; } + if (isset($lang)) { self::$lang = $lang; } + if (isset($units)) { self::$units = $units; } + } + private function setFromCookies() { + if (isset($_COOKIE["ulogger_api"])) { self::$mapapi = $_COOKIE["ulogger_api"]; } + if (isset($_COOKIE["ulogger_lang"])) { self::$lang = $_COOKIE["ulogger_lang"]; } + if (isset($_COOKIE["ulogger_units"])) { self::$units = $_COOKIE["ulogger_units"]; } + if (isset($_COOKIE["ulogger_interval"])) { self::$interval = $_COOKIE["ulogger_interval"]; } + } +} + +?> \ No newline at end of file