diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-11-10 18:13:09 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-11-10 18:13:09 +0100 |
commit | b8f41ef0bac4e82cb3b02cd318efaddbaaeb1a78 (patch) | |
tree | 409746d994c341a7bb29788da5c1e25f8e7d7369 | |
parent | 89d02586756515c9fb68a348e99a787d95e999a2 (diff) | |
download | rpg-b8f41ef0bac4e82cb3b02cd318efaddbaaeb1a78.tar.gz rpg-b8f41ef0bac4e82cb3b02cd318efaddbaaeb1a78.tar.bz2 |
config manager: let PHP parse the config file
Until now, the config manager did read and parse the various PHP config
files itself. This fails for more complex setups like arrays.
I'm not really sure why this was done. This patch replaces the parsing
with a simple include() call. Everything still seems to work.
-rw-r--r-- | lib/plugins/config/settings/config.class.php | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index ebf638526..722c8df7b 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -139,32 +139,13 @@ if (!class_exists('configuration')) { function _read_config($file) { if (!$file) return array(); + if (!file_exists($file)) return array(); $config = array(); if ($this->_format == 'php') { - - 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<count($matches); $i++) { - - // correct issues with the incoming data - // FIXME ... for now merge multi-dimensional array indices using ____ - $key = preg_replace('/.\]\[./',CM_KEYMARKER,$matches[$i][1]); - - // remove quotes from quoted strings & unescape escaped data - $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$matches[$i][2]); - $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"')); - - $config[$key] = $value; - } + include($file); + $config = ${$this->_name}; } return $config; |