Implemented a default config system

This commit is contained in:
Bofh 2021-11-26 01:10:36 +01:00
parent 49016345da
commit c4745f0519
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
$config = [ $default_config = [
"db_host" => "127.0.0.1", "db_host" => "127.0.0.1",
"db_port" => 5432, "db_port" => 5432,
"db_name" => "realfan", "db_name" => "realfan",

View File

@ -28,15 +28,19 @@ function lr($key, $default='') {
# read config # read config
$config = []; $config = [];
require_once '/config/config.default.php';
if (file_exists('/config/config.php')) { if (file_exists('/config/config.php')) {
require_once '/config/config.php'; require_once '/config/config.php';
} }
function conf($key, $default='') { function conf($key, $default='') {
global $config; global $config;
global $default_config;
if (isset($config[$key])) if (isset($config[$key]))
return $config[$key]; return $config[$key];
if (!empty($default))
return $default; return $default;
return $default_config[$key];
} }
require_once '/src/base.methods.php'; require_once '/src/base.methods.php';