aurweb/web/lib/confparser.inc.php
Johannes Löthberg 815e437f0c confparser: Add function for getting the items of a section
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-14 17:58:56 +02:00

39 lines
751 B
PHP

<?php
function config_load() {
global $AUR_CONFIG;
if (!isset($AUR_CONFIG)) {
$AUR_CONFIG = parse_ini_file("../../conf/config", true, INI_SCANNER_RAW);
}
}
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);
}