Пример #1
0
     }
     break;
 case 'subscribe':
     $userid = intval(mosGetParam($_REQUEST, 'userid', 0));
     if ($userid > 0) {
         global $database;
         $query = 'SELECT * FROM `#__users` WHERE `id` = \'' . $userid . '\'';
         $database->setQuery($query);
         $database->loadObject($user);
         if (!empty($user)) {
             $name = $user->name;
             $email = $user->email;
         } else {
             break;
         }
     } elseif (!subscribers::validEmail($email)) {
         echo '<br />' . acajoom::printM('red', _ACA_EMAIL_INVALID);
         echo "<script>alert('" . addslashes(_ACA_EMAIL_INVALID) . "'); window.history.go(-1);</script>\n";
         break;
     }
     if ($userid > 0) {
         $message = frontEnd::newSubscriber($name, $email, true);
     } else {
         $message = frontEnd::newSubscriber($name, $email);
     }
     if ($GLOBALS[ACA . 'addEmailRedLink']) {
         if (preg_match('?', $redirectlink)) {
             $redirectlink .= '&email=' . $email;
         } else {
             $redirectlink .= '?email=' . $email;
         }
Пример #2
0
 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;
     }
 }
Пример #3
0
 function import($listId)
 {
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     @set_time_limit(0);
     $queue = '';
     $queue->sub_list_id = mosGetParam($_REQUEST, 'sub_list_id', '');
     $queue->subscribed = mosGetParam($_REQUEST, 'subscribed', '');
     $queue->acc_level = mosGetParam($_REQUEST, 'acc_level', 29);
     $path = $GLOBALS['mosConfig_absolute_path'] . $GLOBALS[ACA . 'upload_url'];
     $filename = $_FILES['importfile']['name'];
     if (is_writable($path)) {
         if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) {
             echo _ACA_ERROR_MOVING_UPLOAD;
         }
         $import = file_get_contents($path . $filename);
         $import = str_replace(array("\r", "\r\n"), "\n", $import);
         $array = explode("\n", $import);
         if (sizeof($array) > 0) {
             foreach ($array as $row) {
                 $row = trim($row);
                 if (empty($row)) {
                     continue;
                 }
                 $values = explode(',', $row);
                 if (count($values) != 4) {
                     echo '<br />' . acajoom::printM('red', $row . ' : Acajoom needs 4 arguments for each user');
                     continue;
                 }
                 $values[0] = trim($values[0]);
                 $values[1] = trim($values[1]);
                 if (isset($values[1])) {
                     $valid = subscribers::validEmail($values[1]);
                     if (!$valid) {
                         echo '<br />' . acajoom::printM('red', $values[1] . ': ' . _ACA_EMAIL_INVALID);
                         continue;
                     } else {
                         $subscriber = null;
                         $subscriber->name = addslashes($values[0]);
                         $subscriber->email = $values[1];
                         $subscriber->receive_html = empty($values[2]) ? '0' : '1';
                         $subscriber->confirmed = empty($values[3]) ? '0' : '1';
                         $subscriber->subscribe_date = acajoom::getNow();
                         $subscriber->language_iso = 'eng';
                         $subscriber->timezone = '00:00:00';
                         $subscriber->blacklist = '0';
                         $subscriber->params = '';
                         $d['email'] = $subscriber->email;
                         $erro->ck = subscribers::getSubscriberIdFromEmail($d);
                         $erro->Eck(__LINE__, '8679');
                         $subscriberId = $d['subscriberId'];
                         if ($subscriberId < 1) {
                             $erro->ck = subscribers::insertSubscriber($subscriber, $subscriberId);
                             $erro->Eck(__LINE__, '8650');
                         }
                         if (!$erro->ck) {
                             echo '<br />' . acajoom::printM('red', $values[0] . ': ' . _ACA_SUBCRIBER_EXIT);
                         } else {
                             if (!empty($queue->subscribed) and $subscriberId > 0) {
                                 $queue->user_id = $subscriberId;
                                 $erro->ck = queue::updateSuscription($queue);
                                 $erro->Eck(__LINE__, '8651');
                                 if ($GLOBALS[ACA . 'require_confirmation'] == '1' and $values[3] == '0') {
                                     $listIds = array();
                                     $size = sizeof($queue->sub_list_id);
                                     for ($index = 0; $index < $size; $index++) {
                                         if (isset($queue->subscribed[$index])) {
                                             if ($queue->subscribed[$index] > 0) {
                                                 $listIds[] = $queue->sub_list_id[$index];
                                             }
                                         }
                                     }
                                     $erro->ck = acajoom_mail::processConfirmationEmail($subscriberId, $listIds);
                                     $erro->Eck(__LINE__, '8652');
                                 }
                                 if ($erro->ck) {
                                     echo '<br />' . acajoom::printM('green', $values[0] . ': ' . _ACA_IMPORT_SUCCESS);
                                 } else {
                                     echo '<br />' . acajoom::printM('blue', $values[0] . ': ' . _ACA_PB_QUEUE);
                                 }
                             }
                         }
                     }
                 }
             }
             return true;
         }
         $erro->ck = unlink($path . $filename);
         $erro->Eck(__LINE__, '8655');
         if (!$erro->ck) {
             echo _ACA_DELETION_OFFILE . ' ' . $path . $filename . ' ' . _ACA_MANUALLY_DELETE . '.</p>';
         }
     } else {
         echo _ACA_CANNOT_WRITE_DIR . ' ' . $path . '</p>';
         return false;
     }
 }