Example #1
0
 function insertStatsGlobal($mailingId)
 {
     global $database;
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $query = 'SELECT COUNT(mailing_id) FROM `#__acajoom_stats_global` WHERE `mailing_id` = \'' . $mailingId . '\'';
     $database->setQuery($query);
     $nb = $database->loadResult();
     $erro->err = $database->getErrorMsg();
     $erro->E(__LINE__, '8430', $database);
     if ($nb < 1) {
         $query = 'INSERT INTO `#__acajoom_stats_global` ( `mailing_id`, `sentdate`, `html_sent`, `text_sent`	) VALUES (' . $mailingId . ', \'' . acajoom::getNow() . '\', ' . ' 0 , ' . ' 0 )';
         $database->setQuery($query);
         $database->query();
         $erro->err = $database->getErrorMsg();
     }
     return $erro->E(__LINE__, '8422', $database);
 }
Example #2
0
 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;
     }
 }
Example #3
0
 function filetoDatabase($acajoomConfigFile)
 {
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     $erro->show();
     $configKeys = array_keys($acajoomConfigFile);
     $size = sizeof($configKeys);
     for ($index = 0; $index < $size; $index++) {
         $erro->err .= $this->insert($configKeys[$index], $acajoomConfigFile[$configKeys[$index]], 0);
     }
     return $erro->E(__LINE__, '9012');
 }
Example #4
0
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;
    }
}
Example #5
0
 function remove($subscriberId, $cle = '', $listId)
 {
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     if (!empty($subscriberId) and !empty($cle) and $listId > 0) {
         $qid[0] = $subscriberId;
         $subscriber = subscribers::getSubscribersFromId($qid, false);
         if (md5($subscriber->email) == $cle) {
             $suscription = new stdClass();
             $suscription->user_id = $subscriberId;
             $suscription->sub_list_id[1] = $listId;
             $suscription->subscribed[1] = 0;
             $suscription->acc_level[1] = 0;
             $erro->ck = queue::updateSuscription($suscription);
             $erro->Eck(__LINE__, '8277');
             $list = lists::getOneList($listId);
             if ($list->unsubscribesend == 1) {
                 $erro->err = acajoom_mail::sendUnsubcribeEmail($subscriberId, $list);
                 $erro->E(__LINE__, '8278');
             }
         }
     }
     return $erro->R();
 }
Example #6
0
function acajoombot_content_getitem($id)
{
    if (ACA_CMSTYPE) {
        $database =& JFactory::getDBO();
    } else {
        global $database;
    }
    //endif
    $erro = new xerr(__FILE__, __FUNCTION__);
    $query = "SELECT a.title as title, a.sectionid as sectionid, a.catid as catid, a.introtext as introtext, b.name as name, a.created_by_alias as created_by_alias, a.fulltext as `fulltext`, a.images as images FROM #__content as a LEFT JOIN #__users as b ON a.created_by = b.id WHERE a.id = {$id}";
    $database->setQuery($query);
    if (ACA_CMSTYPE) {
        // joomla 15
        $content_item = $database->loadObject();
    } else {
        //joomla 1x
        $database->loadObject($content_item);
    }
    //endif
    $erro->err = $database->getErrorMsg();
    $erro->show();
    if ($content_item->created_by_alias == '') {
        $content_item->created_by_alias = $content_item->name;
    }
    if (!$erro->E(__LINE__, '8011')) {
        return false;
    } else {
        if (get_magic_quotes_runtime()) {
            $content_item->title = stripslashes($content_item->title);
            $content_item->introtext = stripslashes($content_item->introtext);
            $content_item->fulltext = stripslashes($content_item->fulltext);
            $content_item->images = stripslashes($content_item->images);
            $content_item->created_by_alias = stripslashes($content_item->created_by_alias);
        }
        return $content_item;
    }
}
Example #7
0
 function deleteSubsQueue($subscriber_id, $listId)
 {
     if (ACA_CMSTYPE) {
         $database =& JFactory::getDBO();
     } else {
         global $database;
     }
     //endif
     $erro = new xerr(__FILE__, __FUNCTION__, __CLASS__);
     if ($subscriber_id > 0) {
         $query = 'DELETE FROM `#__acajoom_queue` WHERE `subscriber_id` = ' . $subscriber_id;
         if ($listId > 0) {
             $query .= ' AND `list_id` =' . $listId;
         }
         $database->setQuery($query);
         $database->query();
         $erro->err = $database->getErrorMsg();
         $erro->E(__LINE__, '8539', $database);
     }
     return $erro->R();
 }
Example #8
0
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);
    }
}
 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');
                     }
                 }
             }
         }
     }
 }