summaryrefslogtreecommitdiff
path: root/lib/plugins/config/settings/config.class.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-25 11:12:53 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-01-25 11:12:53 +0100
commitb303add4e27e10fbdc4ed64f40ab2046232027bf (patch)
tree0fa9a95149c6a3eef0e90ae30f27c4a18925fc19 /lib/plugins/config/settings/config.class.php
parent33e75ca2f63b10ae1c7c7e9891ae857ce80d1811 (diff)
parentd12150d88f5fe8d5718313ab6c14ab8c907c61ff (diff)
downloadrpg-b303add4e27e10fbdc4ed64f40ab2046232027bf.tar.gz
rpg-b303add4e27e10fbdc4ed64f40ab2046232027bf.tar.bz2
Merge branch 'confmanager' into future
* confmanager: fixed problems with spaced arrays parse arrays from config file
Diffstat (limited to 'lib/plugins/config/settings/config.class.php')
-rw-r--r--lib/plugins/config/settings/config.class.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index d4d98ee01..5e472d16b 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -159,14 +159,32 @@ if (!class_exists('configuration')) {
preg_match_all($pattern,$contents,$matches,PREG_SET_ORDER);
for ($i=0; $i<count($matches); $i++) {
+ $value = $matches[$i][2];
+
// 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('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+
+ // handle arrays
+ if(preg_match('/^array ?\((.*)\)/', $value, $match)){
+ $arr = explode(',', $match[1]);
+
+ // remove quotes from quoted strings & unescape escaped data
+ $len = count($arr);
+ for($j=0; $j<$len; $j++){
+ $arr[$j] = trim($arr[$j]);
+ $arr[$j] = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$arr[$j]);
+ $arr[$j] = strtr($arr[$j], array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
+
+ $value = $arr;
+ }else{
+ // remove quotes from quoted strings & unescape escaped data
+ $value = preg_replace('/^(\'|")(.*)(?<!\\\\)\1$/s','$2',$value);
+ $value = strtr($value, array('\\\\'=>'\\','\\\''=>'\'','\\"'=>'"'));
+ }
$config[$key] = $value;
}