'."\n"; $beforeAll['ul'] = '
', $text);
$text = preg_replace('##i', '
', $text);
$text = preg_replace('#{JoooidContent[^}]*youtube[^}]*id"[^"]*"([^}"]*)"[^}]*}#i', '
', $text);
$text = preg_replace('##Uis', '
', $text);
$text = preg_replace('#{youtube}[^{]+v=([^{&]+)(&[^{]*)?{/youtube}#Uis', '
', $text);
$text = preg_replace('#{vimeo}(https://vimeo.com/[^{]+){/vimeo}#Uis', '', $text);
$text = preg_replace('#{vimeo}([^{]+){/vimeo}#Uis', '', $text);
if (preg_match_all('##Uis', $text, $matches)) {
foreach ($matches[1] as $key => $match) {
$hash = acym_fileGetContent('http://vimeo.com/api/v2/video/'.$match.'.php');
$hash = @unserialize($hash);
if (empty($hash)) continue;
if (strpos($matches[0][$key], ' width="') !== false) {
$extension = substr($hash[0]['thumbnail_large'], strrpos($hash[0]['thumbnail_large'], '.'));
preg_match('#width="([^"]*)"#Uis', $matches[0][$key], $width);
$replace = strpos($hash[0]['thumbnail_large'], '_') === false ? '.' : '_';
$hash[0]['thumbnail_large'] = substr($hash[0]['thumbnail_large'], 0, strrpos($hash[0]['thumbnail_large'], $replace)).'_'.$width[1].$extension;
}
$thumbnail = 'https://i.vimeocdn.com/filter/overlay?src='.urlencode($hash[0]['thumbnail_large']).'&src='.urlencode('http://f.vimeocdn.com/p/images/crawler_play.png');
$text = str_replace($matches[0][$key], '
', $text);
$text = preg_replace('##i', '
', $text);
}
private function _convertbase64pictures(&$html)
{
if (!preg_match_all('#]*>)#i', $html, $results)) {
return;
}
static $replace = [];
foreach ($results[0] as $num => $oneResult) {
if (isset($replace[$oneResult])) {
continue;
}
if (strpos($oneResult, 'width=') || strpos($oneResult, 'height=')) {
continue;
}
if (preg_match('#[^a-z_\-]width *:([0-9 ]{1,8})#i', $oneResult, $res) || preg_match('#[^a-z_\-]height *:([0-9 ]{1,8})#i', $oneResult, $res)) {
continue;
}
if (!preg_match('#src="([^"]*)"#i', $oneResult, $url)) {
continue;
}
$imageUrl = $url[1];
$replace[$oneResult] = $oneResult;
$base = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', ACYM_LIVE);
$replacements = ['https://www.'.$base, 'http://www.'.$base, 'https://'.$base, 'http://'.$base];
$localpict = false;
foreach ($replacements as $oneReplacement) {
if (strpos($imageUrl, $oneReplacement) === false) {
continue;
}
$imageUrl = str_replace([$oneReplacement, '/'], [ACYM_ROOT, DS], urldecode($imageUrl));
$localpict = true;
break;
}
if (!$localpict) {
continue;
}
$dim = @getimagesize($imageUrl);
if (!$dim) {
continue;
}
if (empty($dim[0]) || empty($dim[1])) {
continue;
}
$replace[$oneResult] = str_replace('mailerHelper)) {
$this->mailerHelper = acym_get('helper.mailer');
}
$textreplace = [];
foreach ($tags as $i => $replacement) {
if (isset($textreplace[$i])) {
continue;
}
$textreplace[$i] = $this->mailerHelper->textVersion($replacement, true);
}
} else {
$textreplace = $tags;
}
foreach ($variables as $var) {
if (empty($email->$var)) {
continue;
}
$email->$var = $this->replaceDText($email->$var, in_array($var, $htmlVars) ? $tags : $textreplace);
}
}
public function replaceDText($text, $replacement)
{
if (is_array($text)) {
foreach ($text as $i => &$oneCell) {
if (empty($oneCell)) {
continue;
}
$oneCell = $this->replaceDText($oneCell, $replacement);
}
} elseif (is_string($text) && !empty($text)) {
foreach ($replacement as $code => $value) {
$text = preg_replace('#]+'.preg_quote($code, '#').'.+[^<]*#Uis', $value, $text);
$text = str_replace($code, $value, $text);
}
}
return $text;
}
public function extractTags($email, $tagfamily)
{
$results = [];
$match = '#(?:{|%7B)'.$tagfamily.'(?:%3A|\\:)(.*)(?:}|%7D)#Ui';
$variables = ['subject', 'body', 'From', 'FromName', 'ReplyTo', 'ReplyName', 'bcc', 'cc', 'fromname', 'fromemail', 'replyname', 'replyemail', 'params'];
$found = false;
foreach ($variables as $var) {
if (empty($email->$var)) {
continue;
}
if (is_array($email->$var)) {
foreach ($email->$var as $i => $arrayField) {
if (empty($arrayField)) {
continue;
}
if (is_array($arrayField)) {
foreach ($arrayField as $a => $oneval) {
$found = preg_match_all($match, $oneval, $results[$var.$i.'-'.$a]) || $found;
if (empty($results[$var.$i.'-'.$a][0])) {
unset($results[$var.$i.'-'.$a]);
}
}
} else {
$found = preg_match_all($match, $arrayField, $results[$var.$i]) || $found;
if (empty($results[$var.$i][0])) {
unset($results[$var.$i]);
}
}
}
} else {
$found = preg_match_all($match, $email->$var, $results[$var]) || $found;
if (empty($results[$var][0])) {
unset($results[$var]);
}
}
}
if (!$found) {
return [];
}
$tags = [];
foreach ($results as $var => $allresults) {
foreach ($allresults[0] as $i => $oneTag) {
if (isset($tags[$oneTag])) {
continue;
}
$tags[$oneTag] = $this->extractTag($allresults[1][$i]);
}
}
return $tags;
}
public function extractTag($oneTag)
{
$arguments = explode('|', strip_tags(urldecode($oneTag)));
$tag = new stdClass();
$tag->id = $arguments[0];
$tag->default = '';
for ($i = 1, $a = count($arguments) ; $i < $a ; $i++) {
$args = explode(':', $arguments[$i]);
$arg0 = trim($args[0]);
if (empty($arg0)) {
continue;
}
if (isset($args[1])) {
$tag->$arg0 = $args[1];
if (isset($args[2])) {
$tag->{$args[0]} .= ':'.$args[2];
}
} else {
$tag->$arg0 = true;
}
}
return $tag;
}
public function wrapText($text, $tag)
{
$this->wraped = false;
if (!empty($tag->wrap)) {
$tag->wrap = intval($tag->wrap);
}
if (empty($tag->wrap)) {
return $text;
}
$allowedTags = [];
$allowedTags[] = 'b';
$allowedTags[] = 'strong';
$allowedTags[] = 'i';
$allowedTags[] = 'em';
$allowedTags[] = 'a';
$aloneAllowedTags = [];
$aloneAllowedTags[] = 'br';
$aloneAllowedTags[] = 'img';
$newText = preg_replace('/
]*>/i', '
', $text);
$newText = preg_replace('/
| '; if ($format->tag->format == 'COL_LEFT') { $result .= $image.' | ';
}
}
}
if (!empty($format->title)) {
if (!empty($format->link)) {
$format->title = 'tag->type) && $format->tag->type == 'title' ? ' class="acym_title"' : '').' href="'.$format->link.'" target="_blank" name="'.$this->name.'-'.$format->tag->id.'">'.$format->title.'';
}
if (empty($format->tag->type) || $format->tag->type != 'title') {
$format->title = ''.$format->title.''; } $result .= $format->title; } if (!empty($format->afterTitle)) $result .= $format->afterTitle; if (!empty($format->description)) { $format->description = $this->wrapText($format->description, $format->tag); } $rowText = '';
$endRow = ' '; if (in_array($format->tag->format, ['TOP_LEFT', 'TOP_RIGHT', 'TITLE_IMG', 'TITLE_IMG_RIGHT', 'TOP_IMG'])) { if (!empty($image) || !empty($format->description)) { $result .= $rowText.$image.$format->description.$endRow; } } elseif ($format->tag->format == 'CENTER_IMG') { if (!empty($image)) { $result .= ' '.$image.$endRow;
}
if (!empty($format->description)) {
$result .= $rowText.$format->description.$endRow;
}
} elseif (in_array($format->tag->format, ['COL_LEFT', 'COL_RIGHT'])) {
if (!empty($format->description)) {
$result .= $rowText.$format->description.$endRow;
}
if ($format->tag->format == 'COL_RIGHT') {
$result .= ' | '.$image; } $result .= ' |
| '; } else { $result .= 'label">'.$oneField[1].' | '; } $result .= $oneField[0].' | '; $i++; } while ($i % $format->cols != 0) { $result .= ''; $i++; } $result .= ' | ||