| | |
| | | { |
| | | private $prop = array(); |
| | | private $errors = array(); |
| | | private $userprefs = array(); |
| | | |
| | | |
| | | /** |
| | |
| | | * @param string Full path to the config file to be loaded |
| | | * @return booelan True on success, false on failure |
| | | */ |
| | | public function load_from_file($fpath, $merge = true) |
| | | public function load_from_file($fpath) |
| | | { |
| | | if (is_file($fpath) && is_readable($fpath)) { |
| | | include($fpath); |
| | | if (is_array($rcmail_config)) { |
| | | $this->prop = $merge ? array_merge($this->prop, $rcmail_config) : $this->prop + $rcmail_config; |
| | | $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public function merge($prefs) |
| | | { |
| | | $this->prop = array_merge($this->prop, $prefs); |
| | | $this->prop = array_merge($this->prop, $prefs, $this->userprefs); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Merge the given prefs over the current config |
| | | * and make sure that they survive further merging. |
| | | * |
| | | * @param array Hash array with user prefs |
| | | */ |
| | | public function set_user_prefs($prefs) |
| | | { |
| | | $this->userprefs = $prefs; |
| | | $this->prop = array_merge($this->prop, $prefs); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Getter for all config options |
| | |
| | | { |
| | | return $this->prop; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return requested DES crypto key. |
| | |
| | | if (!array_key_exists($key, $this->prop)) |
| | | { |
| | | raise_error(array( |
| | | 'code' => 500, |
| | | 'type' => 'php', |
| | | 'file' => __FILE__, |
| | | 'code' => 500, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Request for unconfigured crypto key \"$key\"" |
| | | ), true, true); |
| | | } |
| | |
| | | if (strlen($key) != 24) |
| | | { |
| | | raise_error(array( |
| | | 'code' => 500, |
| | | 'type' => 'php', |
| | | 'file' => __FILE__, |
| | | 'code' => 500, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | | 'message' => "Configured crypto key \"$key\" is not exactly 24 bytes long" |
| | | ), true, true); |
| | | } |
| | | |
| | | return $key; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Try to autodetect operating system and find the correct line endings |
| | |
| | | else |
| | | return "\n"; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Return the mail domain configured for the given host |
| | | * |