- Reduced memory footprint when forwarding attachments (#1485345)
- Fixed endless loop in iil_C_HandlePartBody()
- rcube_message::get_part_content() speed up using 3rd argument of rcube_imap::get_message_part()
| | |
| | | CHANGELOG RoundCube Webmail |
| | | --------------------------- |
| | | |
| | | 2008/09/16 (alec) |
| | | ---------- |
| | | - Reduced memory footprint when forwarding attachments (#1485345) |
| | | |
| | | 2008/09/15 (thomasb) |
| | | ---------- |
| | | - Redesign of the identities settings (#1484042) |
| | |
| | | * @param string Part number |
| | | * @param object rcube_message_part Part object created by get_structure() |
| | | * @param mixed True to print part, ressource to write part contents in |
| | | * @param resource File pointer to save the message part |
| | | * @return string Message/part body if not printed |
| | | */ |
| | | function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL) |
| | | function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL) |
| | | { |
| | | if (!($msg_id = $this->_uid2id($uid))) |
| | | return FALSE; |
| | |
| | | // get part encoding if not provided |
| | | if (!is_object($o_part)) |
| | | { |
| | | write_log('errors', 'get_message_part: !is_object'); |
| | | $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id); |
| | | $structure = iml_GetRawStructureArray($structure_str); |
| | | $part_type = iml_GetPartTypeCode($structure, $part); |
| | |
| | | } |
| | | else |
| | | { |
| | | if ($fp && $o_part->encoding == 'base64') |
| | | return iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 3, $fp); |
| | | else |
| | | $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1); |
| | | |
| | | // decode part body |
| | |
| | | |
| | | $body = rcube_charset_convert($body, $o_part->charset); |
| | | } |
| | | |
| | | if ($fp) |
| | | { |
| | | fwrite($fp, $body); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return $body; |
| | |
| | | * Get content of a specific part of this message |
| | | * |
| | | * @param string Part MIME-ID |
| | | * @param resource File pointer to save the message part |
| | | * @return string Part content |
| | | */ |
| | | public function get_part_content($mime_id) |
| | | public function get_part_content($mime_id, $fp=NULL) |
| | | { |
| | | if ($part = $this->mime_parts[$mime_id]) |
| | | return $this->imap->get_message_part($this->uid, $mime_id, $part); |
| | | return $this->imap->get_message_part($this->uid, $mime_id, $part, NULL, $fp); |
| | | else |
| | | return null; |
| | | } |
| | |
| | | - RFC3501 [7.1] don't call CAPABILITY if was returned in server |
| | | optional resposne in iil_Connect(), added iil_C_GetCapability() |
| | | - remove 'undisclosed-recipients' string from 'To' header |
| | | - iil_C_HandlePartBody(): added 6th argument and fixed endless loop |
| | | |
| | | ********************************************************/ |
| | | |
| | |
| | | return $result; |
| | | } |
| | | |
| | | function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode) { |
| | | function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode, $file=NULL) { |
| | | /* modes: |
| | | 1: return string |
| | | 1: return string (or write to $file pointer) |
| | | 2: print |
| | | 3: base64 and print |
| | | 3: base64 and print (or write to $file pointer) |
| | | */ |
| | | |
| | | $fp = $conn->fp; |
| | |
| | | if ($mode == 2) { |
| | | echo $result; |
| | | } else if ($mode == 3) { |
| | | if ($file) |
| | | fwrite($file, base64_decode($result)); |
| | | else |
| | | echo base64_decode($result); |
| | | } |
| | | } else if ($line[$len-1] == '}') { |
| | |
| | | $len = $to - $from; |
| | | $sizeStr = substr($line, $from, $len); |
| | | $bytes = (int)$sizeStr; |
| | | $received = 0; |
| | | |
| | | while ($received < $bytes) { |
| | | $remaining = $bytes - $received; |
| | | while ($bytes > 0) { |
| | | $line = iil_ReadLine($fp, 1024); |
| | | $len = strlen($line); |
| | | |
| | | if ($len > $remaining) { |
| | | $line = substr($line, 0, $remaining); |
| | | if ($len > $bytes) { |
| | | $line = substr($line, 0, $bytes); |
| | | } |
| | | $received += strlen($line); |
| | | $bytes -= strlen($line); |
| | | |
| | | if ($mode == 1) { |
| | | if ($file) |
| | | fwrite($file, rtrim($line, "\t\r\n\0\x0B") . "\n"); |
| | | else |
| | | $result .= rtrim($line, "\t\r\n\0\x0B") . "\n"; |
| | | } else if ($mode == 2) { |
| | | echo rtrim($line, "\t\r\n\0\x0B") . "\n"; |
| | | } else if ($mode == 3) { |
| | | if ($file) |
| | | fwrite($file, base64_decode($line)); |
| | | else |
| | | echo base64_decode($line); |
| | | } |
| | | } |
| | | } |
| | | // read in anything up until 'til last line |
| | | // read in anything up until last line |
| | | do { |
| | | $line = iil_ReadLine($fp, 1024); |
| | | } while (!iil_StartsWith($line, $key)); |
| | | |
| | | if ($mode == 3 && $file) { |
| | | return true; |
| | | } |
| | | |
| | | if ($result) { |
| | | $result = rtrim($result, "\t\r\n\0\x0B"); |
| | | if ($file) { |
| | | fwrite($file, $result); |
| | | return true; |
| | | } |
| | | return $result; // substr($result, 0, strlen($result)-1); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if ($mode==1) { |
| | | if ($file) { |
| | | fwrite($file, $result); |
| | | return true; |
| | | } |
| | | return $result; |
| | | } |
| | | return $received; |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function iil_C_FetchPartBody(&$conn, $mailbox, $id, $part) { |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1); |
| | | function iil_C_FetchPartBody(&$conn, $mailbox, $id, $part, $file=NULL) { |
| | | return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1, $file); |
| | | } |
| | | |
| | | function iil_C_PrintPartBody(&$conn, $mailbox, $id, $part) { |
| | |
| | | $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); |
| | | if ($fp = fopen($tmp_path, 'w')) |
| | | { |
| | | fwrite($fp, $message->get_part_content($pid)); |
| | | $message->get_part_content($pid, $fp); |
| | | fclose($fp); |
| | | |
| | | $_SESSION['compose']['attachments'][] = array( |