From c4745f0519e3136fbe22a8ef88a0ab41b2a80174 Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Fri, 26 Nov 2021 01:10:36 +0100 Subject: [PATCH] Implemented a default config system --- config/{config.php.example => config.default.php} | 2 +- src/base.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) rename config/{config.php.example => config.default.php} (90%) diff --git a/config/config.php.example b/config/config.default.php similarity index 90% rename from config/config.php.example rename to config/config.default.php index 2b45788..628ae23 100644 --- a/config/config.php.example +++ b/config/config.default.php @@ -1,6 +1,6 @@ "127.0.0.1", "db_port" => 5432, "db_name" => "realfan", diff --git a/src/base.php b/src/base.php index 1f8de65..ca65425 100644 --- a/src/base.php +++ b/src/base.php @@ -28,15 +28,19 @@ function lr($key, $default='') { # read config $config = []; +require_once '/config/config.default.php'; if (file_exists('/config/config.php')) { require_once '/config/config.php'; } function conf($key, $default='') { global $config; + global $default_config; if (isset($config[$key])) return $config[$key]; - return $default; + if (!empty($default)) + return $default; + return $default_config[$key]; } require_once '/src/base.methods.php';