summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-20 11:01:56 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-20 12:21:02 +0200
commit2cf72fefc2d987f4b97b376cdc13d96998e730db (patch)
tree59eb0a60972bef143cdd5464b3e0fff43972ec06
parentf9da7438d93d12de64cfd08e02d4c8d2949ffdaa (diff)
downloadwebadmin-2cf72fefc2d987f4b97b376cdc13d96998e730db.tar.gz
Extract reading configuration file to a different function, make sure configuration is read in time
-rw-r--r--lib/Conf.php62
1 files changed, 35 insertions, 27 deletions
diff --git a/lib/Conf.php b/lib/Conf.php
index 4f1f883..e8a9a02 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -26,6 +26,8 @@
class Conf {
static private $instance;
+ private $_conf = array();
+
const CONFIG_FILE = '/etc/kolab/kolab.conf';
/**
@@ -49,33 +51,8 @@ class Conf {
return;
}
- $_ini_raw = file(self::CONFIG_FILE);
-
- $this->_conf = array();
+ $this->read_config();
- foreach ($_ini_raw as $_line) {
- if (preg_match('/^\[([a-z0-9-_\.]+)\]/', $_line, $matches)) {
- $_cur_section = $matches[1];
- $this->_conf[$_cur_section] = array();
- unset($_cur_key);
- }
-
- if (preg_match('/^;/', $_line, $matches)) {
- }
-
- if (preg_match('/^([a-z0-9\.-_]+)\s*=\s*(.*)/', $_line, $matches)) {
- if (isset($_cur_section) && !empty($_cur_section)) {
- $_cur_key = $matches[1];
- $this->_conf[$_cur_section][$matches[1]] = isset($matches[2]) ? $matches[2] : '';
- }
- }
-
- if (preg_match('/^\s+(.*)$/', $_line, $matches)) {
- if (isset($_cur_key) && !empty($_cur_key)) {
- $this->_conf[$_cur_section][$_cur_key] .= $matches[1];
- }
- }
- }
}
public function get($key1, $key2 = NULL)
@@ -130,7 +107,7 @@ class Conf {
return $this->_conf[$domain_section_name][$key1];
}
} catch (Exception $e) {
- $domain_section_name = $this->get('kolab', 'primary_domain');
+ $domain_section_name = $this->get_raw('kolab', 'primary_domain');
if (isset($this->_conf[$domain_section_name][$key1])) {
return $this->_conf[$domain_section_name][$key1];
}
@@ -183,4 +160,35 @@ class Conf {
return $str;
}
}
+
+ private function read_config()
+ {
+ $_ini_raw = file(self::CONFIG_FILE);
+
+ $this->_conf = array();
+
+ foreach ($_ini_raw as $_line) {
+ if (preg_match('/^\[([a-z0-9-_\.]+)\]/', $_line, $matches)) {
+ $_cur_section = $matches[1];
+ $this->_conf[$_cur_section] = array();
+ unset($_cur_key);
+ }
+
+ if (preg_match('/^;/', $_line, $matches)) {
+ }
+
+ if (preg_match('/^([a-z0-9\.-_]+)\s*=\s*(.*)/', $_line, $matches)) {
+ if (isset($_cur_section) && !empty($_cur_section)) {
+ $_cur_key = $matches[1];
+ $this->_conf[$_cur_section][$matches[1]] = isset($matches[2]) ? $matches[2] : '';
+ }
+ }
+
+ if (preg_match('/^\s+(.*)$/', $_line, $matches)) {
+ if (isset($_cur_key) && !empty($_cur_key)) {
+ $this->_conf[$_cur_section][$_cur_key] .= $matches[1];
+ }
+ }
+ }
+ }
}