thomascube
2011-08-13 1c72e9983dfc9bbfb0fe4c0f02215855b0cb3e5f
program/include/rcmail.php
@@ -208,7 +208,7 @@
    $task = asciiwords($task);
    if ($this->user && $this->user->ID)
      $task = !$task || $task == 'login' ? 'mail' : $task;
      $task = !$task ? 'mail' : $task;
    else
      $task = 'login';
@@ -503,7 +503,7 @@
      'auth_method' => $this->config->get('imap_auth_type', 'check'),
      'auth_cid'    => $this->config->get('imap_auth_cid'),
      'auth_pw'     => $this->config->get('imap_auth_pw'),
      'debug_mode'  => (bool) $this->config->get('imap_debug', 0),
      'debug'       => (bool) $this->config->get('imap_debug', 0),
      'force_caps'  => (bool) $this->config->get('imap_force_caps'),
      'timeout'     => (int) $this->config->get('imap_timeout', 0),
    );
@@ -673,9 +673,9 @@
    // Check if we need to add domain
    if (!empty($config['username_domain']) && strpos($username, '@') === false) {
      if (is_array($config['username_domain']) && isset($config['username_domain'][$host]))
        $username .= '@'.rcube_parse_host($config['username_domain'][$host]);
        $username .= '@'.rcube_parse_host($config['username_domain'][$host], $host);
      else if (is_string($config['username_domain']))
        $username .= '@'.rcube_parse_host($config['username_domain']);
        $username .= '@'.rcube_parse_host($config['username_domain'], $host);
    }
    // Convert username to lowercase. If IMAP backend
@@ -691,12 +691,12 @@
    // Here we need IDNA ASCII
    // Only rcube_contacts class is using domain names in Unicode
    $host = idn_to_ascii($host);
    $host = rcube_idn_to_ascii($host);
    if (strpos($username, '@')) {
      // lowercase domain name
      list($local, $domain) = explode('@', $username);
      $username = $local . '@' . mb_strtolower($domain);
      $username = idn_to_ascii($username);
      $username = rcube_idn_to_ascii($username);
    }
    // user already registered -> overwrite username
@@ -915,6 +915,21 @@
    return $text;
  }
  /**
   * Check if the given text lable exists
   *
   * @param string Label name
   * @return boolean True if text exists (either in the current language or in en_US)
   */
  public function text_exists($name, $domain=null)
  {
    // load localization files if not done yet
    if (empty($this->texts))
      $this->load_language();
    // check for text with domain first
    return ($domain && isset($this->texts[$domain.'.'.$name])) || isset($this->texts[$name]);
  }
  /**
   * Load a localization package
@@ -928,6 +943,9 @@
    // load localized texts
    if (empty($this->texts) || $lang != $_SESSION['language']) {
      $this->texts = array();
      // handle empty lines after closing PHP tag in localization files
      ob_start();
      // get english labels (these should be complete)
      @include(INSTALL_PATH . 'program/localization/en_US/labels.inc');
@@ -948,6 +966,8 @@
        if (is_array($messages))
          $this->texts = array_merge($this->texts, $messages);
      }
      ob_end_clean();
      $_SESSION['language'] = $lang;
    }
@@ -1066,15 +1086,15 @@
   */
  public function shutdown()
  {
    if (is_object($this->imap))
      $this->imap->close();
    if (is_object($this->smtp))
      $this->smtp->disconnect();
    foreach ($this->books as $book)
      if (is_object($book))
        $book->close();
    if (is_object($this->imap))
      $this->imap->close();
    // before closing the database connection, write session data
    if ($_SERVER['REMOTE_ADDR'])
@@ -1103,12 +1123,9 @@
   */
  public function get_request_token()
  {
    $key = $this->task;
    if (!$_SESSION['request_tokens'][$key])
      $_SESSION['request_tokens'][$key] = md5(uniqid($key . mt_rand(), true));
    return $_SESSION['request_tokens'][$key];
    $sess_id = $_COOKIE[ini_get('session.name')];
    if (!$sess_id) $sess_id = session_id();
    return md5('RT' . $this->task . $this->config->get('des_key') . $sess_id);
  }
@@ -1121,7 +1138,8 @@
  public function check_request($mode = RCUBE_INPUT_POST)
  {
    $token = get_input_value('_token', $mode);
    return !empty($token) && $_SESSION['request_tokens'][$this->task] == $token;
    $sess_id = $_COOKIE[ini_get('session.name')];
    return !empty($sess_id) && $token == $this->get_request_token();
  }