Exemple #1
0
 /**
  * Extract parts of a message
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 private function extractPart($part, $data)
 {
     switch ($part->encoding) {
         case '3':
             // base 64
             $data = base64_decode($data);
             break;
         case '4':
             // quoted-printable
             $data = quoted_printable_decode($data);
             break;
         case '5':
             // other
         // other
         case '0':
             // 7bit
         // 7bit
         case '1':
             // 8 bit
         // 8 bit
         case '2':
             // binary
         // binary
         default:
             break;
     }
     // Get the params
     $params = EasyBlogMailboxMessage::getformatedParams($part);
     $encoding = 'UTF-8';
     if (isset($params['charset'])) {
         $encoding = $params['charset'];
     }
     $type = $part->type;
     $subtype = strtolower($part->subtype);
     // Get the part id
     $id = isset($part->id) ? $part->id : '';
     // Plain text messages
     if ($type == 0 && $subtype == 'plain') {
         $this->plain_data .= EasyblogMailboxMessage::stringToUTF8($encoding, trim($data));
     }
     // Html messages
     if ($type == 0 && $subtype == 'html') {
         $this->html_data .= EasyblogMailboxMessage::stringToUTF8($encoding, trim($data));
     }
     // What type is this?
     if ($type == 2) {
         $this->plain_data .= EasyblogMailboxMessage::stringToUTF8($encoding, trim($data));
     }
     // PDF files
     if ($type == 3 && $subtype == 'pdf') {
         $file = array();
         $file['mime'] = $subtype;
         $file['data'] = $data;
         $file['name'] = isset($params['name']) ? $params['name'] : $params['filename'];
         $file['id'] = $id;
         $file['size'] = $part->bytes;
         $this->attachment[] = $file;
     }
     // Image parts
     if ($type == 5) {
         $image = array();
         $image['mime'] = $subtype;
         // GIF
         $image['data'] = $data;
         // binary
         $image['name'] = isset($params['name']) ? $params['name'] : $params['filename'];
         // 35D.gif
         $image['id'] = $id;
         // <*****@*****.**>
         $image['size'] = $part->bytes;
         $this->attachment[] = $image;
     }
     return;
 }
Exemple #2
0
 /**
  * Formats the content from the email to a normal blog content
  *
  * @since   4.0
  * @access  public
  * @param   string
  * @return
  */
 public function getMessageContents(EasyBlogMailboxMessage $message, $format = 'html')
 {
     $result = new stdClass();
     $result->html = $message->getHTML();
     $result->plain = nl2br($message->getPlain());
     // If plain text is empty, just fall back to html
     if (empty($result->plain)) {
         $result->body = nl2br(strip_tags($result->html));
     }
     $result->body = $format == 'html' ? $result->html : $result->plain;
     // If we can't get any result, just use the plain text
     $result->body = $result->body ? $result->body : $result->plain;
     // Filter the contents to avoid any unecessary data
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     // JFilterInput doesn't strip css tags
     $result->body = preg_replace("'<style[^>]*>.*?</style>'si", '', $result->body);
     // Clean up the input
     $result->body = $filter->clean($result->body, 'html');
     $result->body = JString::trim($result->body);
     // Tidup content so that does not contain unclosed html codes
     $result->body = EB::string()->tidyHTMLContent($result->body);
     return $result;
 }