alecpl
2010-03-24 d8c440c03f3c66b93793c40e54d3c9329d9b5ea9
program/include/rcube_config.php
@@ -15,7 +15,7 @@
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 +-----------------------------------------------------------------------+
 $Id: $
 $Id$
*/
@@ -28,6 +28,7 @@
{
  private $prop = array();
  private $errors = array();
  private $userprefs = array();
  /**
@@ -68,9 +69,9 @@
      $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['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, 'UTF7-IMAP');
@@ -134,10 +135,10 @@
   */
  public function load_from_file($fpath)
  {
    if (is_file($fpath)) {
      @include($fpath);
    if (is_file($fpath) && is_readable($fpath)) {
      include($fpath);
      if (is_array($rcmail_config)) {
        $this->prop = array_merge($this->prop, $rcmail_config);
        $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs);
        return true;
      }
    }
@@ -178,9 +179,22 @@
   */
  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
@@ -191,6 +205,7 @@
  {
    return $this->prop;
  }
  /**
   * Return requested DES crypto key.
@@ -204,9 +219,8 @@
    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);
    }
@@ -217,15 +231,15 @@
    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
@@ -237,16 +251,15 @@
    // 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";
  }
  /**
   * Return the mail domain configured for the given host
   *