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