| | |
| | | | | |
| | | | This file is part of the RoundCube Webmail client | |
| | | | Copyright (C) 2005, RoundCube Dev. - Switzerland | |
| | | | All rights reserved. | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | PURPOSE: | |
| | | | IMAP wrapper that implements the Iloha IMAP Library (IIL) | |
| | |
| | | require_once('lib/imap.inc'); |
| | | require_once('lib/mime.inc'); |
| | | |
| | | // check for Open-SSL support in PHP build |
| | | //$ICL_SSL = TRUE; |
| | | //$ICL_PORT = 993; |
| | | |
| | | class rcube_imap |
| | | { |
| | |
| | | var $mailbox = 'INBOX'; |
| | | var $list_page = 1; |
| | | var $page_size = 10; |
| | | var $cacheing_enabled = FALSE; |
| | | var $delimiter = NULL; |
| | | var $caching_enabled = FALSE; |
| | | var $default_folders = array('inbox', 'drafts', 'sent', 'junk', 'trash'); |
| | | var $cache = array(); |
| | | var $cache_changes = array(); |
| | |
| | | // PHP 5 constructor |
| | | function __construct() |
| | | { |
| | | if (function_exists('rcube_read_cache')) |
| | | $this->cacheing_enabled = TRUE; |
| | | |
| | | } |
| | | |
| | | // PHP 4 compatibility |
| | |
| | | } |
| | | |
| | | |
| | | function connect($host, $user, $pass, $port=143) |
| | | function connect($host, $user, $pass, $port=143, $use_ssl=FALSE) |
| | | { |
| | | global $ICL_PORT; |
| | | global $ICL_PORT, $CONFIG; |
| | | |
| | | // check for Open-SSL support in PHP build |
| | | if ($use_ssl && in_array('openssl', get_loaded_extensions())) |
| | | $ICL_SSL = TRUE; |
| | | |
| | | $ICL_PORT = $port; |
| | | $this->conn = iil_Connect($host, $user, $pass); |
| | | $this->conn = iil_Connect($host, $user, $pass, array('imap' => 'check')); |
| | | $this->host = $host; |
| | | $this->user = $user; |
| | | $this->pass = $pass; |
| | | |
| | | if ($this->conn && ($CONFIG['debug_level'] & 8)) |
| | | print $this->conn->message; |
| | | |
| | | else if (!$this->conn && $GLOBALS['iil_error']) |
| | | { |
| | | raise_error(array('code' => 403, |
| | | 'type' => 'imap', |
| | | 'message' => $GLOBALS['iil_error']), TRUE, FALSE); |
| | | } |
| | | |
| | | return $this->conn ? TRUE : FALSE; |
| | | } |
| | |
| | | return $this->conn ? $this->_mod_mailbox($this->mailbox, 'out') : ''; |
| | | } |
| | | |
| | | |
| | | function get_hierarchy_delimiter() |
| | | { |
| | | if ($this->conn && empty($this->delimiter)) |
| | | $this->delimiter = iil_C_GetHierarchyDelimiter($this->conn); |
| | | |
| | | return $this->delimiter; |
| | | } |
| | | |
| | | // public method for mailbox listing |
| | | // convert mailbox name with root dir first |
| | |
| | | |
| | | |
| | | /* -------------------------------- |
| | | * internal cacheing functions |
| | | * internal caching functions |
| | | * --------------------------------*/ |
| | | |
| | | |
| | | |
| | | function set_caching($set) |
| | | { |
| | | if ($set && function_exists('rcube_read_cache')) |
| | | $this->caching_enabled = TRUE; |
| | | else |
| | | $this->caching_enabled = FALSE; |
| | | } |
| | | |
| | | function get_cache($key) |
| | | { |
| | | // read cache |
| | | if (!isset($this->cache[$key]) && $this->cacheing_enabled) |
| | | if (!isset($this->cache[$key]) && $this->caching_enabled) |
| | | { |
| | | $cache_data = rcube_read_cache('IMAP.'.$key); |
| | | $this->cache[$key] = strlen($cache_data) ? unserialize($cache_data) : FALSE; |
| | |
| | | |
| | | function write_cache() |
| | | { |
| | | if ($this->cacheing_enabled && $this->cache_changed) |
| | | if ($this->caching_enabled && $this->cache_changed) |
| | | { |
| | | foreach ($this->cache as $key => $data) |
| | | { |