function language() { $this->setLayout('default'); $code = JRequest::getString('code'); if (empty($code)) { acymailing::display('Code not specified', 'error'); return; } $file = null; $file->name = $code; $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini'; $file->path = $path; jimport('joomla.filesystem.file'); $showLatest = true; $loadLatest = false; if (JFile::exists($path)) { $file->content = JFile::read($path); if (empty($file->content)) { acymailing::display('File not found : ' . $path, 'error'); } } else { $loadLatest = true; acymailing::display(JText::_('LOAD_ENGLISH_1') . '<br/>' . JText::_('LOAD_ENGLISH_2') . '<br/>' . JText::_('LOAD_ENGLISH_3'), 'info'); $file->content = JFile::read(JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'en-GB' . DS . 'en-GB.com_acymailing.ini'); } if ($loadLatest or JRequest::getString('task') == 'latest') { $doc =& JFactory::getDocument(); $doc->addScript(ACYMAILING_UPDATEURL . 'languageload&code=' . JRequest::getString('code')); $showLatest = false; } elseif (JRequest::getString('task') == 'save') { $showLatest = false; } $this->assignRef('showLatest', $showLatest); $this->assignRef('file', $file); }
function export() { $selectedMail = JRequest::getInt('filter_mail', 0); $selectedStatus = JRequest::getString('filter_status', ''); $filters = array(); if (!empty($selectedMail)) { $filters[] = 'a.mailid = ' . $selectedMail; } if (!empty($selectedStatus)) { if ($selectedStatus == 'bounce') { $filters[] = 'a.bounce > 0'; } elseif ($selectedStatus == 'open') { $filters[] = 'a.open > 0'; } elseif ($selectedStatus == 'notopen') { $filters[] = 'a.open < 1'; } elseif ($selectedStatus == 'failed') { $filters[] = 'a.fail > 0'; } } $query = 'SELECT `subid` FROM `#__acymailing_userstats` as a '; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } $db =& JFactory::getDBO(); $db->setQuery($query); $_SESSION['acymailing']['exportusers'] = $db->loadResultArray(); $this->setRedirect(acymailing::completeLink('data&task=export&sessionvalues=1', false, true)); }
function acymailing_replaceusertags(&$email, &$user) { if (!empty($email->altbody)) { $email->altbody = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->altbody); } if (!$email->sendHTML or empty($email->type) or !in_array($email->type, array('news', 'autonews', 'followup')) or strpos($email->body, '{nostatpicture}')) { $email->body = str_replace(array('{statpicture}', '{nostatpicture}'), '', $email->body); return; } if (empty($user->subid)) { return $this->acymailing_replaceusertagspreview($email, $user); } $widthsize = $this->params->get('width', 50); $heightsize = $this->params->get('height', 1); $width = empty($widthsize) ? '' : ' width="' . $widthsize . '" '; $height = empty($heightsize) ? '' : ' height="' . $heightsize . '" '; $statPicture = '<img alt="' . $this->params->get('alttext', '') . '" src="' . acymailing::frontendLink('index.php?option=com_acymailing&ctrl=stats&mailid=' . $email->mailid . '&subid=' . $user->subid) . '" border="0" ' . $height . $width . '/>'; if (strpos($email->body, '{statpicture}')) { $email->body = str_replace('{statpicture}', $statPicture, $email->body); } elseif (strpos($email->body, '</body>')) { $email->body = str_replace('</body>', $statPicture . '</body>', $email->body); } else { $email->body .= $statPicture; } }
function export() { $listClass = acymailing::get('class.list'); $db =& JFactory::getDBO(); $fields = reset($db->getTableFields(acymailing::table('subscriber'))); acymailing::setTitle(JText::_('ACY_EXPORT'), 'acyexport', 'data&task=export'); $bar =& JToolBar::getInstance('toolbar'); JToolBarHelper::custom('doexport', 'acyexport', '', JText::_('ACY_EXPORT'), false); $bar->appendButton('Link', 'cancel', JText::_('ACY_CANCEL'), acymailing::completeLink('subscriber')); JToolBarHelper::divider(); $bar->appendButton('Pophelp', 'data-export'); $this->assignRef('charset', $charsetType = acymailing::get('type.charset')); $this->assignRef('lists', $listClass->getLists()); $this->assignRef('fields', $fields); if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) { $i = 1; $subids = array(); foreach ($_SESSION['acymailing']['exportusers'] as $subid) { $subids[] = (int) $subid; $i++; if ($i > 10) { break; } } $db->setQuery('SELECT `name`,`email` FROM `#__acymailing_subscriber` WHERE `subid` IN (' . implode(',', $subids) . ')'); $users = $db->loadObjectList(); $this->assignRef('users', $users); } }
/** * Event "onNewsletterSubscribe" * * @access private * @param null * @return int */ public function onNewsletterSubscribe($user, $state) { if ($this->isEnabled() == false) { return false; } $list_id = $this->getParams()->get('newsletter'); if (empty($list_id)) { return true; } if (!(include_once rtrim(JPATH_ADMINISTRATOR, '/') . '/components/com_acymailing/helpers/helper.php')) { return false; } // See if the user exists in the database $acyUser = null; $acyUser->email = $user->email; $acyUser->name = $user->name; $acyUser->userid = $user->id; $subscriberClass = acymailing::get('class.subscriber'); $subscriberClass->checkVisitor = false; $subid = $subscriberClass->save($acyUser); if (empty($subid)) { return false; } $newSubscription = array(); $newList = array(); $newList['status'] = $state == 0 ? 0 : 1; $newSubscription[intval($list_id)] = $newList; $subscriberClass->saveSubscription($subid, $newSubscription); return true; }
function remove() { if (!$this->isAllowed($this->aclCat, 'delete')) { return; } JRequest::checkToken() or die('Invalid Token'); $mailid = JRequest::getVar('filter_mail', 0, 'post', 'int'); $queueClass = acymailing::get('class.queue'); $search = JRequest::getString('search'); $filters = array(); if (!empty($search)) { $db = JFactory::getDBO(); $searchVal = '\'%' . $db->getEscaped($search, true) . '%\''; $searchFields = array('b.name', 'b.email', 'c.subject', 'a.mailid', 'a.subid'); $filters[] = implode(" LIKE {$searchVal} OR ", $searchFields) . " LIKE {$searchVal}"; } if (!empty($mailid)) { $filters[] = 'a.mailid = ' . intval($mailid); } $total = $queueClass->delete($filters); $app =& JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $total), 'message'); JRequest::setVar('filter_mail', 0, 'post'); JRequest::setVar('search', '', 'post'); return $this->listing(); }
function listing() { JRequest::setVar('tmpl', 'component'); $statsClass = acymailing::get('class.stats'); $statsClass->saveStats(); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); ob_end_clean(); JPluginHelper::importPlugin('acymailing'); $this->dispatcher =& JDispatcher::getInstance(); $results = $this->dispatcher->trigger('acymailing_getstatpicture'); $picture = reset($results); if (empty($picture)) { $picture = 'components/com_acymailing/images/statpicture.png'; } $picture = ltrim(str_replace(array('\\', '/'), DS, $picture), DS); $imagename = ACYMAILING_ROOT . $picture; $handle = fopen($imagename, 'r'); if (!$handle) { exit; } header("Content-type: image/png"); $contents = fread($handle, filesize($imagename)); fclose($handle); echo $contents; exit; }
function generate() { $app =& JFactory::getApplication(); $autoNewsHelper = acymailing::get('helper.autonews'); if (!$autoNewsHelper->generate()) { $app->enqueueMessage(JText::_('NO_AUTONEWS'), 'notice'); $db =& JFactory::getDBO(); $db->setQuery("SELECT * FROM " . acymailing::table('mail') . " WHERE `type` = 'autonews'"); $allAutonews = $db->loadObjectList(); if (!empty($allAutonews)) { $time = time(); foreach ($allAutonews as $oneAutonews) { if ($oneAutonews->published != 1) { $app->enqueueMessage(JText::sprintf('AUTONEWS_NOT_PUBLISHED', $oneAutonews->subject), 'notice'); } elseif ($oneAutonews->senddate >= $time) { $app->enqueueMessage(JText::sprintf('AUTONEWS_NOT_READY', $oneAutonews->subject), 'notice'); } } } } else { foreach ($autoNewsHelper->messages as $oneMessage) { $app->enqueueMessage($oneMessage); } } return $this->listing(); }
function addClick($urlid, $mailid, $subid) { $mailid = intval($mailid); $urlid = intval($urlid); $subid = intval($subid); if (empty($mailid) or empty($urlid) or empty($subid)) { return false; } $statsClass = acymailing::get('class.stats'); $statsClass->countReturn = false; if (!$statsClass->saveStats()) { return false; } $date = time(); $query = 'INSERT IGNORE INTO ' . acymailing::table('urlclick') . ' (urlid,mailid,subid,date,click) VALUES (' . $urlid . ',' . $mailid . ',' . $subid . ',' . $date . ',1)'; $this->database->setQuery($query); $this->database->query(); if (!$this->database->getAffectedRows()) { $query = 'UPDATE ' . acymailing::table('urlclick') . ' SET click = click +1,`date` = ' . $date . ' WHERE mailid = ' . $mailid . ' AND urlid = ' . $urlid . ' AND subid = ' . $subid . ' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); } $query = 'SELECT SUM(click) FROM ' . acymailing::table('urlclick') . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid; $this->database->setQuery($query); $totalUserClick = $this->database->loadResult(); $query = 'UPDATE ' . acymailing::table('stats') . ' SET clicktotal = clicktotal + 1 '; if ($totalUserClick <= 1) { $query .= ' , clickunique = clickunique + 1'; } $query .= ' WHERE mailid = ' . $mailid . ' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); return true; }
function insert($subid, $action, $data = array()) { $user =& JFactory::getUser(); if (!empty($user->id)) { $data[] = 'EXECUTED_BY::' . $user->id . ' ( ' . $user->username . ' )'; } $history = null; $history->subid = intval($subid); $history->action = strip_tags($action); $history->data = implode("\n", $data); $history->date = time(); $userHelper = acymailing::get('helper.user'); $history->ip = $userHelper->getIP(); if (!empty($_SERVER)) { $source = array(); $vars = array('HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_HOST', 'SERVER_ADDR', 'REMOTE_ADDR', 'REQUEST_URI', 'QUERY_STRING'); foreach ($vars as $oneVar) { if (!empty($_SERVER[$oneVar])) { $source[] = $oneVar . '::' . strip_tags($_SERVER[$oneVar]); } } $history->source = implode("\n", $source); } return $this->database->insertObject(acymailing::table('history'), $history); }
function display() { static $i = 0; $i++; $this->filters['group'] = JHTML::_('select.genericlist', $this->groups, "filter[{$i}][group]", 'class="inputbox" size="1"', 'value', 'text'); $this->filters['list'] = $this->status->display("filter[{$i}][list_status]", 1, false) . ' ' . JHTML::_('select.genericlist', $this->lists, "filter[{$i}][list]", 'class="inputbox" size="1"', 'value', 'text'); $this->filters['acymailingfield'] = JHTML::_('select.genericlist', $this->acymailingfields, "filter[{$i}][acymailingfield]", 'class="inputbox" size="1"', 'value', 'text'); $this->filters['acymailingfield'] .= ' ' . $this->operators->display("filter[{$i}][acymailingfield_operator]") . ' <input class="inputbox" type="text" name="filter[' . $i . '][acymailingfield_value]" size="50" value="">'; $this->filters['joomlafield'] = JHTML::_('select.genericlist', $this->joomlafields, "filter[{$i}][joomlafield]", 'class="inputbox" size="1"', 'value', 'text'); $this->filters['joomlafield'] .= ' ' . $this->operators->display("filter[{$i}][joomlafield_operator]") . ' <input class="inputbox" type="text" name="filter[' . $i . '][joomlafield_value]" size="50" value="">'; if (!empty($this->cbfield)) { $this->filters['cbfield'] = JHTML::_('select.genericlist', $this->cbfield, "filter[{$i}][cbfield]", 'class="inputbox" size="1"', 'value', 'text'); $this->filters['cbfield'] .= ' ' . $this->operators->display("filter[{$i}][cbfield_operator]") . ' <input class="inputbox" type="text" name="filter[' . $i . '][cbfield_value]" size="50" value="">'; } if (acymailing::level(3)) { include dirname(__FILE__) . DS . 'filterenterprisedisplay.php'; } $return = '<div id="filter_' . $i . '">'; $return .= JHTML::_('select.genericlist', $this->type, "filter[type][{$i}]", 'class="inputbox" size="1" onchange="updateFilter(' . $i . ');"', 'value', 'text'); foreach ($this->filters as $oneFilterName => $content) { $return .= '<div id="filter_' . $i . $oneFilterName . '" style="display:none;margin-left:150px">'; $return .= $content; $return .= '</div>'; } $return .= '</div>'; return $return; }
function saveStats() { $subid = JRequest::getInt('subid'); $mailid = JRequest::getInt('mailid'); if (empty($subid) or empty($mailid)) { return false; } $db = JFactory::getDBO(); $db->setQuery('SELECT open FROM ' . acymailing::table('userstats') . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid . ' LIMIT 1'); $actual = $db->loadObject(); if (empty($actual)) { return false; } $open = 0; if (empty($actual->open)) { $open = 1; $unique = ',openunique = openunique +1'; } elseif ($this->countReturn) { $open = $actual->open + 1; $unique = ''; } if (empty($open)) { return true; } $db->setQuery('UPDATE ' . acymailing::table('userstats') . ' SET open = ' . $open . ', opendate = ' . time() . ' WHERE mailid = ' . $mailid . ' AND subid = ' . $subid . ' LIMIT 1'); $db->query(); $db->setQuery('UPDATE ' . acymailing::table('stats') . ' SET opentotal = opentotal +1 ' . $unique . ' WHERE mailid = ' . $mailid . ' LIMIT 1'); $db->query(); return true; }
public static function getMails() { $db = JFactory::getDbo(); $query = "SELECT * FROM " . acymailing::table('mail') . " WHERE published = 1 AND visible = 1"; $db->setQuery($query); return $db->loadObjectList(); }
function getInput() { include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_acymailing' . DS . 'helpers' . DS . 'helper.php'; $listType = acymailing::get('type.lists'); array_shift($listType->values); return $listType->display($this->name, (int) $this->value, false); }
function save($list) { if (empty($list->listid)) { if (empty($list->userid)) { $user =& JFactory::getUser(); $list->userid = $user->id; } if (empty($list->alias)) { $list->alias = $list->name; } } if (isset($list->alias)) { if (empty($list->alias)) { $list->alias = $list->name; } $list->alias = JFilterOutput::stringURLSafe(trim($list->alias)); } if (empty($list->listid)) { $status = $this->database->insertObject(acymailing::table('list'), $list); } else { $status = $this->database->updateObject(acymailing::table('list'), $list, 'listid'); } if ($status) { return empty($list->listid) ? $this->database->insertid() : $list->listid; } return false; }
function fetchElement($name, $value, &$node, $control_name) { include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_acymailing' . DS . 'helpers' . DS . 'helper.php'; $listType = acymailing::get('type.lists'); array_shift($listType->values); return $listType->display($control_name . '[listid]', (int) $value, false); }
function view() { $statsClass = acymailing::get('class.stats'); $statsClass->countReturn = false; $statsClass->saveStats(); JRequest::setVar('layout', 'view'); return parent::display(); }
function acymailing_replaceusertags(&$email, &$user, $addbody = true) { if (!$email->sendHTML) { return; } $email->body = preg_replace('#< *(tr|td|table)([^>]*)(style="[^"]*)background-image *: *url\\(\'?([^)\']*)\'?\\);?#Ui', '<$1 background="$4" $2 $3', $email->body); $email->body = acymailing::absoluteURL($email->body); $email->body = preg_replace('#< *img([^>]*)(style="[^"]*)(float *: *)(right|left|top|bottom|middle)#Ui', '<img$1 align="$4" hspace="5" $2$3$4', $email->body); if (empty($email->tempid)) { return; } if (!isset($this->templates[$email->tempid])) { $this->templates[$email->tempid] = array(); if (empty($this->templateClass)) { $this->templateClass = acymailing::get('class.template'); } $template = $this->templateClass->get($email->tempid); if (!empty($template->stylesheet)) { $this->stylesheets[$email->tempid] = $template->stylesheet; } if (!empty($template->styles)) { foreach ($template->styles as $class => $style) { if (preg_match('#^tag_(.*)$#', $class, $result)) { $this->tags[$email->tempid]['#< *' . $result[1] . '((?:(?!style).)*)>#Ui'] = '<' . $result[1] . ' style="' . $style . '" $1>'; } elseif ($class == 'color_bg') { $this->others[$email->tempid][$class] = $style; } else { $this->templates[$email->tempid]['class="' . $class . '"'] = 'style="' . $style . '"'; } } } } if ($addbody and !strpos($email->body, '</body>')) { $before = '<html><head>' . "\n"; $before .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->config->get('charset') . '">' . "\n"; $before .= '<title>' . $email->subject . '</title>' . "\n"; $before .= '</head>' . "\n" . '<body'; if (!empty($this->others[$email->tempid]['color_bg'])) { $before .= ' bgcolor="' . $this->others[$email->tempid]['color_bg'] . '" '; } $before .= '>' . "\n"; $email->body = $before . $email->body . '</body>' . "\n" . '</html>'; } if (!empty($this->templates[$email->tempid])) { $email->body = str_replace(array_keys($this->templates[$email->tempid]), $this->templates[$email->tempid], $email->body); } if (!empty($this->tags[$email->tempid])) { $email->body = preg_replace(array_keys($this->tags[$email->tempid]), $this->tags[$email->tempid], $email->body); } if (!empty($this->stylesheets[$email->tempid]) and class_exists('Emogrifier')) { $emogrifier = new Emogrifier($email->body, $this->stylesheets[$email->tempid]); $email->body = $emogrifier->emogrify(); if (!$addbody and strpos($email->body, '<!DOCTYPE') !== false) { $email->body = preg_replace('#<\\!DOCTYPE.*<body([^>]*)>#Usi', '', $email->body); $email->body = preg_replace('#</body>.*$#si', '', $email->body); } } }
function massremove() { JRequest::checkToken() or die('Invalid Token'); $importHelper = acymailing::get('helper.import'); if (!$importHelper->mass(false)) { return $this->addusers(); } $this->setRedirect(acymailing::completeLink('list', false, true)); }
function editorHelper() { $config =& acymailing::config(); $this->editor = $config->get('editor', null); if (empty($this->editor)) { $this->editor = null; } $this->myEditor =& JFactory::getEditor($this->editor); $this->myEditor->initialise(); }
function cron() { $cronHelper = acymailing::get('helper.cron'); $cronHelper->report = true; $launched = $cronHelper->cron(); if ($launched) { $cronHelper->report(); } exit; }
function remove() { JRequest::checkToken() or die('Invalid Token'); $subscriberIds = JRequest::getVar('cid', array(), '', 'array'); $subscriberObject = acymailing::get('class.subscriber'); $num = $subscriberObject->delete($subscriberIds); $app =& JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $num), 'message'); JRequest::setVar('layout', 'listing'); return parent::display(); }
function _quickiconButton($link, $image, $text, $description, $level) { $url = acymailing::level($level) ? 'onclick="document.location.href=\'' . acymailing::completeLink($link) . '\';"' : ''; $html = '<div style="float:left;width: 100%;" ' . $url . ' class="icon"><a href="'; $html .= acymailing::level($level) ? acymailing::completeLink($link) : '#'; $html .= '"><table width="100%"><tr><td style="text-align: center;" width="120px">'; $html .= '<span class="icon-48-' . $image . '" style="background-repeat:no-repeat;background-position:center;height:48px" title="' . $text . '"> </span>'; $html .= '<span>' . $text . '</span></td><td>' . $description . '</td></tr></table></a>'; $html .= '</div>'; return $html; }
function listing() { if (!acymailing_level(3)) { $acyToolbar = acymailing::get('helper.toolbar'); $acyToolbar->setTitle(JText::_('EXTRA_FIELDS'), 'fields'); $acyToolbar->display(); acymailing_display(JText::_('ACY_CUSTOMFIELDS_UPGRADE') . '<br /><br /><a target="_blank" href="' . ACYMAILING_REDIRECT . 'acymailing-features">' . JText::_('ACY_FEATURES') . '</a>', 'info'); return; } return parent::listing(); }
function deliverstatusType() { $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_STATUS')); $this->values[] = JHTML::_('select.option', 'open', JText::_('OPEN')); $this->values[] = JHTML::_('select.option', 'notopen', JText::_('NOT_OPEN')); $this->values[] = JHTML::_('select.option', 'failed', JText::_('FAILED')); if (acymailing::level(3)) { $this->values[] = JHTML::_('select.option', 'bounce', JText::_('BOUNCES')); } }
function listing() { if (!acymailing_level(3)) { $acyToolbar = acymailing::get('helper.toolbar'); $acyToolbar->setTitle(JText::_('BOUNCE_HANDLING'), 'bounces'); $acyToolbar->display(); acymailing_display(JText::_('ACY_BOUNCE_AVAILABLE') . '<br /><br /><a target="_blank" href="' . ACYMAILING_REDIRECT . 'acymailing-features">' . JText::_('ACY_FEATURES') . '</a>', 'info'); return; } return parent::listing(); }
function save($configObject) { $query = 'REPLACE INTO ' . acymailing::table('config') . ' (namekey,value) VALUES '; $params = array(); foreach ($configObject as $namekey => $value) { $this->values[$namekey]->value = $value; $params[] = '(' . $this->database->Quote(strip_tags($namekey)) . ',' . $this->database->Quote(strip_tags($value, '<br/>')) . ')'; } $query .= implode(',', $params); $this->database->setQuery($query); return $this->database->query(); }
function remove() { JRequest::checkToken() or die('Invalid Token'); $cids = JRequest::getVar('cid', array(), '', 'array'); $class = acymailing::get('class.fields'); $num = $class->delete($cids); if ($num) { $app =& JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $num), 'message'); } return $this->listing(); }
function welcomeType() { $query = 'SELECT `subject`, `mailid` FROM ' . acymailing::table('mail') . ' WHERE `type`= \'welcome\''; $db =& JFactory::getDBO(); $db->setQuery($query); $messages = $db->loadObjectList(); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('NO_WELCOME_MESSAGE')); foreach ($messages as $oneMessage) { $this->values[] = JHTML::_('select.option', $oneMessage->mailid, '[' . $oneMessage->mailid . '] ' . $oneMessage->subject); } }
function listsType() { $query = 'SELECT name,listid,color,description FROM ' . acymailing::table('list') . ' WHERE type = \'list\' ORDER BY ordering ASC'; $db =& JFactory::getDBO(); $db->setQuery($query); $this->data = $db->loadObjectList('listid'); $this->values = array(); $this->values[] = JHTML::_('select.option', '0', JText::_('ALL_LISTS')); foreach ($this->data as $onelist) { $this->values[] = JHTML::_('select.option', $onelist->listid, $onelist->name); } }