summaryrefslogtreecommitdiff
path: root/lib/plugins
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-11-16 13:28:15 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-11-16 13:28:15 +0100
commitd30b165d18ab3a6868d3b3e96e7bac782fb58441 (patch)
tree72bfa92ceb2946835c56066dcc09e4fc82c9ff46 /lib/plugins
parent60dd32d957e6c4ce2d969c45cc60497f55a39abe (diff)
downloadrpg-d30b165d18ab3a6868d3b3e96e7bac782fb58441.tar.gz
rpg-d30b165d18ab3a6868d3b3e96e7bac782fb58441.tar.bz2
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.
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/config/settings/config.class.php25
1 files changed, 22 insertions, 3 deletions
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<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;
+ }
}
return $config;