function deleteList($listId)
 {
     global $database;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $xf = new xonfig();
     $list = lists::getOneList($listId);
     $query = 'DELETE FROM `#__acajoom_lists` WHERE `id` = ' . $listId;
     $database->setQuery($query);
     $database->query();
     $erro->err = $database->getErrorMsg();
     $erro->E(__LINE__, '8317', $database);
     $query = 'DELETE FROM `#__acajoom_queue` WHERE `list_id` = ' . $listId;
     $database->setQuery($query);
     $database->query();
     $erro->err = $database->getErrorMsg();
     $erro->E(__LINE__, '8319', $database);
     $mailings = xmailing::getMailings($listId, '', -1, -1, '', $total, '', false, false);
     if (!empty($mailings)) {
         foreach ($mailings as $mailing) {
             $listingList[] = $mailing->id;
         }
         $query = "DELETE FROM `#__acajoom_stats_global` WHERE `mailing_id` IN ( " . implode(' , ', $listingList) . " ) ";
         $database->setQuery($query);
         $database->query();
         $erro->err .= $database->getErrorMsg();
         $erro->E(__LINE__, '8320', $database);
         $query = "DELETE FROM `#__acajoom_stats_details` WHERE  `mailing_id` IN ( " . implode(' , ', $listingList) . " ) ";
         $database->setQuery($query);
         $database->query();
         $erro->err .= $database->getErrorMsg();
         $erro->E(__LINE__, '8321', $database);
     }
     $query = 'DELETE FROM `#__acajoom_mailings` WHERE `list_id` = ' . $listId;
     $database->setQuery($query);
     $database->query();
     $erro->err = $database->getErrorMsg();
     $erro->E(__LINE__, '8318', $database);
     if (!$erro->result) {
         return false;
     } else {
         $xf->plus('act_totallist0', -1);
         $xf->plus('act_totalmailing' . $list->list_type, -1);
         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;
     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 insertMailingData($mailing)
 {
     global $database;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $xf = new xonfig();
     $query = "INSERT INTO `#__acajoom_mailings` (`list_id`, `list_type`,`send_date`, `subject`, `htmlcontent`, `textonly`," . "\n `attachments`, `images`, `published`, `html`, `visible`, `fromname`, `fromemail`, `frombounce`, " . "\n `author_id`, `delay`, `issue_nb` , `acc_level` , `createdate`) " . "\n VALUES ( {$mailing->list_id}, " . "{$mailing->list_type}, " . "'{$mailing->send_date}', " . "'" . addslashes($mailing->subject) . "', " . "'" . addslashes($mailing->htmlcontent) . "', " . "'" . addslashes($mailing->textonly) . "', " . "'{$mailing->attachments}', " . "'{$mailing->images}', " . "{$mailing->published}, " . "{$mailing->html}, " . "{$mailing->visible}, " . "'{$mailing->fromname}', " . "'{$mailing->fromemail}', " . "'{$mailing->frombounce}', " . "'{$mailing->author_id}', " . "{$mailing->delay}, " . "{$mailing->issue_nb}, " . "{$mailing->acc_level}, " . "'{$mailing->createdate}' ) ";
     $database->setQuery($query);
     $database->query();
     $erro->err = $database->getErrorMsg();
     if (empty($erro->err)) {
         $xf->plus('totalmailing0', 1);
         $xf->plus('act_totalmailing0', 1);
         $xf->plus('totalmailing' . $mailing->list_type, 1);
         $xf->plus('act_totalmailing' . $mailing->list_type, 1);
     }
     return $erro->E(__LINE__, '8419', $database);
 }
function createGuide()
{
    global $my;
    $xf = new xonfig();
    $option = mosGetParam($_REQUEST, 'option', '');
    $guide = '';
    if ($option != 'com_installer') {
        $guide .= '<div width="80%"><center><fieldset class="menubackgr" style="padding: 10px; text-align: left">';
        $guide .= "<legend><img src='images/support.png' border='0' align='absmiddle' alt='acajoom guide' style='width: 35px; height: 35px;' hspace='6'>";
        $guide .= "<strong>Acajoom" . _ACA_GUIDE . "</strong></legend>";
        if ($GLOBALS[ACA . 'act_totallist0'] <= 0) {
            $guide .= _HI . ' ' . $my->username . "!" . _ACA_GUIDE_FIRST_ACA_STEP;
            $guide .= '<strong><u>' . _ACA_STEP . '1</u></strong><br />';
            if (($GLOBALS[ACA . 'news1'] == 1 or $GLOBALS[ACA . 'news2'] == 1 or $GLOBALS[ACA . 'news3'] == 1) and $option != 'com_installer') {
                $guide .= _ACA_GUIDE_FIRST_ACA_STEP_UPGRADE;
            }
            $guide .= _ACA_GUIDE_FIRST_ACA_STEP_DESC;
            $guide .= "<a href='index2.php?option=com_acajoom&act=list&task=new'>";
            $guide .= "<img src='images/new_f2.png' border='0' align='absmiddle' alt='acajoom guide' style='width: 26px; height: 26px;' hspace='6'>";
            $guide .= "</a>";
        } elseif ($GLOBALS[ACA . 'act_totalmailing0'] <= 0) {
            if ($GLOBALS[ACA . 'act_totallist1'] == 1) {
                $type_list = _ACA_NEWSLETTER;
                $link = '<a href="index2.php?option=com_acajoom&act=mailing&listype=1">' . _ACA_GUIDE_SECOND_ACA_STEP_NEWS . '</a>';
            } else {
                $type_list = _ACA_AUTORESP;
                $link = '<a href="index2.php?option=com_acajoom&act=mailing&listype=2">' . _ACA_GUIDE_SECOND_ACA_STEP_AUTO . '</a>';
            }
            $guide .= '<strong><u>' . _ACA_STEP . '2</u></strong><br />';
            $guide .= sprintf(_ACA_GUIDE_SECOND_ACA_STEP, $type_list);
            $guide .= $link;
            $guide .= sprintf(_ACA_GUIDE_SECOND_ACA_STEP_FINAL, $type_list, $type_list);
            $guide .= "<img src='images/new_f2.png' border='0' align='absmiddle' alt='acajoom guide' style='width: 26px; height: 26px;' hspace='6'>";
        } elseif ($GLOBALS[ACA . 'act_totalmailing0'] < 2 and $GLOBALS[ACA . 'mod_pub'] == 0) {
            acajoom::resetUpgrade();
            if ($GLOBALS[ACA . 'firstmailing'] == 2) {
                $guide .= '<strong><u>' . _ACA_STEP . '3</u></strong><br />';
                $guide .= _ACA_GUIDE_THRID_ACA_STEP_AUTOS;
                if ($GLOBALS[ACA . 'mod_pub'] == 0) {
                    $guide .= _ACA_GUIDE_MODULE;
                }
            } else {
                $guide .= '<strong><u>' . _ACA_STEP . '3</u></strong><br />';
                $guide .= _ACA_GUIDE_THRID_ACA_STEP_NEWS;
                if ($GLOBALS[ACA . 'mod_pub'] == 0) {
                    $guide .= _ACA_GUIDE_MODULE;
                }
                $guide .= _ACA_GUIDE_THRID2_ACA_STEP_NEWS;
                $guide .= "<img src='images/forward_f2.png' border='0' align='absmiddle' alt='acajoom guide' style='width: 26px; height: 26px;' hspace='6'>";
            }
        } elseif (($GLOBALS[ACA . 'mod_pub'] == 1 or $GLOBALS[ACA . 'act_totallist0'] > 1) and $GLOBALS[ACA . 'act_totalmailing0'] < 2) {
            if ($GLOBALS[ACA . 'firstmailing'] == 1) {
                $guide .= '<strong><u>' . _ACA_STEP . '4</u></strong><br />';
                if ($GLOBALS[ACA . 'listype2'] == 1) {
                    $guide .= _ACA_GUIDE_FOUR_ACA_STEP_NEWS . '<br />' . _ACA_GUIDE_THRID_ACA_STEP_AUTOS;
                }
            } else {
                $guide .= '<strong><u>' . _ACA_STEP . '4</u></strong><br />';
                $guide .= _ACA_GUIDE_FOUR_ACA_STEP_AUTOS . '<br />' . _ACA_GUIDE_THRID_ACA_STEP_NEWS;
            }
            $guide .= _ACA_GUIDE_FOUR_ACA_STEP;
        } else {
            $guide .= '<strong>' . _ACA_GUIDE_TURNOFF . '</strong>';
            $config = array();
            $config['show_guide'] = '0';
            $xf->saveConfig($config);
        }
        $guide .= '</fieldset></center></div>';
    }
    return $guide;
}
function lists($action, $task, $listId, $listType)
{
    global $database, $my;
    $message = '';
    $xf = new xonfig();
    $erro = new xerr(__FILE__, __FUNCTION__);
    $erro->show();
    $showLists = true;
    switch ($task) {
        case 'new':
            if ($listType < 1) {
                $listType = 1;
            }
            $filename = $GLOBALS['mosConfig_absolute_path'] . '/components/com_acajoom/templates/default/default.html';
            $handle = fopen($filename, "rb");
            $template = fread($handle, filesize($filename));
            fclose($handle);
            $template = str_replace('src="', 'src="' . $GLOBALS['mosConfig_live_site'] . '/', $template);
            $subscriber = subscribers::getSubscriberInfoFromUserId($my->id);
            $showLists = false;
            $newList->id = '';
            $newList->html = 1;
            $newList->new_letter = 1;
            $newList->list_name = '';
            $newList->list_desc = '';
            $newList->sendername = $subscriber->name;
            $newList->senderemail = $subscriber->email;
            $newList->bounceadres = $subscriber->email;
            $newList->layout = $template;
            $newList->template = 0;
            $newList->hidden = 1;
            $newList->auto_add = 0;
            $newList->list_type = $listType;
            $newList->delay_min = 1;
            $newList->delay_max = 7;
            $newList->user_choose = 0;
            $newList->cat_id = 0;
            $newList->follow_up = '';
            $newList->notify_id = 0;
            $newList->owner = $my->id;
            $newList->acc_level = 25;
            $newList->acc_id = 29;
            $newList->published = 0;
            $newList->start_date = date('Y-m-d', time());
            $newList->next_date = time();
            $newList->subscribemessage = _ACA_DEFAULT_SUBSCRIBE_MESS;
            $newList->unsubscribemessage = _ACA_DEFAULT_UNSUBSCRIBE_MESS;
            $newList->unsubscribesend = 1;
            $newList->footer = 1;
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n ";
            $show = lisType::showType($newList->list_type, 'editlist');
            backHTML::_header(_ACA_NEW . ' ' . _ACA_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
            backHTML::formStart('listedit', $newList->html, '');
            listsHTML::editList($newList, $forms, $show);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('listid', $newList->id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            $listname = mosGetParam($_REQUEST, 'list_name', '');
            $listType = mosGetParam($_REQUEST, 'list_type', 0);
            $now = acajoom::getNow();
            $query = "SELECT `id` FROM `#__acajoom_lists` WHERE `list_name`= '{$listname}' ";
            $database->setQuery($query);
            $lId = $database->loadResult();
            $erro->err = $database->getErrorMsg();
            $erro->E(__LINE__, '1091', $database);
            if ($lId > 0) {
                echo "<script> alert(' This list already exist, please choose another name. '); window.history.go(-1);</script>\n";
                return false;
            } else {
                $query = "INSERT INTO `#__acajoom_lists` (`list_name`,`createdate`) VALUES ( '" . addslashes($listname) . "'  , '{$now}' )";
                $database->setQuery($query);
                $database->query();
                $erro->err = $database->getErrorMsg();
            }
            if ($erro->E(__LINE__, '1001', $database)) {
                $query = "SELECT * FROM `#__acajoom_lists` WHERE `list_name`= '{$listname}' ";
                $database->setQuery($query);
                $database->loadObject($mynewlist);
                $mynewlist->list_name = stripslashes($mynewlist->list_name);
                $mynewlist->list_desc = stripslashes($mynewlist->list_desc);
                $mynewlist->layout = stripslashes($mynewlist->layout);
                $mynewlist->subscribemessage = stripslashes($mynewlist->subscribemessage);
                $mynewlist->unsubscribemessage = stripslashes($mynewlist->unsubscribemessage);
                $erro->err = $database->getErrorMsg();
                $erro->E(__LINE__, '1005');
                $listId = $mynewlist->id;
                $message = acajoom::printYN(lists::updateListFromEdit($listId, '', true), _ACA_LIST_ADDED, _ACA_ERROR);
                $xf->plus('totallist0', 1);
                $xf->plus('act_totallist0', 1);
                $xf->plus('totallist' . $listType, 1);
                $xf->plus('act_totallist' . $listType, 1);
            }
            break;
        case 'edit':
            if ($listId == 0) {
                echo "<script> alert('" . addslashes(_ACA_SELECT_LIST) . "'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $showLists = false;
                $query = 'SELECT * FROM `#__acajoom_lists` WHERE `id` = ' . intval($listId);
                $database->setQuery($query);
                $database->loadObject($listEdit);
                $erro->err = $database->getErrorMsg();
                if (!$erro->E(__LINE__, '1002')) {
                    return false;
                } else {
                    $listEdit->list_name = stripslashes($listEdit->list_name);
                    $listEdit->list_desc = stripslashes($listEdit->list_desc);
                    $listEdit->layout = stripslashes($listEdit->layout);
                    $listEdit->subscribemessage = stripslashes($listEdit->subscribemessage);
                    $listEdit->unsubscribemessage = stripslashes($listEdit->unsubscribemessage);
                    $listEdit->new_letter = 0;
                    $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n ";
                    $show = lisType::showType($listEdit->list_type, 'editlist');
                    backHTML::_header(_ACA_EDIT_A . @constant($GLOBALS[ACA . 'listname' . $listEdit->list_type]) . ' ' . _ACA_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
                    backHTML::formStart('listedit', $listEdit->html, '');
                    listsHTML::editList($listEdit, $forms, $show);
                    $go[] = acajoom::makeObj('act', $action);
                    $go[] = acajoom::makeObj('listid', $listEdit->id);
                    backHTML::formEnd($go);
                }
            }
            break;
        case 'update':
            $message = acajoom::printYN(lists::updateListFromEdit($listId, '', false), _ACA_LIST_UPDATED, _ACA_ERROR);
            break;
        case 'delete':
            $message = acajoom::printYN(lists::deleteList($listId), _ACA_LIST . _ACA_SUCCESS_DELETED, _ACA_ERROR);
            break;
        case 'copy':
            $message = acajoom::printYN(lists::copyList($listId), _ACA_LIST_COPY, _ACA_ERROR);
            break;
        case 'publish':
            $message = acajoom::printYN(lists::updateListFromList($listId, true, false), _ACA_PUBLISHED, _ACA_ERROR);
            break;
        case 'unpublish':
            $message = acajoom::printYN(lists::updateListFromList($listId, false, false), _ACA_UNPUBLISHED, _ACA_ERROR);
            break;
        case 'forms':
        case 'make':
            if (class_exists('createForm')) {
                createForm::taskOptions($task);
                $showLists = false;
            } else {
                $showLists = true;
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
    }
    if ($showLists) {
        backHTML::_header(_ACA_MENU_LIST, $GLOBALS[ACA . 'listlogo0'], $message, $task, $action);
        $show = lisType::showType(0, 'showListsBack');
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        backHTML::formStart('show_mailing', '', '');
        $listing = lists::getLists(0, 0, 1, '', false, false, false);
        if ($show['list_type']) {
            $show['list_type'] = lisType::checkOthers();
        }
        listsHTML::showListingLists($listing, $action, 'edit', $forms, $show);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
        return true;
    }
}
Exemple #6
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;
     }
 }
Exemple #7
0
 function updateActiveList()
 {
     $xf = new xonfig();
     $j = 0;
     $nb = array();
     for ($i = 1; $i < $GLOBALS[ACA . 'nblist']; $i++) {
         if ($GLOBALS[ACA . 'listype' . $i] == 1) {
             $j++;
             $nb[$j] = $i;
         }
     }
     $activeList = implode(",", $nb);
     return $xf->update('activelist', $activeList);
 }
Exemple #8
0
function installPlugin()
{
    if (ACA_CMSTYPE) {
        $database =& JFactory::getDBO();
    } else {
        global $database;
    }
    //endif
    $return = '<b>' . _ACA_INSTALL_PLUGIN . '</b> : ';
    $error = '';
    $files = array('acajoom_cb.php', 'acajoom_cb.xml', 'index.html');
    if (!is_file(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin/acajoom_cb.php')) {
        @mkdir(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin', 0755);
        @chmod(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin', 0755);
    }
    foreach ($files as $file) {
        if (is_file(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin/' . $file)) {
            @unlink(WPATH_ADMIN . 'cbplugin/' . $file);
        } else {
            if (!@rename(WPATH_ADMIN . 'cbplugin/' . $file, ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin/' . $file)) {
                $error .= '<br /> Error copying plugin file ' . $file . ' to CB plugin directory.';
            }
        }
    }
    if (is_file(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin/acajoom_cb.php')) {
        @chmod(ACA_JPATH_ROOT . '/components/com_comprofiler/plugin/user/plug_acajoomcbplugin', 0755);
    }
    if (!@rmdir(WPATH_ADMIN . 'cbplugin/')) {
        $error .= '<br /> Error deleting the temporary cbplugin directory.';
    }
    $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_acajoomcbplugin' ";
    $database->setQuery($query);
    $database->query();
    $id = $database->loadResult();
    $mysqlerror = $database->getErrorMsg();
    if (!empty($mysqlerror)) {
        $error .= '<br />Error getting plugin information from cb plugin table. Database error: <br />' . $mysqlerror . '';
    } else {
        if ($id < 1) {
            $row->name = 'Acajoom CB Plugin';
            $row->element = 'acajoom_cb';
            $row->type = 'user';
            $row->folder = 'plug_acajoomcbplugin';
            $row->ordering = '99';
            $query = "INSERT INTO `#__comprofiler_plugin` (`name` , `element`, `type`, `ordering`, `folder`) VALUES ( " . "'{$row->name}', " . "'{$row->element}', " . "'{$row->type}', " . "'{$row->ordering}', " . " '{$row->folder}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB plug table.';
            }
            $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_acajoomcbplugin' ";
            $database->setQuery($query);
            $database->query();
            $id = $database->loadResult();
            $error .= $database->getErrorMsg();
            $row = '';
            $row->title = 'Mailing Lists';
            $row->description = 'Listing of all the mailing lists for Acajoom';
            $row->ordering = '99';
            $row->width = '.5';
            $row->enabled = '0';
            $row->pluginclass = 'getAcajoomTab';
            $row->pluginid = $id;
            $row->sys = '0';
            $row->params = 'NULL';
            $row->displaytype = 'tab';
            $row->position = 'cb_tabmain';
            $query = "INSERT INTO `#__comprofiler_tabs` (`title` , `description`, `ordering`, `width`, `enabled`, " . " `pluginclass` , `pluginid`, `sys`, `displaytype`, `params` , `position` ) VALUES ( " . "'{$row->title}', " . "'{$row->description}', " . "'{$row->ordering}', " . "'{$row->width}', " . "'{$row->enabled}', " . "'{$row->pluginclass}', " . "'{$row->pluginid}', " . "'{$row->sys}', " . "'{$row->displaytype}', " . "'{$row->params}', " . "'{$row->position}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB tab table.';
            }
        }
    }
    if (empty($error)) {
        $xf = new xonfig();
        $xf->update('cb_pluginInstalled', '1');
        $return .= acajoom::printM('green', _ACA_INSTALL_SUCCESS) . '<br />';
    } else {
        $return .= $error . acajoom::printM('red', _ACA_INSTALL_ERROR) . '<br />';
    }
    return $return;
}
 function checkNewVersion()
 {
     static $available = false;
     $xf = new xonfig();
     $canUpdate = false;
     if ($this->canUpdate()) {
         foreach ($this->compsList as $compList) {
             if ($compList[0] == $this->local['component'] and $compList[1] == $this->local['type'] and $this->checkVersion($this->local['version'], $compList[2])) {
                 $joomlaVer = new joomlaVersion();
                 $joomla = $joomlaVer->getShortVersion();
                 $value = $compList[3] . '_' . $compList[2];
                 if (empty($this->local[$value . '_requirement']) or $this->requiredVersion($joomla, $this->local[$value . '_requirement'])) {
                     $xf->update('update_avail', '1');
                     $available = true;
                     if (isset($this->local[$value . '_message']) and defined('_ACA_UPDATE_MESS' . $this->local[$value . '_message'])) {
                         $xf->update('update_message', @constant('_ACA_UPDATE_MESS' . $this->local[$value . '_message']));
                     } else {
                         $xf->update('update_message', '');
                     }
                 } else {
                     $xf->update('update_avail', '0');
                 }
             } else {
                 $xf->update('update_avail', '0');
             }
         }
     }
     $xf->update('date_update', acajoom::getNow());
     return $available;
 }
 function upgrade_News3()
 {
     global $my, $database;
     $xf = new xonfig();
     $newLists = array();
     $idImportedList = array();
     $i = 0;
     $database->setQuery("SELECT * FROM #__newsletter_letters");
     $newsletters = $database->loadObjectList();
     $error = $database->getErrorMsg();
     if (!empty($error)) {
         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>';
         return false;
     } else {
         foreach ($newsletters as $newsletter) {
             $list->list_name = $newsletter->list_name;
             $list->list_desc = $newsletter->list_desc;
             $list->sendername = $newsletter->sendername;
             $list->senderemail = $newsletter->senderemail;
             $list->bounceadres = $newsletter->bounceadres;
             $list->layout = $newsletter->layout;
             $list->template = 0;
             $list->subscribemessage = $newsletter->subscribemessage;
             $list->unsubscribemessage = $newsletter->unsubscribemessage;
             $list->html = $newsletter->html;
             $list->hidden = !$newsletter->hidden;
             $list->unsubscribesend = 1;
             $list->list_type = '1';
             $list->auto_add = 0;
             $list->user_choose = 0;
             $list->cat_id = 0;
             $list->delay_min = 0;
             $list->delay_max = 0;
             $list->follow_up = 0;
             $list->owner = $my->id;
             $list->auto_add = 0;
             $list->acc_level = $newsletter->aid;
             $list->acc_id = 29;
             $list->published = 1;
             $list->createdate = acajoom::getNow();
             $list->footer = 1;
             $list->notify_id = 0;
             $list->notification = 0;
             $query = 'INSERT INTO `#__acajoom_lists` (`list_name`) VALUES (\'' . $list->list_name . '\'  )';
             $database->setQuery($query);
             $database->query();
             $error = $database->getErrorMsg();
             if (!empty($error)) {
                 echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use?    The list name has to be different for each list! <br /><br />';
             } else {
                 $query = 'SELECT * FROM `#__acajoom_lists` WHERE `list_name`= \'' . $list->list_name . '\'';
                 $database->setQuery($query);
                 $database->loadObject($mynewlist);
                 $error = $database->getErrorMsg();
                 $xf->plus('totallist0', 1);
                 $xf->plus('act_totallist0', 1);
                 $xf->plus('totallist1', 1);
                 $xf->plus('act_totallist1', 1);
                 if (!empty($error)) {
                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>';
                     return false;
                 } else {
                     $idImportedList[$newsletter->id] = $mynewlist->id;
                     $newLists[$i] = $mynewlist->id;
                     $i++;
                     $list->id = $mynewlist->id;
                     $error = lists::updateListData($list);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>';
                     } else {
                         echo '<br /><b>' . @constant($GLOBALS[ACA . 'listnames1']) . ': </b>' . $list->list_name . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS);
                         $database->setQuery("SELECT * FROM #__newsletter_mailing WHERE `list_id`=" . $newsletter->id);
                         $mailingsImports = $database->loadObjectList();
                         $error = $database->getErrorMsg();
                         if (!empty($error)) {
                             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>';
                             return false;
                         } else {
                             $issue_nb = 1;
                             foreach ($mailingsImports as $mailingsImport) {
                                 $mailings->list_id = $mynewlist->id;
                                 $mailings->list_type = '1';
                                 $mailings->send_date = $mailingsImport->send_date;
                                 $mailings->subject = $mailingsImport->subject;
                                 $mailings->htmlcontent = $mailingsImport->htmlcontent;
                                 $mailings->textonly = $mailingsImport->textonly;
                                 $mailings->attachments = $mailingsImport->attachments;
                                 $mailings->images = $mailingsImport->images;
                                 $mailings->published = $mailingsImport->published;
                                 $mailings->visible = $mailingsImport->visible;
                                 $mailings->html = $mynewlist->html;
                                 $mailings->fromname = $list->sendername;
                                 $mailings->fromemail = $list->senderemail;
                                 $mailings->frombounce = $list->bounceadres;
                                 $mailings->author_id = $my->id;
                                 $mailings->delay = 0;
                                 $mailings->issue_nb = $issue_nb;
                                 $mailings->acc_level = 25;
                                 $mailings->createdate = $list->createdate;
                                 $issue_nb++;
                                 $error = xmailing::insertMailingData($mailings);
                                 if (!$error) {
                                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>';
                                 } else {
                                     echo '<br /><b>' . _ACA_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $database->setQuery("SELECT * FROM #__newsletter_subscribers");
         $subscribers = $database->loadObjectList();
         $error = $database->getErrorMsg();
         if (!empty($error)) {
             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>';
             return false;
         } else {
             foreach ($subscribers as $subscriber) {
                 $newSubs = true;
                 $acajoomsubscribers = subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', '');
                 foreach ($acajoomsubscribers as $acajoomsubscriber) {
                     if ($subscriber->subscriber_email == $acajoomsubscriber->email) {
                         $newSubs = false;
                         $subId[0] = $acajoomsubscriber->id;
                     }
                 }
                 if ($newSubs) {
                     $newSubscriber->user_id = $subscriber->userid;
                     $newSubscriber->name = $subscriber->subscriber_name;
                     $newSubscriber->email = $subscriber->subscriber_email;
                     $newSubscriber->receive_html = $subscriber->receive_html;
                     $newSubscriber->confirmed = $subscriber->confirmed;
                     $newSubscriber->subscribe_date = $subscriber->subscribe_date;
                     $newSubscriber->blacklist = 0;
                     $newSubscriber->timezone = '00:00:00';
                     $newSubscriber->language_iso = 'eng';
                     $newSubscriber->params = '';
                     $error = subscribers::insertSubscriber($newSubscriber, $subscriberId);
                     if (!empty($error)) {
                         if ($subscriberId < 1) {
                             echo ' Error inserting subscriber:' . $newSubscriber->name;
                         }
                         $error = '';
                         $subId[0] = $subscriberId;
                     } else {
                         echo '<br /><b>' . _ACA_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . acajoom::printM('green', _ACA_IMPORT_SUCCESS);
                         $d['email'] = $subscriber->email;
                         $erro->ck = subscribers::getSubscriberIdFromEmail($d);
                         $erro->Eck(__LINE__, '8304');
                         $subId[0] = $d['subscriberId'];
                     }
                 } else {
                     echo '<br /><b>' . _ACA_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . acajoom::printM('red', _ACA_IMPORT_EXIST);
                 }
                 $j = 0;
                 $queue = queue::suscriptionExist($subId[0], $idImportedList[$subscriber->list_id]);
                 if (empty($queue)) {
                     $error = queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>';
                     }
                 }
             }
         }
     }
     return true;
 }
function configuration($action, $task)
{
    global $database;
    $config = array();
    $redirect = true;
    $xf = new xonfig();
    $message = mosGetParam($_REQUEST, 'message', '');
    switch ($task) {
        case 'sendQueue':
            if (class_exists('auto')) {
                echo acajoom::printYN(auto::processQueue(true, true), _ACA_QUEUE_SENT_SUCCESS, _ACA_ERROR);
            }
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
        case 'reset':
            $xf->update('next_autonews', '');
            $xf->update('last_cron', '');
            $xf->update('last_sub_update', '');
            $query = "UPDATE #__acajoom_lists SET `next_date` = '0' WHERE list_type = 7";
            $database->setQuery($query);
            $database->query();
            echo acajoom::printYN(true, ' Smart-Newsletter counter reset successful! ', _ACA_ERROR);
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
        case 'syncUsers':
            echo acajoom::printYN(subscribers::syncSubscribers(), _ACA_SYNC_USERS_SUCCESS, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
        case 'apply':
            $clear_log = mosGetParam($_REQUEST, 'clear_log', 0);
            if ($clear_log != 0) {
                unlink($GLOBALS['save_log_file']);
            }
            if (empty($config)) {
                $config = $_REQUEST['config'];
            }
            $message = acajoom::printYN($xf->saveConfig($config), _ACA_CONFIG_UPDATED, _ACA_ERROR);
            $xf->updateActiveList();
            compa::redirect('index2.php?option=com_acajoom&act=configuration&message=' . $message);
            break;
        case 'save':
            $clear_log = mosGetParam($_REQUEST, 'clear_log', 0);
            if ($clear_log != 0) {
                @unlink($GLOBALS['save_log_file']);
            }
            if (empty($config)) {
                $config = $_REQUEST['config'];
            }
            $message = acajoom::printYN($xf->saveConfig($config), _ACA_CONFIG_UPDATED, _ACA_ERROR);
            $xf->updateActiveList();
            backHTML::controlPanel();
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom');
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        default:
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
    }
    return true;
}
 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');
                     }
                 }
             }
         }
     }
 }
Exemple #13
0
function configuration($action, $task)
{
    if (ACA_CMSTYPE) {
        $database =& JFactory::getDBO();
    } else {
        global $database;
    }
    //endif
    $config = array();
    $redirect = true;
    $xf = new xonfig();
    if (ACA_CMSTYPE) {
        // joomla 15
        $message = JRequest::getVar('message', '');
    } else {
        //joomla 1x
        $message = mosGetParam($_REQUEST, 'message', '');
    }
    //endif
    switch ($task) {
        case 'sendQueue':
            if (class_exists('auto')) {
                echo acajoom::printYN(auto::processQueue(true, true), 'Queue processed', _ACA_ERROR);
            }
            auto::displayStatus();
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
        case 'reset':
            $xf->update('next_autonews', '');
            $xf->update('last_cron', '');
            $xf->update('last_sub_update', '');
            $query = "UPDATE #__acajoom_lists SET `next_date` = '0' WHERE list_type = 7";
            $database->setQuery($query);
            $database->query();
            echo acajoom::printYN(true, ' Smart-Newsletter counter reset successful! ', _ACA_ERROR);
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
        case 'syncUsers':
            echo acajoom::printYN(subscribers::syncSubscribers(), _ACA_SYNC_USERS_SUCCESS, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
        case 'apply':
            if (ACA_CMSTYPE) {
                // joomla 15
                $clear_log = JRequest::getVar('clear_log', '0');
            } else {
                //joomla 1x
                $clear_log = mosGetParam($_REQUEST, 'clear_log', 0);
            }
            //endif
            if ($clear_log != 0) {
                unlink(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'save_log_file']);
            }
            if (empty($config)) {
                $config = $_REQUEST['config'];
            }
            $message = strip_tags(acajoom::printYN($xf->saveConfig($config), _ACA_CONFIG_UPDATED, _ACA_ERROR));
            $xf->updateActiveList();
            compa::redirect('index2.php?option=com_acajoom&act=configuration&message=' . $message);
            break;
        case 'save':
            if (ACA_CMSTYPE) {
                // joomla 15
                $clear_log = JRequest::getVar('clear_log', '0');
            } else {
                //joomla 1x
                $clear_log = mosGetParam($_REQUEST, 'clear_log', 0);
            }
            //endif
            if ($clear_log != 0) {
                @unlink(ACA_JPATH_ROOT_NO_ADMIN . $GLOBALS[ACA . 'save_log_file']);
            }
            if (empty($config)) {
                $config = $_REQUEST['config'];
            }
            $message = acajoom::printYN($xf->saveConfig($config), _ACA_CONFIG_UPDATED, _ACA_ERROR);
            $xf->updateActiveList();
            backHTML::controlPanel();
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom');
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        default:
            backHTML::_header(_ACA_MENU_CONF, 'menu.png', $message, $task, $action);
            configHTML::showConfigEdit($GLOBALS);
            break;
    }
    return true;
}
function update($action, $task)
{
    $update = new wupdate();
    $showListing = true;
    $showComplete = false;
    $message = mosGetParam($_REQUEST, 'message', '');
    if (ini_get('safe_mode')) {
    } else {
        @set_time_limit(60 * $GLOBALS[ACA . 'script_timeout']);
    }
    /*if ((ini_get('allow_url_fopen') == false && !in_array('curl', get_loaded_extensions())) || ini_get('safe_mode') == true) {
    		 echo _ACA_WARNING_1011;
    		 return;
    	 }*/
    switch ($task) {
        case 'doUpdate':
            backHTML::_header(_ACA_MENU_UPDATE, 'update', $message, $task, $action);
            $update->doUpdate();
            $showListing = false;
            $showComplete = false;
            break;
        case 'version':
            $update->getVersion();
            break;
        case 'complete':
            $update->checkNewVersion();
            $update->completeCheck($message);
            $showComplete = true;
            $showListing = false;
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom&act=update');
            $showListing = false;
            break;
        case 'cpanel':
            compa::redirect('index2.php?option=com_acajoom');
            $showListing = false;
            break;
        case 'new1':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News1(), '<br />' . _ACA_IMPORT_SUCCESS . ' Anjel data', _ACA_ERROR);
            acajoom::resetUpgrade(1);
            echo '<br />' . $message;
            break;
        case 'new2':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News2(), '<br />' . _ACA_IMPORT_SUCCESS . ' Letterman data', _ACA_ERROR);
            acajoom::resetUpgrade(2);
            echo '<br />' . $message;
            break;
        case 'new3':
            backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
            $message = acajoom::printYN(acajoom::upgrade_News3(), '<br />' . _ACA_IMPORT_SUCCESS . ' YaNC data', _ACA_ERROR);
            acajoom::resetUpgrade(3);
            echo '<br />' . $message;
            break;
        case 'show':
        default:
            $newVersion = $update->checkUpdate($message);
            if ($newVersion) {
                $xf = new xonfig();
                $xf->update('update_avail', 0);
            }
    }
    if ($showListing) {
        backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
        backHTML::_upgrade();
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showCompsList($update);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
    } elseif ($showComplete) {
        backHTML::_header(_ACA_MENU_UPDATE, 'backup.png', $message, $task, $action);
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        echo $forms['main'];
        backHTML::formStart('', '', '');
        backHTML::showUpdateOptions($update);
        $go[] = acajoom::makeObj('act', $action);
        backHTML::formEnd($go);
    }
}