diff --git a/inc/confutils.php b/inc/confutils.php index 14b2ad727e498d7188594fe5709e5b1bb42fef1a..aab0be4bef1ff5fcab26c75c7ee9b22ee006947a 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -123,19 +123,16 @@ function getSchemes() { } /** - * Builds a hash from a configfile + * Builds a hash from an array of lines * * If $lower is set to true all hash keys are converted to * lower case. * * @author Harry Fuecks <hfuecks@gmail.com> * @author Andreas Gohr <andi@splitbrain.org> + * @author Gina Haeussge <gina@foosel.net> */ -function confToHash($file,$lower=false) { - $conf = array(); - $lines = @file( $file ); - if ( !$lines ) return $conf; - +function linesToHash($lines, $lower=false) { foreach ( $lines as $line ) { //ignore comments (except escaped ones) $line = preg_replace('/(?<![&\\\\])#.*$/','',$line); @@ -154,6 +151,24 @@ function confToHash($file,$lower=false) { return $conf; } +/** + * Builds a hash from a configfile + * + * If $lower is set to true all hash keys are converted to + * lower case. + * + * @author Harry Fuecks <hfuecks@gmail.com> + * @author Andreas Gohr <andi@splitbrain.org> + * @author Gina Haeussge <gina@foosel.net> + */ +function confToHash($file,$lower=false) { + $conf = array(); + $lines = @file( $file ); + if ( !$lines ) return $conf; + + return linesToHash($lines, $lower); +} + /** * Retrieve the requested configuration information *