| | |
| | | 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 |
| | |
| | | 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(); |
| | |
| | | */ |
| | | 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); |
| | | } |
| | | |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | |
| | | ), true, true); |
| | | } |
| | | } |
| | | |
| | | if (is_object($this->imap)) |
| | | $this->imap->close(); |
| | | |
| | | return $base64 ? base64_encode($cipher) : $cipher; |
| | | } |