| | |
| | | $this->port = $port; |
| | | $this->ssl = $use_ssl; |
| | | |
| | | // print trace mesages |
| | | // print trace messages |
| | | if ($this->conn && ($this->debug_level & 8)) |
| | | console($this->conn->message); |
| | | |
| | |
| | | */ |
| | | function _fetch_headers($mailbox, $msgs, &$a_msg_headers, $cache_key) |
| | | { |
| | | // cache is incomplete |
| | | $cache_index = $this->get_message_cache_index($cache_key); |
| | | |
| | | // fetch reqested headers from server |
| | | $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs, false, $this->fetch_add_headers); |
| | | |
| | | |
| | | if (!empty($a_header_index)) |
| | | { |
| | | // cache is incomplete |
| | | $cache_index = $this->get_message_cache_index($cache_key); |
| | | |
| | | foreach ($a_header_index as $i => $headers) |
| | | { |
| | | /* |
| | |
| | | $a_msg_headers[$headers->uid] = $headers; |
| | | } |
| | | } |
| | | |
| | | |
| | | return count($a_msg_headers); |
| | | } |
| | | |
| | |
| | | FROM ".get_table_name('messages')." |
| | | WHERE user_id=? |
| | | AND cache_key=? |
| | | ORDER BY ".$this->db->quoteIdentifier($sort_field)." ". |
| | | strtoupper($sort_order), |
| | | ORDER BY ".$this->db->quoteIdentifier($sort_field)." ".strtoupper($sort_order), |
| | | $from, |
| | | $to-$from, |
| | | $_SESSION['user_id'], |
| | |
| | | while ($sql_arr = $this->db->fetch_assoc($sql_result)) |
| | | { |
| | | $uid = $sql_arr['uid']; |
| | | $this->cache[$cache_key][$uid] = unserialize($sql_arr['headers']); |
| | | |
| | | $this->cache[$cache_key][$uid] = $this->db->decode(unserialize($sql_arr['headers'])); |
| | | |
| | | // featch headers if unserialize failed |
| | | if (empty($this->cache[$cache_key][$uid])) |
| | | $this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true, $this->fetch_add_headers); |
| | | } |
| | | } |
| | | |
| | | |
| | | return $this->cache[$cache_key]; |
| | | } |
| | | |
| | |
| | | $uid); |
| | | if ($sql_arr = $this->db->fetch_assoc($sql_result)) |
| | | { |
| | | $this->cache[$internal_key][$uid] = unserialize($sql_arr['headers']); |
| | | $this->cache[$internal_key][$uid] = $this->db->decode(unserialize($sql_arr['headers'])); |
| | | if (is_object($this->cache[$internal_key][$uid]) && !empty($sql_arr['structure'])) |
| | | $this->cache[$internal_key][$uid]->structure = unserialize($sql_arr['structure']); |
| | | $this->cache[$internal_key][$uid]->structure = $this->db->decode(unserialize($sql_arr['structure'])); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function add_message_cache($key, $index, $headers, $struct=null) |
| | | private function add_message_cache($key, $index, $headers, $struct=null) |
| | | { |
| | | if (empty($key) || !is_object($headers) || empty($headers->uid)) |
| | | return; |
| | |
| | | // add to internal (fast) cache |
| | | $this->cache['__single_msg'][$headers->uid] = $headers; |
| | | $this->cache['__single_msg'][$headers->uid]->structure = $struct; |
| | | |
| | | |
| | | // no further caching |
| | | if (!$this->caching_enabled) |
| | | return; |
| | |
| | | SET idx=?, headers=?, structure=? |
| | | WHERE message_id=?", |
| | | $index, |
| | | serialize($headers), |
| | | is_object($struct) ? serialize($struct) : NULL, |
| | | serialize($this->db->encode(clone $headers)), |
| | | is_object($struct) ? serialize($this->db->encode(clone $struct)) : NULL, |
| | | $sql_arr['message_id'] |
| | | ); |
| | | } |
| | |
| | | $key, |
| | | $index, |
| | | $headers->uid, |
| | | (string)substr($this->decode_header($headers->subject, TRUE), 0, 128), |
| | | (string)substr($this->decode_header($headers->from, TRUE), 0, 128), |
| | | (string)substr($this->decode_header($headers->to, TRUE), 0, 128), |
| | | (string)substr($this->decode_header($headers->cc, TRUE), 0, 128), |
| | | |
| | | (string)rc_substr($this->db->encode($this->decode_header($headers->subject, TRUE)), 0, 128), |
| | | (string)rc_substr($this->db->encode($this->decode_header($headers->from, TRUE)), 0, 128), |
| | | (string)rc_substr($this->db->encode($this->decode_header($headers->to, TRUE)), 0, 128), |
| | | (string)rc_substr($this->db->encode($this->decode_header($headers->cc, TRUE)), 0, 128), |
| | | (int)$headers->size, |
| | | serialize($headers), |
| | | is_object($struct) ? serialize($struct) : NULL |
| | | serialize($this->db->encode(clone $headers)), |
| | | is_object($struct) ? serialize($this->db->encode(clone $struct)) : NULL |
| | | ); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function remove_message_cache($key, $uids) |
| | | private function remove_message_cache($key, $uids) |
| | | { |
| | | if (!$this->caching_enabled) |
| | | return; |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function clear_message_cache($key, $start_index=1) |
| | | private function clear_message_cache($key, $start_index=1) |
| | | { |
| | | if (!$this->caching_enabled) |
| | | return; |
| | |
| | | /** |
| | | * @access private |
| | | */ |
| | | function get_message_cache_index_min($key, $uids=NULL) |
| | | private function get_message_cache_index_min($key, $uids=NULL) |
| | | { |
| | | if (!$this->caching_enabled) |
| | | return; |