Implemented a default config system
This commit is contained in:
parent
49016345da
commit
c4745f0519
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
$config = [
|
||||
$default_config = [
|
||||
"db_host" => "127.0.0.1",
|
||||
"db_port" => 5432,
|
||||
"db_name" => "realfan",
|
|
@ -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];
|
||||
if (!empty($default))
|
||||
return $default;
|
||||
return $default_config[$key];
|
||||
}
|
||||
|
||||
require_once '/src/base.methods.php';
|
||||
|
|
Loading…
Reference in New Issue