/** * Icon for email * * @param object $member Member info * @param JRegistry $params HTML Params * @param array $attribs Member attribs * * @return string * * @since 1.5 */ public static function email($member, $params, $attribs = []) { require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php'; $uri = JUri::getInstance(); $base = $uri->toString(['scheme', 'host', 'port']); $link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($member->slug, $member->catid), false); $url = 'index.php?option=com_mailto&tmpl=component&link=' . MailtoHelper::addLink($link); $status = 'width=400,height=350,menubar=yes,resizable=yes'; if ($params->get('show_icons')) { $text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true); } else { $text = ' ' . JText::_('JGLOBAL_EMAIL'); } $attribs['title'] = JText::_('JGLOBAL_EMAIL'); $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;"; $output = JHtml::_('link', JRoute::_($url), $text, $attribs); return $output; }
function build(&$vars, &$segments, &$do_sef, &$metadata, &$item_limitstart) { // Extract variables extract($vars); if (isset($link)) { if ($this->_helperExists) { $link = MailtoHelper::validateHash($link); } else { $link = base64_decode($link); } $link = str_replace(JURI::root(), '', $link); // Remove URL Suffix if ($this->params->get('remove_url_suffix', 0) && $this->MijosefConfig->url_suffix != '') { $urlSuffix = $this->MijosefConfig->url_suffix; if ($urlSuffix == substr($link, -strlen($urlSuffix))) { $link = substr($link, 0, -strlen($urlSuffix)); } } if (substr($link, 0, 1) == '/') { $link = substr($link, 1, strlen($link) - 1); } $segments[] = rtrim($link, '/'); unset($vars['link']); } $metadata = parent::getMetaData($vars, $item_limitstart); unset($vars['limit']); unset($vars['limitstart']); }
/** * Checks if a URL is a Flash file * * @param string * @return URL */ function validateHash($hash) { $retval = false; $session =& JFactory::getSession(); MailtoHelper::cleanHashes(); $mailto_links = $session->get('com_mailto.links', array()); if (isset($mailto_links[$hash])) { $retval = $mailto_links[$hash]->link; } return $retval; }
/** * Method to generate a link to the email item page for the given article * * @param object $article The article information * @param Registry $params The item parameters * @param array $attribs Optional attributes for the link * @param boolean $legacy True to use legacy images, false to use icomoon based graphic * * @return string The HTML markup for the email item link */ public static function email($article, $params, $attribs = array(), $legacy = false) { JLoader::register('MailtoHelper', JPATH_SITE . '/components/com_mailto/helpers/mailto.php'); $uri = JUri::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $template = JFactory::getApplication()->getTemplate(); $link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language), false); $url = 'index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailtoHelper::addLink($link); $status = 'width=400,height=350,menubar=yes,resizable=yes'; $text = JLayoutHelper::render('joomla.content.icons.email', array('params' => $params, 'legacy' => $legacy)); $attribs['title'] = JText::_('JGLOBAL_EMAIL_TITLE'); $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;"; $attribs['rel'] = 'nofollow'; $output = JHtml::_('link', JRoute::_($url), $text, $attribs); return $output; }
/** * Method to generate a link to the email item page for the given article * * @param object $article The article information * @param Registry $params The item parameters * @param array $attribs Optional attributes for the link * @param boolean $legacy True to use legacy images, false to use icomoon based graphic * * @return string The HTML markup for the email item link */ public static function email($article, $params, $attribs = array(), $legacy = false) { JLoader::register('MailtoHelper', JPATH_SITE . '/components/com_mailto/helpers/mailto.php'); $uri = JUri::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $template = JFactory::getApplication()->getTemplate(); $link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language), false); $url = 'index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailtoHelper::addLink($link); $status = 'width=400,height=350,menubar=yes,resizable=yes'; if ($params->get('show_icons')) { if ($legacy) { $text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true); } else { $text = '<span class="icon-envelope"></span>' . JText::_('JGLOBAL_EMAIL'); } } else { $text = JText::_('JGLOBAL_EMAIL'); } $attribs['title'] = JText::_('JGLOBAL_EMAIL_TITLE'); $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;"; $attribs['rel'] = 'nofollow'; $output = JHtml::_('link', JRoute::_($url), $text, $attribs); return $output; }
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { // Check for request forgeries JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $session = JFactory::getSession(); $db = JFactory::getDbo(); $timeout = $session->get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 20) { JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } jimport('joomla.mail.helper'); $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $link = MailtoHelper::validateHash(JRequest::getCMD('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } // An array of email headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $subject_default = JText::sprintf('COM_MAILTO_SENT_BY', $sender); $subject = JRequest::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = JText::_('COM_MAILTO_EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JUtility::sendMail($from, $sender, $email, $subject, $body) !== true) { JError::raiseNotice(500, JText::_('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } JRequest::setVar('view', 'sent'); $this->display(); }
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { // Check for request forgeries Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN')); $timeout = Session::get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 20) { throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } $SiteName = Config::get('sitename'); $MailFrom = Config::get('mailfrom'); $FromName = Config::get('fromname'); $link = MailtoHelper::validateHash(Request::getCMD('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } // An array of email headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { App::abort(403, ''); } } } // Free up memory unset($headers, $fields); $email = Request::getString('mailto', '', 'post'); $sender = Request::getString('sender', '', 'post'); $from = Request::getString('from', '', 'post'); $subject_default = Lang::txt('COM_MAILTO_SENT_BY', $sender); $subject = Request::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $email); Notify::warning($error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = Lang::txt('COM_MAILTO_EMAIL_INVALID', $from); Notify::warning($error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = Lang::txt('COM_MAILTO_EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true) { throw new Exception(Lang::txt('COM_MAILTO_EMAIL_NOT_SENT'), 500); return $this->mailto(); } Request::setVar('view', 'sent'); $this->display(); }
/** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $session =& JFactory::getSession(); $db =& JFactory::getDBO(); // we return time() instead of 0 (as it previously was), so that the session variable has to be set in order to send the mail $timeout = $session->get('com_mailto.formtime', time()); if ($timeout == 0 || time() - $timeout < MAILTO_TIMEOUT) { JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } // here we unset the counter right away so that you have to wait again, and you have to visit mailto() first $session->set('com_mailto.formtime', null); jimport('joomla.mail.helper'); $SiteName = $mainframe->getCfg('sitename'); $MailFrom = $mainframe->getCfg('mailfrom'); $FromName = $mainframe->getCfg('fromname'); $link = MailtoHelper::validateHash(JRequest::getString('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } // An array of e-mail headers we do not want to allow as input $headers = array('Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array('mailto', 'sender', 'from', 'subject'); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $subject_default = JText::sprintf('Item sent by', $sender); $subject = JRequest::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (!$email || !JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (!$from || !JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = JText::_('EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JUtility::sendMail($from, $sender, $email, $subject, $body) !== true) { JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT')); return $this->mailto(); } JRequest::setVar('view', 'sent'); $this->display(); }