예제 #1
0
파일: jnewsbotk2.php 프로젝트: naka211/kkvn
function jnewsbot_k2_transformall(&$html, &$text, &$subject, $queueInfo = null)
{
    $mainframe = JFactory::getApplication();
    $livesite = $mainframe->getCfg("live_site");
    $sef = $mainframe->getCfg("sef");
    $k2_items = array();
    $k2_items_new = array();
    $k2_items_old = array();
    preg_match_all('/\\{k2item:(.{1,8})\\|(.{1})}/', $html, $k2_items_old, PREG_SET_ORDER);
    preg_match_all('/\\{k2item:(.{1,8})\\|(.{1})\\|(.{1})}/', $html, $k2_items_new, PREG_SET_ORDER);
    $k2_items = jnewsbot_class_transform_mergeArray($k2_items_new, $k2_items_old);
    foreach ($k2_items as $k2_item) {
        //j15
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $Itemid = $mainframe->getItemId($k2_item[1]);
        }
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
        }
        $replacement = jnewsbot_k2_getitem($k2_item[1]);
        if ($GLOBALS[JNEWS . 'show_author'] == 1) {
            $author = '<br />' . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->introtext = str_replace('{mospagebreak}', '<div style="clear: both;" ><div />', $replacement->introtext);
        $replacement->fulltext = str_replace('{mospagebreak}', '<div style="clear: both;" ><div />', $replacement->fulltext);
        //   [0] => {k2item:3|1|1}
        //    [1] => 3
        //    [2] => 1
        //    [3] => 1
        if (isset($k2_item[3])) {
            if ($k2_item[3] == 1 && $k2_item[2] != 2) {
                $replacement->title = "";
            }
        }
        if ($k2_item[2] == 0) {
            $html = str_replace($k2_item[0], '<div class="aca_content"><span class="aca_title">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . $replacement->fulltext . "\r\n" . '</div>', $html);
        } else {
            if ($GLOBALS[JNEWS . 'use_sef'] == '1' and $sef == '1' and function_exists('sefRelToAbs')) {
                $link = sefRelToAbs('index.php?option=com_k2&view=item&id=' . $k2_item[1] . '&Itemid=' . $Itemid);
            } else {
                $link = $livesite . '/index.php?option=com_k2&view=item&id=' . $k2_item[1] . '&Itemid=' . $Itemid;
            }
            if ($k2_item[2] == 1) {
                $html = str_replace($k2_item[0], '<div class="aca_content"><span class="aca_title">' . $replacement->title . '</span>' . "\r\n" . $author . '<br />' . $replacement->introtext . '<br />' . "\r\n" . '<a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>' . "\r\n" . '</div>', $html);
            } else {
                $html = str_replace($k2_item[0], '<a href="' . $link . '"><span class="aca_title">' . $replacement->title . '</span></a>', $html);
            }
        }
        $image = jnewsbot_k2_getimage($replacement->image);
        if (version_compare(JVERSION, '1.6.0', '<')) {
            //j15
            $imgfolders = '/images/stories';
        } else {
            //j16
            $imgfolders = '/images/sampledata';
        }
        foreach ($image as $image) {
            $image_string = '<img src="' . $livesite . $imgfolders . $image['image'] . '" align="' . $image['align'] . '" alt="' . $image['alttext'] . '" border="' . $image['border'] . '" />';
            $html = preg_replace('/{mosimage}/', $image_string, $html, 1);
        }
    }
    $k2_items = array();
    $k2_items_new = array();
    $k2_items_old = array();
    preg_match_all('/\\{k2item:(.{1,5})\\|(.{1})}/', $text, $k2_items_old, PREG_SET_ORDER);
    preg_match_all('/\\{k2item:(.{1,5})\\|(.{1})\\|(.{1})}/', $text, $k2_items_new, PREG_SET_ORDER);
    $k2_items = jnewsbot_class_transform_mergeArray($k2_items_new, $k2_items_old);
    foreach ($k2_items as $k2_item) {
        //j15
        if (version_compare(JVERSION, '1.6.0', '<')) {
            $Itemid = $mainframe->getItemId($k2_item[1]);
        }
        if (empty($Itemid)) {
            $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
        }
        $replacement = jnewsbot_k2_getitem($k2_item[1]);
        if ($GLOBALS[JNEWS . 'show_author'] == 1) {
            $author = "\r\n" . $replacement->created_by_alias;
        } else {
            $author = '';
        }
        $replacement->title = strtoupper(jNews_ProcessMail::htmlToText($replacement->title));
        $replacement->introtext = jNews_ProcessMail::htmlToText($replacement->introtext);
        $replacement->fulltext = jNews_ProcessMail::htmlToText($replacement->fulltext);
        if (isset($k2_item[3])) {
            if ($k2_item[3] == 1 && $k2_item[2] != 2) {
                $replacement->title = "";
            }
        }
        if ($k2_item[2] == 0) {
            $text = str_replace($k2_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . $replacement->fulltext . "\r\n", $text);
        } else {
            if ($GLOBALS[JNEWS . 'use_sef'] == '1' and $sef == '1' and function_exists('sefRelToAbs')) {
                $link = sefRelToAbs('index.php?option=com_k2&view=item&id=' . $k2_item[1] . '&Itemid=' . $Itemid);
            } else {
                $link = $livesite . '/index.php?option=com_k2&view=item&id=' . $k2_item[1] . '&Itemid=' . $Itemid;
            }
            if ($k2_item[2] == 1) {
                $text = str_replace($k2_item[0], $replacement->title . $author . "\r\n" . $replacement->introtext . "\r\n" . '* ' . _JNEWS_READMORE . ' ( ' . $link . ' )' . "\r\n", $text);
            } else {
                $text = str_replace($k2_item[0], $replacement->title . ' ( ' . $link . ' )', $text);
            }
        }
        $text = str_replace('{mosimage}', '', $text);
    }
    $html = str_replace('{mospagebreak}', '<div style="clear: both;" ><div />', $html);
    $text = str_replace('{mospagebreak}', "\r\n \r\n", $text);
}
예제 #2
0
    public static function viewMailing($mailing, $forms)
    {
        echo $forms['main'];
        if ($mailing->html) {
            ?>
			<fieldset class="adminform" width="100%" id="htmlfieldset">
			<legend><?php 
            echo _JNEWS_HTML_VERSION;
            ?>
</legend>
			<div class="newsletter_content" ><?php 
            echo $mailing->htmlcontent;
            ?>
</div>
			</fieldset>
		<?php 
        } else {
            ?>
			<fieldset class="adminform" >
			<legend><?php 
            echo _JNEWS_NONHTML;
            ?>
</legend>
			<textarea style="width:100%" rows="20" readonly><?php 
            echo jNews_ProcessMail::htmlToText($mailing->textonly);
            ?>
</textarea>
			</fieldset>
		<?php 
        }
        echo '<div class="clr"></div>';
        $act = JRequest::getVar('act', '', '', 'WORD');
        $task = JRequest::getVar('task');
        if ($act != 'mailing' && $task != 'view') {
            ?>
			<fieldset class="adminform" >
			<legend><?php 
            echo _JNEWS_NONHTML;
            ?>
</legend>
			<textarea style="width:100%" rows="20" readonly><?php 
            echo jNews_ProcessMail::htmlToText($mailing->textonly);
            ?>
</textarea>
			</fieldset>
			<div class="clr"></div>
		<?php 
        }
        if (!empty($mailing->attachments)) {
            ?>
		<table width="100%" cellpadding="4" cellspacing="0" border="0" align="left" class="adminlist">
		<tr>
			<th align="left" valign="top">
				<strong><?php 
            echo _JNEWS_ATTACHED_FILES;
            ?>
:</strong>
			</th>
			<td align="left">
				<?php 
            foreach ($mailing->attachments as $file) {
                echo '<a href="' . JNEWS_JPATH_LIVE . $GLOBALS[JNEWS . 'upload_url'] . DS . basename($file) . '" target="_blank">' . basename($file) . '</a><br />';
            }
            ?>
			</td>
		</tr>
		</table>
		<?php 
        }
    }
예제 #3
0
 /**
  * This public static function will save the subscriber information every new subscription or update subscription
  * @param listids - listid subscribed from the module if the saving of subscriber is via ajax
  * @param redirect - if to redirect the page or not
  */
 public static function saveSubscriber($subscriber, &$subscriberId, $newSubscriber = false, $listids = null, $redirect = false)
 {
     $subscriber->receive_html = isset($subscriber->receive_html) && (is_bool($subscriber->receive_html) && $subscriber->receive_html || is_string($subscriber->receive_html) && ($subscriber->receive_html == 'true' || $subscriber->receive_html == '1') || is_int($subscriber->receive_html) && $subscriber->receive_html) ? 1 : 0;
     $db = JFactory::getDBO();
     $xf = new jNews_Config();
     //dashboard summary
     jnews::objectHTMLSafe($subscriber);
     $d['confirm'] = true;
     $d['email'] = $subscriber->email;
     if (empty($subscriber->ip)) {
         $subscriber->ip = '';
     }
     if ($newSubscriber) {
         $query = "INSERT IGNORE INTO `#__jnews_subscribers` (`name`,`email` ,`ip`, `receive_html` , `confirmed` ";
         $query .= " , `subscribe_date` , `language_iso` , `timezone`, `blacklist`";
         //" , `params`";
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             $query .= " , `column1`";
             $query .= " , `column2`";
             $query .= " , `column3`";
             $query .= " , `column4`";
             $query .= " , `column5`";
         }
         if (!empty($subscriber->user_id)) {
             $query .= " , `user_id` ";
         }
         $query .= ") VALUES (" . " '{$subscriber->name}' , " . " '{$subscriber->email}' , " . " '{$subscriber->ip}' , " . " '{$subscriber->receive_html}' , " . " '{$subscriber->confirmed}' , " . " '{$subscriber->subscribe_date}', " . " '{$subscriber->language_iso}', " . " '{$subscriber->timezone}', " . " '{$subscriber->blacklist}' ";
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             //check if the version is pro
             //$query .=" '$subscriber->params' , ";
             $query .= ",";
             if (array_key_exists('column1', $subscriber)) {
                 $query .= " '{$subscriber->column1}',  ";
             } else {
                 $query .= " '',  ";
             }
             if (array_key_exists('column2', $subscriber)) {
                 $query .= " '{$subscriber->column2}',  ";
             } else {
                 $query .= " '',  ";
             }
             if (array_key_exists('column3', $subscriber)) {
                 $query .= " '{$subscriber->column3}',  ";
             } else {
                 $query .= " '',  ";
             }
             if (array_key_exists('column4', $subscriber)) {
                 $query .= " '{$subscriber->column4}',  ";
             } else {
                 $query .= " '',  ";
             }
             if (array_key_exists('column5', $subscriber)) {
                 $query .= " '{$subscriber->column5}'  ";
             } else {
                 $query .= " '' ";
             }
         }
         if (!empty($subscriber->user_id)) {
             $query .= " , " . intval($subscriber->user_id);
         }
         $query .= ")";
         $db->setQuery($query);
         $db->query();
         //get the subscriber id which is newly inserted
         //Update dashboard summary
         if (jNews_Subscribers::getSubscriberIdFromEmail($d)) {
             $d['confirm'] = false;
             $xf->plus('totalsubcribers0', 1);
             $xf->plus('act_totalsubcribers0', 1);
         }
         //subscriber_id from the inserted subscriber
         if ($d['subscriberId'] > 0) {
             $subscriberId = $d['subscriberId'];
             $subscriber->id = $d['subscriberId'];
         } else {
             $subscriber->id = 0;
             $subscriberId = 0;
         }
         //TODO: Add an option either to require confirmation during site registration once the sync users plugin is turn on
         //added condition  empty($subscriber->user_id) so that it will not send confirmation email during registration
         if ($newSubscriber && $GLOBALS[JNEWS . 'require_confirmation'] == '1' && empty($subscriber->user_id)) {
             //added $subscriber
             jNews_ProcessMail::sendConfirmationEmail($subscriber, $subscriberId);
         }
     } else {
         //Update Subscriber
         if (empty($subscriber->id)) {
             $subscriber->id =& $subscriberId;
         }
         $query = "UPDATE IGNORE `#__jnews_subscribers` SET ";
         $query .= " `name` = '{$subscriber->name}' , ";
         $query .= " `email` = '{$subscriber->email}' , ";
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             if (!empty($subscriber->column1)) {
                 $query .= " `column1` = '{$subscriber->column1}' , ";
             }
             if (!empty($subscriber->column2)) {
                 $query .= " `column2` = '{$subscriber->column2}' , ";
             }
             if (!empty($subscriber->column3)) {
                 $query .= " `column3` = '{$subscriber->column3}' , ";
             }
             if (!empty($subscriber->column4)) {
                 $query .= " `column4` = '{$subscriber->column4}' , ";
             }
             if (!empty($subscriber->column5)) {
                 $query .= " `column5` = '{$subscriber->column5}' , ";
             }
         }
         $query .= " `receive_html` = {$subscriber->receive_html}  , ";
         $query .= " `confirmed` =  {$subscriber->confirmed}  , " . " `timezone` = '{$subscriber->timezone}' , ";
         $query .= " `language_iso` = '{$subscriber->language_iso}' , ";
         $query .= " `blacklist` = {$subscriber->blacklist} ";
         //$query.= " `params` = '$subscriber->params'  " .
         $query .= " WHERE `id` = {$subscriber->id} ";
         $db->setQuery($query);
         $db->query();
     }
     $subscriberInfo = jNews_ListsSubs::getListidsSubscribedInfo($subscriber->id, $listids, $redirect);
     return true;
 }
예제 #4
0
파일: frontend.php 프로젝트: naka211/kkvn
 public static function unsubscribeall($subscriber, $subscriberId, $cle = '')
 {
     $my = JFactory::getUser();
     if ((!empty($subscriberId) and !empty($cle)) || !empty($my->id)) {
         if (md5($subscriber->email) == $cle || !empty($my->id)) {
             //we unsubscribe the user to all lists
             $db = JFactory::getDBO();
             $query = 'SELECT * FROM `#__jnews_lists`';
             $query .= ' WHERE `id` IN (SELECT `list_id` FROM `#__jnews_listssubscribers` WHERE `subscriber_id`=' . $subscriberId . ' AND `unsubscribe`=0)';
             $db->setQuery($query);
             $listsO = $db->loadObjectList();
             if (!empty($listsO)) {
                 foreach ($listsO as $key => $list) {
                     //we send the unsubscription notification to the subscriber if it is turn to yes
                     if ($list->unsubscribesend == 1) {
                         jNews_ProcessMail::sendUnsubcribeEmail($subscriber, $subscriberId, $list);
                     }
                     //we send the unsubscription notification to the list owner if it is turn to yes
                     if ($GLOBALS[JNEWS . 'level'] > 2 && $list->unsubscribenotifyadmin == 1 && !empty($list->notifyadminmsg) && !empty($list->owner)) {
                         $my = JFactory::getUser($list->owner);
                         jNews_ProcessMail::sendNotification($list->notifyadminmsg, $subscriber, $my, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
                     }
                     if (!empty($GLOBALS[JNEWS . 'unsubscribe_notification'])) {
                         $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'unsubscribe_notification']);
                         if (!empty($listOfAdminA)) {
                             foreach ($listOfAdminA as $oneAdmin) {
                                 if (empty($oneAdmin)) {
                                     continue;
                                 }
                                 $owner = new stdClass();
                                 $owner->name = $oneAdmin;
                                 $owner->email = $oneAdmin;
                                 jNews_ProcessMail::sendNotification(_JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION, $newSubscriber, $owner, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
                             }
                         }
                     }
                 }
             }
             $query = 'UPDATE `#__jnews_listssubscribers` SET `unsubscribe`=1, `unsubdate`=' . time() . ' WHERE `subscriber_id`=' . $subscriberId;
             $db->setQuery($query);
             $result = $db->query();
         }
     }
     return $result;
 }
예제 #5
0
/**
* <p>Templates controller</p>
* <p>This function is the controller to view the templates view</p>
* @author Joobi Limited <wwww.joobi.co>
*/
function templates($action, $task, $template_id)
{
    $my = JFactory::getUser();
    $css = '.icon-48-templates { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/templates.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'templates.png';
    $templatesearch = JRequest::getVar('templatesearch', '');
    $showTemplates = true;
    // defined toggle for publish and unpublish of mailings
    $willRedirect = false;
    $checkToggle = false;
    $cid = JRequest::getVar('cid');
    if (empty($template_id)) {
        if (!empty($cid) && is_array($cid)) {
            $template_id = $cid[key($cid)];
        }
    } else {
        if (empty($cid)) {
            $cid[] = $template_id;
        }
    }
    if (!empty($task) && $task == 'togle') {
        $checkToggle = true;
        //		$id = JRequest::getVar( 'templateid' );
        $id = $template_id;
        $col = JRequest::getVar('col');
        $template_id = !empty($id) && !empty($col) ? $id : $template_id;
        $task = !empty($template_id) && !empty($col) ? $col : $task;
        $willRedirect = true;
    }
    switch ($task) {
        case 'new':
        case 'add':
            $showTemplates = false;
            $template = null;
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\"> \n";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            backHTML::formEnd($go);
            break;
        case 'edit':
            $showTemplates = false;
            $template = jNews_Templates::loadOneTemplate('*', $template_id);
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\">";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('template_id', $template_id);
            backHTML::formEnd($go);
            break;
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'apply':
            JRequest::checkToken() or die('Invalid Token');
            $message = '';
            $message .= jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            $id = empty($template_id) ? jNews_Templates::loadOneTemplate('template_id', '', 'template_id', 'DESC') : $template_id;
            $converMessage = JRequest::getVar('message', '', '', 'string', JREQUEST_ALLOWRAW);
            if (!empty($converMessage)) {
                $message .= '<br/>';
                $message .= implode("", $converMessage);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $id, $message);
            break;
        case 'publish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $message = jnews::printYN(jNews_Templates::updateTemplate($cid, 'published', true), 'Successfully published template!', 'Error publishing the template!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'unpublish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $condition = jNews_Templates::updateTemplate($cid, 'published', false);
            if ($condition) {
                $message = jnews::printM('ok', 'Successfully unpublished template!');
            } else {
                $message = jnews::printM('defaulterror', 'Unable to unpublished default template!');
            }
            //	   		$message = jnews::defaultYN( jNews_Templates::updateTemplate($template_id,'published', false) ,  'Successfully unpublished template!' , 'Unable to unpublished default  template!' );
            if ($willRedirect) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            }
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::copyTemplate($template_id), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_COPIED, _JNEWS_ERROR);
            $showTemplates = true;
            break;
        case 'default':
            $success = false;
            //set all the templates to premium = 0
            if (jNews_Templates::updateTemplate($template_id, 'default', false, false)) {
                $success = true;
            }
            //set the template published and premium
            if ($success) {
                jNews_Templates::updateTemplate($template_id, 'default', true, true);
            }
            $message = jnews::printYN($success, 'Successfully set the template to default!', 'Unable to set template to default!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            $showTemplates = true;
            $isDefault = jNews_Templates::loadOneTemplate('premium', $template_id);
            if (!$isDefault) {
                $message = jnews::printYN(jNews_Templates::deleteTemplate($cid), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            } else {
                $message = jnews::printM('red', _JNEWS_TEMPLATE_DEFAULT_NODEL);
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
        case 'toggle':
            JRequest::checkToken() or die('Invalid Token');
            // main toggle for all usage
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            if (!empty($listid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_lists';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $listid;
                jnews::toggle($passObj);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates');
            break;
        case 'tempupload':
            // HTML for upload template
            //			JRequest::checkToken() or die( 'Invalid Token' );
            $html = '<form action="index.php?option=' . JNEWS_OPTION . '&act=templates&task=upload" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">';
            $html .= '<table style="width:100%;padding:100px;">';
            $html .= '<tr>';
            $html .= '<td style="text-align:center;"> <input type="FILE" name="tempupload"> </td>';
            $html .= '</tr><tr">';
            $html .= '<td style="text-align:center;padding:20px;"> <input type="submit" value="Upload Template" style="width:130px;height:25px;"> </td>';
            $html .= '</tr>';
            $html .= '</table>';
            if (version_compare(JVERSION, '3.0.0', '<')) {
                $html .= JHTML::_('form.token');
            } else {
                $html .= JHtml::_('form.token');
            }
            $html .= '</form><br/><br/>';
            echo $html;
            $showTemplates = false;
            break;
        case 'sendtest':
            JRequest::checkToken() or die('Invalid Token');
            //we save first the template
            $saveStatus = jNews_Templates::saveTemplate($task, $template_id);
            //then we send it if the template is successfully saved
            if ($saveStatus) {
                $message = jnews::printM('ok', _JNEWS_TEMPLATE_SAVED);
                $my = JFactory::getUser();
                $mailing = new stdClass();
                $receiver = new stdClass();
                $status = false;
                $mailing->id = 1;
                $mailing->html = 1;
                $mailing->images = '';
                $mailing->attachments = '';
                $mailing->subject = jNews_Templates::loadOneTemplate('name', $template_id);
                $mailing->htmlcontent = jNews_Templates::loadOneTemplate('body', $template_id);
                $mailing->template_id = $template_id;
                $receiver->name = $my->name;
                $receiver->email = $my->email;
                $receiver->receive_html = 1;
                $receiver->user_id = $my->id;
                $mailerC = new jNews_ProcessMail();
                $sendStatus = $mailerC->send($mailing, $receiver);
                $success = 'Template ' . $mailing->subject . ' successfully sent to ' . $receiver->email;
                $error = 'There is a problem in sending the template ' . $mailing->subject . ' <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
                $message = $sendStatus ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            } else {
                //otherwise we give an error message
                $message = jnews::printM('error', _JNEWS_ERROR);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $template_id, $message);
            break;
        case 'upload':
            JRequest::checkToken() or die('Invalid Token');
            $db = JFactory::getDBO();
            $fileName = $_FILES['tempupload']['name'];
            $folderName = substr($fileName, 0, -4);
            // explode to array to compare and check if the uploaded file is a zip file
            $type = $_FILES['tempupload']['type'];
            // if zip is not found then return to previous upload page
            if (strtolower($type) != 'application/zip') {
                if (strtolower(substr($fileName, -4)) != '.zip') {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); document.location.href='index.php?option='.JNEWS_OPTION.'&act=templates';</script>";
                    } else {
                        if (version_compare(JVERSION, '3.0.0', '<')) {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); window.parent.SqueezeBox.close();</script>";
                        } else {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                        }
                    }
                    break;
                }
            }
            $result = jNews_Templates::uploadTemplate();
            if ($result) {
                // if success
                // read index.html of file for template body content
                $tempPath = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'templates' . DS;
                $file = fopen($tempPath . $folderName . DS . 'index.html', "r") or exit("Unable to open file!");
                $tempbody = array();
                while (!feof($file)) {
                    $tempbody[] = fgets($file);
                }
                //endwhile
                fclose($file);
                $tempbody = implode(' ', $tempbody);
                $standardCSSA = array();
                $extraCSSStyles = '';
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package with style.css file
                    //we get here the css codes from the uploaded template
                    $cssfile = fopen($tempPath . $folderName . DS . 'css' . DS . 'style.css', "r") or exit("Unable to open file!");
                    $cssstyle = array();
                    while (!feof($cssfile)) {
                        $cssstyle[] = fgets($cssfile);
                    }
                    //endwhile
                    fclose($cssfile);
                    $cssstyle = implode(' ', $cssstyle);
                    $cleanCSSstyle = jNews_Templates::cleanCSSComments($cssstyle);
                    //cleancsscomments
                    @(require_once JNEWSPATH_CLASS . 'class.cssinlinestyles.php');
                    if (class_exists('CSSToInlineStyles')) {
                        $newCSSProcess = new CSSToInlineStyles();
                        $newCSSProcess->setCSS($cleanCSSstyle);
                        $newCSSProcess->processCSS();
                        //we define the predefined selectors for the css
                        $standardSelectorsA = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'ul', 'li', '.unsubscribe', '.subscriptions', '.content', '.title', '.readmore', '.online', '.aca_content', '.aca_title', '.aca_readmore', '.aca_online', '.aca_subscribe', '.aca_unsubscribe', '.aca_subscriptions');
                        $standardCSSA = $newCSSProcess->getStandardCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                        $extraCSSStyles = $newCSSProcess->getExtraCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                    }
                }
                // replace source image paths from 'images/' to 'media/.../templates/$FOLDERNAME/'
                $bodyImgA = JRequest::getVar('bodyImg');
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/' . $folderName .'/images/', $tempbody);
                    $origin = '"images/';
                    $destination = '"' . JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/images/';
                    $body = str_replace($origin, $destination, $tempbody);
                } else {
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/'. $folderName.'/' , $tempbody);
                    $origin = 'media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $destination = JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $body = str_replace($origin, $destination, $tempbody);
                }
                $template = null;
                $template->name = ucfirst($folderName);
                $template->description = '';
                $template->created = time();
                $template->body = addslashes($body);
                $template->altbody = '';
                $template->premium = 0;
                $template->namekey = $folderName;
                $template->published = 1;
                $template->styles = addslashes(serialize($standardCSSA));
                $template->csstyle = addslashes($extraCSSStyles);
                $template->thumbnail = '';
                $templateA = (array) $template;
                $query = 'SELECT * FROM `#__jnews_templates` WHERE `namekey` = \'' . $template->namekey . '\' ';
                $db->setQuery($query);
                $findresult = $db->loadObject();
                if (empty($findresult)) {
                    // store template
                    $status = jNews_Templates::storeTemplate($templateA);
                } else {
                    //update template
                    $query = 'UPDATE `#__jnews_templates` SET `body` = \'' . $template->body . '\' , `availability` = 1 WHERE `namekey`= \'' . $template->namekey . '\'  AND `template_id`=' . $findresult->template_id;
                    $db->setQuery($query);
                    $status = $db->query();
                }
                // upload success
                // display success message
                if ($status) {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                    } else {
                        //j16
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); window.parent.location.reload();</script>";
                    }
                }
            } else {
                // failed uploading
                // display an error message
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                } else {
                    if (version_compare(JVERSION, '3.0.0', '<')) {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); window.parent.SqueezeBox.close();</script>";
                    } else {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                    }
                }
            }
            $showTemplates = false;
            break;
        case 'preview':
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
            $id = JRequest::getInt('template_id', 0, 'request');
            $body = jNews_Templates::loadOneTemplate('body', $id);
            jNews_Templates::includeStyles($body, $id);
            jNews_TemplatesHTML::previewTemplate($body, $forms);
            $showTemplates = false;
            break;
        case 'assign':
            $templatesearch = JRequest::getVar('templatesearch', '');
            $linkTh = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true);
            $forms['main'] = "<form action=" . $linkTh . " method='post' name='adminForm' id=\"adminForm\">";
            $paginationStart = JRequest::getVar('pg');
            if (!empty($paginationStart)) {
                $limitstart = 0;
                $limitend = $paginationStart;
            } else {
                $app = JFactory::getApplication();
                $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
                $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
            }
            $limittotal = jNews_Templates::countTemplates(1, 1);
            $setLimit = new stdClass();
            $setLimit->total = !empty($limittotal) ? $limittotal : 0;
            $setLimit->start = !empty($limitstart) ? $limitstart : 0;
            $setLimit->end = !empty($limitend) ? $limitend : 20;
            $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1);
            //first param to true to show only the published
            jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch);
            $showTemplates = false;
            break;
    }
    if ($showTemplates) {
        $start = JRequest::getVar('start', '0');
        $templatesearch = JRequest::getVar('templatesearch', '');
        $limit = -1;
        $message = isset($message) ? $message : '';
        backHTML::_header(_JNEWS_TEMPLATES, $img, $message, $task, $action);
        $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
        backHTML::formStart('show_template', '', '');
        // added this code for pagination ===========================
        $paginationStart = JRequest::getVar('pg');
        $app = JFactory::getApplication();
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order', 'filter_order', 'premium', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
        $limittotal = jNews_Templates::countTemplates();
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        // recheck start
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $templates = jNews_Templates::getTemplates(false, false, $templatesearch, $setLimit->start, $setLimit->end, $setSort);
        //recheck limit total [pagination]
        if (isset($setLimit->total) && !empty($templatesearch)) {
            $setLimit->total = !empty($temps) ? count($templates) : $setLimit->total;
        }
        jNews_TemplatesHTML::displayTemplateList($templates, $forms, $setLimit->start, $setLimit->end, $templatesearch, $action, $setLimit, $setSort);
        $go[] = jnews::makeObj('act', 'templates');
        $go[] = jnews::makeObj('filter_order', $setSort->orderValue);
        $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir);
        backHTML::formEnd($go);
    }
    return true;
}
예제 #6
0
function checkTag()
{
    if ($GLOBALS[JNEWS . 'sntag_norequired']) {
        return true;
    }
    $content = JRequest::getVar('jnewsContent', '', 'request', 'string', JREQUEST_ALLOWRAW);
    $alt_content = JRequest::getVar('textcontent_', '', JREQUEST_ALLOWRAW);
    if (empty($alt_content)) {
        $alt_content = jNews_ProcessMail::htmlToText($content);
    }
    $inHTML = strpos($alt_content, '[SMARTNEWSLETTER]');
    $inText = strpos($content, '[SMARTNEWSLETTER]');
    $inHTMLK2 = strpos($alt_content, '[SMARTK2]');
    $inTextK2 = strpos($content, '[SMARTK2]');
    $inHTMLflex = strpos($alt_content, '[SMARTFLEXI]');
    $inTexflex = strpos($content, '[SMARTFLEXI]');
    if ($inHTML === false and $inText === false and $inHTMLflex === false and $inTexflex === false and $inHTMLK2 === false and $inTextK2 === false) {
        $text = _JNEWS_NOSMARTTAG;
        echo "<script> alert('" . addslashes($text) . "'); window.history.go(-1);</script>\n";
        return false;
    }
    return true;
}
예제 #7
0
파일: jnews.php 프로젝트: naka211/kkvn
             //donot need to check captcha
         } else {
             $security_captcha_enter = JRequest::getVar('security_code');
             if ($_SESSION['captcha'] != strtolower($security_captcha_enter)) {
                 ob_end_clean();
                 echo "<script>alert('" . addslashes(_JNEWS_CAPTCHA_MSG) . "'); window.history.go(-1);</script>\n";
                 break;
             }
         }
     }
     JRequest::checkToken() or die('Invalid Token');
     $message = jnews::printYN(jNews_Subscribers::updateCBFESubscriber(), _JNEWS_UPDATED_SUCCESSFULLY, _JNEWS_ERROR);
     $showPanel = true;
     break;
 case 'log':
     jNews_ProcessMail::logStatistics($mailingId);
     break;
 case 'rendermod':
     require_once JNEWSPATH_CLASS . 'rendermod.php';
     $rendMod = new jnews_renderMod();
     $rendMod->renderModule();
     break;
 case 'updatesubscription':
     $message = frontEnd::updateFrontSubscription($subscriberId);
     if (!empty($redirectlink)) {
         jNews_Tools::redirect($redirectlink, $message);
     } else {
         $showPanel = true;
     }
     break;
 case 'module':
예제 #8
0
파일: install.php 프로젝트: naka211/kkvn
function sendWelcomeEmail()
{
    $my = JFactory::getUser();
    $docuLink = JNEWS_HOME_SITE . '/index.php?option=com_jlinks&controller=redirect&link=doc_jnews';
    $liveChatLink = JNEWS_HOME_SITE . '/index.php?option=com_jlinks&controller=redirect&link=live-chat';
    $moduleDocu = JNEWS_HOME_SITE . '/index.php?option=com_jlinks&controller=redirect&link=Mod_jnews';
    $content = 'Hi ' . $my->name . ',<br /><br />Welcome to jNews!<br />This is a welcome email to jNews and also an email to let you know that everything has been configured and you can now start using sending newsletter with jNews. In case you need more information here are some useful links:<br />
	 	<br />For jNews documentation <a href="' . $docuLink . '" target=_blank>Click here</a>.<br />
	 	<br />Talk to one of our representative through <a href="' . $liveChatLink . '" TARGET="_NEW">Live Chat</a>.<br />
	 	<br />Want to setup your newsletter module here is the documentation to <a href="' . $moduleDocu . '" TARGET="_NEW">configure jNews Module</a>.<br />
	 	<br />This is an automatic email sent by jNews to you after the installation. Please don\'t reply.<br /> All the best from the Joobi team!';
    $subject = 'Welcome to jNews, everything is setup properly.';
    return jNews_ProcessMail::sendExtraEmail($content, $subject, $my->email, $my->name);
}
예제 #9
0
파일: jnewsbot.php 프로젝트: naka211/kkvn
function jnewsbot_jcalpro_transformall(&$html, &$text, &$subject, $queueInfo = null)
{
    $db = JFactory::getDBO();
    $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
    preg_match_all('#{jcalevent:.{7,15}}#', $html . $text, $tags);
    $replace = array();
    $replacebyHTML = array();
    $replacebyText = array();
    if (!empty($tags[0])) {
        foreach ($tags[0] as $tag) {
            $isolate = explode(':', $tag);
            if (count($isolate) != 2) {
                continue;
            }
            $parameters = explode('|', $isolate[1]);
            if (count($parameters) != 4) {
                continue;
            }
            if (!empty($replace[$tag])) {
                continue;
            }
            $replace[$tag] = $tag;
            $query = 'SELECT `title`, `description`, `end_date`, `start_date`, `extid` from #__jcalpro2_events where `extid` = ' . intval($parameters[0]);
            $db->setQuery($query);
            $event = $db->loadObject();
            $db->loadObject($event);
            if (empty($event->extid)) {
                $replacebyHTML[$tag] = '';
                $replacebyText[$tag] = '';
                continue;
            }
            if (get_magic_quotes_runtime()) {
                $event->title = stripslashes($event->title);
                $event->description = stripslashes($event->description);
            }
            $eventhtml = '';
            if ($parameters[2]) {
                $eventhtml .= '<div class="aca_jcalcontent">';
            }
            $eventhtml .= '<span class="aca_jcaltitle">' . $event->title . '</span>';
            $eventtext = strtoupper(jNews_ProcessMail::htmlToText($event->title));
            if ($parameters[1]) {
                $start_date_array = explode('-', $event->start_date);
                $start_time_array = explode(':', substr($event->start_date, 10, 15));
                $date = strftime(JText::_('DATE_FORMAT_LC'), mktime($start_time_array[0], $start_time_array[1], 0, $start_date_array[1], $start_date_array[2], $start_date_array[0]));
                $eventhtml .= '<br/>' . $date;
                $eventtext .= "\r\n" . $date;
            }
            if ($parameters[2]) {
                $eventhtml .= '<br/>' . $event->description;
                $eventtext .= "\r\n" . jNews_ProcessMail::htmlToText($event->description);
            }
            if ($parameters[3]) {
                $link = 'option=com_jcalpro&extmode=view&extid=' . $event->extid . '&Itemid=' . $Itemid;
                $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
                $eventhtml .= '<br/><a href="' . $link . '"><span class="aca_readmore">' . _JNEWS_READMORE . '</span></a>';
                $eventtext .= "\r\n" . ' * ' . _JNEWS_READMORE . ' ( ' . $link . ' )';
            }
            if ($parameters[2]) {
                $eventhtml .= '</div>';
            }
            $replacebyHTML[$tag] = $eventhtml;
            $replacebyText[$tag] = $eventtext;
        }
    }
    $html = str_replace($replace, $replacebyHTML, $html);
    $text = str_replace($replace, $replacebyText, $text);
}
예제 #10
0
파일: jnews.php 프로젝트: naka211/kkvn
function configuration($action, $task)
{
    $db = JFactory::getDBO();
    $config = array();
    $redirect = true;
    $xf = new jNews_Config();
    $message = JRequest::getVar('message', '');
    $clear_log = JRequest::getVar('clear_log', '0');
    switch ($task) {
        case 'syncUsers':
            echo jnews::printYN(jNews_Subscribers::syncSubscribers(), _JNEWS_SYNC_USERS_SUCCESS, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
        case 'sendtest':
            $my = JFactory::getUser();
            $mailing = new stdClass();
            $status = false;
            $mailing->id = 1;
            $mailing->images = '';
            $mailing->attachments = '';
            $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']);
            $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']);
            if (empty($mailing->fromemail)) {
                $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']);
            }
            ### create the mail
            $mail = jNews_ProcessMail::getMailer($mailing);
            ### create content
            $mail->IsHTML(true);
            $mail->Body = '<p>This message has been sent at ' . date('l, j F Y h:i:s', jnews::getNow(0, true)) . ' from ' . JNEWS_JPATH_LIVE . ' to test your mail configuration.</p><br/><p style="color:green;">' . _JNEWS_SENDTEST_CONFIGSUCC . '</p>';
            $mail->AddAddress($my->email, $my->name);
            $mail->Subject = 'Test Email from ' . JNEWS_JPATH_LIVE;
            $status = $mail->Send();
            $success = 'Email "' . $mail->Subject . '" successfully sent to ' . $my->name . ' (' . $my->email . ')';
            $error = 'Failed sending "' . $mail->Subject . '" to ' . $my->name . ' (' . $my->email . '). <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
            $message = is_bool($status) && $status ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            echo $message;
            break;
        case 'apply':
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            if ($clear_log != 0) {
                @unlink(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file']);
            }
            $config = JRequest::getVar('config');
            $message = jnews::printYN($xf->saveConfig($config), _JNEWS_CONFIG_UPDATED, _JNEWS_ERROR);
            $listCreator = JRequest::getVar('list_creatorfe', '', 'post');
            if (!empty($listCreator)) {
                $xf->update('list_creatorfe', $listCreator);
            }
            //we update the active list
            $xf->updateActiveList();
            if ($GLOBALS[JNEWS . 'level'] > 1) {
                //we require the cron controller
                require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'cron.jnews.php';
                //we update the published/enabld of the jnews cron plugin according to what is selected
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    $db->setQuery("UPDATE `#__plugins` SET `published` = " . $config['jnewscronplugin'] . " WHERE `element`='jnewscron' ");
                } else {
                    //j16
                    $db->setQuery("UPDATE `#__extensions` SET `enabled` = " . $config['jnewscronplugin'] . " WHERE `type` = 'plugin' AND `element`='jnewscron' ");
                }
                $db->query();
                //Joobi Cron System
                $cron = $GLOBALS[JNEWS . 'j_cron'];
                if ($cron == 2) {
                    joobiCron('Yes');
                } else {
                    joobiCron('No');
                }
            }
            if ($task == 'apply') {
                backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
                jNews_ConfigHTML::showConfigEdit();
                echo $message;
            } else {
                backHTML::controlPanel();
            }
            break;
        case 'cancel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'acaupdate':
            // update jnews datas from acajoom
            $msg = jNews_TableUpdate::executeUpdate();
            echo $msg . '<br><br>';
        default:
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
    }
    return true;
}
예제 #11
0
 /**
  *
  * function to send extra mails eg: welcome email, test email, notification that the mailing is sending, notifciation that the mailing has finished sending
  * @param unknown_type $content - content the mail
  * @param unknown_type $subject - subject of the mail
  * @param unknown_type $name - name of the user to be sent
  * @param unknown_type $email - email ofthe user to be sent
  */
 public static function sendExtraEmail($content, $subject, $email, $name, $username = '')
 {
     $mailing = new stdClass();
     $status = false;
     $mailing->id = 1;
     $mailing->images = '';
     $mailing->attachments = '';
     $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']);
     $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']);
     if (empty($mailing->fromemail)) {
         $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']);
     }
     ### create the mail
     $mail = jNews_ProcessMail::getMailer($mailing);
     ### create content
     $mail->IsHTML(true);
     $mail->Body = $content;
     $mail->AddAddress($email, $name);
     $mail->Subject = $subject;
     // DKIM code addition by Amod begins
     $mail = self::_addDKIM($mail);
     // DKIM code addition by Amod ends
     $status = $mail->Send();
     return $status;
 }
예제 #12
0
 public static function sendTestEmail($mailingId, $listId)
 {
     $list = new stdClass();
     $new = null;
     $mailing = jNews_Mailing::getOneMailing($list, $mailingId, '', $new);
     if ($listId > 0) {
         $list = jNews_Lists::getOneList($listId);
     } else {
         $list = jNews_Lists::getOneList($mailing->list_id);
     }
     $previewemailaddress = JRequest::getVar('emailaddress', '');
     $previewname = JRequest::getVar('name', '');
     $previewhtml = JRequest::getVar('html', '0');
     $receivers = new stdClass();
     $my = JFactory::getUser();
     $d['email'] = trim($previewemailaddress);
     $infos = jNews_Subscribers::getSubscriberIdFromEmail($d);
     if (empty($infos['subscriberId'])) {
         $d['email'] = $my->email;
         $infos = jNews_Subscribers::getSubscriberIdFromEmail($d);
     }
     if (!empty($infos['subscriberId'])) {
         $receivers = jNews_Subscribers::getSubscribersFromId(array($infos['subscriberId']));
     } else {
         $receivers->id = 0;
     }
     $receivers->email = $previewemailaddress;
     $receivers->name = $previewname;
     $receivers->receive_html = $previewhtml;
     $mailerC = new jNews_ProcessMail();
     return $mailerC->send($mailing, $receivers);
 }
예제 #13
0
/**
 * <p>Function to send/forward the mailings to a the friends</p>
 * @param object $mailing - the mailing object that will be sent. Its from a query
 * @param object $messagePlgin  - the messages in the parameter of the plugin
 * @param array $receiversNames - the name to whom the mail to be forwarded
 * @param array $receiversEmails - the emails where the mail to be forwarded
 * @param object $list - the list where the mailing belongs.
 */
function sendtofriend($mailing = null, $messagePlgin = null, $receiversNames = '', $receiversEmails = '', $list = null)
{
    $message = '';
    $receivers = null;
    $inEmailMessageHTML = '<br/><div align="left" style="border: 1px solid rgb(239, 236, 186); padding: 5px; background-color: rgb(251, 250, 231); text-align: left;">';
    $replaceWhat = array('[FWDEMAIL]', '[FWDNAME]');
    $replaceBy = array($mailing->fromemail, $mailing->name);
    $inEmailMessageHTML .= str_replace($replaceWhat, $replaceBy, $messagePlgin->inEmail);
    $inEmailMessageHTML .= '</div><br/>';
    $body = $messagePlgin->dflt . '<br/>' . $inEmailMessageHTML . $mailing->htmlcontent;
    $textonly = $messagePlgin->dflt . $messagePlgin->inEmail . $mailing->textonly;
    $mailing->htmlcontent = $body;
    $mailing->textonly = $textonly;
    $receivers->receive_html = $list->html;
    $status = true;
    $successM = '';
    static $mailerC = null;
    if (!isset($mailerC)) {
        $mailerC = new jNews_ProcessMail();
    }
    foreach ($receiversNames as $key => $receiversName) {
        $receivers->name = $receiversName;
        $receivers->email = $receiversEmails[$key];
        //		$reWhat = array('[FWDEMAIL]','[FWDNAME]', '[NAME]','[FIRSTNAME]','[USERNAME]');
        $reWhat = array('[FWDEMAIL]', '[FWDNAME]', '{tag:name}', '{tag:firstname}', '{tag:username}');
        $reBy = array($mailing->fromemail, $mailing->name, $receiversName, $receiversName, $receiversName);
        $mailing->htmlcontent = str_replace($reWhat, $reBy, $mailing->htmlcontent);
        $mailing->textonly = str_replace($reWhat, $reBy, $mailing->textonly);
        if (!$mailerC->send($mailing, $receivers)) {
            $status = false;
        }
        if ($status) {
            $successM .= _JNEWS_FWDTOFRIEND_SUCCESS . $receiversName . '.<br>';
        } else {
            $successM .= _JNEWS_FWDTOFRIEND_FAILED . $receiversName . '.<br>';
        }
    }
    // 	$url = JURI::current().'?option='.JNEWS_OPTION.'&act=fwdtofriend&frmname='.base64_encode($mailing->fromname).'&frmemail='.base64_encode($mailing->fromemail).'&mailingid='.$mailing->id;
    $url = 'index.php?option=' . JNEWS_OPTION . '&act=fwdtofriend&frmname=' . base64_encode($mailing->fromname) . '&frmemail=' . base64_encode($mailing->fromemail) . '&mailingid=' . $mailing->id;
    jNews_Tools::redirect($url, $successM);
}
예제 #14
0
    /** Send element stored in the queue
     * @return bool if the queue still have values to be sent then return true ( for manual send ) otherwise return false
     */
    function sendQueue($showHTML = false, $mailingId = null, $onlyAutoRsponder = false, $manualSend = false)
    {
        $showHTML = true;
        $stillProcess = null;
        $maxTask = $manualSend ? $this->limitEmails : $this->maxQueue;
        if ($maxTask < 1) {
            $maxTask = 1;
        }
        if ($maxTask > 1000) {
            $maxTask = 1000;
        }
        //8889990
        $arPRiority = empty($GLOBALS[JNEWS . 'ar_prior']) ? 1 : $GLOBALS[JNEWS . 'ar_prior'];
        //get all the queue
        $query = 'SELECT A.qid,A.subscriber_id,A.attempt, A.params as `qparams`, A.delay as `qdelay`, B.* FROM `#__jnews_queue` as A';
        $query .= ' LEFT JOIN `#__jnews_mailings` as B on A.mailing_id = B.id ';
        $query .= ' WHERE A.send_date <= ' . time() . ' AND B.published > 0 AND A.type != 8 AND A.type != 99';
        if (!empty($mailingId)) {
            $query .= ' AND A.mailing_id = ' . $mailingId;
        }
        if ($onlyAutoRsponder && $GLOBALS[JNEWS . 'level'] > 1) {
            $query .= ' AND A.`priority` = ' . $arPRiority;
        }
        //do not select the suspend
        $query .= ' AND `suspend`= 0';
        //filter for unconfirmed subscribers
        $query .= ' AND `block` = 0';
        //filter the entries are still being processed from the last sending/processing of the queue
        $query .= ' ORDER BY A.`priority` ASC, A.send_date ASC';
        $query .= ' LIMIT ' . $maxTask;
        $this->db->setQuery($query);
        $allQueuedA = $this->db->loadObjectList();
        $error = $this->db->getErrorMsg();
        if (!empty($error)) {
            //prompt message if an error occured while retrieving entries from the queue
            echo '<br><br><span style="font-weight:bold; font-style:italic; color:blue;">' . _JNEWS_QUEUE_PROCESS_ERROR . '<span><br><br>';
            echo $error;
        }
        if (empty($allQueuedA)) {
            echo '<br><br><span style="font-weight:bold; font-style:italic; color:blue;">' . _JNEWS_NO_MAILINGS_YET . '<span>';
            // prompt message if there is nothing to send
            jNews_Queue::sendReport();
            return false;
        }
        //we update the retrieved allQueuedA to blocked so that  the entries will not be processed double
        foreach ($allQueuedA as $oneQueue) {
            $this->updateQueueBlock($oneQueue->qid, 1);
        }
        $totalSubscribers = count($allQueuedA);
        //make an array of all subscribers and all mailings
        $mySubcribersA = array();
        $subscribersPerMailingsA = array();
        foreach ($allQueuedA as $oneQueue) {
            $mySubcribersA[$oneQueue->subscriber_id] = true;
        }
        //get all the subcribers
        $query = 'SELECT A.`id`,A.`user_id`,A.`name`,A.`email`,A.`receive_html`,A.`confirmed`,A.`blacklist`, B.`id` AS \'user\' ';
        if ($GLOBALS[JNEWS . 'level'] > 2) {
            //check if the version of jnews is pro
            if ($GLOBALS[JNEWS . 'show_column1']) {
                $query .= ',A.`column1`';
            }
            if ($GLOBALS[JNEWS . 'show_column2']) {
                $query .= ',A.`column2`';
            }
            if ($GLOBALS[JNEWS . 'show_column3']) {
                $query .= ',A.`column3`';
            }
            if ($GLOBALS[JNEWS . 'show_column4']) {
                $query .= ',A.`column4`';
            }
            if ($GLOBALS[JNEWS . 'show_column5']) {
                $query .= ',A.`column5`';
            }
        }
        $query .= ' FROM `#__jnews_subscribers` AS A  ';
        $query .= ' LEFT JOIN  `#__users` AS B ON A.id=B.id';
        $query .= ' WHERE A.`id` IN (' . jnews::implode(',', array_keys($mySubcribersA)) . ' )';
        $this->db->setQuery($query);
        $allSubcribersA = $this->db->loadObjectList('id');
        if (empty($allSubcribersA)) {
            jNews_Queue::sendReport();
            return false;
        }
        $mailerC = new jNews_ProcessMail();
        $queueToBeDelted = array();
        $queueToBeAttempted = array();
        $queueSuccessfullySent = array();
        $addToStatisticsA = array();
        $log_detailed = '';
        $message = '';
        $screenMsg = '';
        $maxAttempt = $GLOBALS[JNEWS . 'max_attempts'] < 1 ? 1 : $GLOBALS[JNEWS . 'max_attempts'];
        if ($this->total == 0) {
            $this->total = jNews_Queue::getQueueCount($mailingId);
        }
        //for manual sending processing
        if ($manualSend) {
            if (!headers_sent() and ob_get_level() > 0) {
                @ob_end_flush();
            }
            $url = JURI::base() . jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=continuesend&mailingid=' . $mailingId . '&totalsend=' . $this->total . '&alreadysent=', true, false, true);
            $screenMsg = "<div style='position:fixed; top:3px;left:3px;color:orange; padding : 3px;'>";
            $screenMsg .= "<span id='waitinginfo' style='padding:10px;margin:5px;font-size:16px;font-weight:bold;display:none;background-color:#FFF8C6; color:red;'> </span>";
            $screenMsg .= '<i>' . _JNEWS_SENDING_EMAIL . ' <span id="emailcounter"/><strong>' . $this->start . '</strong></span> out of <strong>' . $this->total . '</strong>... </i>';
            $screenMsg .= "</div><div id='details' style='display:none; position:fixed; bottom:3px;left:3px;background-color : white; border : 1px solid grey; padding : 3px;'> </div><br /><br />";
            $screenMsg .= '<script type="text/javascript" language="javascript">';
            $screenMsg .= 'var myEmailCounter = document.getElementById("emailcounter");';
            $screenMsg .= 'var details = document.getElementById("details");
var waitinginfo = document.getElementById("waitinginfo");
function setDetails(message){ details.style.display = \'block\';details.innerHTML=message; }
function setWaitingInfo(waitingtime){ waitinginfo.style.display = \'\';waitinginfo.innerHTML="Waiting "+waitingtime+" seconds..."; }
function setEmailCounter(val){ myEmailCounter.innerHTML=val;}
var waitingtime = ' . intval($this->pause) . ';
function setWaitingTime(){
	setWaitingInfo(waitingtime);
	if(waitingtime > 0){
		waitingtime = waitingtime - 1;
		setTimeout(\'setWaitingTime()\',1000);
	}else{
		document.location.href=\'' . $url . '\'+myEmailCounter.innerHTML;
	}
}
</script>';
            echo $screenMsg;
            if (function_exists('ob_flush')) {
                @ob_flush();
            } else {
                @flush();
            }
        }
        //we assign counter for the current email being processed
        $counterEmail = $this->start;
        //we determine if the mailings on the queue is lesser than the limit given per batch of manual sending
        if (count($allQueuedA) < $maxTask) {
            $stillProcess = false;
        }
        //get the size of the queue
        foreach ($allQueuedA as $oneQueue) {
            $counterEmail++;
            if ($manualSend) {
                echo '<script type="text/javascript" language="javascript">setEmailCounter(' . $counterEmail . ')</script>';
                if (function_exists('ob_flush')) {
                    @ob_flush();
                }
                @flush();
            }
            //attachements
            if (!empty($oneQueue->attachments)) {
                $oneQueue->attachments = explode("\n", $oneQueue->attachments);
                if (count($oneQueue->attachments) != 0 && trim($oneQueue->attachments[count($oneQueue->attachments) - 1]) == "") {
                    array_pop($oneQueue->attachments);
                }
            } else {
                $oneQueue->attachments = array();
            }
            //images
            if (!empty($oneQueue->images)) {
                $oneQueue->images = explode("\n", $oneQueue->images);
            } else {
                $oneQueue->images = array();
            }
            //5 is maximun attempt
            if ($oneQueue->attempt >= $maxAttempt) {
                $queueToBeDelted[] = $oneQueue->qid;
                continue;
            }
            if (!isset($this->sentHTML[$oneQueue->id])) {
                $this->sentHTML[$oneQueue->id] = 0;
            }
            if (!isset($this->sentText[$oneQueue->id])) {
                $this->sentText[$oneQueue->id] = 0;
            }
            if (!isset($this->sentFailed[$oneQueue->id])) {
                $this->sentFailed[$oneQueue->id] = 0;
            }
            if (isset($allSubcribersA[$oneQueue->subscriber_id]) && is_object($allSubcribersA[$oneQueue->subscriber_id])) {
                $emailSentStatus = $mailerC->send($oneQueue, $allSubcribersA[$oneQueue->subscriber_id]);
                if ($emailSentStatus) {
                    //we update the senddate of the newsletter
                    jNews_Mailing::updatesenddate($oneQueue->id);
                }
            } else {
                continue;
            }
            if (!empty($allSubcribersA[$oneQueue->subscriber_id]->email)) {
                if ($GLOBALS[JNEWS . 'save_log']) {
                    if (!$emailSentStatus) {
                        $log_detailed .= '[' . $oneQueue->id . '] ' . $oneQueue->subject . ' : ' . $allSubcribersA[$oneQueue->subscriber_id]->email . ' -> ' . _JNEWS_MESSAGE_NOT . "\r\n" . _JNEWS_MAILER_ERROR . ': ' . $mailerC->ErrorInfo . "\r\n";
                    } else {
                        $log_detailed .= '[' . $oneQueue->id . '] ' . $oneQueue->subject . ' : ' . $allSubcribersA[$oneQueue->subscriber_id]->email . ' -> ' . _JNEWS_MESSAGE_SENT_SUCCESSFULLY . "\r\n";
                    }
                } else {
                    $log_detailed .= '[' . $oneQueue->id . '] ' . $oneQueue->subject . ' : ' . $allSubcribersA[$oneQueue->subscriber_id]->email . ' -> ' . _JNEWS_MESSAGE_SENT_SUCCESSFULLY . "\r\n";
                }
            }
            //Screen message for manual sending
            if ($manualSend) {
                if ($emailSentStatus) {
                    $message = '<strong><i>' . $oneQueue->subject . '</i></strong> ' . _JNEWS_MSG_SENT_SUCCESS . ' <strong><i>' . $allSubcribersA[$oneQueue->subscriber_id]->name . ' ( ' . $allSubcribersA[$oneQueue->subscriber_id]->email . ' )</i></strong>' . "\r\n";
                } else {
                    $message = '<i>' . _JNEWS_ATTEMPTED . ' ' . $oneQueue->subject . ' to ' . $allSubcribersA[$oneQueue->subscriber_id]->name . ' ( ' . $allSubcribersA[$oneQueue->subscriber_id]->email . ' )' . ".\r\n" . _JNEWS_RESCHEDULED . "\r\n\r\n" . _JNEWS_REACHED_MAX_ATTEMPT . "</i>\r\n\r\n";
                }
                $this->_displayDetails($message, $emailSentStatus, $counterEmail);
            }
            if ($emailSentStatus) {
                //succeess send
                $query = 'DELETE FROM `#__jnews_queue` WHERE `qid`=' . $oneQueue->qid;
                $this->db->setQuery($query);
                $this->db->query();
                if ($mailerC->html) {
                    $this->sentHTML[$oneQueue->id]++;
                } else {
                    $this->sentText[$oneQueue->id]++;
                }
                //user statistics
                if ($GLOBALS[JNEWS . 'enable_statistics'] && $GLOBALS[JNEWS . 'statistics_per_subscriber']) {
                    $addToStatisticsA[$oneQueue->id][$oneQueue->subscriber_id] = (int) $mailerC->html;
                }
                $this->sentSuccess++;
                $this->recurringError = 0;
                $queueSuccessfullySent[] = $oneQueue->qid;
                //we save the successfully sent qids so that we can differentiate from the allqueue what qids that were not processed because the max execution time has been reached
            } else {
                // failed send
                $queueToBeAttempted[] = $oneQueue->qid;
                $this->sentFailed[$oneQueue->id]++;
                $this->recurringError++;
            }
            $time = time();
            if ($this->maxExetime != 0 && $this->maxExetime <= $time) {
                $stillProcess = true;
                break;
            }
            if ($this->recurringError > 2 && $this->sentSuccess > 3) {
                $stillProcess = false;
                break;
            }
            if ($this->recurringError > 5 || connection_aborted()) {
                $stillProcess = false;
                break;
            }
        }
        //we close the processing of emails
        $mail = JFactory::getMailer();
        $mailerC->close($mail);
        if (!empty($this->total) && $counterEmail >= $this->total) {
            $stillProcess = false;
        }
        //update queue with try + 1;
        if (!empty($queueToBeAttempted)) {
            $query = 'UPDATE `#__jnews_queue` SET `attempt`=`attempt`+1,`send_date`=`send_date`+`attempt`*25299+4000, `block`= 0 WHERE `qid` IN (' . jnews::implode(',', $queueToBeAttempted) . ')';
            //we will also update the block to 0 so that it will be processed again
            $this->db->setQuery($query);
            $this->db->query();
        }
        //delete the queue when the emails are sent successfully after x number of attempts
        if (!empty($queueToBeDelted)) {
            $query = 'DELETE FROM `#__jnews_queue` WHERE `qid` IN (' . jnews::implode(',', $queueToBeDelted) . ')';
            $this->db->setQuery($query);
            $this->db->query();
        }
        //unblock again the queue that were not sent because the timeout has been reached so that they will be processed again
        if (!empty($allQueuedA)) {
            foreach ($allQueuedA as $oneQueue) {
                if (!in_array($oneQueue->qid, $queueSuccessfullySent)) {
                    $query = 'UPDATE `#__jnews_queue` SET `block` = 0 WHERE `qid` =' . $oneQueue->qid;
                    $this->db->setQuery($query);
                    $this->db->query();
                }
            }
        }
        //we update and increment the statistics
        if ($GLOBALS[JNEWS . 'enable_statistics']) {
            $this->_updateStatsGlobal($allQueuedA);
        }
        if (!empty($addToStatisticsA)) {
            $this->_insertStats($addToStatisticsA);
        }
        //we prompt message that the mailing has been sent successfully for each batch
        //		echo '<br><br><span style="font-weight:bold; font-style:italic; color:green;">'.$oneQueue->subject.' successfully sent to subscribers.'.'</span> ';
        //mailing reports
        $this->_writeLogs($log_detailed);
        if (isset($stillProcess)) {
            //manual sending
            if ($stillProcess && $manualSend) {
                echo '<script type="text/javascript" language="javascript">setWaitingTime();</script>';
            } else {
                echo '<br><br><span style="font-weight:bold; font-style:italic; color:green;">' . _JNEWS_THE_MAILING . $oneQueue->subject . _JNEWS_SENT_ALL . '</span> ';
                //					$subject = 'jNews Mailing Notification - Status: End';
                //					$content = 'The mailing '.$oneQueue->subject.' has been successfully sent.';
                //					if( version_compare(JVERSION,'1.6.0','<') ){ //j15
                //						$this->db->setQuery( "SELECT * FROM `#__users` WHERE `gid` = 25 ORDER BY `id` ASC LIMIT 1" );
                //					}else{
                //						$this->db->setQuery( "SELECT * FROM `#__users` AS U LEFT JOIN `#__user_usergroup_map` AS UGM ON U.id =UGM.user_id  WHERE `group_id` = 8 ORDER BY `id` ASC LIMIT 1" );
                //					}
                //					$admin = $this->db->loadObject();
                //
                //					JUTility::sendMail($admin->email, $admin->name, $admin->email, $subject, $content );
            }
            if (!$stillProcess) {
                jNews_Queue::sendReport();
            }
            return $stillProcess ? true : false;
        } else {
            //manual sending
            if ($manualSend && $maxTask < $this->total) {
                echo '<script type="text/javascript" language="javascript">setWaitingTime();</script>';
            } else {
                echo '<br><br><span style="font-weight:bold; font-style:italic; color:green;">' . _JNEWS_THE_MAILING . $oneQueue->subject . _JNEWS_SENT_ALL . '</span> ';
                //					$subject = 'jNews Mailing Notification - Status: End';
                //					$content = 'The mailing '.$oneQueue->subject.' has been successfully sent.';
                //					if( version_compare(JVERSION,'1.6.0','<') ){ //j15
                //						$this->db->setQuery( "SELECT * FROM `#__users` WHERE `gid` = 25 ORDER BY `id` ASC LIMIT 1" );
                //					}else{
                //						$this->db->setQuery( "SELECT * FROM `#__users` AS U LEFT JOIN `#__user_usergroup_map` AS UGM ON U.id =UGM.user_id  WHERE `group_id` = 8 ORDER BY `id` ASC LIMIT 1" );
                //					}
                //					$admin = $this->db->loadObject();
                //
                //					JUTility::sendMail($admin->email, $admin->name, $admin->email, $subject, $content );
            }
            if ($this->maxQueue > count($allQueuedA)) {
                jNews_Queue::sendReport();
            }
            return $this->maxQueue > count($allQueuedA) ? false : true;
        }
    }
예제 #15
0
 /** public static function to put the CSS in the mailing
  * @param string $body
  * @param int $templateId
  */
 public static function includeStyles(&$body, $templateId)
 {
     static $checkMe = true;
     $body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $body);
     jNews_ProcessMail::normalizeURL($body);
     $body = preg_replace('#< *img([^>]*)(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', '<img$1 align="$4" hspace="5" $2$3$4', $body);
     //load template
     $template = jNews_Templates::loadOneTemplate('*', $templateId);
     $template->csstyle = jNews_Templates::cleanCSSComments($template->csstyle);
     if (!empty($template->styles) || !empty($template->csstyle)) {
         $csstyle = jNews_Templates::convertCSSInline($template->styles, $template->csstyle);
     }
     $themeCSS = array();
     if (!empty($template->styles)) {
         foreach ($template->styles as $cName => $sContent) {
             if ($cName != 'color_bg') {
             } elseif (preg_match('#^tag_(.*)$#', $cName, $result)) {
                 $mainStyle['#< *' . $result[1] . '((?:(?!style).)*)>#Ui'] = '<' . $result[1] . ' style="' . $sContent . '" $1>';
             } else {
                 $themeCSS['class="' . $cName . '"'] = 'style="' . $sContent . '"';
             }
         }
     }
     if (!empty($mainStyle)) {
         $body = preg_replace(array_keys($mainStyle), $mainStyle, $body);
     }
     if (!empty($themeCSS)) {
         $body = str_replace(array_keys($themeCSS), $themeCSS, $body);
     }
     if (!empty($template->styles['color_bg'])) {
         $pattern1 = '#^([^<]*<[^>]*background-color:)([^;">]{1,10})#i';
         $found = false;
         if (preg_match($pattern1, $body)) {
             $body = preg_replace($pattern1, '$1' . $template->styles['color_bg'], $body);
             $found = true;
         }
         $pattern2 = '#^([^<]*<[^>]*bgcolor=")([^;">]{1,10})#i';
         if (preg_match($pattern2, $body)) {
             $body = preg_replace($pattern2, '$1' . $template->styles['color_bg'], $body);
             $found = true;
         }
         if (!$found) {
             $body = '<div style="background-color:' . $template->styles['color_bg'] . ';" width="100%">' . $body . '</div>';
         }
     }
     if ($checkMe) {
         if (version_compare(PHP_VERSION, '5.0.0', '>=') && class_exists('DOMDocument') && function_exists('mb_convert_encoding')) {
             require_once JNEWS_PATH_INCLUDES . 'emogrifier' . DS . 'emogrifier.php';
         }
         $checkMe = false;
     }
     if (!empty($csstyle) && class_exists('Emogrifier')) {
         $emogrifier = new Emogrifier($body, $csstyle);
         $body = $emogrifier->emogrify();
         if (strpos($body, '<!DOCTYPE') !== false) {
             $body = preg_replace('#<\\!DOCTYPE.*<body([^>]*)>#Usi', '', $body);
             $body = preg_replace('#</body>.*$#si', '', $body);
         }
     }
 }
예제 #16
0
파일: content.php 프로젝트: naka211/kkvn
 function _convertAndLayoutText($articleA, $layout)
 {
     global $mainframe;
     if (empty($layout)) {
         $layout = 1;
     }
     foreach ($articleA as $oneArticle) {
         if (version_compare(JVERSION, '1.6.0', '<')) {
             $Itemid = $mainframe->getItemId($oneArticle->id);
         }
         if (empty($Itemid)) {
             $Itemid = $GLOBALS[JNEWS . 'itemidAca'];
         }
         if ($GLOBALS[JNEWS . 'show_author'] == 1) {
             $author = "\r\n" . $oneArticle->created_by_alias;
         } else {
             $author = '';
         }
         $oneArticle->title = "<b>" . strtoupper(jNews_ProcessMail::htmlToText($oneArticle->title)) . "</b>";
         $oneArticle->introtext = jNews_ProcessMail::htmlToText($oneArticle->introtext);
         $oneArticle->fulltext = jNews_ProcessMail::htmlToText($oneArticle->fulltext);
         if ($layout == 0) {
             $text = $oneArticle->title . $author . "\r\n" . $oneArticle->introtext . "\r\n" . $oneArticle->fulltext . "\r\n" . $text;
         } else {
             $link = 'option=com_content&view=article&id=' . $oneArticle->id . '&Itemid=' . $Itemid;
             $link = jNews_Tools::completeLink($link, false, $GLOBALS[JNEWS . 'use_sef']);
             if ($layout == 1) {
                 if (empty($oneArticle->fulltext) and !empty($GLOBALS[JNEWS . 'word_wrap'])) {
                     if (strlen($oneArticle->introtext) > $GLOBALS[JNEWS . 'word_wrap']) {
                         $oneArticle->introtext = substr(strip_tags($oneArticle->introtext), 0, $GLOBALS[JNEWS . 'word_wrap']) . '...';
                     }
                 }
                 $text = $oneArticle->title . $author . "\r\n" . $oneArticle->introtext . "\r\n" . '* ' . _JNEWS_READMORE . ' ( ' . $link . ' )' . "\r\n";
             } else {
                 $text = $oneArticle->title . ' ( ' . $link . ' )';
             }
         }
         $text = str_replace('{mosimage}', '', $text);
     }
     $text = str_replace('{mospagebreak}', "\r\n \r\n", $text);
 }