2017-12-17 20:40:04 +00:00
|
|
|
<?php
|
2018-03-07 04:44:06 +00:00
|
|
|
/**
|
2018-03-07 04:45:25 +00:00
|
|
|
* @file config.php
|
2018-04-13 05:07:39 +00:00
|
|
|
* @date 2018-04-13
|
2018-03-07 04:44:06 +00:00
|
|
|
* @author Go Namhyeon <gnh1201@gmail.com>
|
2018-04-13 05:07:39 +00:00
|
|
|
* @brief Configuration module
|
2018-03-07 04:44:06 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-09 12:31:50 +00:00
|
|
|
if(!function_exists("read_config")) {
|
2018-05-25 16:28:17 +00:00
|
|
|
function read_config() {
|
|
|
|
$config = array();
|
|
|
|
|
2018-05-25 16:39:18 +00:00
|
|
|
$files = retrieve_storage_files("config");
|
2018-05-25 16:28:17 +00:00
|
|
|
foreach($files as $file) {
|
|
|
|
if(check_file_extension($file, "ini")) {
|
|
|
|
$ini = parse_ini_file($file);
|
|
|
|
foreach($ini as $k=>$v) {
|
|
|
|
$config[$k] = $v;
|
|
|
|
}
|
|
|
|
}
|
2018-02-12 05:43:11 +00:00
|
|
|
}
|
2018-03-09 12:33:04 +00:00
|
|
|
|
2018-05-25 16:28:17 +00:00
|
|
|
return $config;
|
|
|
|
}
|
2017-12-17 20:40:04 +00:00
|
|
|
}
|
2018-02-12 05:43:11 +00:00
|
|
|
|
2018-03-14 04:34:08 +00:00
|
|
|
if(!function_exists("get_config")) {
|
|
|
|
function get_config() {
|
2018-04-13 05:06:21 +00:00
|
|
|
$config = get_scope("config");
|
|
|
|
|
|
|
|
if(!is_array($config)) {
|
|
|
|
set_scope("config", read_config());
|
|
|
|
}
|
|
|
|
|
|
|
|
return get_scope("config");
|
2018-03-14 04:34:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!function_exists("get_config_value")) {
|
|
|
|
function get_config_value($key) {
|
2018-04-13 05:07:39 +00:00
|
|
|
$config = get_config();
|
2018-03-14 04:34:08 +00:00
|
|
|
|
2018-04-13 05:06:21 +00:00
|
|
|
$config_value = "";
|
2018-03-14 04:34:08 +00:00
|
|
|
if(!array_key_empty($key, $config)) {
|
|
|
|
$config_value = $config[$key];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $config_value;
|
|
|
|
}
|
2018-03-07 04:44:06 +00:00
|
|
|
}
|
|
|
|
|
2018-04-13 05:07:39 +00:00
|
|
|
if(!function_exists("get_current_datetime")) {
|
|
|
|
function get_current_datetime() {
|
|
|
|
$config = get_config();
|
2018-05-24 06:02:53 +00:00
|
|
|
return date(get_value_in_array("timeformat", $config, "Y-m-d H:i:s"));
|
2018-04-13 05:07:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 05:06:21 +00:00
|
|
|
set_scope("config", read_config());
|