alecpl
2009-12-12 317a7d9f677b50db12c5988f38abb10ade0634a5
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
@@ -72,17 +68,16 @@
      $this->prop['skin'] = 'default';
    // 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';
    $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs';
    $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp';
    // 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,10 +119,30 @@
      $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, $merge = true)
  {
    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;
        return true;
      }
    }
    return false;
  }
  
  
@@ -222,9 +237,9 @@
    // use the configured delimiter for headers
    if (!empty($this->prop['mail_header_delimiter']))
      return $this->prop['mail_header_delimiter'];
    else if (strtolower(substr(PHP_OS, 0, 3) == 'win'))
    else if (strtolower(substr(PHP_OS, 0, 3)) == 'win')
      return "\r\n";
    else if (strtolower(substr(PHP_OS, 0, 3) == 'mac'))
    else if (strtolower(substr(PHP_OS, 0, 3)) == 'mac')
      return "\r\n";
    else
      return "\n";