diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-10-24 08:31:47 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-10-24 10:03:54 +0200 |
commit | 76343fb91511b9f53e58b6c01b258bfe00ddb4c6 (patch) | |
tree | 60eb4d3727bae159a1807915a58348b210ead206 /web/lib/confparser.inc.php | |
parent | a0a523070847230565c2ad5993ee058ff475a8e1 (diff) |
Use an INI-style configuration file
Replace web/lib/config.inc.php with an INI-style configuration file.
This allows us to get rid of several globals and makes it easier to use
the same configuration file in external scripts.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/confparser.inc.php')
-rw-r--r-- | web/lib/confparser.inc.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php new file mode 100644 index 0000000..41ee581 --- /dev/null +++ b/web/lib/confparser.inc.php @@ -0,0 +1,20 @@ +<?php + +function config_get($section, $key) { + global $AUR_CONFIG; + + if (!isset($AUR_CONFIG)) { + $AUR_CONFIG = parse_ini_file("../../conf/config", true); + } + + 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'); +} |