コード例 #1
0
$mail_id = CValue::get("mail_id");
$part = CValue::get("part");
$log_pop = new CSourcePOP();
$log_pop->name = "user-pop-" . $user->_id;
$log_pop->loadMatchingObject();
if (!$log_pop) {
    CAppUI::stepAjax("Source POP indisponible", UI_MSG_ERROR);
}
if (!$mail_id) {
    CAppUI::stepAjax("CSourcePOP-error-mail_id", UI_MSG_ERROR);
}
$mail = new CUserMail();
$mail->load($mail_id);
if ($mail->_id) {
    $pop = new CPop($log_pop);
    $pop->open();
    $attach = new CMailAttachments();
    $struct = $pop->structure($mail->uid);
    $parts = explode(".", $part);
    //recursive parts
    foreach ($parts as $key => $value) {
        $struct = $struct->parts[$value];
    }
    $attach->loadFromHeader($struct);
    $attach->part = $part;
    $attach->loadContentFromPop($pop->openPart($mail->uid, $attach->getpartDL()));
    $smarty = new CSmartyDP();
    $smarty->assign("_attachment", $attach);
    $smarty->display("inc_show_attachments.tpl");
    $pop->close();
}
コード例 #2
0
ファイル: CPop.class.php プロジェクト: fbone/mediboard4
 /**
  * Get the body of the mail : HTML & plain text if available!
  *
  * @param int  $mail_id     test
  * @param bool $structure   test
  * @param bool $part_number test
  * @param bool $only_text   test
  *
  * @return array
  */
 function getFullBody($mail_id, $structure = false, $part_number = false, $only_text = false)
 {
     if (!$structure) {
         $structure = $this->structure($mail_id);
     }
     if ($structure) {
         if (!isset($structure->parts) && !$part_number) {
             //plain text only, no recursive
             $part_number = "1";
         }
         if (!$part_number) {
             $part_number = "0";
         }
         switch ($structure->type) {
             case 0:
                 //text or html
                 if ($structure->subtype == "PLAIN") {
                     $this->content["text"]["plain"] = self::decodeMail($structure->encoding, self::openPart($mail_id, $part_number), $structure);
                     if (stripos($this->content["text"]["plain"], '$APICRYPT') !== false) {
                         $this->content["text"]["is_apicrypt"] = "plain";
                     }
                 }
                 if ($structure->subtype == "HTML") {
                     $this->content["text"]["html"] = self::decodeMail($structure->encoding, self::openPart($mail_id, $part_number), $structure);
                     if (stripos($this->content["text"]["html"], '$APICRYPT') !== false) {
                         $this->content["text"]["is_apicrypt"] = "html";
                     }
                 }
                 break;
             case 1:
                 //multipart, alternatived
                 while (list($index, $sub_structure) = each($structure->parts)) {
                     if ($part_number) {
                         $prefix = $part_number . '.';
                     } else {
                         $prefix = null;
                     }
                     self::getFullBody($mail_id, $sub_structure, $prefix . ($index + 1));
                 }
                 break;
             case 2:
                 //message
             //message
             case 3:
                 //application
             //application
             case 4:
                 //audio
             //audio
             case 5:
                 //images
             //images
             case 6:
                 //video
             //video
             default:
                 //other
                 if ($only_text) {
                     $attach = new CMailAttachments();
                     $attach->loadFromHeader($structure);
                     if ($attach->name) {
                         $attach->loadContentFromPop($this->openPart($mail_id, $part_number));
                         //inline attachments
                         if ($attach->id && $attach->subtype != "SVG+XML") {
                             $id = 'cid:' . str_replace(array("<", ">"), array("", ""), $attach->id);
                             $url = "data:image/{$attach->subtype}|strtolower;base64," . $attach->_content;
                             $this->content["text"]["html"] = str_replace($id, $url, $this->content["text"]["html"]);
                         } else {
                             //attachments below
                             $this->content["attachments"][] = $attach;
                         }
                     }
                 }
         }
     }
     return $this->content;
 }