当前位置: 首页>>代码示例>>PHP>>正文


PHP CerberusApplication::stripHTML方法代码示例

本文整理汇总了PHP中CerberusApplication::stripHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP CerberusApplication::stripHTML方法的具体用法?PHP CerberusApplication::stripHTML怎么用?PHP CerberusApplication::stripHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CerberusApplication的用法示例。


在下文中一共展示了CerberusApplication::stripHTML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _handleImportTicket


//.........这里部分代码省略.........
             // Insert requesters
             if (null == ($requesterAddyInst = CerberusApplication::hashLookupAddress($sRequesterAddy, true))) {
                 $logger->warn('[Importer] Ticket ' . $sMask . ' - Ignoring malformed requester: ' . $sRequesterAddy);
                 continue;
             }
             DAO_Ticket::createRequester($requesterAddyInst->id, $ticket_id);
         }
     }
     // Create messages
     $is_first = true;
     if (!is_null($xml->messages)) {
         foreach ($xml->messages->message as $eMessage) {
             /* @var $eMessage SimpleXMLElement */
             $eHeaders =& $eMessage->headers;
             /* @var $eHeaders SimpleXMLElement */
             $sMsgFrom = (string) $eHeaders->from;
             $sMsgDate = (string) $eHeaders->date;
             $sMsgFrom = self::_parseRfcAddressList($sMsgFrom, true);
             if (NULL == $sMsgFrom) {
                 $logger->warn('[Importer] Ticket ' . $sMask . ' - Invalid message sender: ' . $sMsgFrom . ' (skipping)');
                 continue;
             }
             if (null == ($msgFromInst = CerberusApplication::hashLookupAddress($sMsgFrom, true))) {
                 $logger->warn('[Importer] Ticket ' . $sMask . ' - Invalid message sender: ' . $sMsgFrom . ' (skipping)');
                 continue;
             }
             @($msgWorkerId = intval($email_to_worker_id[strtolower($msgFromInst->email)]));
             //			$logger->info('Checking if '.$msgFromInst->email.' is a worker');
             $fields = array(DAO_Message::TICKET_ID => $ticket_id, DAO_Message::CREATED_DATE => strtotime($sMsgDate), DAO_Message::ADDRESS_ID => $msgFromInst->id, DAO_Message::IS_OUTGOING => !empty($msgWorkerId) ? 1 : 0, DAO_Message::WORKER_ID => !empty($msgWorkerId) ? $msgWorkerId : 0);
             $email_id = DAO_Message::create($fields);
             // First thread
             if ($is_first) {
                 DAO_Ticket::updateTicket($ticket_id, array(DAO_Ticket::FIRST_MESSAGE_ID => $email_id));
                 $is_first = false;
             }
             // Create attachments
             if (!is_null($eMessage->attachments)) {
                 foreach ($eMessage->attachments->attachment as $eAttachment) {
                     /* @var $eAttachment SimpleXMLElement */
                     $sFileName = (string) $eAttachment->name;
                     $sMimeType = (string) $eAttachment->mimetype;
                     $sFileSize = (int) $eAttachment->size;
                     $sFileContentB64 = (string) $eAttachment->content;
                     // [TODO] This could be a little smarter about detecting extensions
                     if (empty($sMimeType)) {
                         $sMimeType = "application/octet-stream";
                     }
                     $sFileContent = base64_decode($sFileContentB64);
                     unset($sFileContentB64);
                     $fields = array(DAO_Attachment::MESSAGE_ID => $email_id, DAO_Attachment::DISPLAY_NAME => $sFileName, DAO_Attachment::FILE_SIZE => intval($sFileSize), DAO_Attachment::FILEPATH => '', DAO_Attachment::MIME_TYPE => $sMimeType);
                     $file_id = DAO_Attachment::create($fields);
                     // Write file to disk using ID (Model)
                     $file_path = Model_Attachment::saveToFile($file_id, $sFileContent);
                     unset($sFileContent);
                     // Update attachment table
                     DAO_Attachment::update($file_id, array(DAO_Attachment::FILEPATH => $file_path));
                 }
             }
             // Create message content
             $sMessageContentB64 = (string) $eMessage->content;
             $sMessageContent = base64_decode($sMessageContentB64);
             // Content-type specific handling
             if (isset($eMessage->content['content-type'])) {
                 // do we have a content-type?
                 if (strtolower($eMessage->content['content-type']) == 'html') {
                     // html?
                     // Force to plaintext part
                     $sMessageContent = CerberusApplication::stripHTML($sMessageContent);
                 }
             }
             unset($sMessageContentB64);
             DAO_MessageContent::create($email_id, $sMessageContent);
             unset($sMessageContent);
             // Headers
             foreach ($eHeaders->children() as $eHeader) {
                 /* @var $eHeader SimpleXMLElement */
                 DAO_MessageHeader::create($email_id, $eHeader->getName(), (string) $eHeader);
             }
         }
     }
     // Create comments
     if (!is_null($xml->comments)) {
         foreach ($xml->comments->comment as $eComment) {
             /* @var $eMessage SimpleXMLElement */
             $iCommentDate = (int) $eComment->created_date;
             $sCommentAuthor = (string) $eComment->author;
             // [TODO] Address Hash Lookup
             $sCommentTextB64 = (string) $eComment->content;
             $sCommentText = base64_decode($sCommentTextB64);
             unset($sCommentTextB64);
             $commentAuthorInst = CerberusApplication::hashLookupAddress($sCommentAuthor, true);
             // [TODO] Sanity checking
             $fields = array(DAO_TicketComment::TICKET_ID => intval($ticket_id), DAO_TicketComment::CREATED => intval($iCommentDate), DAO_TicketComment::ADDRESS_ID => intval($commentAuthorInst->id), DAO_TicketComment::COMMENT => $sCommentText);
             $comment_id = DAO_TicketComment::create($fields);
             unset($sCommentText);
         }
     }
     $logger->info('[Importer] Imported ticket #' . $ticket_id);
     return true;
 }
开发者ID:rmiddle,项目名称:cerb4,代码行数:101,代码来源:cron.classes.php

示例2: parseMime


//.........这里部分代码省略.........
                 $message->headers[$header_name] = self::fixQuotePrintableString($header_val);
             }
         }
     }
     $settings = DevblocksPlatform::getPluginSettingsService();
     $is_attachments_enabled = $settings->get('cerberusweb.core', CerberusSettings::ATTACHMENTS_ENABLED, 1);
     $attachments_max_size = $settings->get('cerberusweb.core', CerberusSettings::ATTACHMENTS_MAX_SIZE, 10);
     foreach ($struct as $st) {
         //		    echo "PART $st...<br>\r\n";
         $section = mailparse_msg_get_part($mime, $st);
         $info = mailparse_msg_get_part_data($section);
         // handle parts that shouldn't have a content-name, don't handle twice
         $handled = 0;
         if (empty($info['content-name'])) {
             if ($info['content-type'] == 'text/plain') {
                 $text = mailparse_msg_extract_part_file($section, $full_filename, NULL);
                 if (isset($info['content-charset']) && !empty($info['content-charset'])) {
                     $message->body_encoding = $info['content-charset'];
                     if (@mb_check_encoding($text, $info['content-charset'])) {
                         $text = mb_convert_encoding($text, LANG_CHARSET_CODE, $info['content-charset']);
                     } else {
                         $text = mb_convert_encoding($text, LANG_CHARSET_CODE);
                     }
                 }
                 @($message->body .= $text);
                 unset($text);
                 $handled = 1;
             } elseif ($info['content-type'] == 'text/html') {
                 @($text = mailparse_msg_extract_part_file($section, $full_filename, NULL));
                 if (isset($info['content-charset']) && !empty($info['content-charset'])) {
                     if (@mb_check_encoding($text, $info['content-charset'])) {
                         $text = mb_convert_encoding($text, LANG_CHARSET_CODE, $info['content-charset']);
                     } else {
                         $text = mb_convert_encoding($text, LANG_CHARSET_CODE);
                     }
                 }
                 $message->htmlbody .= $text;
                 unset($text);
                 // Add the html part as an attachment
                 // [TODO] Make attaching the HTML part an optional config option (off by default)
                 $tmpname = ParserFile::makeTempFilename();
                 $html_attach = new ParserFile();
                 $html_attach->setTempFile($tmpname, 'text/html');
                 @file_put_contents($tmpname, $message->htmlbody);
                 $html_attach->file_size = filesize($tmpname);
                 $message->files["original_message.html"] = $html_attach;
                 unset($html_attach);
                 $handled = 1;
             } elseif ($info['content-type'] == 'message/rfc822') {
                 @($message_content = mailparse_msg_extract_part_file($section, $full_filename, NULL));
                 $message_counter = empty($message_counter) ? 1 : $message_counter + 1;
                 $tmpname = ParserFile::makeTempFilename();
                 $html_attach = new ParserFile();
                 $html_attach->setTempFile($tmpname, 'message/rfc822');
                 @file_put_contents($tmpname, $message_content);
                 $html_attach->file_size = filesize($tmpname);
                 $message->files['inline' . $message_counter . '.msg'] = $html_attach;
                 unset($html_attach);
                 $handled = 1;
             }
         }
         // whether or not it has a content-name, we need to add it as an attachment (if not already handled)
         if ($handled == 0) {
             if (false === strpos(strtolower($info['content-type']), 'multipart')) {
                 if (!$is_attachments_enabled) {
                     break;
                     // skip attachment
                 }
                 $attach = new ParseCronFileBuffer($section, $info, $full_filename);
                 // [TODO] This could be more efficient by not even saving in the first place above:
                 // Make sure our attachment is under the max preferred size
                 if (filesize($attach->tmpname) > $attachments_max_size * 1024000) {
                     @unlink($attach->tmpname);
                     break;
                 }
                 // if un-named, call it "unnamed message part"
                 if (!isset($info['content-name']) || isset($info['content-name']) && empty($info['content-name'])) {
                     // or blank
                     $info['content-name'] = 'unnamed_message_part';
                 }
                 // filenames can be quoted-printable strings, too...
                 $info['content-name'] = self::fixQuotePrintableString($info['content-name']);
                 // content-name is not necessarily unique...
                 if (isset($message->files[$info['content-name']])) {
                     $j = 1;
                     while (isset($message->files[$info['content-name'] . '(' . $j . ')'])) {
                         $j++;
                     }
                     $info['content-name'] = $info['content-name'] . '(' . $j . ')';
                 }
                 $message->files[$info['content-name']] = $attach;
             }
         }
     }
     // generate the plaintext part (if necessary)
     if (empty($message->body) && !empty($message->htmlbody)) {
         $message->body = CerberusApplication::stripHTML($message->htmlbody);
     }
     return $message;
 }
开发者ID:Hildy,项目名称:cerb5,代码行数:101,代码来源:Parser.php


注:本文中的CerberusApplication::stripHTML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。