From e6ee84bcf8a70765985eb7644bc07f177dc96bef Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 20 Jun 2009 03:50:12 -0400
Subject: [PATCH] - check is_readable in load_from_file()

---
 program/include/rcube_config.php |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 60064e7..e596c0b 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -51,15 +51,11 @@
     ob_start();
     
     // load main config file
-    if (include(RCMAIL_CONFIG_DIR . '/main.inc.php'))
-      $this->prop = (array)$rcmail_config;
-    else
+    if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php'))
       $this->errors[] = 'main.inc.php was not found.';
 
     // load database config
-    if (include(RCMAIL_CONFIG_DIR . '/db.inc.php'))
-      $this->prop += (array)$rcmail_config;
-    else
+    if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php'))
       $this->errors[] = 'db.inc.php was not found.';
     
     // load host-specific configuration
@@ -74,15 +70,14 @@
     // fix paths
     $this->prop['log_dir'] = $this->prop['log_dir'] ? unslashify($this->prop['log_dir']) : INSTALL_PATH . 'logs';
     $this->prop['temp_dir'] = $this->prop['temp_dir'] ? unslashify($this->prop['temp_dir']) : INSTALL_PATH . 'temp';
-    $this->prop['plugins_dir'] = $this->prop['plugins_dir'] ? unslashify($this->prop['plugins_dir']) : INSTALL_PATH . 'plugins';
 
     // fix default imap folders encoding
     foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
-      $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF-7');
+      $this->prop[$folder] = rcube_charset_convert($this->prop[$folder], RCMAIL_CHARSET, 'UTF7-IMAP');
 
     if (!empty($this->prop['default_imap_folders']))
       foreach ($this->prop['default_imap_folders'] as $n => $folder)
-        $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF-7');
+        $this->prop['default_imap_folders'][$n] = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
 
     // set PHP error logging according to config
     if ($this->prop['debug_level'] & 1) {
@@ -124,14 +119,34 @@
       $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';
     }
 
-    if ($fname && is_file(RCMAIL_CONFIG_DIR . '/' . $fname)) {
-      include(RCMAIL_CONFIG_DIR . '/' . $fname);
-      $this->prop = array_merge($this->prop, (array)$rcmail_config);
+    if ($fname) {
+      $this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname);
     }
   }
   
   
   /**
+   * Read configuration from a file
+   * and merge with the already stored config values
+   *
+   * @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)
+  {
+    if (is_file($fpath) && is_readable($fpath)) {
+      include($fpath);
+      if (is_array($rcmail_config)) {
+        $this->prop = array_merge($this->prop, $rcmail_config);
+        return true;
+      }
+    }
+    
+    return false;
+  }
+  
+  
+  /**
    * Getter for a specific config parameter
    *
    * @param  string Parameter name

--
Gitblit v1.9.1