/** * Fetch message body of a specific message from the server * * @param int Message UID * @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, $fp = NULL) { if (!($msg_id = $this->_uid2id($uid))) { return FALSE; } // get part encoding if not provided if (!is_object($o_part)) { $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id); $structure = iml_GetRawStructureArray($structure_str); $part_type = iml_GetPartTypeCode($structure, $part); $o_part = new rcube_message_part(); $o_part->ctype_primary = $part_type == 0 ? 'text' : ($part_type == 2 ? 'message' : 'other'); $o_part->encoding = strtolower(iml_GetPartEncodingString($structure, $part)); $o_part->charset = iml_GetPartCharset($structure, $part); } // 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); $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode); // we have to decode the part manually before printing if ($mode == 1) { echo $this->mime_decode($body, $o_part->encoding); $body = true; } } 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 if ($o_part->encoding) { $body = $this->mime_decode($body, $o_part->encoding); } // convert charset (if text or message part) if ($o_part->ctype_primary == 'text' || $o_part->ctype_primary == 'message') { // assume default if no charset specified if (empty($o_part->charset)) { $o_part->charset = $this->default_charset; } $body = rcube_charset_convert($body, $o_part->charset); } if ($fp) { fwrite($fp, $body); return true; } } return $body; }
/** * Fetch message body of a specific message from the server * * @param int Message UID * @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, $fp = NULL) { // get part encoding if not provided if (!is_object($o_part)) { $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $uid, true); $structure = iml_GetRawStructureArray($structure_str); // error or message not found if (empty($structure)) { return false; } $part_type = iml_GetPartTypeCode($structure, $part); $o_part = new rcube_message_part(); $o_part->ctype_primary = $part_type == 0 ? 'text' : ($part_type == 2 ? 'message' : 'other'); $o_part->encoding = strtolower(iml_GetPartEncodingString($structure, $part)); $o_part->charset = iml_GetPartCharset($structure, $part); } // TODO: Add caching for message parts if (!$part) { $part = 'TEXT'; } $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $uid, true, $part, $o_part->encoding, $print, $fp); if ($fp || $print) { return true; } // convert charset (if text or message part) if ($o_part->ctype_primary == 'text' || $o_part->ctype_primary == 'message') { // assume default if no charset specified if (empty($o_part->charset) || strtolower($o_part->charset) == 'us-ascii') { $o_part->charset = $this->default_charset; } $body = rcube_charset_convert($body, $o_part->charset); } return $body; }
$my_colors["main_hilite"] = "#E6EDB6"; $fp = fopen($filename, "r"); $header = iil_C_FetchHeader($fp); fseek($fp, 0); $structure_str = iil_C_FetchStructureString($fp); fseek($fp, 0); echo "\n<!-- " . $structure_str . "-->\n"; flush(); $structure = iml_GetRawStructureArray($structure_str); $num_parts = iml_GetNumParts($structure, $part); $parent_type = iml_GetPartTypeCode($structure, $part); $uid = $header->uid; if ($parent_type == 1 && $num_parts == 1) { $part = 1; $num_parts = iml_GetNumParts($structure, $part); $parent_type = iml_GetPartTypeCode($structure, $part); } //show subject echo "\n<!-- SUBJECT //-->\n"; echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"" . $my_colors["main_darkbg"] . "\">\n"; echo "<tr bgcolor=\"" . $my_colors["main_darkbg"] . "\"><td valign=\"top\" colspan=2>\n"; echo "\n<span><b>" . encodeUTFSafeHTML(LangDecodeSubject($header->subject, $my_prefs["charset"])) . "</b>"; echo "<br> </span></td>\n"; echo "</tr>\n"; echo "</table>\n\n"; //show header echo "\n<!-- HEADER //-->\n"; echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"" . $my_colors["main_head_bg"] . "\">\n"; echo "<tr bgcolor=\"" . $my_colors["main_hilite"] . "\"><td valign=\"top\">\n"; echo "<span><b>日期: </b>" . encodeUTFSafeHTML($header->date) . "<br></span>\n"; echo "</td></tr>\n";