function get_body_msg($msg_number, $msg_folder) { /* * Requires of librarys */ require_once dirname(__FILE__) . '/../../prototype/library/mime/mimePart.php'; require_once dirname(__FILE__) . '/../../prototype/library/mime/mimeDecode.php'; require_once dirname(__FILE__) . '/class.attachment.inc.php'; //include_once("class.message_components.inc.php"); //--------------------------------------------------------------------// $return = array(); // $msg = new message_components($this->mbox); // $msg->fetch_structure($msg_number); $content = ''; /* * Chamada original $this->getRawHeader($msg_number)."\r\n".$this->getRawBody($msg_number); * Inserido replace para corrigir um bug que acontece raramente em mensagens vindas do outlook com muitos destinatarios */ $rawMessageData = str_replace("\r\n\t", '', $this->getRawHeader($msg_number)) . "\r\n" . $this->getRawBody($msg_number); $decoder = new Mail_mimeDecode($rawMessageData); $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; if (array_key_exists('nested_messages_are_shown', $_SESSION['phpgw_info']['user']['preferences']['expressoMail']) && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['nested_messages_are_shown'] == '1') { $params['rfc_822bodies'] = true; } $structure = $decoder->decode($params); /* * Inicia Gerenciador de Anexos */ $attachmentManager = new attachment(); $attachmentManager->setStructure($structure); //----------------------------------------------// /* * Monta informações dos anexos para o cabecalhos */ $attachments = $attachmentManager->getAttachmentsInfo(); $return['attachments'] = $attachments; //----------------------------------------------// /* * Monta informações das imagens */ $images = $attachmentManager->getEmbeddedImagesInfo(); //----------------------------------------------// if (!$this->has_cid) { $return['thumbs'] = $this->get_thumbs($images, $msg_number, $msg_folder); // $return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder); } switch (strtolower($structure->ctype_primary)) { case 'text': if (strtolower($structure->ctype_secondary) == 'x-pkcs7-mime') { $return['body'] = 'isCripted'; return $return; } $attachment = array(); $msg_subtype = strtolower($structure->ctype_secondary); if (isset($structure->disposition)) { $disposition = strtolower($structure->disposition); } else { $disposition = ''; } if (($msg_subtype == "html" || $msg_subtype == 'plain') && $disposition != 'attachment') { if (strtolower($msg_subtype) == 'plain') { if (isset($structure->ctype_parameters['charset'])) { $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'], false); } else { $content = $this->decodeMailPart($structure->body, null, false); } $content = str_replace(array('<', '>'), array('#$<$# ', ')#$>$#'), $content); $content = htmlentities($content); $this->replace_links($content); $content = str_replace(array('#$<$#', ')#$>$#'), array('<', '>'), $content); $content = '<pre>' . $content . '</pre>'; $return['body'] = $content; return $return; } $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']); } if (strtolower($structure->ctype_secondary) == 'calendar') { $content .= $this->builderMsgCalendar($structure->body); } break; case 'multipart': $this->builderMsgBody($structure, $content); break; case 'message': if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['nested_messages_are_shown'] != 1) { if (!is_array($structure->parts)) { $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; $content .= '<pre>' . htmlentities($this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'], false)) . '</pre>'; $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; } else { $this->builderMsgBody($structure, $content, true); } } break; case 'application': if (strtolower($structure->ctype_secondary) == 'x-pkcs7-mime') { // $return['body']='isCripted'; // return $return; //TODO: Descartar código após atualização do módulo de segurança da SERPRO $rawMessageData2 = $this->extractSignedContents($rawMessageData); if ($rawMessageData2 === false) { $return['body'] = 'isCripted'; return $return; } $decoder2 = new Mail_mimeDecode($rawMessageData2); $structure2 = $decoder2->decode($params); $this->builderMsgBody($structure2, $content); $attachmentManager->setStructure($structure2); /* * Monta informações dos anexos para o cabecarios */ $attachments = $attachmentManager->getAttachmentsInfo(); $return['attachments'] = $attachments; //----------------------------------------------// /* * Monta informações das imagens */ $images = $attachmentManager->getEmbeddedImagesInfo(); //----------------------------------------------// if (!$this->has_cid) { $return['thumbs'] = $this->get_thumbs($images, $msg_number, $msg_folder); $return['signature'] = $this->get_signature($msg, $msg_number, $msg_folder); } } /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// default: if (count($attachments) > 0) { $content .= ''; } break; } $params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen"); $this->set_messages_flag($params); $content = $this->process_embedded_images($images, $msg_number, $content, $msg_folder); $content = $this->replace_special_characters($content); $content = $this->replace_email_mailto($content); $this->replace_links($content); $return['body'] =& $content; return $return; }