function config($file, $allow = FALSE)
{
preg_match_all('/(?<=^|\\n)(?:' . '\\[(?<section>.+?)\\]|' . '(?<lval>[^\\h\\r\\n;].*?)\\h*=\\h*' . '(?<rval>(?:\\\\\\h*\\r?\\n|.+?)*)' . ')(?=\\r?\\n|$)/', $this->read($file), $matches, PREG_SET_ORDER);
if ($matches) {
$sec = 'globals';
$cmd = [];
foreach ($matches as $match) {
if ($match['section']) {
$sec = $match['section'];
if (preg_match('/^(?!(?:global|config|route|map|redirect)s\\b)' . '((?:\\.?\\w)+)/i', $sec, $msec) && !$this->exists($msec[0])) {
$this->set($msec[0], NULL);
}
preg_match('/^(config|route|map|redirect)s\\b|' . '^((?:\\.?\\w)+)\\s*\\>\\s*(.*)/i', $sec, $cmd);
} else {
if ($allow) {
$match['lval'] = Preview::instance()->resolve($match['lval']);
$match['rval'] = Preview::instance()->resolve($match['rval']);
}
if (!empty($cmd)) {
isset($cmd[3]) ? $this->call($cmd[3], [$match['lval'], $match['rval'], $cmd[2]]) : call_user_func_array([$this, $cmd[1]], array_merge([$match['lval']], str_getcsv($match['rval'])));
} else {
$rval = preg_replace('/\\\\\\h*(\\r?\\n)/', '\\1', $match['rval']);
$ttl = NULL;
if (preg_match('/^(.+)\\|\\h*(\\d+)$/', $rval, $tmp)) {
array_shift($tmp);
list($rval, $ttl) = $tmp;
}
$args = array_map(function ($val) {
if (is_numeric($val)) {
return $val + 0;
}
$val = trim($val);
if (preg_match('/^\\w+$/i', $val) && defined($val)) {
return constant($val);
}
return preg_replace('/\\\\"/', '"', $val);
}, str_getcsv(preg_replace('/(?<!\\\\)(")(.*?)\\1/', "\\1\\2\\1", trim($rval))));
preg_match('/^(?<section>[^:]+)(?:\\:(?<func>.+))?/', $sec, $parts);
$func = isset($parts['func']) ? $parts['func'] : NULL;
$custom = strtolower($parts['section']) != 'globals';
if ($func) {
$args = [$this->call($func, $args)];
}
if (count($args) > 1) {
$args = [$args];
}
if (isset($ttl)) {
$args = array_merge($args, [$ttl]);
}
call_user_func_array([$this, 'set'], array_merge([($custom ? $parts['section'] . '.' : '') . $match['lval']], $args));
}
}
}
}
return $this;
}