Update wiki links to the new short URL
[aur.git] / web / lib / confparser.inc.php
blob1152e1320db553f33cd50e05e80b37483da4181d
1 <?php
3 function config_load() {
4 global $AUR_CONFIG;
6 if (!isset($AUR_CONFIG)) {
7 $path = getenv('AUR_CONFIG');
8 if (!$path) {
9 $path = "/etc/aurweb/config";
11 $defaults_path = getenv('AUR_CONFIG_DEFAULTS');
12 if (!$defaults_path) {
13 $defaults_path = $path . ".defaults";
15 if (file_exists($defaults_path)) {
16 $default_config = parse_ini_file($defaults_path, true, INI_SCANNER_RAW);
17 } else {
18 $default_config = [];
20 if (file_exists($path)) {
21 $config = parse_ini_file($path, true, INI_SCANNER_RAW);
22 } else {
23 die("aurweb config file not found");
25 $AUR_CONFIG = array_replace_recursive($default_config, $config);
29 function config_get($section, $key) {
30 global $AUR_CONFIG;
31 config_load();
33 return $AUR_CONFIG[$section][$key];
36 function config_get_int($section, $key) {
37 return intval(config_get($section, $key));
40 function config_get_bool($section, $key) {
41 $val = strtolower(config_get($section, $key));
42 return ($val == 'yes' || $val == 'true' || $val == '1');
45 function config_items($section) {
46 global $AUR_CONFIG;
47 config_load();
49 return $AUR_CONFIG[$section];
52 function config_section_exists($key) {
53 global $AUR_CONFIG;
54 config_load();
56 return array_key_exists($key, $AUR_CONFIG);