aurweb/web/lib/confparser.inc.php
Lukas Fleischer 5c48302aaf confparser.inc.php: Add missing dollar sign
Fixes a regression introduced in 97c5bce (config: allow reading both the
defaults file and the modified config, 2018-04-15).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-05-12 12:37:16 +02:00

57 lines
1.2 KiB
PHP

<?php
function config_load() {
global $AUR_CONFIG;
if (!isset($AUR_CONFIG)) {
$path = getenv('AUR_CONFIG');
if (!$path) {
$path = "/etc/aurweb/config";
}
$defaults_path = getenv('AUR_CONFIG_DEFAULTS');
if (!$defaults_path) {
$defaults_path = $path . ".defaults";
}
if (file_exists($defaults_path)) {
$default_config = parse_ini_file($defaults_path, true, INI_SCANNER_RAW);
} else {
$default_config = [];
}
if (file_exists($path)) {
$config = parse_ini_file($path, true, INI_SCANNER_RAW);
} else {
die("aurweb config file not found");
}
$AUR_CONFIG = array_replace_recursive($default_config, $config);
}
}
function config_get($section, $key) {
global $AUR_CONFIG;
config_load();
return $AUR_CONFIG[$section][$key];
}
function config_get_int($section, $key) {
return intval(config_get($section, $key));
}
function config_get_bool($section, $key) {
$val = strtolower(config_get($section, $key));
return ($val == 'yes' || $val == 'true' || $val == '1');
}
function config_items($section) {
global $AUR_CONFIG;
config_load();
return $AUR_CONFIG[$section];
}
function config_section_exists($key) {
global $AUR_CONFIG;
config_load();
return array_key_exists($key, $AUR_CONFIG);
}