Пример #1
0
/**
* 
* 
* @copyright	Inspiration Web Design http://www.iswebdesign.co.uk
* License GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Include the syndicate functions only once
require_once dirname(__FILE__) . DS . 'helper.php';
//$list = modMailThisPageHelper::getList($params);
if (modMailThisPageHelper::checkThisForm()) {
    $lists = modMailThisPageHelper::getPostValues($params);
    if (!$lists->error) {
        modMailThisPageHelper::sendTheMessage($lists, $params);
    } else {
        $document =& JFactory::getDocument();
        $js = 'window.alert("' . $lists->error_message . '");';
        $domready = "window.addEvent('domready', function() { " . $js . " });";
        $document->addScriptDeclaration($domready);
    }
} else {
    $lists->error = false;
    $lists->error_message = '';
    $lists->success_message = '';
}
$lists->token = '<input type="hidden" name="' . JUtility::getToken() . '" value="1" />';
$lists->submit = JText::_("Send");
$lists->scripts = modMailThisPageHelper::addScripts($params);
require JModuleHelper::getLayoutPath('mod_mail_this_page');
Пример #2
0
 function sendTheMessage(&$lists, &$params)
 {
     if (JRequest::checkToken()) {
         $mainframe =& JFactory::getApplication();
         $document =& JFactory::getDocument();
         $uri =& JURI::getInstance();
         $currentURL = $uri->current();
         if ($currentURL == JURI::root() || preg_match('/index.php$/', $currentURL)) {
             //current url may not be reported correctly
             if ($params->get('use_detection', '0') == '1') {
                 $getvars = JRequest::get('GET');
                 if (is_array($getvars) && count($getvars) > 0) {
                     $value_pairs = array();
                     foreach ($getvars as $key => $val) {
                         $value_pairs[] = rawurlencode(modMailThisPageHelper::clean($key)) . '=' . rawurlencode(modMailThisPageHelper::clean($val));
                     }
                     $querystring = '?' . implode('&', $value_pairs);
                     //$currentURL = JURI::base(). 'index.php' . $querystring;
                     $currentURL = JURI::getInstance()->toString();
                 }
             }
         }
         $message = JText::_("YOURFRIEND") . ' ' . $lists->mtp_user_name . ', ' . JText::_("EMAILADDRESS") . ' ' . $lists->mtp_user_email . ', ' . JText::_("RECOMMENDSPAGE") . "\r\n";
         $message .= '<a href="' . $currentURL . '">' . "\r\n";
         $message .= $currentURL . '</a><br /><br />' . "\r\n";
         $message .= JText::_("ENJOYVISIT");
         //$message .= '<br /><hr /><br />';
         //$message .= 'This message is sent using the Mail This Page Module by '. "\r\n";
         //$message .= '<a href="http://www.spiralscripts.co.uk">Spiral</a>';
         $mailer =& JFactory::getMailer();
         $mailer->setSender($lists->mtp_from_email);
         $mailer->addRecipient($lists->mtp_friend_email);
         if (JMailHelper::isEmailAddress($lists->mtp_bcc)) {
             $mailer->addBCC($lists->mtp_bcc);
         }
         $mailer->setSubject(JText::_('MESSAGEFROM') . ' ' . $mainframe->getCfg('sitename'));
         $mailer->setBody($message);
         $mailer->IsHTML(true);
         if ($mailer->Send() !== true) {
             $lists->error = true;
             $lists->error_message = JText::_("ERRORSENDINGMESSAGE");
             $js = 'window.alert("' . JText::_("ERRORSENDINGMESSAGE") . '");';
         } else {
             $lists->success_message = JText::_("SUCCESSSENDINGMESSAGE");
             $js = 'window.alert("' . JText::_("SUCCESSSENDINGMESSAGE") . '");';
         }
         $domready = "window.addEvent('domready', function() { " . $js . " });";
         $document->addScriptDeclaration($domready);
     }
 }