function acymailing_replaceusertags(&$email, &$user) { if (!empty($email->altbody)) { $email->altbody = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->altbody); } if (!$email->sendHTML or empty($email->type) or !in_array($email->type, array('news', 'autonews', 'followup')) or strpos($email->body, '{nostatpicture}')) { $email->body = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->body); return; } if (empty($user->subid)) { return $this->acymailing_replaceusertagspreview($email, $user); } $widthsize = $this->params->get('width', 50); $heightsize = $this->params->get('height', 1); $width = empty($widthsize) ? '' : ' width="' . $widthsize . '" '; $height = empty($heightsize) ? '' : ' height="' . $heightsize . '" '; $statPicture = '<img alt="' . $this->params->get('alttext', '') . '" src="' . acymailing::frontendLink('index.php?option=com_acymailing&ctrl=stats&mailid=' . $email->mailid . '&subid=' . $user->subid) . '" border="0" ' . $height . $width . '/>'; if (strpos($email->body, '{statpicture}')) { $email->body = str_replace('{statpicture}', $statPicture, $email->body); } elseif (strpos($email->body, '</body>')) { $email->body = str_replace('</body>', $statPicture . '</body>', $email->body); } else { $email->body .= $statPicture; } }
function acymailing_replacetags(&$email) { $match = '#{share:(.*)}#Ui'; $variables = array('body', 'altbody'); $found = false; $results = array(); foreach ($variables as $var) { if (empty($email->{$var})) { continue; } $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found; if (empty($results[$var][0])) { unset($results[$var]); } } if (!$found) { return; } $archiveLink = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid=' . $email->mailid, $this->params->get('template') == 'component' ? true : false); $tags = array(); foreach ($results as $var => $allresults) { foreach ($allresults[0] as $i => $tagname) { if (isset($tags[$tagname])) { continue; } $arguments = explode('|', $allresults[1][$i]); $tag = null; $tag->network = $arguments[0]; for ($i = 1, $a = count($arguments); $i < $a; $i++) { $args = explode(':', $arguments[$i]); if (isset($args[1])) { $tag->{$args}[0] = $args[1]; } else { $tag->{$args}[0] = true; } } if ($tag->network == 'facebook') { $tags[$tagname] = '<a target="_blank" href="http://www.facebook.com/sharer.php?u=' . urlencode($archiveLink) . '&t=' . urlencode($email->subject) . '" title="' . JText::sprintf('SOCIAL_SHARE', 'Facebook') . '"><img src="' . ACYMAILING_LIVE . $this->params->get('picturefb', 'media/com_acymailing/images/fbshare.gif') . '" /></a>'; } elseif ($tag->network == 'twitter') { $text = JText::sprintf('SHARE_TEXT', $archiveLink); $tags[$tagname] = '<a target="_blank" href="http://twitter.com/home?status=' . urlencode($text) . '" title="' . JText::sprintf('SOCIAL_SHARE', 'Twitter') . '"><img src="' . ACYMAILING_LIVE . $this->params->get('picturetwitter', 'media/com_acymailing/images/twittershare.png') . '" /></a>'; } elseif ($tag->network == 'linkedin') { $tags[$tagname] = '<a target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url=' . urlencode($archiveLink) . '&title=' . urlencode($email->subject) . '" title="' . JText::sprintf('SOCIAL_SHARE', 'LinkedIn') . '"><img src="' . ACYMAILING_LIVE . $this->params->get('picturelinkedin', 'media/com_acymailing/images/linkedin.png') . '" /></a>'; } } } $email->body = str_replace(array_keys($tags), $tags, $email->body); $email->altbody = str_replace(array_keys($tags), '', $email->altbody); }
function getUrl($url, $mailid, $subid) { static $allurls; $url = str_replace('&', '&', $url); if (empty($allurls[$url])) { $currentURL = $this->get($url); if (empty($currentURL->urlid)) { $currentURL = null; $currentURL->url = $url; $currentURL->name = $url; $currentURL->urlid = $this->save($currentURL); } $allurls[$url] = $currentURL; } else { $currentURL = $allurls[$url]; } $config = acymailing::config(); $itemId = $config->get('itemid', 0); $item = empty($itemId) ? '' : '&Itemid=' . $itemId; return str_replace('&', '&', acymailing::frontendLink('index.php?option=com_acymailing&ctrl=url&urlid=' . $currentURL->urlid . '&mailid=' . $mailid . '&subid=' . $subid . $item)); }
function acymailing_replaceusertags(&$email, &$user) { $match = '#{(readonline|forward)}(.*){/(readonline|forward)}#Uis'; $variables = array('body', 'altbody'); $found = false; foreach ($variables as $var) { if (empty($email->{$var})) { continue; } $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found; if (empty($results[$var][0])) { unset($results[$var]); } } if (!$found) { return; } $config = acymailing::config(); $itemId = $config->get('itemid', 0); $item = empty($itemId) ? '' : '&Itemid=' . $itemId; $tags = array(); $tmplview = ''; $tmplforward = ''; if (!empty($email->key) and $this->params->get('addkey', 'yes') == 'yes') { $tmplview .= '&key=' . $email->key; $tmplforward .= '&key=' . $email->key; } if (!empty($user->key) and $this->params->get('adduserkey', 'yes') == 'yes') { $tmplview .= '&subid=' . $user->subid . '-' . $user->key; $tmplforward .= '&subid=' . $user->subid . '-' . $user->key; } if ($this->params->get('viewtemplate', 'standard') == 'notemplate') { $tmplview .= '&tmpl=component'; } if ($this->params->get('forwardtemplate', 'standard') == 'notemplate') { $tmplforward .= '&tmpl=component'; } foreach ($results as $var => $allresults) { foreach ($allresults[0] as $i => $oneTag) { if (isset($tags[$oneTag])) { continue; } if ($allresults[1][$i] == 'readonline') { $link = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=archive&task=view&mailid=' . $email->mailid . $tmplview . $item); } elseif ($allresults[1][$i] == 'forward') { $link = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=archive&task=forward&mailid=' . $email->mailid . $tmplforward . $item); } if (empty($allresults[2][$i])) { $tags[$oneTag] = $link; } else { $tags[$oneTag] = '<a style="text-decoration:none;" href="' . $link . '"><span class="acymailing_online">' . $allresults[2][$i] . '</span></a>'; } } } $email->body = str_replace(array_keys($tags), $tags, $email->body); if (!empty($email->altbody)) { $email->altbody = str_replace(array_keys($tags), $tags, $email->altbody); } }
function _replaceContent(&$results, $i) { $arguments = explode('|', strip_tags($results[1][$i])); $tag = null; $tag->id = (int) $arguments[0]; for ($i = 1, $a = count($arguments); $i < $a; $i++) { $args = explode(':', $arguments[$i]); if (isset($args[1])) { $tag->{$args}[0] = $args[1]; } else { $tag->{$args}[0] = true; } } if (version_compare(JVERSION, '1.6.0', '<')) { $query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle, s.alias as secalias, s.title as sectitle FROM ' . acymailing::table('content', false) . ' as a '; $query .= 'LEFT JOIN ' . acymailing::table('users', false) . ' as b ON a.created_by = b.id '; $query .= ' LEFT JOIN ' . acymailing::table('categories', false) . ' AS c ON c.id = a.catid '; $query .= ' LEFT JOIN ' . acymailing::table('sections', false) . ' AS s ON s.id = a.sectionid '; $query .= 'WHERE a.id = ' . $tag->id . ' LIMIT 1'; } else { $query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle FROM ' . acymailing::table('content', false) . ' as a '; $query .= 'LEFT JOIN ' . acymailing::table('users', false) . ' as b ON a.created_by = b.id '; $query .= ' LEFT JOIN ' . acymailing::table('categories', false) . ' AS c ON c.id = a.catid '; $query .= 'WHERE a.id = ' . $tag->id . ' LIMIT 1'; } $db =& JFactory::getDBO(); $db->setQuery($query); $article = $db->loadObject(); $result = ''; if (empty($article)) { $app =& JFactory::getApplication(); if ($app->isAdmin()) { $app->enqueueMessage('The article "' . $tag->id . '" could not be loaded', 'notice'); } return $result; } if (!empty($tag->lang)) { $langid = (int) substr($tag->lang, strpos($tag->lang, ',') + 1); if (!empty($langid)) { $query = "SELECT reference_field, value FROM `#__jf_content` WHERE `published` = 1 AND `reference_table` = 'content' AND `language_id` = {$langid} AND `reference_id` = " . $tag->id; $db->setQuery($query); $translations = $db->loadObjectList(); if (!empty($translations)) { foreach ($translations as $oneTranslation) { if (!empty($oneTranslation->value)) { $translatedfield = $oneTranslation->reference_field; $article->{$translatedfield} = $oneTranslation->value; } } } } } if ($this->params->get('integration') == 'jreviews' and !empty($article->images)) { $firstpict = explode('|', trim(reset(explode("\n", $article->images))) . '|||||||'); if (!empty($firstpict[0])) { $myPict = '<img src="' . ACYMAILING_LIVE . 'images/stories/' . $firstpict[0] . '" hspace="5" style="margin:5px" align="left" border="' . intval($firstpict[5]) . '" />'; $article->introtext = $myPict . $article->introtext; } } $completeId = $article->id; $completeCat = $article->catid; if (!empty($article->alias)) { $completeId .= ':' . $article->alias; } if (!empty($article->catalias)) { $completeCat .= ':' . $article->catalias; } if (version_compare(JVERSION, '1.6.0', '<')) { $completeSec = $article->sectionid; if (!empty($article->secalias)) { $completeSec .= ':' . $article->secalias; } $link = ContentHelperRoute::getArticleRoute($completeId, $completeCat, $completeSec); } else { $link = ContentHelperRoute::getArticleRoute($completeId, $completeCat); } if ($this->params->get('integration') == 'flexicontent') { $link = 'index.php?option=com_flexicontent&view=items&id=' . $completeId; } if (!empty($tag->lang)) { $link .= (strpos($link, '?') ? '&' : '?') . 'lang=' . substr($tag->lang, 0, strpos($tag->lang, ',')); } $link = acymailing::frontendLink($link); $styleTitle = ''; $styleTitleEnd = ''; if ($tag->type != "title") { $styleTitle = '<h2 class="acymailing_title">'; $styleTitleEnd = '</h2>'; } if (empty($tag->notitle)) { if (!empty($tag->link)) { $result .= '<a href="' . $link . '" '; if ($tag->type != "title") { $result .= 'style="text-decoration:none" name="content-' . $article->id . '" '; } $result .= 'target="_blank" >' . $styleTitle . $article->title . $styleTitleEnd . '</a>'; } else { $result .= $styleTitle . $article->title . $styleTitleEnd; } } if (!empty($tag->author)) { $authorName = empty($article->created_by_alias) ? $article->authorname : $article->created_by_alias; if ($tag->type == 'title') { $result .= '<br/>'; } $result .= $authorName . '<br/>'; } if (!empty($tag->created)) { $result .= '<span class="createddate">' . JHTML::_('date', $article->created, JText::_('DATE_FORMAT_LC2')) . '</span>'; } if (!isset($tag->pict) and $tag->type != 'title') { if ($this->params->get('removepictures', 'never') == 'always' || ($this->params->get('removepictures', 'never') == 'intro' and $tag->type == "intro")) { $tag->pict = 0; } else { $tag->pict = 1; } } if ($tag->type != "title") { $contentText = ''; if ($tag->type == "intro") { $forceReadMore = false; $wordwrap = $this->params->get('wordwrap', 0); if (!empty($wordwrap) and empty($article->fulltext)) { $newintrotext = strip_tags($article->introtext, '<br><img>'); $numChar = strlen($newintrotext); if ($numChar > $wordwrap) { $stop = strlen($newintrotext); for ($i = $wordwrap; $i < $numChar; $i++) { if ($newintrotext[$i] == " ") { $stop = $i; $forceReadMore = true; break; } } $article->introtext = substr($newintrotext, 0, $stop) . '...'; } } } if (empty($article->fulltext) or $tag->type != "text") { $contentText .= $article->introtext; } if ($tag->type != "intro" and !empty($article->fulltext)) { if ($tag->type != "text" && !empty($article->introtext)) { $contentText .= '<br />'; } $contentText .= $article->fulltext; } if (strpos($contentText, 'jseblod') !== false and file_exists(ACYMAILING_ROOT . 'plugins' . DS . 'content' . DS . 'cckjseblod.php')) { global $mainframe; include_once ACYMAILING_ROOT . 'plugins' . DS . 'content' . DS . 'cckjseblod.php'; if (function_exists('plgContentCCKjSeblod')) { $paramsContent =& JComponentHelper::getParams('com_content'); $article->text = $contentText; plgContentCCKjSeblod($article, $paramsContent); $contentText = $article->text; } } if (!empty($tag->wrap)) { $newtext = strip_tags($contentText, '<br><img>'); $numChar = strlen($newtext); if ($numChar > $tag->wrap) { $stop = strlen($newtext); for ($i = $tag->wrap; $i < $numChar; $i++) { if ($newtext[$i] == " ") { $stop = $i; $forceReadMore = true; break; } } $contentText = substr($newtext, 0, $stop) . '...'; } } $result .= $contentText; if ($tag->type == "intro") { if (empty($tag->noreadmore) and (!empty($article->fulltext) or $forceReadMore)) { $readMoreText = empty($tag->readmore) ? JText::_('JOOMEXT_READ_MORE') : $tag->readmore; $result .= '<a style="text-decoration:none;" target="_blank" href="' . $link . '"><span class="acymailing_readmore">' . $readMoreText . '</span></a>'; } } $result = '<div class="acymailing_content">' . $result . '</div>'; } if (file_exists(ACYMAILING_MEDIA . 'plugins' . DS . 'tagcontent_html.php')) { ob_start(); require ACYMAILING_MEDIA . 'plugins' . DS . 'tagcontent_html.php'; $result = ob_get_clean(); } elseif (file_exists(ACYMAILING_MEDIA . 'plugins' . DS . 'tagcontent.php')) { ob_start(); require ACYMAILING_MEDIA . 'plugins' . DS . 'tagcontent.php'; $result = ob_get_clean(); } if ($tag->type != 'title' and $this->params->get('removejs', 'yes') == 'yes') { $result = $this->_removeJS($result); } if (isset($tag->pict)) { $pictureHelper = acymailing::get('helper.acypict'); $pictureHelper->maxHeight = empty($tag->maxheight) ? $this->params->get('maxheight', 150) : $tag->maxheight; $pictureHelper->maxWidth = empty($tag->maxwidth) ? $this->params->get('maxwidth', 150) : $tag->maxwidth; if ($tag->pict == '0') { $result = $pictureHelper->removePictures($result); } elseif ($tag->pict == 'resized') { if ($pictureHelper->available()) { $result = $pictureHelper->resizePictures($result); } elseif ($app->isAdmin()) { $app->enqueueMessage($pictureHelper->error, 'notice'); } } } return $result; }
function replaceSubscriptionTag(&$allresults, $i, &$user, &$email) { if (empty($user->subid)) { return ''; } if (empty($user->key)) { $user->key = md5(substr($user->email, 0, strpos($user->email, '@')) . time()); $db = JFactory::getDBO(); $db->setQuery('UPDATE ' . acymailing::table('subscriber') . ' SET `key`= ' . $db->Quote($user->key) . ' WHERE subid = ' . (int) $user->subid . ' LIMIT 1'); $db->query(); } $config = acymailing::config(); $itemId = $config->get('itemid', 0); $item = empty($itemId) ? '' : '&Itemid=' . $itemId; if ($allresults[1][$i] == 'confirm') { //confirm your subscription link $myLink = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=user&task=confirm&subid=' . $user->subid . '&key=' . $user->key . $item); if (empty($allresults[2][$i])) { $allresults[2][$i] = $myLink; } return '<a target="_blank" href="' . $myLink . '">' . $allresults[2][$i] . '</a>'; } elseif ($allresults[1][$i] == 'modify') { //modify your subscription link $myLink = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=user&task=modify&subid=' . $user->subid . '&key=' . $user->key . $item); if (empty($allresults[2][$i])) { $allresults[2][$i] = $myLink; } return '<a style="text-decoration:none;" target="_blank" href="' . $myLink . '"><span class="acymailing_unsub">' . $allresults[2][$i] . '</span></a>'; } //unsubscribe link $myLink = acymailing::frontendLink('index.php?option=com_acymailing&ctrl=user&task=unsub&mailid=' . $email->mailid . '&subid=' . $user->subid . '&key=' . $user->key . $item); if (empty($allresults[2][$i])) { $allresults[2][$i] = $myLink; } $email->customHeaders['list-unsub'] = 'List-Unsubscribe: <' . $myLink . '>'; return '<a style="text-decoration:none;" target="_blank" href="' . $myLink . '"><span class="acymailing_unsub">' . $allresults[2][$i] . '</span></a>'; }
function _replaceContent(&$results, $i) { $arguments = explode('|', strip_tags($results[1][$i])); $tag = null; $tag->id = (int) $arguments[0]; for ($i = 1, $a = count($arguments); $i < $a; $i++) { $args = explode(':', $arguments[$i]); if (isset($args[1])) { $tag->{$args}[0] = $args[1]; } else { $tag->{$args}[0] = true; } } $query = 'SELECT a.*,b.name as authorname, c.alias as catalias, c.title as cattitle, s.alias as secalias, s.title as sectitle FROM ' . acymailing::table('content', false) . ' as a '; $query .= 'LEFT JOIN ' . acymailing::table('users', false) . ' as b ON a.created_by = b.id '; $query .= ' LEFT JOIN ' . acymailing::table('categories', false) . ' AS c ON c.id = a.catid '; $query .= ' LEFT JOIN ' . acymailing::table('sections', false) . ' AS s ON s.id = a.sectionid '; $query .= 'WHERE a.id = ' . $tag->id . ' LIMIT 1'; $db =& JFactory::getDBO(); $db->setQuery($query); $article = $db->loadObject(); $result = null; $result->text = ''; $result->html = ''; if (empty($article)) { $app =& JFactory::getApplication(); if ($app->isAdmin()) { $app->enqueueMessage('The article "' . $tag->id . '" could not be loaded', 'notice'); } return $result; } if (!empty($tag->lang)) { $langid = (int) substr($tag->lang, strpos($tag->lang, ',') + 1); if (!empty($langid)) { $query = "SELECT reference_field, value FROM `#__jf_content` WHERE `published` = 1 AND `reference_table` = 'content' AND `language_id` = {$langid} AND `reference_id` = " . $tag->id; $db->setQuery($query); $translations = $db->loadObjectList(); if (!empty($translations)) { foreach ($translations as $oneTranslation) { if (!empty($oneTranslation->value)) { $translatedfield = $oneTranslation->reference_field; $article->{$translatedfield} = $oneTranslation->value; } } } } } $completeId = $article->id; $completeCat = $article->catid; $completeSec = $article->sectionid; if (!empty($article->alias)) { $completeId .= ':' . $article->alias; } if (!empty($article->catalias)) { $completeCat .= ':' . $article->catalias; } if (!empty($article->secalias)) { $completeSec .= ':' . $article->secalias; } $link = ContentHelperRoute::getArticleRoute($completeId, $completeCat, $completeSec); if (!empty($tag->lang)) { $link .= (strpos($link, '?') ? '&' : '?') . 'lang=' . substr($tag->lang, 0, strpos($tag->lang, ',')); } $link = acymailing::frontendLink($link); $styleTitle = ''; $styleTitleEnd = ''; if ($tag->type != "title") { $styleTitle = '<h2 class="acymailing_title">'; $styleTitleEnd = '</h2>'; } if (!empty($tag->link)) { $result->html .= '<a href="' . $link . '" '; if ($tag->type != "title") { $result->html .= 'style="text-decoration:none" name="content-' . $article->id . '" '; } $result->html .= 'target="_blank" >' . $styleTitle . $article->title . $styleTitleEnd . '</a>'; $result->text .= $article->title . ' ( ' . $link . ' )'; } else { $result->html .= $styleTitle . $article->title . $styleTitleEnd; $result->text .= $article->title; } if (!empty($tag->author)) { $authorName = empty($article->created_by_alias) ? $article->authorname : $article->created_by_alias; $result->html .= $authorName . '<br/>'; $result->text .= "\n" . $authorName; } if ($tag->type != "title") { if ($this->params->get('removejs', 'yes') == 'yes') { $article->introtext = $this->_removeJS($article->introtext); $article->fulltext = $this->_removeJS($article->fulltext); } if ($this->params->get('removepictures', 'never') == 'always') { $article->introtext = $this->_removePictures($article->introtext); $article->fulltext = $this->_removePictures($article->fulltext); } elseif ($this->params->get('removepictures', 'never') == 'intro' and $tag->type == "intro") { $article->introtext = $this->_removePictures($article->introtext); } if ($tag->type == "intro") { $forceReadMore = false; $wordwrap = $this->params->get('wordwrap', 0); if (!empty($wordwrap)) { $newintrotext = strip_tags($article->introtext, '<br><img>'); $numChar = strlen($newintrotext); if ($numChar > $wordwrap) { $stop = strlen($newintrotext); for ($i = $wordwrap; $i < $numChar; $i++) { if ($newintrotext[$i] == " ") { $stop = $i; $forceReadMore = true; break; } } $article->introtext = substr($newintrotext, 0, $stop) . '...'; } } } if (empty($article->fulltext) or $tag->type != "text") { $result->html .= $article->introtext; $result->text .= "\n" . $this->mailerHelper->textVersion($article->introtext); } if ($tag->type == "intro") { if (!empty($article->fulltext) or $forceReadMore) { $result->html .= '<a style="text-decoration:none;" target="_blank" href="' . $link . '"><span class="acymailing_readmore">' . JText::_('JOOMEXT_READ_MORE') . '</span></a>'; $result->text .= "\n" . JText::_('JOOMEXT_READ_MORE') . '( ' . $link . ' )'; } } elseif (!empty($article->fulltext)) { $result->html .= '<br/>' . $article->fulltext; $result->text .= "\n" . $this->mailerHelper->textVersion($article->fulltext); } $result->html = '<div class="acymailing_content">' . $result->html . '</div>'; $result->text .= "\n" . "\n"; } if (file_exists(ACYMAILING_TEMPLATE . 'plugins' . DS . 'tagcontent_html.php')) { ob_start(); require ACYMAILING_TEMPLATE . 'plugins' . DS . 'tagcontent_html.php'; $result->html = ob_get_clean(); } if (file_exists(ACYMAILING_TEMPLATE . 'plugins' . DS . 'tagcontent_text.php')) { ob_start(); require ACYMAILING_TEMPLATE . 'plugins' . DS . 'tagcontent_text.php'; $result->text = ob_get_clean(); } return $result; }