function acymailing_replaceusertags(&$email, &$user, $addbody = true) { if (!$email->sendHTML) { return; } $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing::absoluteURL($email->body); $email->body = preg_replace('#< *img([^>]*)(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', '<img$1 align="$4" hspace="5" $2$3$4', $email->body); if (empty($email->tempid)) { return; } if (!isset($this->templates[$email->tempid])) { $this->templates[$email->tempid] = array(); if (empty($this->templateClass)) { $this->templateClass = acymailing::get('class.template'); } $template = $this->templateClass->get($email->tempid); if (!empty($template->stylesheet)) { $this->stylesheets[$email->tempid] = $template->stylesheet; } if (!empty($template->styles)) { foreach ($template->styles as $class => $style) { if (preg_match('#^tag_(.*)$#', $class, $result)) { $this->tags[$email->tempid]['#< *' . $result[1] . '((?:(?!style).)*)>#Ui'] = '<' . $result[1] . ' style="' . $style . '" $1>'; } elseif ($class == 'color_bg') { $this->others[$email->tempid][$class] = $style; } else { $this->templates[$email->tempid]['class="' . $class . '"'] = 'style="' . $style . '"'; } } } } if ($addbody and !strpos($email->body, '</body>')) { $before = '<html><head>' . "\n"; $before .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->config->get('charset') . '">' . "\n"; $before .= '<title>' . $email->subject . '</title>' . "\n"; $before .= '</head>' . "\n" . '<body'; if (!empty($this->others[$email->tempid]['color_bg'])) { $before .= ' bgcolor="' . $this->others[$email->tempid]['color_bg'] . '" '; } $before .= '>' . "\n"; $email->body = $before . $email->body . '</body>' . "\n" . '</html>'; } if (!empty($this->templates[$email->tempid])) { $email->body = str_replace(array_keys($this->templates[$email->tempid]), $this->templates[$email->tempid], $email->body); } if (!empty($this->tags[$email->tempid])) { $email->body = preg_replace(array_keys($this->tags[$email->tempid]), $this->tags[$email->tempid], $email->body); } if (!empty($this->stylesheets[$email->tempid]) and class_exists('Emogrifier')) { $emogrifier = new Emogrifier($email->body, $this->stylesheets[$email->tempid]); $email->body = $emogrifier->emogrify(); if (!$addbody and strpos($email->body, '<!DOCTYPE') !== false) { $email->body = preg_replace('#<\\!DOCTYPE.*<body([^>]*)>#Usi', '', $email->body); $email->body = preg_replace('#</body>.*$#si', '', $email->body); } } }
function _generateAutoNews($newNewsletter) { $newNewsletter->senddate = $this->time; $newNewsletter->type = 'news'; if (!empty($newNewsletter->params['generate'])) { $newNewsletter->published = 2; } else { $newNewsletter->published = 0; } $notification = $newNewsletter->params['generateto']; $mailidModel = $newNewsletter->mailid; unset($newNewsletter->mailid); unset($newNewsletter->username); unset($newNewsletter->name); unset($newNewsletter->email); $issueNb = $newNewsletter->params['issuenb']; $newNewsletter->body = str_replace('{issuenb}', $issueNb, $newNewsletter->body); $newNewsletter->altbody = str_replace('{issuenb}', $issueNb, $newNewsletter->altbody); $newNewsletter->subject = str_replace('{issuenb}', $issueNb, $newNewsletter->subject); $newNewsletter->mailid = $this->mailClass->save($newNewsletter); $this->dispatcher->trigger('acymailing_replacetags', array(&$newNewsletter)); $this->mailClass->save($newNewsletter); $query = 'INSERT IGNORE INTO ' . acymailing::table('listmail') . ' (mailid,listid) SELECT ' . $newNewsletter->mailid . ', b.`listid` FROM ' . acymailing::table('listmail') . ' as b'; $query .= ' WHERE b.mailid = ' . $mailidModel; $db = JFactory::getDBO(); $db->setQuery($query); $db->query(); $this->messages[] = JText::sprintf('NEWSLETTER_GENERATED', $newNewsletter->mailid, $newNewsletter->subject); if (!empty($notification)) { $app =& JFactory::getApplication(); $mailer = acymailing::get('helper.mailer'); $mailer->report = $app->isAdmin(); $mailer->autoAddUser = true; $mailer->checkConfirmField = false; $mailer->addParam('mailid', $newNewsletter->mailid); $mailer->addParam('subject', $newNewsletter->subject); $mailer->addParam('body', acymailing::absoluteURL($newNewsletter->body)); $mailer->addParam('issuenb', $issueNb); $mailer->forceTemplate = $newNewsletter->tempid; $mailer->sendOne('notification_autonews', $notification); } }
function resizePictures($input) { $this->destination = ACYMAILING_MEDIA . 'resized' . DS; acymailing::createDir($this->destination); $content = acymailing::absoluteURL($input); preg_match_all('#<img([^>]*)>#Ui', $content, $results); if (empty($results[1])) { return $input; } $replace = array(); foreach ($results[1] as $onepicture) { if (!preg_match('#src="([^"]*)"#Ui', $onepicture, $path)) { continue; } $imageUrl = $path[1]; if (strpos($imageUrl, ACYMAILING_LIVE) !== false) { $imageUrl = str_replace(array(ACYMAILING_LIVE, '/'), array(ACYMAILING_ROOT, DS), $imageUrl); } $newPicture = $this->generateThumbnail($imageUrl); if (!$newPicture) { continue; } $newPicture['file'] = str_replace(array(ACYMAILING_ROOT, DS), array(ACYMAILING_LIVE, '/'), $newPicture['file']); $replaceImage = array(); $replaceImage[$path[1]] = $newPicture['file']; if (preg_match_all('#(width|height)(:|=) *"?([0-9]+)#i', $onepicture, $resultsSize)) { foreach ($resultsSize[0] as $i => $oneArg) { $newVal = strtolower($resultsSize[1][$i]) == 'width' ? $newPicture['width'] : $newPicture['height']; if ($newVal > $resultsSize[3][$i]) { continue; } $replaceImage[$oneArg] = str_replace($resultsSize[3][$i], $newVal, $oneArg); } } $replace[$onepicture] = str_replace(array_keys($replaceImage), $replaceImage, $onepicture); } if (!empty($replace)) { $input = str_replace(array_keys($replace), $replace, $content); } return $input; }
<?php echo JHTML::_('grid.id', $i, $row->tempid); ?> </td> <td> <a href="<?php echo acymailing::completeLink('template&task=edit&cid[]=' . $row->tempid); ?> "><?php echo $row->name; ?> </a> </td> <td> <?php echo acymailing::absoluteURL($row->description); ?> </td> <td class="order"> <span><?php echo $this->pagination->orderUpIcon($i, $this->order->reverse xor $row->ordering >= @$this->rows[$i - 1]->ordering, $this->order->orderUp, 'Move Up', $this->order->ordering); ?> </span> <span><?php echo $this->pagination->orderDownIcon($i, $a, $this->order->reverse xor $row->ordering <= @$this->rows[$i + 1]->ordering, $this->order->orderDown, 'Move Down', $this->order->ordering); ?> </span> <input type="text" name="order[]" size="5" <?php if (!$this->order->ordering) { echo 'disabled="disabled"'; }
function acymailing_replaceusertags(&$email, &$user, $addbody = true) { if (!$email->sendHTML) { return; } $this->_applyTemplate($email, $addbody); $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing::absoluteURL($email->body); $email->body = preg_replace('#< *img([^>]*)(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', '<img$1 align="$4" hspace="5" $2$3$4', $email->body); }
function form() { $tempid = acymailing::getCID('tempid'); $app =& JFactory::getApplication(); $config = acymailing::config(); if (!empty($tempid)) { $templateClass = acymailing::get('class.template'); $template = $templateClass->get($tempid); if (!empty($template->body)) { $template->body = acymailing::absoluteURL($template->body); } } else { $template->body = ''; $template->tempid = 0; $template->published = 1; } $editor = acymailing::get('helper.editor'); $editor->setTemplate($template->tempid); $editor->name = 'editor_body'; $editor->content = $template->body; $editor->prepareDisplay(); if (version_compare(JVERSION, '1.6.0', '<')) { $script = 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; } else { $script = 'Joomla.submitbutton = function(pressbutton) { if (pressbutton == \'cancel\') { Joomla.submitform(pressbutton,document.adminForm); return; }'; } $script .= 'if(window.document.getElementById("name").value.length < 2){alert(\'' . JText::_('ENTER_TITLE', true) . '\'); return false;}'; $script .= "if(pressbutton == 'test' && window.document.getElementById('sendtest') && window.document.getElementById('sendtest').style.display == 'none'){ window.document.getElementById('sendtest').style.display = 'block'; return false;}"; $script .= $editor->jsCode(); if (version_compare(JVERSION, '1.6.0', '<')) { $script .= 'submitform( pressbutton );} '; } else { $script .= 'Joomla.submitform(pressbutton,document.adminForm);}; '; } $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $script .= 'function addStyle(){ var myTable=window.document.getElementById("classtable"); var newline = document.createElement(\'tr\'); var column = document.createElement(\'td\'); var column2 = document.createElement(\'td\'); var input = document.createElement(\'input\'); var input2 = document.createElement(\'input\'); input.type = \'text\'; input2.type = \'text\'; input.size = \'30\'; input2.size = \'50\'; input.name = \'otherstyles[classname][]\'; input2.name = \'otherstyles[style][]\'; input.value = "' . JText::_('CLASS_NAME', true) . '"; input2.value = "' . JText::_('CSS_STYLE', true) . '"; column.appendChild(input); column2.appendChild(input2); newline.appendChild(column); newline.appendChild(column2); myTable.appendChild(newline); }'; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($script); $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName(); $infos = null; $infos->receiver_type = $app->getUserStateFromRequest($paramBase . ".receiver_type", 'receiver_type', '', 'string'); $infos->test_email = $app->getUserStateFromRequest($paramBase . ".test_email", 'test_email', '', 'string'); acymailing::setTitle(JText::_('ACY_TEMPLATE'), 'acytemplate', 'template&task=edit&tempid=' . $tempid); $bar =& JToolBar::getInstance('toolbar'); if (acymailing::isAllowed($config->get('acl_tags_view', 'all'))) { $bar->appendButton('Acytags'); } JToolBarHelper::divider(); JToolBarHelper::custom('test', 'send', '', JText::_('SEND_TEST'), false); JToolBarHelper::spacer(); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'template-form'); $this->assignRef('editor', $editor); $this->assignRef('receiverClass', acymailing::get('type.testreceiver')); $this->assignRef('template', $template); $this->assignRef('colorBox', acymailing::get('type.color')); $this->assignRef('infos', $infos); jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $this->assignRef('tabs', $tabs); }
function form() { $mailid = acymailing::getCID('mailid'); $templateClass = acymailing::get('class.template'); $config =& acymailing::config(); if (!empty($mailid)) { $mailClass = acymailing::get('class.mail'); $mail = $mailClass->get($mailid); if (!empty($mail->tempid)) { $myTemplate = $templateClass->get($mail->tempid); } } else { $mail->created = time(); $mail->published = 0; $mail->visible = 1; $mail->html = 1; $mail->body = ''; $mail->altbody = ''; $mail->tempid = 0; $myTemplate = $templateClass->getDefault(); if (!empty($myTemplate->tempid)) { $mail->body = acymailing::absoluteURL($myTemplate->body); $mail->altbody = $myTemplate->altbody; $mail->tempid = $myTemplate->tempid; $mail->subject = $myTemplate->subject; $mail->replyname = $myTemplate->replyname; $mail->replyemail = $myTemplate->replyemail; $mail->fromname = $myTemplate->fromname; $mail->fromemail = $myTemplate->fromemail; } if ($this->type == 'autonews') { $mail->frequency = 604800; } } $sentbyname = ''; if (!empty($mail->sentby)) { $db =& JFactory::getDBO(); $db->setQuery('SELECT `name` FROM `#__users` WHERE `id`= ' . intval($mail->sentby) . ' LIMIT 1'); $sentbyname = $db->loadResult(); } $this->assignRef('sentbyname', $sentbyname); if (JRequest::getVar('task', '') == 'replacetags') { $mailerHelper = acymailing::get('helper.mailer'); JPluginHelper::importPlugin('acymailing'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('acymailing_replacetags', array(&$mail)); if (!empty($mail->altbody)) { $mail->altbody = $mailerHelper->textVersion($mail->altbody, false); } } $extraInfos = ''; $values = null; if ($this->type == 'followup') { $campaignid = JRequest::getInt('campaign', 0); $extraInfos .= '&campaign=' . $campaignid; $values->delay = acymailing::get('type.delay'); $this->assignRef('campaignid', $campaignid); } else { $listmailClass = acymailing::get('class.listmail'); $lists = $listmailClass->getLists($mailid); } acymailing::setTitle(JText::_($this->nameForm), $this->icon, $this->ctrl . '&task=edit&mailid=' . $mailid . $extraInfos); $bar =& JToolBar::getInstance('toolbar'); if (empty($mail->mailid)) { $bar->appendButton('Popup', 'acytemplate', JText::_('TEMPLATE'), acymailing::completeLink("template&task=theme", true)); } $bar->appendButton('Popup', 'tag', JText::_('TAGS'), acymailing::completeLink("tag&task=tag&type=" . $this->type, true), 750, 550); if (in_array($this->type, array('news', 'followup'))) { JToolBarHelper::custom('replacetags', 'replacetag', '', JText::_('REPLACE_TAGS'), false); } $buttonPreview = JText::_('PREVIEW'); if ($this->type == 'news') { $buttonPreview .= ' / ' . JText::_('SEND'); } JToolBarHelper::divider(); JToolBarHelper::custom('savepreview', 'preview', '', $buttonPreview, false); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel(); JToolBarHelper::divider(); $bar->appendButton('Pophelp', $this->ctrl . '-form'); jimport('joomla.html.pane'); $tabs =& JPane::getInstance('tabs'); $values->maxupload = acymailing::bytes(ini_get('upload_max_filesize')) > acymailing::bytes(ini_get('post_max_size')) ? ini_get('post_max_size') : ini_get('upload_max_filesize'); $toggleClass = acymailing::get('helper.toggle'); $editor = acymailing::get('helper.editor'); $editor->name = 'editor_body'; $editor->content = $mail->body; $js = "function updateEditor(htmlvalue){"; $js .= 'if(htmlvalue == \'0\'){window.document.getElementById("htmlfieldset").style.display = \'none\'}else{window.document.getElementById("htmlfieldset").style.display = \'block\'}'; $js .= '}'; $js .= 'window.addEvent(\'load\', function(){ updateEditor(' . $mail->html . '); });'; $script = 'function addFileLoader(){ var divfile=window.document.getElementById("loadfile"); var input = document.createElement(\'input\'); input.type = \'file\'; input.size = \'30\'; input.name = \'attachments[]\'; divfile.appendChild(document.createElement(\'br\')); divfile.appendChild(input);} '; $script .= 'function submitbutton(pressbutton){ if (pressbutton == \'cancel\') { submitform( pressbutton ); return; }'; $script .= 'if(window.document.getElementById("subject").value.length < 2){alert(\'' . JText::_('ENTER_SUBJECT', true) . '\'); return false;}'; $script .= $editor->jsCode(); $script .= 'submitform( pressbutton );} '; $script .= "function changeTemplate(newhtml,newtext,newsubject,stylesheet,fromname,fromemail,replyname,replyemail,tempid){\r\r\n\t\t\tif(newhtml.length>2){" . $editor->setContent('newhtml') . "}\r\r\n\t\t\tvar vartextarea =\$('altbody'); if(newtext.length>2) vartextarea.setHTML(newtext);\r\r\n\t\t\tdocument.getElementById('tempid').value = tempid;\r\r\n\t\t\tif(fromname.length>1){document.getElementById('fromname').value = fromname;}\r\r\n\t\t\tif(fromemail.length>1){document.getElementById('fromemail').value = fromemail;}\r\r\n\t\t\tif(replyname.length>1){document.getElementById('replyname').value = replyname;}\r\r\n\t\t\tif(replyemail.length>1){document.getElementById('replyemail').value = replyemail;}\r\r\n\t\t\tif(newsubject.length>1){document.getElementById('subject').value = newsubject;}\r\r\n\t\t}\r\r\n\t\t"; $script .= "function insertTag(tag){ try{jInsertEditorText(tag,'editor_body'); return true;} catch(err){alert('Your editor does not enable AcyMailing to automatically insert the tag, please copy/paste it manually in your Newsletter'); return false;}}"; $script .= "window.addEvent('domready', function(){ mytoolbar = \$('toolbar'); if(!mytoolbar) return true; mytoolbar.addEvent('mouseover', function(){ try{IeCursorFix();}catch(e){} }); }); "; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js . $script); if ($this->type == 'autonews') { JHTML::_('behavior.modal', 'a.modal'); $this->assignRef('delay', acymailing::get('type.delay')); $this->assignRef('generatingMode', acymailing::get('type.generatemode')); $link = 'index.php?option=com_acymailing&tmpl=component&ctrl=email&task=edit&mailid=notification_autonews'; $values->editnotification = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 500}}"><button onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>'; } $this->assignRef('toggleClass', $toggleClass); $this->assignRef('lists', $lists); $this->assignRef('editor', $editor); $this->assignRef('mail', $mail); $this->assignRef('tabs', $tabs); $this->assignRef('values', $values); }
function textVersion($html, $fullConvert = true) { $html = acymailing::absoluteURL($html); if ($fullConvert) { $html = preg_replace('# +#', ' ', $html); $html = str_replace(array("\n", "\r", "\t"), '', $html); } $removepictureslinks = "#< *a[^>]*> *< *img[^>]*> *< *\\/ *a *>#isU"; $removeScript = "#< *script(?:(?!< */ *script *>).)*< */ *script *>#isU"; $removeStyle = "#< *style(?:(?!< */ *style *>).)*< */ *style *>#isU"; $removeStrikeTags = '#< *strike(?:(?!< */ *strike *>).)*< */ *strike *>#iU'; $replaceByTwoReturnChar = '#< *(h1|h2)[^>]*>#Ui'; $replaceByStars = '#< *li[^>]*>#Ui'; $replaceByReturnChar1 = '#< */ *(li|td|tr|div|p)[^>]*> *< *(li|td|tr|div|p)[^>]*>#Ui'; $replaceByReturnChar = '#< */? *(br|p|h1|h2|legend|h3|li|ul|h4|h5|h6|tr|td|div)[^>]*>#Ui'; $replaceLinks = '/< *a[^>]*href *= *"([^#][^"]*)"[^>]*>(.*)< *\\/ *a *>/Uis'; $text = preg_replace(array($removepictureslinks, $removeScript, $removeStyle, $removeStrikeTags, $replaceByTwoReturnChar, $replaceByStars, $replaceByReturnChar1, $replaceByReturnChar, $replaceLinks), array('', '', '', '', "\n\n", "\n* ", "\n", "\n", '${2} ( ${1} )'), $html); $text = str_replace(array(" ", " "), ' ', strip_tags($text)); $text = trim(@html_entity_decode($text, ENT_QUOTES, 'UTF-8')); if ($fullConvert) { $text = preg_replace('# +#', ' ', $text); $text = preg_replace('#\\n *\\n\\s+#', "\n\n", $text); } return $text; }
<div class="templatedescription"><?php echo acymailing::absoluteURL($row->description); ?> </div> <div style="display:none" id="stylesheet_<?php echo $row->tempid; ?> "><?php echo $row->stylesheet; ?> </div> <div style="display:none" id="htmlcontent_<?php echo $row->tempid; ?> "><?php echo acymailing::absoluteURL($row->body); ?> </div> <div style="display:none" id="textcontent_<?php echo $row->tempid; ?> "><?php echo $row->altbody; ?> </div> <div style="display:none" id="subject_<?php echo $row->tempid; ?> "><?php echo $row->subject; ?>
function test() { if (!$this->isAllowed($this->aclCat, 'manage')) { return; } $this->store(); $tempid = acymailing::getCID('tempid'); $receiver_type = JRequest::getVar('receiver_type', '', '', 'string'); if (empty($tempid) or empty($receiver_type)) { return false; } $mailer = acymailing::get('helper.mailer'); $mailer->report = true; $config = acymailing::config(); $subscriberClass = acymailing::get('class.subscriber'); $userHelper = acymailing::get('helper.user'); JPluginHelper::importPlugin('acymailing'); $dispatcher =& JDispatcher::getInstance(); $app =& JFactory::getApplication(); $receivers = array(); if ($receiver_type == 'user') { $user = JFactory::getUser(); $receivers[] = $user->email; } elseif ($receiver_type == 'other') { $receivers[] = JRequest::getVar('test_email', '', '', 'string'); } else { $gid = substr($receiver_type, strpos($receiver_type, '_') + 1); if (empty($gid)) { return false; } $db =& JFactory::getDBO(); $db->setQuery('SELECT email from ' . acymailing::table('users', false) . ' WHERE gid = ' . intval($gid)); $receivers = $db->loadResultArray(); } if (empty($receivers)) { $app->enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice'); return $this->edit(); } $classTemplate = acymailing::get('class.template'); $myTemplate = $classTemplate->get($tempid); $myTemplate->sendHTML = 1; $myTemplate->mailid = 0; if (empty($myTemplate->subject)) { $myTemplate->subject = $myTemplate->name; } if (empty($myTemplate->altBody)) { $myTemplate->altbody = $mailer->textVersion($myTemplate->body); } $dispatcher->trigger('acymailing_replacetags', array(&$myTemplate)); $myTemplate->body = acymailing::absoluteURL($myTemplate->body); $result = true; foreach ($receivers as $receiveremail) { $copy = $myTemplate; $mailer->clearAll(); $mailer->setFrom($copy->fromemail, $copy->fromname); if (!empty($copy->replyemail)) { $replyToName = $config->get('add_names', true) ? $mailer->cleanText($copy->replyname) : ''; $mailer->AddReplyTo($mailer->cleanText($copy->replyemail), $replyToName); } $receiver = $subscriberClass->get($receiveremail); if (empty($receiver->subid)) { if ($userHelper->validEmail($receiveremail)) { $newUser = null; $newUser->email = $receiveremail; $subscriberClass->sendConf = false; $subid = $subscriberClass->save($newUser); $receiver = $subscriberClass->get($subid); } if (empty($receiver->subid)) { continue; } } $addedName = $config->get('add_names', true) ? $mailer->cleanText($receiver->name) : ''; $mailer->AddAddress($mailer->cleanText($receiver->email), $addedName); $dispatcher->trigger('acymailing_replaceusertags', array(&$copy, &$receiver)); $mailer->IsHTML(true); $mailer->sendHTML = true; $mailer->Body = $copy->body; $mailer->Subject = $copy->subject; if ($config->get('multiple_part', false)) { $mailer->AltBody = $copy->altbody; } $mailer->send(); } return $this->edit(); }