function insertMailing($mailing) { global $database; $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); $erro->ck = xmailing::insertMailingData($mailing); if ($erro->Eck(__LINE__, '8417')) { $query = 'SELECT `id` FROM `#__acajoom_mailings` WHERE '; $query .= ' `list_id` = ' . $mailing->list_id . ' AND `issue_nb` = \'' . $mailing->issue_nb . '\''; $query .= ' AND `author_id` = ' . $mailing->author_id . ' AND `list_type` = \'' . $mailing->list_type . '\''; $query .= ' AND `published` != -1'; $database->setQuery($query); $mailingId = $database->loadResult(); $erro->err = $database->getErrorMsg(); if (!$erro->E(__LINE__, '8418', $database)) { return ''; } else { return $mailingId; } } else { return ''; } }
function updateList($listId, $listUpdated, $status, $new) { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); $total = 0; @set_time_limit(0); if ($listUpdated->list_type != '7' and $listUpdated->delay_min > $listUpdated->delay_max) { $listUpdated->delay_min = $listUpdated->delay_max; } $erro->ck = lists::updateListData($listUpdated); if (!$erro->Eck(__LINE__, '8304')) { return false; } else { if ($listUpdated->auto_add == 2) { subscribers::updateSubscribers(true); $subscribers = subscribers::getSubscribers(-1, -1, '', $total, 0, '', 1, 1, ''); $subId = acajoom::convertObjectToIdList($subscribers, 'id'); if (!empty($subId)) { $erro->ck = queue::updateQueues($subId, '', $listId, $listUpdated->acc_id, $new); if (!$erro->Eck(__LINE__, '8305')) { return false; } } } elseif ($status == '' and $listUpdated->list_type == 2) { $queues = queue::getAllOneList($listId); $qid = acajoom::convertObjectToIdList($queues, 'qid'); $erro->ck = queue::updatePublished($qid, $status); if (!$erro->Eck(__LINE__, '8306')) { return false; } } else { if (class_exists('auto')) { auto::updateListNb($listUpdated->list_type, $listUpdated->id); } } } lisType::updateNewsletters(); return true; }
function sendSchedule($d, $showHTML, $receivers, $list, &$message, &$max, $tags = null) { static $countEmails = 0; $mailing = $d['mailing']; $h = ''; $xf = new xonfig(); if (empty($mailing)) { $message = _ACA_NO_MAILING_ENTERED; return false; } elseif (empty($receivers)) { $message = _ACA_NO_ADDRESS_ENTERED; return false; } elseif (empty($list)) { $message = _ACA_NO_LIST_ENTERED; return false; } else { $message = ''; } $mailingId = $mailing->id; $issue_nb = $mailing->issue_nb; $subject = $mailing->subject; $content = $mailing->htmlcontent; $textonly = $mailing->textonly; $fromname = $mailing->fromname; $fromemail = $mailing->fromemail; $images = $mailing->images; $listId = $list->id; $html = $list->html; $layout = $list->layout; $totalsofar = number_format(0, 4, ',', ''); $nbPause = 0; $tags['issuenb'] = $issue_nb; //Just in case of... @ini_set('max_execution_time', 0); @ini_set('memory_limit', '128M'); ignore_user_abort(true); ### create the mail $mail = acajoom_mail::getMailer($mailing); ### create content acajoom_mail::getContent($images, $layout, $content, $textonly, true); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $html_sent = 0; $text_sent = 0; $size = sizeof($receivers); $format = defined('_DATE_FORMAT_LC') ? _DATE_FORMAT_LC : JText::_('DATE_FORMAT_LC'); $log_detailed = "\r\n" . "\r\n" . '*** ' . strftime($format) . ' ***' . "\r\n"; //variables used in integration of jLinks $mailCatID = null; $convertedLinks = null; foreach ($receivers as $receiver) { $tags['user_id'] = $receiver->user_id; if ($html && intval($receiver->receive_html) == 1) { $mail->IsHTML(true); $ashtml = 1; $Altbody = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, 0, $tags); $mail->AltBody = acajoom_mail::safe_utf8_encode($Altbody, $mail->CharSet); $html_sent++; $mail->Body = acajoom_mail::replaceTags($content, $receiver, $list, $mailingId, $ashtml, $tags); acajoom_mail::replaceClass($mail->Body, $mail->AltBody, $receiver); } else { $mail->IsHTML(false); $mail->AltBody = ''; $ashtml = 0; $text_sent++; $mail->Body = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, $ashtml, $tags); $simpleText = ''; acajoom_mail::replaceClass($mail->Body, $simpleText, $receiver); } $tname = explode(" ", $receiver->name); $firstname = $tname[0]; $toUser = $GLOBALS[ACA . 'minisendmail'] ? '' : $receiver->name; $mail->AddAddress($receiver->email, $toUser); if (!empty($receiver->id)) { $mail->addCustomHeader("X-SubscriberID: {$receiver->id}"); } $username = empty($receiver->username) ? $firstname : $receiver->username; $date = ACA_CMSTYPE ? JHTML::_('date', acajoom::getNow(), JText::_('DATE_FORMAT_LC1'), 0) : mosFormatDate(acajoom::getNow(), '', 0); $replaceWhat = array('[NAME]', '[FIRSTNAME]', '[USERNAME]', '[DATE]'); $replaceBy = array($receiver->name, $firstname, $username, $date); $sujetReplaced = str_replace($replaceWhat, $replaceBy, $subject); if (class_exists('auto')) { auto::tags($sujetReplaced, $tags); } $mail->Subject = $sujetReplaced; if ($GLOBALS[ACA . 'embed_images']) { acajoom_mail::embedImages($mail); } $mailssend = $mail->Send(); $countEmails++; if ($countEmails >= $GLOBALS[ACA . 'cron_max_emails']) { $max = true; } if (!$mailssend || $mail->error_count > 0) { static $info = false; if (!$info and acajoom::checkPermissions('admin')) { echo '<br/>Mailer Error : ' . $mail->ErrorInfo; echo " : Newsletter '{$sujetReplaced}' to {$receiver->email}"; $info = true; } $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_NOT . "\r\n" . _ACA_MAILER_ERROR . ': ' . $mail->ErrorInfo . "\r\n"; if ($html && intval($receiver->receive_html) == 1) { $html_sent--; } else { $text_sent--; } if (!subscribers::validEmail($receiver->email, true)) { $deleteQueue = array(); $deleteQueue[0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); queue::deleteQueues($deleteQueue); } } else { $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_SENT_SUCCESSFULLY . "\r\n"; if ($GLOBALS[ACA . 'enable_statistics'] == 1 and $GLOBALS[ACA . 'statistics_per_subscriber'] == 1) { xmailing::insertStats($mailingId, $receiver->id, $ashtml); } $d['qids'] = array(); $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); if ($d['listype'] == '2') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = auto::updateAutoresponderSent($d); $erro->Eck(__LINE__, '8137', $d); } elseif ($d['listype'] == '1' || $d['listype'] == '7') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = queue::deleteQueues($d['qids']); $erro->Eck(__LINE__, '8127', $d); } } $mail->ClearAddresses(); } if ($GLOBALS[ACA . 'enable_statistics'] == 1) { xmailing::updateStatsGlobal($mailingId, $html_sent, $text_sent, false); } $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; if ($totalsofar > 0) { $totaltime = $totalsofar; $totalstr = strval($totaltime); } else { $totaltime = number_format($endtime - $starttime - $nbPause * $GLOBALS[ACA . 'pause_time'], 4, ',', ''); $totalstr = strval($totaltime); } $xf->plus('totalmailingsent' . $list->list_type, $html_sent + $text_sent); $xf->plus('totalmailingsent0', $html_sent + $text_sent); $log_simple = 'Time to send: ' . $totalstr . ' ' . _ACA_SECONDS . "\r\n" . 'Number of subscribers: ' . ($text_sent + $html_sent) . "\r\n" . 'HTML format: ' . $html_sent . "\r\n" . 'Text format: ' . $text_sent . "\r\n"; $log_detailed = $log_simple . 'Details: ' . "\r\n" . $log_detailed . "\r\n"; if (class_exists('lisType')) { acajoom_mail::writeLogs($list, $log_simple, $log_detailed); } if ($d['listype'] == '2') { echo '<br/>' . _ACA_QUEUE_AUTO_PROCESSED; } elseif ($d['listype'] == '1') { echo '<br/>' . _ACA_QUEUE_NEWS_PROCESSED; } if ($html_sent + $text_sent > 0) { return true; } else { $message = xmailing::M('no', _ACA_NO_MAILING_SENT); return false; } }
function sendSchedule($d, $showHTML, $receivers, $list, &$message, &$max, $tags = null) { static $countEmails = 0; $mailing = $d['mailing']; $h = ''; $xf = new xonfig(); if (empty($mailing)) { $message = _ACA_NO_MAILING_ENTERED; return false; } elseif (empty($receivers)) { $message = _ACA_NO_ADDRESS_ENTERED; return false; } elseif (empty($list)) { $message = _ACA_NO_LIST_ENTERED; return false; } else { $message = ''; } $mailingId = $mailing->id; $issue_nb = $mailing->issue_nb; $subject = $mailing->subject; $content = $mailing->htmlcontent; $textonly = $mailing->textonly; $fromname = $mailing->fromname; $fromemail = $mailing->fromemail; $images = $mailing->images; $listId = $list->id; $html = $list->html; $layout = $list->layout; $totalsofar = number_format(0, 4, ',', ''); $nbPause = 0; $tags['issuenb'] = $issue_nb; if (ini_get('safe_mode')) { } else { @set_time_limit(60 * $GLOBALS[ACA . 'script_timeout']); } ignore_user_abort(true); ### create the mail $mail = acajoom_mail::getMailer($mailing); ### create content acajoom_mail::getContent($images, $layout, $content, $textonly); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; $html_sent = 0; $text_sent = 0; $size = sizeof($receivers); $log_detailed = "\r\n" . "\r\n" . '*** ' . strftime(_DATE_FORMAT_LC) . ' ***' . "\r\n"; foreach ($receivers as $receiver) { $tags['user_id'] = $receiver->user_id; if ($html && intval($receiver->receive_html) == 1) { $mail->IsHTML(true); $ashtml = 1; $Altbody = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, 0, $tags); $mail->AltBody = acajoom_mail::safe_utf8_encode($Altbody, $mail->CharSet); $html_sent++; $mail->Body = acajoom_mail::replaceTags($content, $receiver, $list, $mailingId, $ashtml, $tags); } else { $mail->IsHTML(false); $mail->AltBody = ''; $ashtml = 0; $text_sent++; $mail->Body = acajoom_mail::replaceTags($textonly, $receiver, $list, $mailingId, $ashtml, $tags); // if we are in TEXT Mode, Why do we add embedded images??? if (!empty($images)) { foreach ($images as $image) { $img = explode('|', $image); $attrib = explode("/", $img[0]); $path = $GLOBALS['mosConfig_absolute_path'] . '/images/stories/'; if (count($img) == 1) { $imageName = $img[0]; } else { $imageName = $attrib[count($attrib) - 1]; for ($index = 0; $index < sizeof($attrib) - 1; $index++) { $path .= $attrib[$index] . '/'; } } $mail->AddAttachment($path . $imageName); } } } $tname = explode(" ", $receiver->name); $firstname = $tname[0]; $mail->AddAddress($receiver->email, $receiver->name); $sujetReplaced = str_replace('[NAME]', $receiver->name, $subject); $sujetReplaced = str_replace('[FIRSTNAME]', $firstname, $sujetReplaced); if (class_exists('auto')) { auto::tags($sujetReplaced, $tags); } $mail->Subject = $sujetReplaced; $mailssend = $mail->Send(); $countEmails++; if ($countEmails >= $GLOBALS[ACA . 'cron_max_emails']) { $max = true; } if ($mail->error_count > 0) { static $info = false; if (!$info and acajoom::checkPermissions('admin')) { echo '<br/>Mailer Error : ' . $mail->ErrorInfo; $info = true; } $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_NOT . "\r\n" . _ACA_MAILER_ERROR . ': ' . $mail->ErrorInfo . "\r\n"; if ($html && intval($receiver->receive_html) == 1) { $html_sent--; } else { $text_sent--; } } else { $log_detailed .= '[' . $mailingId . '] ' . $subject . ' : ' . $receiver->email . ' -> ' . _ACA_MESSAGE_SENT_SUCCESSFULLY . "\r\n"; if ($GLOBALS[ACA . 'enable_statistics'] == 1 and $GLOBALS[ACA . 'statistics_per_subscriber'] == 1) { xmailing::insertStats($mailingId, $receiver->id, $ashtml); } $d['qids'] = array(); $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); if ($d['listype'] == '2') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = auto::updateAutoresponderSent($d); $erro->Eck(__LINE__, '8137', $d); } elseif ($d['listype'] == '1' || $d['listype'] == '7') { $d['qids'][0] = queue::whatQID($mailingId, $receiver->id, $d['listype']); $erro->ck = queue::deleteQueues($d['qids']); $erro->Eck(__LINE__, '8127', $d); } } $mail->ClearAddresses(); } if ($GLOBALS[ACA . 'enable_statistics'] == 1) { xmailing::updateStatsGlobal($mailingId, $html_sent, $text_sent, false); } $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; if ($totalsofar > 0) { $totaltime = $totalsofar; $totalstr = strval($totaltime); } else { $totaltime = number_format($endtime - $starttime - $nbPause * $GLOBALS[ACA . 'pause_time'], 4, ',', ''); $totalstr = strval($totaltime); } if ($GLOBALS[ACA . 'send_data'] == 1) { acajoom_mail::sendReport($fromemail, $totalstr, $html_sent, $text_sent); } $xf->plus('totalmailingsent' . $list->list_type, $html_sent + $text_sent); $xf->plus('totalmailingsent0', $html_sent + $text_sent); $log_simple = 'Time to send: ' . $totalstr . ' ' . _ACA_SECONDS . "\r\n" . 'Number of subscribers: ' . ($text_sent + $html_sent) . "\r\n" . 'HTML format: ' . $html_sent . "\r\n" . 'Text format: ' . $text_sent . "\r\n"; $log_detailed = $log_simple . 'Details: ' . "\r\n" . $log_detailed . "\r\n"; if (class_exists('lisType')) { acajoom_mail::writeLogs($list, $log_simple, $log_detailed); } if ($d['listype'] == '2') { echo '<br/>' . _ACA_QUEUE_AUTO_PROCESSED; } elseif ($d['listype'] == '1') { echo '<br/>' . _ACA_QUEUE_NEWS_PROCESSED; } if ($html_sent + $text_sent > 0) { return true; } else { $message = xmailing::M('no', _ACA_NO_MAILING_SENT); return false; } }
function remove($subscriberId, $cle = '', $listId) { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); if (!empty($subscriberId) and !empty($cle) and $listId > 0) { $qid[0] = $subscriberId; $subscriber = subscribers::getSubscribersFromId($qid, false); if (md5($subscriber->email) == $cle) { $suscription = new stdClass(); $suscription->user_id = $subscriberId; $suscription->sub_list_id[1] = $listId; $suscription->subscribed[1] = 0; $suscription->acc_level[1] = 0; $erro->ck = queue::updateSuscription($suscription); $erro->Eck(__LINE__, '8277'); $list = lists::getOneList($listId); if ($list->unsubscribesend == 1) { $erro->err = acajoom_mail::sendUnsubcribeEmail($subscriberId, $list); $erro->E(__LINE__, '8278'); } } } return $erro->R(); }
function updateSuscription($suscription) { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); //$i = 0; //do { //$i++; foreach ($suscription->sub_list_id as $i => $value) { $queues = queue::suscriptionExist($suscription->user_id, $suscription->sub_list_id[$i]); if (!empty($queues)) { if (isset($suscription->subscribed[$i])) { if ($suscription->subscribed[$i] == 0) { $erro->ck = queue::deleteSubsQueue($suscription->user_id, $suscription->sub_list_id[$i]); $erro->Eck(__LINE__, '8520'); } else { $updatedQueue = $queues; $updatedQueue->acc_level = $suscription->acc_level[$i]; if ($queues->mailing_id < 1) { $mailingId = xmailing::getFirstMailingId($queues->list_id); if (!empty($mailingId)) { $list = lists::getOneList($queues->list_id); $mailing = queue::getValidMailing($list, $mailingId); if (!empty($mailing)) { $updatedQueue->type = $mailing->list_type; $updatedQueue->list_id = $list->id; $updatedQueue->mailing_id = $mailing->id; $updatedQueue->published = $list->published; $updatedQueue->send_date = acajoom::getNow(); if ($mailing->list_type == 1 or $mailing->list_type == 7) { $updatedQueue->issue_nb = 0; $updatedQueue->send_date = '0000-00-00 00:00:00'; $updatedQueue->delay = 0; } else { $updatedQueue->issue_nb = $mailing->issue_nb; $updatedQueue->send_date = acajoom::getNow(); $updatedQueue->delay = $mailing->delay; } } } $qid = ''; $qid[0] = $updatedQueue->qid; $erro->ck = queue::updateQueueData($qid, '', $updatedQueue->type, $updatedQueue->list_id, $updatedQueue->mailing_id, $updatedQueue->issue_nb, $updatedQueue->send_date, $updatedQueue->delay, $updatedQueue->acc_level, $updatedQueue->published); $erro->Eck(__LINE__, '8521'); } else { queue::updateAccessLevel($updatedQueue); } } } } else { if (isset($suscription->subscribed[$i])) { if ($suscription->subscribed[$i] == 1) { $subId = array(); $subId[0] = $suscription->user_id; $subList = isset($suscription->sub_list_id[$i]) ? $suscription->sub_list_id[$i] : 0; $subLevel = isset($suscription->acc_level[$i]) ? $suscription->acc_level[$i] : 29; $erro->ck = queue::updateQueues($subId, '', $subList, $subLevel, true); $erro->Eck(__LINE__, '8522'); } } } } //while (count($suscription->sub_list_id ) > $i ); return $erro->R(); }
function updateUserstoAcajoom($force = false) { global $database; $time = isset($GLOBALS[ACA . 'last_sub_update']) && $GLOBALS[ACA . 'last_sub_update'] > 0 ? $GLOBALS[ACA . 'last_sub_update'] : 10000; $newTask = mktime(date("H") - 1, date("i"), date("s"), date("m"), date("d") - 1, date("Y")); if ($force or $newTask > $GLOBALS[ACA . 'last_sub_update']) { $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__); $xf = new xonfig(); $newtime = mktime(date("H", $time) - 1, date("i", $time), date("s", $time), date("m", $time), date("d", $time), date("Y", $time)); $oneDay = date('Y-m-d H:i:s', $newtime); $query = 'SELECT M.* FROM `#__users` AS M ' . ' LEFT JOIN `#__acajoom_subscribers` AS N ON M.id = N.user_id OR M.email = N.email '; $query .= ' WHERE M.registerDate > \'' . $oneDay . '\''; $query .= ' AND N.id IS NULL AND M.block=0 '; $database->setQuery($query); $rows = $database->loadObjectList(); $erro->err = $database->getErrorMsg(); $erro->E(__LINE__, '8638', $database); if ($erro->result and !empty($rows)) { foreach ($rows as $row) { $query = "INSERT INTO `#__acajoom_subscribers` (`user_id`,`subscribe_date`, `name`,`email`,`confirmed`)"; $query .= " VALUES ( {$row->id} , '{$row->registerDate}', '{$row->name}', '{$row->email}' , 1 ) "; $database->setQuery($query); $database->query(); $erro->err = $database->getErrorMsg(); $xf->plus('totalsubcribers0', 1); $xf->plus('act_totalsubcribers0', 1); $lists = lists::getLists(0, 0, null, '', true, false, false); if (!empty($lists)) { foreach ($lists as $list) { $qid[0] = subscribers::getSubscriberId($row->registerDate); $subscriber = subscribers::getSubscribersFromId($qid, false); $subId = array(); $subId[0] = $subscriber->id; $erro->ck = queue::updateQueues($subId, '', $list->id, @$list->acc_id, true); $erro->Eck(__LINE__, '8640'); } } } } } }
function userDeleted($user, $success) { require_once ACA_JPATH_ROOT_NO_ADMIN . '/administrator/components/com_acajoom/classes/class.acajoom.php'; $erro = new xerr(__FILE__, __FUNCTION__); if (!empty($user->user_id)) { $subscriberId = subscribers::getSubscriberIdFromUserId($user->user_id); if (!empty($subscriberId)) { subscribers::deleteOneSubscriber($subscriberId); } } $erro->ck = subscribers::updateSubscribers(); $erro->Eck(__LINE__, '7009'); return true; }
function userDeleted($user, $success) { require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/components/com_acajoom/classes/class.acajoom.php'; $erro = new xerr(__FILE__, __FUNCTION__); $erro->ck = subscribers::updateSubscribers(); $erro->Eck(__LINE__, '7009'); return true; }