From d30b165d18ab3a6868d3b3e96e7bac782fb58441 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 16 Nov 2012 13:28:15 +0100 Subject: Revert "config manager: let PHP parse the config file" This reverts commit b8f41ef0bac4e82cb3b02cd318efaddbaaeb1a78. We had good reasons for parsing the file ourselves. For example to keep expressions like 7*60*60*24 intact. --- lib/plugins/config/settings/config.class.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/plugins') diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index e4a638eb0..e71a7e5f9 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -139,13 +139,32 @@ if (!class_exists('configuration')) { function _read_config($file) { if (!$file) return array(); - if (!file_exists($file)) return array(); $config = array(); if ($this->_format == 'php') { - include($file); - $config = ${$this->_name}; + + if(@file_exists($file)){ + $contents = @php_strip_whitespace($file); + }else{ + $contents = ''; + } + $pattern = '/\$'.$this->_name.'\[[\'"]([^=]+)[\'"]\] ?= ?(.*?);(?=[^;]*(?:\$'.$this->_name.'|$))/s'; + $matches=array(); + preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER); + + for ($i=0; $i'\\','\\\''=>'\'','\\"'=>'"')); + + $config[$key] = $value; + } } return $config; -- cgit v1.2.3