public function array_transform($array) { $array_text = ''; if (isset($array['item'])) { foreach ($array['item'] as $values) { $array_text .= "<item>\n"; foreach ($values as $key => $value) { if ($key == 'description') { $array_text .= "<{$key}><![CDATA[{$value}]]></{$key}>\n"; } elseif ($key == 'enclosure') { if ($value) { // $image_info = @getimagesize($value); // if($image_info && isset($image_info['mime'])) { // $array_text .= "<$key url=\"".$value."\" type=\"".$image_info['mime']."\" />\n"; // } else { $ext = explode('?', pathinfo($value, PATHINFO_EXTENSION)); $array_text .= "<{$key} url=\"" . $value . "\" type=\"" . JO_File_Ext::getMimeFromExt($ext[0]) . "\" />\n"; // } } } else { $array_text .= "<{$key}>{$value}</{$key}>\n"; } } $array_text .= "</item>\n"; } } return $array_text; }
/** * Evaluates the message and returns modifications for inline images and backgrounds * @access public * @return $message */ public function MsgHTML($message, $basedir = '') { if ($this->attachmendImagesBody && preg_match_all("/(((src|background)=[\"'](.*)[\"'])|((background-image:| )\\s?url\\([\"'](.*)[\"']\\)))/Ui", $message, $match)) { $images = array(); foreach ($match[4] as $r => $img) { $filename = array_shift(explode('?', basename($img ? $img : $match[7][$r]))); $md5 = md5($filename); $cid = 'cid:' . $md5; if (!$img) { $images[] = array('url' => $match[7][$r], 'search' => '/' . preg_quote($match[0][$r], '/') . '/Ui', 'replace' => $match[6][$r] . "url(\"" . $cid . "\")", 'cid' => $cid, 'filename' => $filename, 'md5' => $md5); } else { $images[] = array('url' => $img, 'search' => '/' . preg_quote($match[0][$r], '/') . '/Ui', 'replace' => $match[3][$r] . "=\"" . $cid . "\"", 'cid' => $cid, 'filename' => $filename, 'md5' => $md5); } } if ($images) { foreach ($images as $i => $image) { $ext = pathinfo($image['url'], PATHINFO_EXTENSION); $mimeType = JO_File_Ext::getMimeFromExt($ext); if ($this->AddEmbeddedImage($image['url'], $image['cid'], $image['filename'], 'base64', $mimeType)) { $message = preg_replace($image['search'], $image['replace'], $message); } } } } $this->IsHTML(true); $this->Body = $message; if (empty($this->AltBody)) { $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\\/\\1>/s', '', $message))); if (!empty($textMsg)) { $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet); } } if (empty($this->AltBody)) { $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; } return $message; }