| | |
| | | return array_values($a_msg_headers); |
| | | } |
| | | else { // SEARCH searching result, need sorting |
| | | if ($cnt > $this->pagesize * 2) { |
| | | $cnt = count($msgs); |
| | | if ($cnt > 300 && $cnt > $this->page_size) { // experimantal value for best result |
| | | // use memory less expensive (and quick) method for big result set |
| | | $a_index = $this->message_index($mailbox, $this->sort_field, $this->sort_order); |
| | | // get messages uids for one page... |
| | | $msgs = array_slice(array_keys($a_index), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); |
| | | $msgs = array_slice(array_keys($a_index), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | // ...and fetch headers |
| | | $this->_fetch_headers($mailbox, join(',', $msgs), $a_msg_headers, NULL); |
| | | |
| | |
| | | $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); |
| | | |
| | | // only return the requested part of the set |
| | | return array_slice(array_values($a_msg_headers), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); |
| | | return array_slice(array_values($a_msg_headers), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // TODO: Add caching for message parts |
| | | |
| | | if (!$part) $part = 'TEXT'; |
| | | |
| | | if ($print) |
| | | { |
| | | $mode = $o_part->encoding == 'base64' ? 3 : ($o_part->encoding == 'quoted-printable' ? 1 : 2); |
| | |
| | | if (!($msg_id = $this->_uid2id($uid))) |
| | | return FALSE; |
| | | |
| | | $body = iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL); |
| | | $body .= iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 1); |
| | | |
| | | return $body; |
| | | return iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id); |
| | | } |
| | | |
| | | |
| | |
| | | if (!($msg_id = $this->_uid2id($uid))) |
| | | return FALSE; |
| | | |
| | | print iil_C_FetchPartHeader($this->conn, $this->mailbox, $msg_id, NULL); |
| | | flush(); |
| | | iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, NULL, 2); |
| | | } |
| | | |
| | |
| | | { |
| | | $this->db->query( |
| | | "UPDATE ".get_table_name('cache')." |
| | | SET created=".$this->db->now().", |
| | | data=? |
| | | SET created=".$this->db->now().", data=?, session_id=? |
| | | WHERE user_id=? |
| | | AND cache_key=?", |
| | | $data, |
| | | session_id(), |
| | | $_SESSION['user_id'], |
| | | $key); |
| | | } |
| | |
| | | { |
| | | $this->db->query( |
| | | "INSERT INTO ".get_table_name('cache')." |
| | | (created, user_id, cache_key, data) |
| | | VALUES (".$this->db->now().", ?, ?, ?)", |
| | | (created, user_id, cache_key, data, session_id) |
| | | VALUES (".$this->db->now().", ?, ?, ?, ?)", |
| | | $_SESSION['user_id'], |
| | | $key, |
| | | $data); |
| | | $data, |
| | | session_id()); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * Decode a mime-encoded string to internal charset |
| | | * |
| | | * @param string Header value |
| | | * @param string Fallback charset if none specified |
| | | * @param string $input Header value |
| | | * @param string $fallback Fallback charset if none specified |
| | | * |
| | | * @return string Decoded string |
| | | * @static |
| | | */ |
| | | function decode_mime_string($input, $fallback=null) |
| | | public static function decode_mime_string($input, $fallback=null) |
| | | { |
| | | // Initialize variable |
| | | $out = ''; |