thomascube
2011-08-13 1c72e9983dfc9bbfb0fe4c0f02215855b0cb3e5f
program/include/rcmail.php
@@ -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
@@ -1078,6 +1093,9 @@
      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'])
      session_write_close();
@@ -1105,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);
  }
@@ -1123,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();
  }
@@ -1194,9 +1210,6 @@
        ), true, true);
      }
    }
    if (is_object($this->imap))
      $this->imap->close();
    return $base64 ? base64_encode($cipher) : $cipher;
  }