public static function sendEmail($subject, $from, $to, $title, $body, $language = 'en', $html = true, $attach = array()) { self::init(); // Check that $to/$from are both arrays $from = is_array($from) ? $from : explode(',', $from); $to = is_array($to) ? $to : explode(',', $to); //Create the message $message = self::getSwift()->setSubject($subject)->setFrom($from)->setTo($to); // Purify HTML. All tags for forum posts + <hr> for the footer separation $purifier = MOD_htmlpure::get()->getMailHtmlPurifier(); $body = $purifier->purify($body); $html2text = new Html2Text\Html2Text($body, false, array('do_links' => 'table', 'width' => 75)); $plain = $html2text->getText(); $message->setBody($plain); // $message->addPart($plain, 'text/plain'); // Add the html-body only if the member wants HTML mails if ($html) { // Translate footer text (used in HTML template) $words = new MOD_words(); $footer_message = $words->getPurified('MailFooterMessage', array(date('Y')), $language); // Using a html-template ob_start(); require SCRIPT_BASE . 'templates/shared/mail_html.php'; $mail_html = ob_get_contents(); ob_end_clean(); $message->addPart($mail_html, 'text/html'); } return self::sendSwift($message); }
echo $words->get('written_by'); ?> <a href="user/<?php echo $blog->user_handle; ?> "><?php echo $blog->user_handle; ?> </a> - <?php echo date($format['short'], $blog->unix_created); ?> </span> <p> <?php $snippet = strlen($txt[0]) > 600 ? substr($txt[0], 0, 600) . '...' : $txt[0]; $purifier = MOD_htmlpure::get()->getPurifier(); echo $purifier->purify($snippet); if ($txt[1]) { echo '<p> <a href="blog/' . $blog->user_handle . '/' . $blog->blog_id . '">' . $words->get('BlogItemContinued') . '</a></p>'; } ?> </p> <?php } } ?> <a href="blog/tags/Community News for the frontpage"><?php echo $words->get('ReadMore'); ?> </a>
/** * return the formatted email content for $msg * * @param object $message the msg object as returned by the SQL query * @param bool $html whether to format message in html (true) or plaintext (false) * * @return string the formatted email message body */ private function _formatMessage($message) { $inboxUrl = $this->baseuri . "messages"; $messageUrl = $inboxUrl . '/' . $message->id; $purifier = MOD_htmlpure::get()->getPurifier(); $direction_in = true; // true means received message (false is sent) $contact_username = $this->Sender->Username; $contactProfileUrl = $this->baseuri . 'members/' . $contact_username; $member = $this->Sender; $languages = $this->Sender->get_languages_spoken(); $words = $this->words; $templateUsedInEmail = true; $baseuri = $this->baseuri; ob_start(); include SCRIPT_BASE . 'tools/mailbot/templates/readMessage.php'; $text = ob_get_contents(); ob_end_clean(); return $text; }
/** * Look up texts in words table. * Use purifier to add paragraphs and linkify. Never add translation links. * * @param string $code keyword for finding text, not allowed to be empty * @param array $replacements strings to be inserted into the translation's %s placeholders * @param string $language ShortCode of language, 2 to 4 letter * * @return string localized text, in case of no hit the word keycode */ public function getPurified($code, $replacements = array(), $language = false) { $text = $this->getRaw($code, $replacements, $language); // hack to work around a problem during signup require_once SCRIPT_BASE . '/modules/htmlpurify/lib/htmlpurify.lib.php'; $purifier = MOD_htmlpure::get()->getAdvancedHtmlPurifier(); return $purifier->purify($text); }
private function cleanupText($txt) { $purifier = MOD_htmlpure::get()->getForumsHtmlPurifier(); return $purifier->purify($txt); }
private function cleanupText($txt) { if (strpos($txt, "href=") === false) { // We will only try to make clickable links if there is not yet a href= (ie already present clickable link) in the text $txt = $this->makeClickableLinks($txt); } $purifier = MOD_htmlpure::get()->getPurifier(); $txt = $purifier->purify($txt); return $txt; }