function send($showHTML, $mailing, $receivers, $list, &$message, $tags = null)
    {
        $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);
        $i = 0;
        ?>
		<form action="index2.php" method="post" name="adminForm">
			<input type="hidden" name="option" value="com_acajoom" />
			<input type="hidden" name="act" value="mailing" />
			<input type="hidden" name="listype" value="<?php 
        echo $mailing->list_type;
        ?>
" />
			<input type="hidden" name="task" value="" />
		</form>
		<?php 
        if ($showHTML) {
            echo '<form action="#" name="counterForm">';
            echo _ACA_SENDING_EMAIL;
            echo ': &nbsp;<input type="text" size="6" name="teller" value="0" style="border: 0px solid white; font-family: Arial, Helvetica, sans-serif; font-size: 1.1em;" size="1" /> of ' . $size . '</form>';
        }
        $garde = 0;
        //If two errors occur, we stop to try
        while (ob_get_level() > 0 and $garde < 2) {
            if (!ob_end_flush()) {
                $garde++;
            }
        }
        $log_detailed = "\r\n" . "\r\n" . '*** ' . strftime(_DATE_FORMAT_LC) . ' ***' . "\r\n";
        $skip_subscribers = mosGetParam($_SESSION, 'skip_subscribers' . $mailing->id, 0);
        if (empty($skip_subscribers)) {
            $skip_subscribers = mosGetParam($_REQUEST, 'skip_subscribers' . $mailing->id, 0);
        }
        $nbsubscribers = count($receivers);
        foreach ($receivers as $receiver) {
            $i++;
            if ($i <= $skip_subscribers) {
                continue;
            }
            $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 (!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();
            if ($showHTML) {
                echo '<br /><strong>' . $i . ': ';
            }
            if ($mail->error_count > 0) {
                $h .= $receiver->email . '</strong> -> ' . xmailing::M('red', _ACA_MESSAGE_NOT . '! ' . _ACA_MAILER_ERROR . ': ' . $mail->ErrorInfo);
                $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 {
                $h .= $receiver->email . '</strong> -> ' . xmailing::M('green', _ACA_MESSAGE_SENT_SUCCESSFULLY);
                $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);
                }
            }
            $mail->ClearAddresses();
            if ($showHTML) {
                echo '<script type="text/javascript" language="javascript">document.counterForm.teller.value=\'' . $i . '\';</script>';
            }
            flush();
            if ($i % $GLOBALS[ACA . 'emails_between_pauses'] == 0 and $i < $nbsubscribers) {
                if ($showHTML) {
                    echo $h;
                }
                $h = '';
                flush();
                $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 . 'display_trace'] == 1 and $showHTML) {
                    echo '<br/>Time to send: ' . $totalstr . ' ' . _ACA_SECONDS;
                    echo '<br/>Number of subscribers: ' . ($text_sent + $html_sent) . "<br />" . 'HTML format: ' . $html_sent . "<br />" . 'Text format: ' . $text_sent . "<br />";
                } else {
                    echo _ACA_QUEUE_PROCESSED;
                }
                if ($GLOBALS[ACA . 'wait_for_user'] == 0) {
                    $mtime = microtime();
                    $mtime = explode(" ", $mtime);
                    $mtime = $mtime[1] + $mtime[0];
                    $endtime = $mtime;
                    $totaltime = number_format($endtime - $starttime - $nbPause * $GLOBALS[ACA . 'pause_time'], 4, ',', '');
                    $totalstr = strval($totaltime);
                    //$h .= '<br /><b>--- Waiting ' . $GLOBALS[ACA.'pause_time']. ' seconds ---</b><br />';
                    if (!class_exists('auto')) {
                        $h .= '<b>--- Total time so far: ' . $totalstr . ' seconds ---</b><br />';
                    }
                    $log_detailed .= "\r\n" . '--- Waiting ' . $GLOBALS[ACA . 'pause_time'] . ' seconds ---' . "\r\n\r\n";
                    $log_detailed .= "\r\n" . '<b>--- Total time so far: ' . $totalstr . ' seconds ---</b><br />' . "\r\n\r\n";
                    $nbPause++;
                    echo $h;
                    flush();
                    echo '<br/><b>--- Waiting ' . $GLOBALS[ACA . 'pause_time'] . ' seconds : </b>';
                    for ($a = 0; $a < $GLOBALS[ACA . 'pause_time'] - 1; $a++) {
                        sleep(1);
                        echo $GLOBALS[ACA . 'pause_time'] - $a - 1 . ' ';
                        flush();
                    }
                    //ADRIEN REFRESH PAGE
                    if (class_exists('auto')) {
                        $_SESSION['skip_subscribers' . $mailing->id] = $i;
                        //Ecriture des statistiques
                        if ($GLOBALS[ACA . 'enable_statistics'] == 1 and ($html_sent > 0 or $text_sent > 0)) {
                            xmailing::updateStatsGlobal($mailingId, $html_sent, $text_sent, false);
                        }
                        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);
                        }
                        echo 0;
                        flush();
                        $link = 'index2.php?option=com_acajoom&act=mailing&task=sendNewsletter&listid=' . $listId . '&listype=' . $mailing->list_type . '&mailingid=' . $mailing->id;
                        compa::redirect($link);
                        exit(0);
                    }
                } else {
                    $log_detailed .= "\r\n" . '--- Waiting for user input to continue sending ---' . "\r\n\r\n";
                    $mtime = microtime();
                    $mtime = explode(" ", $mtime);
                    $mtime = $mtime[1] + $mtime[0];
                    $endtime = $mtime;
                    $totaltime = number_format($endtime - $starttime, 4, ',', '');
                    $timeStr = mosGetParam($_REQUEST, 'time', '');
                    $time = floatval($timeStr);
                    $totalsofar = $endtime - $starttime + $time;
                    $totalstr = strval($totalsofar);
                    ?>
			<form action="index2.php" method="post">
				<input type="hidden" name="option" value="com_acajoom" />
				<input type="hidden" name="act" value="mailing" />
				<input type="hidden" name="task" value="sendNewsletter" />
				<input type="hidden" name="listid" value="<?php 
                    echo $listId;
                    ?>
" />
				<input type="hidden" name="listype" value="<?php 
                    echo $mailing->list_type;
                    ?>
" />
				<input type="hidden" name="skip_subscribers" value="<?php 
                    echo $i;
                    ?>
" />
				<input type="hidden" name="mailingid" value="<?php 
                    echo $mailing->id;
                    ?>
" />
				<input type="hidden" name="time" value="<?php 
                    echo $totalstr;
                    ?>
" />
				<br />
				<input type="submit" name="submit" value="<?php 
                    echo _ACA_CONTINUE_SENDING;
                    ?>
" />
			</form>
			<?php 
                }
            } else {
                if ($showHTML) {
                    echo $h;
                }
                $h = '';
            }
        }
        if ($GLOBALS[ACA . 'enable_statistics'] == 1) {
            xmailing::updateStatsGlobal($mailingId, $html_sent, $text_sent, false);
        }
        unset($_SESSION['skip_subscribers' . $mailing->id]);
        $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 ($GLOBALS[ACA . 'display_trace'] == 1 and $showHTML) {
            echo '<br /><b>' . _ACA_SENDING_TOOK . ' ' . $totalstr . ' ' . _ACA_SECONDS . '</b><br />';
            echo 'Number of subscribers: ' . ($text_sent + $html_sent) . "<br />" . 'HTML format: ' . $html_sent . "<br />" . 'Text format: ' . $text_sent . "<br />";
        } else {
            echo _ACA_QUEUE_PROCESSED;
        }
        if (class_exists('lisType')) {
            acajoom_mail::writeLogs($list, $log_simple, $log_detailed);
        }
        ob_start();
        if ($html_sent + $text_sent > 0) {
            return true;
        } else {
            $message = xmailing::M('no', _ACA_NO_MAILING_SENT);
            return false;
        }
    }
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function subscribers($action, $task, $userid, $listId, $cid)
{
    $erro = new xerr(__FILE__, __FUNCTION__);
    if (ACA_CMSTYPE) {
        // joomla 15
        $subscriberId = intval(JRequest::getVar('subscriber_id', ''));
        $message = JRequest::getVar('message', '');
    } else {
        //joomla 1x
        $subscriberId = intval(mosGetParam($_REQUEST, 'subscriber_id', ''));
        $message = mosGetParam($_REQUEST, 'message', '');
    }
    //endif
    $doShowSubscribers = true;
    subscribers::updateSubscribers();
    switch ($task) {
        case 'updateOneSub':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::updateOneSubscriber(), _ACA_UPDATED_SUCCESSFULLY, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'deleteOneSub':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::deleteOneSubscriber($subscriberId), _ACA_SUBSCRIBER_DELETED, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'cancelSub':
            $doShowSubscribers = true;
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'edit':
            foreach ($cid as $id) {
                compa::redirect('index2.php?option=com_acajoom&act=subscribers&task=show&userid=' . $id);
            }
            break;
        case 'show':
            $doShowSubscribers = false;
            $qid[0] = $userid;
            $subscriber = subscribers::getSubscribersFromId($qid, false);
            $lists = lists::getLists(0, 0, 1, '', false, false);
            $queues = queue::getSubscriberLists($userid);
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo subscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, acajoom::checkPermissions('admin'), false, false);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('subscriber_id', $subscriber->id);
            $go[] = acajoom::makeObj('user_id', $subscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'new':
        case 'add':
            $doShowSubscribers = false;
            $newSubscriber->id = '';
            $newSubscriber->user_id = 0;
            $newSubscriber->name = '';
            $newSubscriber->email = '';
            $newSubscriber->receive_html = 1;
            $newSubscriber->confirmed = 1;
            $newSubscriber->blacklist = 0;
            $newSubscriber->timezone = '00:00:00';
            $newSubscriber->language_iso = 'eng';
            $newSubscriber->params = '';
            $newSubscriber->subscribe_date = acajoom::getNow();
            $lists = lists::getLists(0, 0, 1, '', false, false);
            $queues = '';
            $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo subscribersHTML::editSubscriber($newSubscriber, $lists, $queues, $forms, acajoom::checkPermissions('admin'), false, false);
            $go[] = acajoom::makeObj('act', $action);
            $go[] = acajoom::makeObj('subscriber_id', $newSubscriber->id);
            $go[] = acajoom::makeObj('user_id', $newSubscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            $doShowSubscribers = true;
            $message = acajoom::printYN(subscribers::insertOneSubscriber(), _ACA_UPDATED_SUCCESSFULLY, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'delete':
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $status = true;
                foreach ($cid as $id) {
                    $erro->ck = subscribers::deleteOneSubscriber($id);
                    if (!$erro->ck) {
                        $status = false;
                    }
                }
                $message = acajoom::printYN($status, _ACA_SUBSCRIBER_DELETED, _ACA_ERROR);
                backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            }
            break;
        case 'update':
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to update'); window.history.go(-1);</script>\n";
                return false;
            } else {
                foreach ($cid as $id) {
                    if (ACA_CMSTYPE) {
                        // joomla 15
                        $changes = JRequest::getVar($id, array(0));
                    } else {
                        //joomla 1x
                        $changes = mosGetParam($_REQUEST, $id, array(0));
                    }
                    //endif
                    if (!isset($changes['receive_html'])) {
                        $changes['receive_html'] = 0;
                    }
                    if (!isset($changes['confirmed'])) {
                        $changes['confirmed'] = 0;
                    }
                }
            }
            $message = acajoom::print_message(_ACA_UPDATED_SUCCESSFULLY, 1);
            break;
        case 'export':
            $doShowSubscribers = false;
            subscribersHTML::export($action, $listId);
            break;
        case 'doExport':
            $message = acajoom::printYN(subscribers::export($listId), _EXPORT, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'import':
            $doShowSubscribers = false;
            $lists = lists::getLists(0, 0, 1, 'listnameA', false, false, true);
            subscribersHTML::import($action, $lists);
            break;
        case 'doImport':
            $message = acajoom::printYN(subscribers::import($listId), _ACA_IMPORT_FINISHED, _ACA_ERROR);
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
            break;
        case 'subscribeAll':
            break;
        case 'unsubscribeAll':
            break;
        case 'cancel':
            if ($listId != 0) {
                $listId = 0;
            } else {
                compa::redirect('index2.php?option=com_acajoom');
            }
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            $doShowSubscribers = 0;
            break;
        default:
            backHTML::_header(_ACA_MENU_SUBSCRIBERS, 'addusers.png', $message, $task, $action);
            break;
    }
    if ($doShowSubscribers) {
        if (ACA_CMSTYPE) {
            // joomla 15
            $start = intval(JRequest::getVar('start', 0));
            $conf =& JFactory::getConfig();
            $mail->Mailer = $conf->getValue('config.mailer');
            // $GLOBALS['mosConfig_mailer'];
            $limit = intval(JRequest::getVar('limit', $conf->getValue('config.list_limit')));
            $emailsearch = JRequest::getVar('emailsearch', '');
        } else {
            //joomla 1x
            $mail->Mailer = $GLOBALS['mosConfig_mailer'];
            $start = intval(mosGetParam($_REQUEST, 'start', 0));
            $limit = intval(mosGetParam($_REQUEST, 'limit', $GLOBALS['mosConfig_list_limit']));
            $emailsearch = mosGetParam($_REQUEST, 'emailsearch', '');
        }
        //endif
        $total = 0;
        $subscribers = subscribers::getSubscribers($start, $limit, $emailsearch, $total, $listId, '', '', '', 'sub_dateD');
        if ($listId != 0) {
            $showAdmin = true;
        } else {
            $showAdmin = false;
        }
        $dropDownList = lisType::getListsDropList(0, '', '');
        if (ACA_CMSTYPE) {
            // joomla 15
            $lists['listid'] = JHTML::_('select.genericlist', $dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.AcajoomFilterForm.submit();"', 'id', 'list_name', $listId);
        } else {
            //joomla 1x
            $lists['listid'] = mosHTML::selectList($dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.AcajoomFilterForm.submit();"', 'id', 'list_name', $listId);
        }
        //endif
        $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n";
        $forms['select'] = " <form action='index2.php' method='post' name='AcajoomFilterForm'> \n";
        backHTML::formStart('show_mailing', 0, '');
        subscribersHTML::showSubscribers($subscribers, $action, $listId, $lists, $start, $limit, $total, $showAdmin, $listId, $emailsearch, $forms);
    }
    return true;
}
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function mailing($action, $task, $listId, $listType, $mailingId, $message)
{
    $showMailings = false;
    switch ($task) {
        case 'edit':
            if (ACA_CMSTYPE) {
                // joomla 15
                $issue_nb = intval(JRequest::getVar('issue_nb', 1));
            } else {
                //joomla 1x
                $issue_nb = intval(mosGetParam($_REQUEST, 'issue_nb', 1));
            }
            //endif
            $list = lists::getOneList($listId);
            $mailing = xmailing::getOneMailing($list, $mailingId, $issue_nb, $new);
            $show = lisType::showType($mailing->list_type, 'editmailing');
            if ($mailing->published != 1 or $mailing->list_type != 1 or isset($show['admin']) and $show['admin']) {
                $forms['main'] = " <form action='index2.php' method='post' enctype='multipart/form-data' name='adminForm'> \n ";
                xmailing::_header($task, $action, $mailing->list_type, $message, 'edit');
                mailingsHTML::editMailing($mailing, $new, $listId, $forms, $show);
                $go[] = acajoom::makeObj('act', $action);
                backHTML::formEnd($go);
            } else {
                $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n\r";
                xmailing::_header($task, $action, $mailing->list_type, $message);
                //backHTML::formStart();
                mailingsHTML::viewMailing($mailing, $forms);
                $go[] = acajoom::makeObj('act', 'mailing');
                $go[] = acajoom::makeObj('task', 'viewmailing');
                $go[] = acajoom::makeObj('listid', $mailing->list_id);
                backHTML::formEnd($go);
            }
            break;
        case 'new':
        case 'add':
            if ($listId == 0) {
                echo "<script> alert('" . addslashes(_ACA_SELCT_MAILING) . "'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $total = xmailing::countMailings($listId, '');
                $total++;
                compa::redirect('index2.php?option=com_acajoom&act=mailing&task=edit&mailingid=0&issue_nb=' . $total . '&listid=' . $listId);
            }
            break;
        case 'saveSend':
            xmailing::saveMailing($mailingId, $listId);
        case 'sendNewsletter':
            if ($listId < 1 or $listType < 0) {
                $mailing = xmailing::getOneMailing('', $mailingId, '', $new, true);
                $listId = $mailing->list_id;
                $listType = $mailing->list_type;
            }
            if (lisType::sendType($listType)) {
                $checkStatus = lists::checkStatus($listId);
                if ($checkStatus == false) {
                    $message = acajoom::printYN(0, _ACA_MESSAGE_SENT_SUCCESSFULLY, _ACA_NOT_PUBLISHED);
                    $showMailings = true;
                } else {
                    $receivers = subscribers::getSubscribers(-1, -1, '', $total, $listId, '', 1, 1, 'sub_emailA');
                    if (empty($receivers)) {
                        $message = acajoom::printYN(0, _ACA_MESSAGE_SENT_SUCCESSFULLY, _ACA_NO_SUSCRIBERS);
                        $showMailings = true;
                    } else {
                        $status = queue::sendNewsletter(true, $mailingId, $listId, $receivers, $message);
                        $message = acajoom::printYN($status, _ACA_MESSAGE_SENT_SUCCESSFULLY, $message);
                        $showMailings = true;
                        flush();
                        sleep(5);
                        compa::redirect('index2.php?option=com_acajoom&act=mailing&listype=' . $listType, $message);
                    }
                }
            } else {
                if (class_exists('auto')) {
                    $message = acajoom::printYN(auto::processQueue(true), _ACA_QUEUE_SENT_SUCCESS, _ACA_ERROR);
                }
                $showMailings = true;
            }
            break;
        case 'savePreview':
            xmailing::saveMailing($mailingId, $listId);
        case 'preview':
            if (ACA_CMSTYPE) {
                // joomla 15
                $emailaddress = JRequest::getVar('emailaddress', '');
            } else {
                //joomla 1x
                $emailaddress = mosGetParam($_REQUEST, 'emailaddress', '');
            }
            //endif
            if (!empty($emailaddress)) {
                $status = xmailing::preview($mailingId, $listId, $message);
                $message = acajoom::printYN($status, _ACA_MESSAGE_SENT_SUCCESSFULLY, $message);
            }
            backHTML::_header(_ACA_PREVIEW_TITLE, 'preview_f2.png', $message, $task, $action);
            mailingsHTML::previewMailingHTML($mailingId, $listId, $listType);
            if ($listId > 0) {
                $archivemailing = xmailing::getMailingView($mailingId, $listId);
            } else {
                $archivemailing = xmailing::getMailingView($mailingId);
            }
            $forms['main'] = '';
            $list = lists::getOneList($archivemailing->list_id);
            $textonly = '';
            acajoom_mail::getContent($archivemailing->images, $list->layout, $archivemailing->htmlcontent, $textonly);
            acajoom_mail::replaceClass($archivemailing->htmlcontent, $textonly);
            mailingsHTML::viewMailing($archivemailing, $forms);
            break;
        case 'view':
            if ($mailingId != 0) {
                if ($listId > 0) {
                    $archivemailing = xmailing::getMailingView($mailingId, $listId);
                } else {
                    $archivemailing = xmailing::getMailingView($mailingId);
                }
                $forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n\r";
                xmailing::_header($task, $action, $listType, $message);
                backHTML::formStart('', 0, '');
                mailingsHTML::viewMailing($archivemailing, $forms);
                $go[] = acajoom::makeObj('act', 'mailing');
                $go[] = acajoom::makeObj('task', 'viewmailing');
                $go[] = acajoom::makeObj('listid', $archivemailing->list_id);
                backHTML::formEnd($go);
            }
            break;
        case 'deleteMailing':
            $d['mailing'] = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::delete($d), @constant($GLOBALS[ACA . 'listname' . $d['mailing']->list_type]) . _ACA_SUCCESS_DELETED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom');
            break;
        case 'copy':
            $message = acajoom::printYN(xmailing::copyMailing($mailingId), _ACA_MAILING_COPY, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cancelMailing':
            $showMailings = true;
            break;
        case 'publishMailing':
            $mailing = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::publishMailing($mailingId), @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]) . ' ' . _ACA_PUBLISHED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'unpublishMailing':
            $mailing = xmailing::getOneMailing('', $mailingId, '', $new);
            $message = acajoom::printYN(xmailing::unpublishMailing($mailingId), @constant($GLOBALS[ACA . 'listname' . $mailing->list_type]) . ' ' . _ACA_UNPUBLISHED, _ACA_ERROR);
            $showMailings = true;
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'save':
            $message = acajoom::printYN(xmailing::saveMailing($mailingId, $listId), _ACA_MAILING_SAVED, _ACA_ERROR);
            $showMailings = true;
            unset($GLOBALS["task"]);
            unset($_REQUEST["task"]);
            break;
        case 'show':
        default:
            $showMailings = true;
            break;
    }
    if ($showMailings) {
        xmailing::showMailings($task, $action, $listId, $listType, $message, true, _ACA_MENU_MAILING);
    }
    return true;
}
Exemple #4
0
     } else {
         $message = frontEnd::newSubscriber($name, $email);
     }
     if ($GLOBALS[ACA . 'addEmailRedLink']) {
         if (preg_match('?', $redirectlink)) {
             $redirectlink .= '&email=' . $email;
         } else {
             $redirectlink .= '?email=' . $email;
         }
     }
     $showMessage = mosGetParam($_REQUEST, 'listname', 0);
     if (!empty($redirectlink)) {
         if (!$showMessage) {
             $message = '';
         }
         compa::redirect($redirectlink, $message);
     } else {
         $showPanel = true;
     }
     break;
 case 'list':
     frontEnd::showLists($subscriberId, $listId, $lisType, $action, $task);
     break;
 case 'token':
     auto::receiveToken();
     break;
 default:
     if (class_exists('auto')) {
         $showPanel = auto::getCase($action);
     } else {
         $showPanel = true;
Exemple #5
0
/**
* @copyright Copyright (C) 2009 Joobi Limited All rights reserved.
* @license This file is released under the GPL license (http://www.gnu.org/licenses )
* @link http://www.ijoobi.com
*/
function update($action, $task)
{
    $update = new wupdate();
    $showListing = true;
    $showComplete = false;
    if (ACA_CMSTYPE) {
        // joomla 15
        $message = JRequest::getVar('message', '');
    } else {
        //joomla 1x
        $message = mosGetParam($_REQUEST, 'message', '');
    }
    //endif
    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':
            $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;
    }
    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);
    }
}
function statistics($listId, $listType, $mailingId, $message, $task, $action)
{
    global $database;
    $erro = new xerr(__FILE__, __FUNCTION__);
    switch ($task) {
        case 'edit':
        case 'view':
            $mailing = xmailing::getOneMailing(0, $mailingId, '', $new);
            $list = lists::getOneList($mailing->list_id);
            $listId = $list->id;
            $listType = $list->list_type;
            if ($mailingId != 0) {
                $query = 'SELECT * FROM `#__acajoom_stats_global` WHERE `mailing_id` = \'' . $mailingId . '\'';
                $database->setQuery($query);
                $database->loadObject($globalStats);
                $erro->err = $database->getErrorMsg();
                if (empty($globalStats)) {
                    $globalStats->html_sent = '';
                    $globalStats->html_read = 0;
                    $globalStats->text_sent = '';
                }
                $query = 'SELECT U.name, U.email, D.html, D.read FROM `#__acajoom_stats_details` as D ' . 'LEFT JOIN `#__acajoom_subscribers` as U ON D.subscriber_id=U.id WHERE  D.mailing_id = \'' . $mailingId . '\'';
                $database->setQuery($query);
                $detailedStats = $database->loadObjectList();
                $erro->err .= $database->getErrorMsg();
                $erro->show();
                if (!$erro->E(__LINE__, '8009')) {
                    return false;
                } else {
                    $html_read = array();
                    $html_unread = array();
                    $text = array();
                    foreach ($detailedStats as $detailedStat) {
                        if ($detailedStat->html == 1) {
                            if ($detailedStat->read == 1) {
                                $html_read[] = $detailedStat;
                            } else {
                                $html_unread[] = $detailedStat;
                            }
                        } else {
                            $text[] = $detailedStat;
                        }
                    }
                    backHTML::_header(_ACA_MENU_STATS, 'query.png', $message, $task, $action);
                    backHTML::showStatistics($list, $mailing, $globalStats, $html_read, $html_unread, $text, $listId);
                }
            } else {
                echo '<p> Please select a mailings id.</p>';
                return false;
            }
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom&act=statistics&listid=' . $listId);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        default:
            backHTML::_header(_ACA_MENU_STATS, 'query.png', $message, $task, $action);
            xmailing::showMailings($task, $action, $listId, $listType, '', false, _ACA_MENU_STATS_FOR);
    }
}