Example #1
0
 function listing()
 {
     $app = JFactory::getApplication();
     global $Itemid;
     $config = acymailing_config();
     $jsite = JFactory::getApplication('site');
     $menus = $jsite->getMenu();
     $menu = $menus->getActive();
     if (empty($menu) and !empty($Itemid)) {
         $menus->setActive($Itemid);
         $menu = $menus->getItem($Itemid);
     }
     if (empty($menu)) {
         acymailing_enqueueMessage(JText::_('ACY_NOTALLOWED'));
         $app->redirect('index.php');
     }
     $selectedLists = 'all';
     if (is_object($menu)) {
         jimport('joomla.html.parameter');
         $menuparams = new acyParameter($menu->params);
         $this->assign('listsintrotext', $menuparams->get('listsintrotext'));
         $this->assign('listsfinaltext', $menuparams->get('listsfinaltext'));
         $selectedLists = $menuparams->get('lists', 'all');
         $document = JFactory::getDocument();
         if ($menuparams->get('menu-meta_description')) {
             $document->setDescription($menuparams->get('menu-meta_description'));
         }
         if ($menuparams->get('menu-meta_keywords')) {
             $document->setMetadata('keywords', $menuparams->get('menu-meta_keywords'));
         }
         if ($menuparams->get('robots')) {
             $document->setMetadata('robots', $menuparams->get('robots'));
         }
         if ($menuparams->get('page_title')) {
             acymailing_setPageTitle($menuparams->get('page_title'));
         }
     }
     if (empty($menuparams)) {
         $pathway = $app->getPathway();
         $pathway->addItem(JText::_('MAILING_LISTS'));
     }
     $document = JFactory::getDocument();
     $link = '&format=feed&limitstart=';
     if ($config->get('acyrss_format') == 'rss' || $config->get('acyrss_format') == 'both') {
         $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
         $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
     }
     if ($config->get('acyrss_format') == 'atom' || $config->get('acyrss_format') == 'both') {
         $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
         $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
     }
     $listsClass = acymailing_get('class.list');
     $allLists = $listsClass->getLists('', $selectedLists);
     if (acymailing_level(1)) {
         $allLists = $listsClass->onlyCurrentLanguage($allLists);
     }
     $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
     $this->assignRef('rows', $allLists);
     $this->assignRef('item', $myItem);
 }
Example #2
0
 function change($data, $input, $output)
 {
     $input = strtoupper(trim($input));
     $output = strtoupper(trim($output));
     $supportedEncodings = array("BIG5", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-2022-JP", "US-ASCII", "UTF-7", "UTF-8", "UTF-16", "Windows-1251", "Windows-1252", "ARMSCII-8", "ISO-8859-16");
     if (!in_array($input, $supportedEncodings)) {
         acymailing_enqueueMessage('Encoding not supported: ' . $input, 'error');
     } elseif (!in_array($output, $supportedEncodings)) {
         acymailing_enqueueMessage('Encoding not supported: ' . $output, 'error');
     }
     if ($input == $output) {
         return $data;
     }
     if ($input == 'UTF-8' && $output == 'ISO-8859-1') {
         $data = str_replace(array('€', '„', '“'), array('EUR', '"', '"'), $data);
     }
     if (function_exists('iconv')) {
         set_error_handler('acymailing_error_handler_encoding');
         $encodedData = iconv($input, $output . "//IGNORE", $data);
         restore_error_handler();
         if (!empty($encodedData) && !acymailing_error_handler_encoding('result')) {
             return $encodedData;
         }
     }
     if (function_exists('mb_convert_encoding')) {
         return mb_convert_encoding($data, $output, $input);
     }
     if ($input == 'UTF-8' && $output == 'ISO-8859-1') {
         return utf8_decode($data);
     }
     if ($input == 'ISO-8859-1' && $output == 'UTF-8') {
         return utf8_encode($data);
     }
     return $data;
 }
Example #3
0
 function doimport()
 {
     if (!$this->isAllowed('subscriber', 'import')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     $function = JRequest::getCmd('importfrom');
     $importHelper = acymailing_get('helper.import');
     if (!$importHelper->{$function}()) {
         return $this->import();
     }
     $app = JFactory::getApplication();
     if ($function == 'textarea' || $function == 'file') {
         if (file_exists(ACYMAILING_MEDIA . 'import' . DS . JRequest::getCmd('filename'))) {
             $importContent = file_get_contents(ACYMAILING_MEDIA . 'import' . DS . JRequest::getCmd('filename'));
         }
         if (empty($importContent)) {
             acymailing_enqueueMessage(JText::_('ACY_IMPORT_NO_CONTENT'), 'error');
             $this->setRedirect(acymailing_completeLink(($app->isSite() ? 'front' : '') . 'data&task=import', false, true));
         } else {
             JRequest::setVar('hidemainmenu', 1);
             JRequest::setVar('layout', 'genericimport');
             return parent::display();
         }
     } else {
         $this->setRedirect(acymailing_completeLink($app->isAdmin() ? 'subscriber' : 'frontsubscriber', false, true));
     }
 }
Example #4
0
 function remove()
 {
     if (!$this->isAllowed('statistics', 'delete')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     $cids = JRequest::getVar('cid', array(), '', 'array');
     $class = acymailing_get('class.stats');
     $num = $class->delete($cids);
     acymailing_enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $num), 'message');
     return $this->listing();
 }
Example #5
0
 function remove()
 {
     if (!$this->isAllowed($this->aclCat, 'delete')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     $listIds = JRequest::getVar('cid', array(), '', 'array');
     $subscriberObject = acymailing_get('class.list');
     $num = $subscriberObject->delete($listIds);
     acymailing_enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $num), 'message');
     JRequest::setVar('layout', 'listing');
     return parent::display();
 }
Example #6
0
 function cancelNewsletter()
 {
     if (!$this->isAllowed($this->aclCat, 'delete')) {
         return;
     }
     JRequest::checkToken() || JRequest::checkToken('get') || die('Invalid token');
     $mailid = JRequest::getInt('mailid', 0);
     if (empty($mailid)) {
         acymailing_enqueueMessage('Mail id not found', 'error');
         return;
     }
     $queueClass = acymailing_get('class.queue');
     acymailing_enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $queueClass->delete(array('a.mailid = ' . $mailid))), 'info');
 }
Example #7
0
 function store()
 {
     JRequest::checkToken() or die('Invalid Token');
     $oldMailid = acymailing_getCID('mailid');
     $mailClass = acymailing_get('class.mail');
     if ($mailClass->saveForm()) {
         $data = JRequest::getVar('data');
         $type = @$data['mail']['type'];
         if (!empty($type) and in_array($type, array('unsub', 'welcome'))) {
             $subject = addslashes($data['mail']['subject']);
             $mailid = JRequest::getInt('mailid');
             if ($type == 'unsub') {
                 $js = "var mydrop = window.top.document.getElementById('datalistunsubmailid'); ";
                 $js .= "var type = 'unsub';";
             } else {
                 //type=welcome
                 $js = "var mydrop = window.top.document.getElementById('datalistwelmailid'); ";
                 $js .= "var type = 'welcome';";
             }
             if (empty($oldMailid)) {
                 $js .= 'var optn = document.createElement("OPTION");';
                 $js .= "optn.text = '[{$mailid}] {$subject}'; optn.value = '{$mailid}';";
                 $js .= 'mydrop.options.add(optn);';
                 $js .= 'lastid = 0; while(mydrop.options[lastid+1]){lastid = lastid+1;} mydrop.selectedIndex = lastid;';
                 $js .= 'window.top.changeMessage(type,' . $mailid . ');';
             } else {
                 $js .= "lastid = 0; notfound = true; while(notfound && mydrop.options[lastid]){if(mydrop.options[lastid].value == {$mailid}){mydrop.options[lastid].text = '[{$mailid}] {$subject}';notfound = false;} lastid = lastid+1;}";
             }
             if (ACYMAILING_J30) {
                 $js .= 'window.top.jQuery("#datalist' . ($type == 'unsub' ? 'unsub' : 'wel') . 'mailid").trigger("liszt:updated");';
             }
             $doc = JFactory::getDocument();
             $doc->addScriptDeclaration($js);
         }
         acymailing_enqueueMessage(JText::_('JOOMEXT_SUCC_SAVED'), 'success');
     } else {
         acymailing_enqueueMessage(JText::_('ERROR_SAVING'), 'error');
     }
 }
Example #8
0
 function listing()
 {
     $app = JFactory::getApplication();
     $config = acymailing_config();
     if (!class_exists('plgSystemAcymailingClassMail')) {
         $warning_msg = JText::_('ACY_WARNINGOVERRIDE_DISABLED_1') . ' <a href="index.php?option=com_acymailing&ctrl=cpanel">' . JText::sprintf('ACY_WARNINGOVERRIDE_DISABLED_2', ' acymailingclassmail (Override Joomla mailing system plugin)') . '</a>';
         acymailing_enqueueMessage($warning_msg, 'notice');
     }
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'mailid', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     if (strtolower($pageInfo->filter->order->dir) !== 'desc') {
         $pageInfo->filter->order->dir = 'asc';
     }
     $db = JFactory::getDBO();
     $query = 'SELECT mailid, subject, alias, fromname, published, fromname, fromemail, replyname, replyemail FROM #__acymailing_mail WHERE `type` = ' . $db->Quote($this->type);
     if (!empty($pageInfo->filter->order->value)) {
         $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $acyToolbar = acymailing::get('helper.toolbar');
     $acyToolbar->custom('preview', JText::_('ACY_PREVIEW'), 'search', true);
     $acyToolbar->edit();
     $acyToolbar->delete();
     $acyToolbar->divider();
     $acyToolbar->help($this->doc);
     $acyToolbar->setTitle(JText::_($this->nameListing), $this->ctrl);
     $acyToolbar->display();
     $toggleClass = acymailing_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $this->assignRef('pageInfo', $pageInfo);
     $this->assign('config', $config);
     $this->assign('rows', $rows);
 }
Example #9
0
 function installExtensions()
 {
     $path = ACYMAILING_BACK . 'extensions';
     $dirs = JFolder::folders($path);
     if (!ACYMAILING_J16) {
         if (file_exists(ACYMAILING_BACK . 'config.xml')) {
             JFile::delete(ACYMAILING_BACK . 'config.xml');
         }
         $query = "SELECT CONCAT(`folder`,`element`) FROM #__plugins WHERE `folder` = 'acymailing' OR `element` LIKE '%acy%'";
         $query .= " UNION SELECT `module` FROM #__modules WHERE `module` LIKE '%acymailing%'";
         $this->db->setQuery($query);
         $existingExtensions = acymailing_loadResultArray($this->db);
     } else {
         $this->db->setQuery("SELECT CONCAT(`folder`,`element`) FROM #__extensions WHERE `folder` = 'acymailing' OR `element` LIKE '%acy%'");
         $existingExtensions = acymailing_loadResultArray($this->db);
     }
     $plugins = array();
     $modules = array();
     $extensioninfo = array();
     //array('name','ordering','required table or published')
     $extensioninfo['mod_acymailing'] = array('AcyMailing Module');
     $extensioninfo['plg_acymailing_share'] = array('AcyMailing : share on social networks', 20, 1);
     $extensioninfo['plg_acymailing_contentplugin'] = array('AcyMailing : trigger Joomla Content plugins', 15, 0);
     $extensioninfo['plg_acymailing_managetext'] = array('AcyMailing Manage text', 10, 1);
     $extensioninfo['plg_acymailing_tablecontents'] = array('AcyMailing table of contents generator', 5, 1);
     $extensioninfo['plg_acymailing_online'] = array('AcyMailing Tag : Website links', 6, 1);
     $extensioninfo['plg_acymailing_stats'] = array('AcyMailing : Statistics Plugin', 50, 1);
     $extensioninfo['plg_acymailing_tagcbuser'] = array('AcyMailing Tag : CB User information', 4, '#__comprofiler');
     $extensioninfo['plg_acymailing_tagcontent'] = array('AcyMailing Tag : content insertion', 11, 1);
     $extensioninfo['plg_acymailing_tagmodule'] = array('AcyMailing Tag : Insert a Module', 12, 1);
     $extensioninfo['plg_acymailing_tagsubscriber'] = array('AcyMailing Tag : Subscriber information', 2, 1);
     $extensioninfo['plg_acymailing_tagsubscription'] = array('AcyMailing Tag : Manage the Subscription', 1, 1);
     $extensioninfo['plg_acymailing_tagtime'] = array('AcyMailing Tag : Date / Time', 5, 1);
     $extensioninfo['plg_acymailing_taguser'] = array('AcyMailing Tag : Joomla User Information', 3, 1);
     $extensioninfo['plg_acymailing_virtuemart'] = array('AcyMailing Tag : VirtueMart integration', 7, '#__vm_product');
     $extensioninfo['plg_acymailing_template'] = array('AcyMailing Template Class Replacer', 25, 1);
     $extensioninfo['plg_acymailing_urltracker'] = array('AcyMailing : Handle Click tracking part1', 30, 1);
     $extensioninfo['plg_system_acymailingurltracker'] = array('AcyMailing : Handle Click tracking part2', 1, 1);
     $extensioninfo['plg_system_regacymailing'] = array('AcyMailing : (auto)Subscribe during Joomla registration', 0, 1);
     $extensioninfo['plg_system_vmacymailing'] = array('AcyMailing : VirtueMart checkout subscription', 0, 0);
     $extensioninfo['plg_editors_acyeditor'] = array('AcyMailing Editor', 5, 1);
     $extensioninfo['plg_acymailing_geolocation'] = array('AcyMailing Geolocation : Tag and filter', 10, 1);
     $extensioninfo['plg_acymailing_plginboxactions'] = array('AcyMailing : Inbox actions', 35, 1);
     $extensioninfo['plg_system_acymailingclassmail'] = array('Override Joomla mailing system', 1, 0);
     $extensioninfo['plg_acymailing_calltoaction'] = array('AcyMailing Tag : Call to action', 22, 1);
     $listTables = $this->db->getTableList();
     $fromVersion = JRequest::getCmd('fromversion');
     foreach ($dirs as $oneDir) {
         $arguments = explode('_', $oneDir);
         if (!isset($extensioninfo[$oneDir])) {
             continue;
         }
         $additionalInfo = new stdClass();
         if ($arguments[0] == 'mod') {
             $arguments[2] = $oneDir;
         }
         if (ACYMAILING_J16 && !empty($arguments[2]) && file_exists($path . DS . $oneDir . DS . $arguments[2] . '.xml')) {
             $xmlFile = simplexml_load_file($path . DS . $oneDir . DS . $arguments[2] . '.xml');
             $additionalInfo->version = (string) $xmlFile->version;
             $additionalInfo->author = (string) $xmlFile->author;
             $additionalInfo->creationDate = (string) $xmlFile->creationDate;
             $extension = $arguments[0] == 'mod' ? $oneDir : $arguments[1] . $arguments[2];
             if (in_array($extension, $existingExtensions) && version_compare($fromVersion, '4.8.1', '<')) {
                 $query = "UPDATE `#__extensions` SET `manifest_cache` = " . $this->db->Quote(json_encode($additionalInfo)) . " WHERE (type = ";
                 if ($arguments[0] == 'mod') {
                     $query .= "'module' AND `element` = " . $this->db->Quote($oneDir) . ")";
                 } else {
                     $query .= "'plugin' AND folder = " . $this->db->Quote($arguments[1]) . " AND `element` = " . $this->db->Quote($arguments[2]) . ")";
                 }
                 $this->db->setQuery($query);
                 $this->db->query();
             }
         }
         if ($arguments[0] == 'plg') {
             $newPlugin = new stdClass();
             if (!empty($additionalInfo)) {
                 $newPlugin->additionalInfo = json_encode($additionalInfo);
             }
             $newPlugin->name = $oneDir;
             if (isset($extensioninfo[$oneDir][0])) {
                 $newPlugin->name = $extensioninfo[$oneDir][0];
             }
             $newPlugin->type = 'plugin';
             $newPlugin->folder = $arguments[1];
             $newPlugin->element = $arguments[2];
             $newPlugin->enabled = 1;
             if (isset($extensioninfo[$oneDir][2])) {
                 if (is_numeric($extensioninfo[$oneDir][2])) {
                     $newPlugin->enabled = $extensioninfo[$oneDir][2];
                 } elseif (!in_array(str_replace('#__', $this->db->getPrefix(), $extensioninfo[$oneDir][2]), $listTables)) {
                     $newPlugin->enabled = 0;
                 }
             }
             $newPlugin->params = '{}';
             $newPlugin->ordering = 0;
             if (isset($extensioninfo[$oneDir][1])) {
                 $newPlugin->ordering = $extensioninfo[$oneDir][1];
             }
             if (!acymailing_createDir(ACYMAILING_ROOT . 'plugins' . DS . $newPlugin->folder)) {
                 continue;
             }
             if (!ACYMAILING_J16) {
                 $destinationFolder = ACYMAILING_ROOT . 'plugins' . DS . $newPlugin->folder;
             } else {
                 $destinationFolder = ACYMAILING_ROOT . 'plugins' . DS . $newPlugin->folder . DS . $newPlugin->element;
                 if (!acymailing_createDir($destinationFolder)) {
                     continue;
                 }
             }
             if (!$this->copyFolder($path . DS . $oneDir, $destinationFolder)) {
                 continue;
             }
             if (in_array($newPlugin->folder . $newPlugin->element, $existingExtensions)) {
                 continue;
             }
             $plugins[] = $newPlugin;
         } elseif ($arguments[0] == 'mod') {
             $newModule = new stdClass();
             if (!empty($additionalInfo)) {
                 $newModule->additionalInfo = json_encode($additionalInfo);
             }
             $newModule->name = $oneDir;
             if (isset($extensioninfo[$oneDir][0])) {
                 $newModule->name = $extensioninfo[$oneDir][0];
             }
             $newModule->type = 'module';
             $newModule->folder = '';
             $newModule->element = $oneDir;
             $newModule->enabled = 1;
             $newModule->params = '{}';
             $newModule->ordering = 0;
             if (isset($extensioninfo[$oneDir][1])) {
                 $newModule->ordering = $extensioninfo[$oneDir][1];
             }
             $destinationFolder = ACYMAILING_ROOT . 'modules' . DS . $oneDir;
             if (!acymailing_createDir($destinationFolder)) {
                 continue;
             }
             if (!$this->copyFolder($path . DS . $oneDir, $destinationFolder)) {
                 continue;
             }
             if (in_array($newModule->element, $existingExtensions)) {
                 continue;
             }
             $modules[] = $newModule;
         } else {
             acymailing_enqueueMessage('Could not handle : ' . $oneDir, 'error');
         }
     }
     if (!empty($this->errors)) {
         acymailing_enqueueMessage($this->errors, 'error');
     }
     if (!ACYMAILING_J16) {
         $extensions = $plugins;
     } else {
         $extensions = array_merge($plugins, $modules);
     }
     $success = array();
     if (!empty($extensions)) {
         if (!ACYMAILING_J16) {
             $queryExtensions = 'INSERT INTO `#__plugins` (`name`,`element`,`folder`,`published`,`ordering`) VALUES ';
         } else {
             $queryExtensions = 'INSERT INTO `#__extensions` (`name`,`element`,`folder`,`enabled`,`ordering`,`type`,`access`,`manifest_cache`) VALUES ';
         }
         foreach ($extensions as $oneExt) {
             $queryExtensions .= '(' . $this->db->Quote($oneExt->name) . ',' . $this->db->Quote($oneExt->element) . ',' . $this->db->Quote($oneExt->folder) . ',' . $oneExt->enabled . ',' . $oneExt->ordering;
             if (ACYMAILING_J16) {
                 $queryExtensions .= ',' . $this->db->Quote($oneExt->type) . ',1,' . $this->db->Quote(!empty($oneExt->additionalInfo) ? $oneExt->additionalInfo : '');
             }
             $queryExtensions .= '),';
             if ($oneExt->type != 'module') {
                 $success[] = JText::sprintf('PLUG_INSTALLED', $oneExt->name);
             }
         }
         $queryExtensions = trim($queryExtensions, ',');
         $this->db->setQuery($queryExtensions);
         $this->db->query();
     }
     if (!empty($modules)) {
         foreach ($modules as $oneModule) {
             if (!ACYMAILING_J16) {
                 $queryModule = 'INSERT INTO `#__modules` (`title`,`position`,`published`,`module`) VALUES ';
                 $queryModule .= '(' . $this->db->Quote($oneModule->name) . ",'left',0," . $this->db->Quote($oneModule->element) . ")";
             } else {
                 $queryModule = 'INSERT INTO `#__modules` (`title`,`position`,`published`,`module`,`access`,`language`) VALUES ';
                 $queryModule .= '(' . $this->db->Quote($oneModule->name) . ",'position-7',0," . $this->db->Quote($oneModule->element) . ",1,'*')";
             }
             $this->db->setQuery($queryModule);
             $this->db->query();
             $moduleId = $this->db->insertid();
             $this->db->setQuery('INSERT IGNORE INTO `#__modules_menu` (`moduleid`,`menuid`) VALUES (' . $moduleId . ',0)');
             $this->db->query();
             $success[] = JText::sprintf('MODULE_INSTALLED', $oneModule->name);
         }
     }
     if (ACYMAILING_J16) {
         $this->db->setQuery("UPDATE `#__extensions` SET `access` = 1 WHERE ( `folder` = 'acymailing' OR `element` LIKE '%acymailing%' ) AND `type` = 'plugin'");
         $this->db->query();
     }
     $this->cleanPluginCache();
     if (!empty($success)) {
         acymailing_enqueueMessage($success, 'success');
     }
 }
Example #10
0
 function managePicts($tag, $result)
 {
     if (!isset($tag->pict)) {
         return $result;
     }
     $pictureHelper = acymailing_get('helper.acypict');
     if ($tag->pict === 'resized') {
         $app = JFactory::getApplication();
         $pictureHelper->maxHeight = empty($tag->maxheight) ? 150 : $tag->maxheight;
         $pictureHelper->maxWidth = empty($tag->maxwidth) ? 150 : $tag->maxwidth;
         if ($pictureHelper->available()) {
             $result = $pictureHelper->resizePictures($result);
         } elseif ($app->isAdmin()) {
             acymailing_enqueueMessage($pictureHelper->error, 'notice');
         }
     } elseif ($tag->pict == '0') {
         $result = $pictureHelper->removePictures($result);
     }
     return $result;
 }
Example #11
0
 function _savelanguage()
 {
     if (!$this->isAllowed('configuration', 'manage')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     jimport('joomla.filesystem.file');
     $code = JRequest::getCmd('code');
     JRequest::setVar('code', $code);
     $content = JRequest::getVar('content', '', '', 'string', JREQUEST_ALLOWHTML);
     if (empty($code) or empty($content)) {
         return;
     }
     $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing.ini';
     $result = JFile::write($path, $content);
     if ($result) {
         acymailing_enqueueMessage(JText::_('JOOMEXT_SUCC_SAVED'), 'success');
         $js = "window.top.document.getElementById('image{$code}').className = 'acyicon-edit'";
         $doc = JFactory::getDocument();
         $doc->addScriptDeclaration($js);
         $updateHelper = acymailing_get('helper.update');
         $updateHelper->installMenu($code);
     } else {
         acymailing_enqueueMessage(JText::sprintf('FAIL_SAVE', $path), 'error');
     }
     $customcontent = JRequest::getVar('customcontent', '', '', 'string', JREQUEST_ALLOWHTML);
     $custompath = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing_custom.ini';
     $customresult = JFile::write($custompath, $customcontent);
     if (!$customresult) {
         acymailing_enqueueMessage(JText::sprintf('FAIL_SAVE', $custompath), 'error');
     }
     return $result;
 }
Example #12
0
 function updateQuery($query)
 {
     try {
         $this->db->setQuery($query);
         $res = $this->db->query();
     } catch (Exception $e) {
         $res = null;
     }
     if ($res === null) {
         acymailing_enqueueMessage(isset($e) ? $e->getMessage() : substr(strip_tags($this->db->getErrorMsg()), 0, 200) . '...', 'error');
     }
 }
Example #13
0
 function abtest()
 {
     $nbTotalReceivers = JRequest::getInt('nbTotalReceivers');
     $mailids = JRequest::getString('mailid');
     $mailsArray = explode(',', $mailids);
     JArrayHelper::toInteger($mailsArray);
     $db = JFactory::getDBO();
     $abTesting_prct = JRequest::getInt('abTesting_prct');
     $abTesting_delay = JRequest::getInt('abTesting_delay');
     $abTesting_action = JRequest::getString('abTesting_action');
     if (empty($abTesting_prct)) {
         acymailing_display(JText::_('ABTESTING_NEEDVALUE'), 'warning');
         $this->abtesting();
         return;
     }
     $newAbTestDetail = array();
     $newAbTestDetail['mailids'] = implode(',', $mailsArray);
     $newAbTestDetail['prct'] = !empty($abTesting_prct) ? $abTesting_prct : '';
     $newAbTestDetail['delay'] = isset($abTesting_delay) && strlen($abTesting_delay) > 0 ? $abTesting_delay : '2';
     $newAbTestDetail['action'] = !empty($abTesting_action) ? $abTesting_action : 'manual';
     $newAbTestDetail['time'] = time();
     $newAbTestDetail['status'] = 'inProgress';
     $mailClass = acymailing_get('class.mail');
     $nbReceiversTest = $mailClass->ab_test($newAbTestDetail, $mailsArray, $nbTotalReceivers);
     acymailing_enqueueMessage(JText::sprintf('ABTESTING_SUCCESSADD', $nbReceiversTest), 'info');
     JRequest::setVar('validationStatus', 'abTestAdd');
     $this->abtesting();
 }
Example #14
0
 function abtesting()
 {
     $app = JFactory::getApplication();
     $mailids = JRequest::getString('mailid');
     $validationStatus = JRequest::getString('validationStatus');
     $noMsg = false;
     $noBtn = false;
     if (!empty($mailids) && strpos($mailids, ',') !== false) {
         $db = JFactory::getDBO();
         $warningMsg = array();
         $mailsArray = explode(',', $mailids);
         JArrayHelper::toInteger($mailsArray);
         $mailids = implode(',', $mailsArray);
         $this->assign('mailid', $mailids);
         $query = 'SELECT abtesting FROM #__acymailing_mail WHERE mailid IN (' . implode(',', $mailsArray) . ') AND abtesting IS NOT NULL';
         $db->setQuery($query);
         $resDetail = acymailing_loadResultArray($db);
         if (!empty($resDetail) && count($resDetail) != count($mailsArray)) {
             $titlePage = JText::_('ABTESTING');
             acymailing_display(JText::_('ABTESTING_MISSINGEMAIL'), 'warning');
             $this->assign('missingMail', true);
         } else {
             $abTestDetail = array();
             if (empty($resDetail)) {
                 $abTestDetail['mailids'] = $mailids;
                 $abTestDetail['prct'] = 10;
                 $abTestDetail['delay'] = 2;
                 $abTestDetail['action'] = 'manual';
             } else {
                 $abTestDetail = unserialize($resDetail[0]);
                 $savedIds = explode(',', $abTestDetail['mailids']);
                 sort($savedIds);
                 sort($mailsArray);
                 if (!empty($abTestDetail['status']) && in_array($abTestDetail['status'], array('inProgress', 'testSendOver', 'abTestFinalSend')) && $savedIds != $mailsArray) {
                     $warningMsg[] = JText::_('ABTESTING_TESTEXIST');
                     $mailsArray = $savedIds;
                     $mailids = implode(',', $mailsArray);
                 }
                 $this->assign('savedValues', true);
                 if ($abTestDetail['status'] == 'inProgress') {
                     $warningMsg[] = JText::_('ABTESTING_INPROGRESS');
                 }
             }
             if ($validationStatus == 'abTestAdd') {
                 $noMsg = true;
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'abTestFinalSend' && !empty($abTestDetail['newMail'])) {
                 $mailInQueueErrorMsg = JText::_('ABTESTING_FINALMAILINQUEUE');
                 $mailTocheck = '=' . $abTestDetail['newMail'];
             } else {
                 $mailInQueueErrorMsg = JText::_('ABTESTING_TESTMAILINQUEUE');
                 $mailTocheck = ' IN (' . implode(',', $mailsArray) . ')';
             }
             $query = "SELECT COUNT(*) FROM #__acymailing_queue WHERE mailid" . $mailTocheck;
             $db->setQuery($query);
             $queueCheck = $db->loadResult();
             if (!empty($queueCheck) && $validationStatus != 'abTestAdd') {
                 acymailing_enqueueMessage($mailInQueueErrorMsg, 'error');
                 $noMsg = true;
             }
             if (!empty($resDetail) && empty($queueCheck) && in_array($abTestDetail['status'], array('inProgress', 'abTestFinalSend'))) {
                 if ($abTestDetail['status'] == 'inProgress') {
                     $abTestDetail['status'] = 'testSendOver';
                 } else {
                     $abTestDetail['status'] = 'completed';
                 }
                 $query = "UPDATE #__acymailing_mail SET abtesting=" . $db->quote(serialize($abTestDetail)) . " WHERE mailid IN (" . implode(',', $mailsArray) . ")";
                 $db->setQuery($query);
                 $db->query();
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'testSendOver') {
                 acymailing_enqueueMessage(JText::_('ABTESTING_READYTOSEND'), 'info');
             }
             if (!empty($abTestDetail['status']) && $abTestDetail['status'] == 'completed') {
                 acymailing_enqueueMessage(JText::_('ABTESTING_COMPLETE'), 'info');
             }
             $this->assign('abTestDetail', $abTestDetail);
             $nbMails = count($mailsArray);
             $titleStr = "A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z";
             $titlePage = JText::sprintf('ABTESTING_TITLE', substr($titleStr, 0, min($nbMails, 26) * 2 - 1));
             $mailClass = acymailing_get('class.mail');
             $mailsDetails = array();
             foreach ($mailsArray as $mailid) {
                 $mailsDetails[] = $mailClass->get($mailid);
             }
             $this->assign('mailsdetails', $mailsDetails);
             $mailerHelper = acymailing_get('helper.mailer');
             $mailerHelper->loadedToSend = false;
             $mailReceiver = $mailerHelper->load($mailsArray[0]);
             $listmailClass = acymailing_get('class.listmail');
             $lists = $listmailClass->getReceivers($mailReceiver->mailid, true, false);
             $this->assign('lists', $lists);
             $this->assign('mailReceiver', $mailReceiver);
             $filterClass = acymailing_get('class.filter');
             $this->assign('filterClass', $filterClass);
             $listids = array();
             foreach ($lists as $oneList) {
                 $listids[] = $oneList->listid;
             }
             $nbTotalReceivers = $filterClass->countReceivers($listids, $this->mailReceiver->filter, $this->mailReceiver->mailid);
             if ($nbTotalReceivers < 50) {
                 $warningMsg[] = JText::sprintf('ABTESTING_NOTENOUGHUSER', $nbTotalReceivers);
                 $noBtn = true;
             }
             $this->assign('nbTotalReceivers', $nbTotalReceivers);
             $this->assign('nbTestReceivers', floor($nbTotalReceivers * $abTestDetail['prct'] / 100));
             if ($noMsg || $noBtn) {
                 $noButton = true;
             }
             $queryStat = 'SELECT mailid, openunique, clickunique, senthtml, senttext, bounceunique FROM #__acymailing_stats WHERE mailid IN (' . $mailids . ')';
             $db->setQuery($queryStat);
             $resStat = $db->loadObjectList('mailid');
             if (!empty($resStat)) {
                 $this->assign('statMail', $resStat);
                 $warningMsg[] = JText::_('ABTESTING_STAT_WARNING');
             }
             if (!empty($warningMsg) && $noMsg == false) {
                 acymailing_enqueueMessage(implode('<br />', $warningMsg), 'warning');
             }
         }
     } else {
         $titlePage = JText::_('ABTESTING');
     }
     $acyToolbar = acymailing::get('helper.toolbar');
     if (empty($noButton)) {
         $acyToolbar->custom('test', JText::_('ABTESTING_TEST'), 'test', false, "javascript:if(confirm('" . JText::_('PROCESS_CONFIRMATION', true) . "')){submitbutton('abtest');} return false;");
     }
     $acyToolbar->setTitle(JText::_('ABTESTING'));
     $acyToolbar->topfixed = false;
     $acyToolbar->display();
     $this->assign('validationStatus', $validationStatus);
     $this->assign('titlePage', $titlePage);
     $this->assign('app', $app);
     if ($app->isAdmin()) {
         acymailing_setPageTitle(JText::_('ABTESTING'));
     }
 }
Example #15
0
    function export($tempid)
    {
        if (!extension_loaded('zlib')) {
            JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLZLIB'));
            return false;
        }
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.archive');
        $template = $this->get($tempid);
        $fileDeb = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
        if (!empty($template->description)) {
            $fileDeb .= '
<meta name="description" content="' . str_replace('"', "'", $template->description) . '" />';
        }
        if (!empty($template->fromname)) {
            $fileDeb .= '
<meta name="fromname" content="' . $template->fromname . '" />';
        }
        if (!empty($template->fromemail)) {
            $fileDeb .= '
<meta name="fromemail" content="' . $template->fromemail . '" />';
        }
        if (!empty($template->replyname)) {
            $fileDeb .= '
<meta name="replyname" content="' . $template->replyname . '" />';
        }
        if (!empty($template->replyemail)) {
            $fileDeb .= '
<meta name="replyemail" content="' . $template->replyemail . '" />';
        }
        $fileDeb .= '
<title>' . $template->name . '</title>';
        $css = '
<style type="text/css">
';
        $css .= file_get_contents(ACYMAILING_TEMPLATE . DS . 'css' . DS . 'template_' . $tempid . '.css');
        $css .= '
</style>';
        $indexFile = $fileDeb . $css . '
</head>
<body>
' . $template->body . '
</body>
</html>';
        $tmpdir = preg_replace('#[^a-z0-9]#i', '_', strtolower($template->name));
        $jpathURL = ACYMAILING_LIVE . 'media/' . ACYMAILING_COMPONENT . '/tmp';
        $tmp_url_dest = $jpathURL . DS . $tmpdir;
        $jpath = ACYMAILING_MEDIA . 'tmp';
        $tmp_dest = JPath::clean($jpath . DS . $tmpdir);
        if (!JFolder::exists($jpath)) {
            if (!JFolder::create($jpath)) {
                acymailing_enqueueMessage('Error creating temp folder in directory: ' . $jpath, 'error');
                return false;
            }
        }
        if (!JFolder::create($tmp_dest)) {
            acymailing_enqueueMessage('Error creating folder in temp directory: ' . $tmp_dest, 'error');
            return false;
        }
        if (!empty($template->thumb)) {
            $thumbPath = JPath::clean(ACYMAILING_ROOT . DS . $template->thumb);
            $thumbExt = JFile::getExt($thumbPath);
            $resCopyThumb = JFile::copy($thumbPath, $tmp_dest . DS . 'thumbnail.' . $thumbExt);
            if (!$resCopyThumb) {
                acymailing_enqueueMessage('Error copying the thumb picture', 'warning');
            }
        }
        $resHandleImages = $this->handlepict($indexFile, $tmp_dest);
        if (!$resHandleImages) {
            JFolder::delete($tmp_dest);
            return false;
        }
        $resCopyIndex = JFile::write($tmp_dest . DS . 'index.html', $indexFile);
        if (!$resCopyIndex) {
            acymailing_enqueueMessage('Error copying the file index.html to temp directory ' . $tmp_dest, 'error');
            return false;
        }
        $zipFilesArray = array();
        $dirs = JFolder::folders($tmp_dest, '.', true, true);
        array_push($dirs, $tmp_dest);
        foreach ($dirs as $dir) {
            $files = JFolder::files($dir, '.', false, true);
            foreach ($files as $file) {
                $posSlash = strrpos($file, '/');
                $posASlash = strrpos($file, '\\');
                $pos = $posSlash < $posASlash ? $posASlash : $posSlash;
                if (!empty($pos)) {
                    $file = substr_replace($file, DS, $pos, 1);
                }
                $data = JFile::read($file);
                $zipFilesArray[] = array('name' => str_replace($tmp_dest . DS, '', $file), 'data' => $data);
            }
        }
        $zip = JArchive::getAdapter('zip');
        $zip->create($tmp_dest . '.zip', $zipFilesArray);
        JFolder::delete($tmp_dest);
        return $tmp_url_dest . '.zip';
    }
Example #16
0
 public function sendOne($mailid, $receiverid)
 {
     $this->clearAll();
     if (!isset($this->defaultMail[$mailid])) {
         $this->loadedToSend = true;
         if (!$this->load($mailid)) {
             $this->reportMessage = 'Can not load the e-mail : ' . htmlspecialchars($mailid, ENT_COMPAT, 'UTF-8');
             if ($this->report) {
                 acymailing_enqueueMessage($this->reportMessage, 'error');
             }
             $this->errorNumber = 2;
             return false;
         }
     }
     if (!isset($this->forceVersion) and $this->checkPublished and empty($this->defaultMail[$mailid]->published)) {
         $this->reportMessage = JText::sprintf('SEND_ERROR_PUBLISHED', htmlspecialchars($mailid, ENT_COMPAT, 'UTF-8'));
         $this->errorNumber = 3;
         if ($this->report) {
             acymailing_enqueueMessage($this->reportMessage, 'error');
         }
         return false;
     }
     if (!is_object($receiverid)) {
         $receiver = $this->subscriberClass->get($receiverid);
         if (empty($receiver->subid) and is_string($receiverid) and $this->autoAddUser) {
             if ($this->userHelper->validEmail($receiverid)) {
                 $newUser = new stdClass();
                 $newUser->email = $receiverid;
                 $this->subscriberClass->checkVisitor = false;
                 $this->subscriberClass->sendConf = false;
                 $subid = $this->subscriberClass->save($newUser);
                 $receiver = $this->subscriberClass->get($subid);
             }
         }
     } else {
         $receiver = $receiverid;
     }
     if (empty($receiver->email)) {
         $this->reportMessage = JText::sprintf('SEND_ERROR_USER', '<b><i>' . (isset($receiver->subid) ? $receiver->subid : htmlspecialchars($receiverid, ENT_COMPAT, 'UTF-8')) . '</i></b>');
         if ($this->report) {
             acymailing_enqueueMessage($this->reportMessage, 'error');
         }
         $this->errorNumber = 4;
         return false;
     }
     $this->MessageID = "<" . preg_replace("|[^a-z0-9+_]|i", '', base64_encode(rand(0, 9999999)) . "AC" . $receiver->subid . "Y" . $this->defaultMail[$mailid]->mailid . "BA" . base64_encode(time() . rand(0, 99999))) . "@" . $this->serverHostname() . ">";
     if (strpos($this->Host, 'mailjet') !== false && !empty($this->defaultMail[$mailid]->alias)) {
         $this->addCustomHeader('X-Mailjet-Campaign: ' . $this->defaultMail[$mailid]->alias);
     }
     if (!isset($this->forceVersion)) {
         if ($this->checkConfirmField and empty($receiver->confirmed) and $this->config->get('require_confirmation', 0) and strpos($this->defaultMail[$mailid]->alias, 'confirm') === false) {
             $this->reportMessage = JText::sprintf('SEND_ERROR_CONFIRMED', '<b><i>' . htmlspecialchars($receiver->email, ENT_COMPAT, 'UTF-8') . '</i></b>');
             if ($this->report) {
                 acymailing_enqueueMessage($this->reportMessage, 'error');
             }
             $this->errorNumber = 5;
             return false;
         }
         if ($this->checkEnabled and empty($receiver->enabled) and strpos($this->defaultMail[$mailid]->alias, 'enable') === false) {
             $this->reportMessage = JText::sprintf('SEND_ERROR_APPROVED', '<b><i>' . htmlspecialchars($receiver->email, ENT_COMPAT, 'UTF-8') . '</i></b>');
             if ($this->report) {
                 acymailing_enqueueMessage($this->reportMessage, 'error');
             }
             $this->errorNumber = 6;
             return false;
         }
     }
     if ($this->checkAccept and empty($receiver->accept)) {
         $this->reportMessage = JText::sprintf('SEND_ERROR_ACCEPT', '<b><i>' . htmlspecialchars($receiver->email, ENT_COMPAT, 'UTF-8') . '</i></b>');
         if ($this->report) {
             acymailing_enqueueMessage($this->reportMessage, 'error');
         }
         $this->errorNumber = 7;
         return false;
     }
     $addedName = '';
     if ($this->config->get('add_names', true)) {
         $nameTmp = JText::_('ACY_TO_NAME');
         $testTag = preg_match_all('/\\[(.*)\\]/U', $nameTmp, $matches);
         if ($testTag != 0) {
             foreach ($matches[0] as $i => $oneMatch) {
                 if (!empty($receiver->{$matches}[1][$i])) {
                     $nameTmp = str_replace($oneMatch, $receiver->{$matches}[1][$i], $nameTmp);
                 }
             }
         }
         $addedName = $this->cleanText($nameTmp);
     }
     $this->addAddress($this->cleanText($receiver->email), $addedName);
     if (!isset($this->forceVersion)) {
         $this->isHTML($receiver->html && $this->defaultMail[$mailid]->html);
     } else {
         $this->isHTML((bool) $this->forceVersion);
     }
     $this->Subject = $this->defaultMail[$mailid]->subject;
     if ($this->sendHTML) {
         $this->Body = $this->defaultMail[$mailid]->body;
         if ($this->config->get('multiple_part', false)) {
             $this->AltBody = $this->defaultMail[$mailid]->altbody;
         }
     } else {
         $this->Body = $this->defaultMail[$mailid]->altbody;
     }
     $this->setFrom($this->defaultMail[$mailid]->fromemail, $this->defaultMail[$mailid]->fromname);
     $this->_addReplyTo($this->defaultMail[$mailid]->replyemail, $this->defaultMail[$mailid]->replyname);
     if (!empty($this->defaultMail[$mailid]->attachments)) {
         if ($this->config->get('embed_files')) {
             foreach ($this->defaultMail[$mailid]->attachments as $attachment) {
                 $this->addAttachment($attachment->filename);
             }
         } else {
             $attachStringHTML = '<br /><fieldset><legend>' . JText::_('ATTACHMENTS') . '</legend><table>';
             $attachStringText = "\n" . "\n" . '------- ' . JText::_('ATTACHMENTS') . ' -------';
             foreach ($this->defaultMail[$mailid]->attachments as $attachment) {
                 $attachStringHTML .= '<tr><td><a href="' . $attachment->url . '" target="_blank">' . $attachment->name . '</a></td></tr>';
                 $attachStringText .= "\n" . '-- ' . $attachment->name . ' ( ' . $attachment->url . ' )';
             }
             $attachStringHTML .= '</table></fieldset>';
             if ($this->sendHTML) {
                 $this->Body .= $attachStringHTML;
                 if (!empty($this->AltBody)) {
                     $this->AltBody .= "\n" . $attachStringText;
                 }
             } else {
                 $this->Body .= $attachStringText;
             }
         }
     }
     if (!empty($this->parameters)) {
         $this->generateAllParams();
         $keysparams = array_keys($this->parameters);
         $this->Subject = str_replace($keysparams, $this->parameters, $this->Subject);
         $this->Body = str_replace($keysparams, $this->parameters, $this->Body);
         if (!empty($this->AltBody)) {
             $this->AltBody = str_replace($keysparams, $this->parameters, $this->AltBody);
         }
         if (!empty($this->From)) {
             str_replace($keysparams, $this->parameters, $this->From);
         }
         if (!empty($this->FromName)) {
             str_replace($keysparams, $this->parameters, $this->FromName);
         }
         if (!empty($this->ReplyTo)) {
             foreach ($this->ReplyTo as $i => $replyto) {
                 foreach ($replyto as $a => $oneval) {
                     $this->ReplyTo[$i][$a] = str_replace($keysparams, $this->parameters, $this->ReplyTo[$i][$a]);
                 }
             }
         }
     }
     if (!empty($this->introtext)) {
         $this->Body = $this->introtext . $this->Body;
         $this->AltBody = $this->textVersion($this->introtext) . $this->AltBody;
     }
     $this->body =& $this->Body;
     $this->altbody =& $this->AltBody;
     $this->subject =& $this->Subject;
     $this->from =& $this->From;
     $this->fromName =& $this->FromName;
     $this->replyto =& $this->ReplyTo;
     $this->replyname = $this->defaultMail[$mailid]->replyname;
     $this->replyemail = $this->defaultMail[$mailid]->replyemail;
     $this->mailid = $this->defaultMail[$mailid]->mailid;
     $this->key = $this->defaultMail[$mailid]->key;
     $this->alias = $this->defaultMail[$mailid]->alias;
     $this->type = $this->defaultMail[$mailid]->type;
     $this->tempid = $this->defaultMail[$mailid]->tempid;
     $this->sentby = $this->defaultMail[$mailid]->sentby;
     $this->userid = $this->defaultMail[$mailid]->userid;
     $this->filter = $this->defaultMail[$mailid]->filter;
     $this->template = @$this->defaultMail[$mailid]->template;
     $this->language = @$this->defaultMail[$mailid]->language;
     $this->favicon = @$this->defaultMail[$mailid]->favicon;
     if (empty($receiver->key) && !empty($receiver->subid)) {
         $receiver->key = acymailing_generateKey(14);
         $db = JFactory::getDBO();
         $db->setQuery('UPDATE ' . acymailing_table('subscriber') . ' SET `key`= ' . $db->Quote($receiver->key) . ' WHERE subid = ' . (int) $receiver->subid . ' LIMIT 1');
         $db->query();
     }
     $this->dispatcher->trigger('acymailing_replaceusertags', array(&$this, &$receiver, true));
     if ($this->sendHTML) {
         if (!empty($this->AltBody)) {
             $this->AltBody = $this->textVersion($this->AltBody, false);
         }
     } else {
         $this->Body = $this->textVersion($this->Body, false);
     }
     $status = $this->send();
     if ($this->trackEmail) {
         $helperQueue = acymailing_get('helper.queue');
         $statsAdd = array();
         $statsAdd[$this->mailid][$status][$this->sendHTML][] = $receiver->subid;
         $helperQueue->statsAdd($statsAdd);
         $this->trackEmail = false;
     }
     return $status;
 }
Example #17
0
 function saveastmpl()
 {
     $tmplClass = acymailing_get('class.template');
     $newTmpl = new stdClass();
     $formData = JRequest::getVar('data', array(), '', 'array');
     if (!empty($formData['mail']['tempid'])) {
         $template = $tmplClass->get($formData['mail']['tempid']);
         $newTmpl->styles = $template->styles;
         $newTmpl->stylesheet = $template->stylesheet;
         $newTmpl->category = $template->category;
     }
     if (!empty($formData['mail']['subject'])) {
         $formData['mail']['subject'] = str_replace(chr(226) . chr(128) . chr(168), '', $formData['mail']['subject']);
         $newTmpl->subject = strip_tags($formData['mail']['subject']);
         $newTmpl->name = strip_tags($formData['mail']['subject']);
     }
     $newTmpl->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     if (ACYMAILING_J25) {
         $newTmpl->body = JComponentHelper::filterText($newTmpl->body);
     }
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $acypluginsHelper->cleanHtml($newTmpl->body);
     if (!empty($formData['mail']['thumb']) && $formData['mail']['thumb'] == 'delete') {
         $newTmpl->thumb = null;
     } elseif (!empty($formData['mail']['thumb'])) {
         $newTmpl->thumb = strip_tags($formData['mail']['thumb']);
     } else {
         $mailid = acymailing_getCID('mailid');
         if (!empty($mailid)) {
             $mail = $this->get($mailid);
             $newTmpl->thumb = $mail->thumb;
         }
     }
     if (!empty($formData['mail']['altbody'])) {
         $newTmpl->altbody = strip_tags($formData['mail']['altbody']);
     }
     if (!empty($formData['mail']['fromname'])) {
         $newTmpl->fromname = strip_tags($formData['mail']['fromname']);
     }
     if (!empty($formData['mail']['fromemail'])) {
         $newTmpl->fromemail = strip_tags($formData['mail']['fromemail']);
     }
     if (!empty($formData['mail']['replyname'])) {
         $newTmpl->replyname = strip_tags($formData['mail']['replyname']);
     }
     if (!empty($formData['mail']['replyemail'])) {
         $newTmpl->replyemail = strip_tags($formData['mail']['replyemail']);
     }
     if (!empty($formData['mail']['summary'])) {
         $newTmpl->description = strip_tags($formData['mail']['summary']);
     }
     $newTmpl->ordering = 1;
     $tempid = $tmplClass->save($newTmpl);
     if (!empty($tempid)) {
         $formData['mail']['tempid'] = $tempid;
         acymailing_enqueueMessage(JText::_('ACY_SAVEASTMPL_VALID'), 'message');
     } else {
         acymailing_enqueueMessage(JText::_('ERROR_SAVING'), 'error');
     }
     return true;
 }
 function complete_abtest()
 {
     $mailid = JRequest::getInt('mailToSend');
     $mailClass = acymailing_get('class.mail');
     $newMailid = $mailClass->complete_abtest('manual', $mailid);
     $finalMail = $mailClass->get($newMailid);
     acymailing_enqueueMessage(JText::sprintf('ABTESTING_FINALSEND', $finalMail->subject), 'info');
     JRequest::setVar('validationStatus', 'abTestFinalSend');
     $this->abtesting();
 }
Example #19
0
 public function createFolder()
 {
     JRequest::checkToken() or die('Invalid Token to create folder');
     $folderName = str_replace(array('.', '-'), array('', '_'), strtolower(JRequest::getCmd('subFolderName')));
     if (empty($folderName)) {
         $this->browse();
         return false;
     }
     $directoryPath = JRequest::getString('acy_media_browser_files_path') . '/' . $folderName;
     $mediaFolders = acymailing_getFilesFolder('media', true);
     $allowed = false;
     foreach ($mediaFolders as $oneMedia) {
         if (preg_match('#^' . preg_quote($oneMedia) . '[a-z_0-9\\-/]*$#i', $directoryPath)) {
             $allowed = true;
             break;
         }
     }
     if (!$allowed) {
         acymailing_enqueueMessage('You are not allowed to create this folder', 'error');
         $this->browse();
         return false;
     }
     $directoryPath = str_replace('/', DS, $directoryPath);
     if (JFolder::exists(ACYMAILING_ROOT . $directoryPath)) {
         acymailing_enqueueMessage(JText::_('FOLDER_ALREADY_EXISTS'), 'warning');
         $this->browse();
         return false;
     }
     if (!JFolder::create(ACYMAILING_ROOT . $directoryPath)) {
         acymailing_enqueueMessage(JText::sprintf('WRITABLE_FOLDER', substr(ACYMAILING_ROOT . $directoryPath, 0, strrpos(ACYMAILING_ROOT . $directoryPath, DS)), 'error'));
         $this->browse();
         return false;
     }
     JRequest::setVar('selected_folder', JRequest::getString('acy_media_browser_files_path') . '/' . $folderName);
     $this->browse();
 }
Example #20
0
 function language()
 {
     $this->setLayout('default');
     $code = JRequest::getCmd('code');
     if (empty($code)) {
         acymailing_display('Code not specified', 'error');
         return;
     }
     $file = new stdClass();
     $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_enqueueMessage(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');
     }
     $custompath = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $code . DS . $code . '.com_acymailing_custom.ini';
     if (JFile::exists($custompath)) {
         $file->customcontent = JFile::read($custompath);
     }
     if ($loadLatest or JRequest::getCmd('task') == 'latest') {
         if (file_exists(JPATH_ROOT . DS . 'language' . DS . $code)) {
             $doc = JFactory::getDocument();
             $doc->addScript(ACYMAILING_UPDATEURL . 'languageload&code=' . JRequest::getCmd('code'));
         } else {
             acymailing_enqueueMessage('The specified language "' . htmlspecialchars($code, ENT_COMPAT, 'UTF-8') . '" is not installed on your site', 'warning');
         }
         $showLatest = false;
     } elseif (JRequest::getCmd('task') == 'save') {
         $showLatest = false;
     }
     if (JRequest::getString('tmpl') == 'component') {
         $acyToolbar = acymailing::get('helper.toolbar');
         $acyToolbar->save();
         $acyToolbar->custom('share', JText::_('SHARE'), 'share', false);
         $acyToolbar->setTitle(JText::_('ACY_FILE') . ' : ' . $this->escape($file->name));
         $acyToolbar->topfixed = false;
         $acyToolbar->display();
     }
     $this->assignRef('showLatest', $showLatest);
     $this->assignRef('file', $file);
 }
Example #21
0
 function save()
 {
     $pkey = $this->pkey;
     $cid = JRequest::getVar('cid', array(), 'post', 'array');
     $order = JRequest::getVar('order', array(), 'post', 'array');
     JArrayHelper::toInteger($cid);
     $database = JFactory::getDBO();
     $query = 'SELECT `ordering`,`' . $pkey . '` FROM ' . acymailing_table($this->table) . ' WHERE `' . $pkey . '` NOT IN (' . implode(',', $cid) . ') ';
     if (!empty($this->groupMap)) {
         $query .= ' AND ' . $this->groupMap . ' = ' . $database->Quote($this->groupVal);
     }
     $query .= ' ORDER BY `ordering` ASC';
     $database->setQuery($query);
     $results = $database->loadObjectList($pkey);
     $oldResults = $results;
     asort($order);
     $newOrder = array();
     while (!empty($order) or !empty($results)) {
         $dbElement = reset($results);
         if (empty($dbElement->ordering) or !empty($order) and reset($order) <= $dbElement->ordering) {
             $newOrder[] = $cid[(int) key($order)];
             unset($order[key($order)]);
         } else {
             $newOrder[] = $dbElement->{$pkey};
             unset($results[$dbElement->{$pkey}]);
         }
     }
     $i = 1;
     $status = true;
     $element = new stdClass();
     foreach ($newOrder as $val) {
         $element->{$pkey} = $val;
         $element->ordering = $i;
         if (!isset($oldResults[$val]) or $oldResults[$val]->ordering != $i) {
             $status = $database->updateObject(acymailing_table($this->table), $element, $pkey) && $status;
         }
         $i++;
     }
     if ($status) {
         acymailing_enqueueMessage(JText::_('ACY_NEW_ORDERING_SAVED'), 'message');
     } else {
         acymailing_enqueueMessage(JText::_('ERROR_ORDERING'), 'error');
     }
     return $status;
 }
Example #22
0
 function test()
 {
     if (!$this->isAllowed($this->aclCat, 'manage')) {
         return;
     }
     $this->store();
     $tempid = acymailing_getCID('tempid');
     $test_selection = JRequest::getVar('test_selection', '', '', 'string');
     if (empty($tempid) or empty($test_selection)) {
         return;
     }
     $mailer = acymailing_get('helper.mailer');
     $mailer->report = true;
     $config = acymailing_config();
     $subscriberClass = acymailing_get('class.subscriber');
     $userHelper = acymailing_get('helper.user');
     JPluginHelper::importPlugin('acymailing');
     $dispatcher = JDispatcher::getInstance();
     $receivers = array();
     if ($test_selection == 'users') {
         $receiverEntry = JRequest::getVar('test_emails', '', '', 'string');
         if (!empty($receiverEntry)) {
             if (substr_count($receiverEntry, '@') > 1) {
                 $receivers = explode(',', trim(preg_replace('# +#', '', $receiverEntry)));
             } else {
                 $receivers[] = trim($receiverEntry);
             }
         }
     } else {
         $gid = JRequest::getInt('test_group', '-1');
         if ($gid == -1) {
             return false;
         }
         $db = JFactory::getDBO();
         if (!ACYMAILING_J16) {
             $db->setQuery('SELECT email FROM ' . acymailing_table('users', false) . ' WHERE gid = ' . intval($gid));
         } else {
             $db->setQuery('SELECT u.email FROM ' . acymailing_table('users', false) . ' AS u JOIN ' . acymailing_table('user_usergroup_map', false) . ' AS ugm ON u.id = ugm.user_id WHERE ugm.group_id = ' . intval($gid));
         }
         $receivers = acymailing_loadResultArray($db);
     }
     if (empty($receivers)) {
         acymailing_enqueueMessage(JText::_('NO_SUBSCRIBER'), 'notice');
         return $this->edit();
     }
     $classTemplate = acymailing_get('class.template');
     $myTemplate = $classTemplate->get($tempid);
     $myTemplate->sendHTML = 1;
     $myTemplate->mailid = 0;
     $myTemplate->template = $myTemplate;
     if (empty($myTemplate->subject)) {
         $myTemplate->subject = $myTemplate->name;
     }
     if (empty($myTemplate->altBody)) {
         $myTemplate->altbody = $mailer->textVersion($myTemplate->body);
     }
     $dispatcher->trigger('acymailing_replacetags', array(&$myTemplate, true));
     $myTemplate->body = acymailing_absoluteURL($myTemplate->body);
     $result = true;
     foreach ($receivers as $receiveremail) {
         $copy = $myTemplate;
         $mailer->clearAll();
         $mailer->setFrom($copy->fromemail, $copy->fromname);
         if (!empty($copy->replyemail)) {
             $replyToName = $config->get('add_names', true) ? $mailer->cleanText($copy->replyname) : '';
             $mailer->AddReplyTo($mailer->cleanText($copy->replyemail), $replyToName);
         }
         $receiver = $subscriberClass->get($receiveremail);
         if (empty($receiver->subid)) {
             if ($userHelper->validEmail($receiveremail)) {
                 $newUser = new stdClass();
                 $newUser->email = $receiveremail;
                 $subscriberClass->sendConf = false;
                 $subid = $subscriberClass->save($newUser);
                 $receiver = $subscriberClass->get($subid);
             }
             if (empty($receiver->subid)) {
                 continue;
             }
         }
         $addedName = $config->get('add_names', true) ? $mailer->cleanText($receiver->name) : '';
         $mailer->AddAddress($mailer->cleanText($receiver->email), $addedName);
         $dispatcher->trigger('acymailing_replaceusertags', array(&$copy, &$receiver, true));
         $mailer->isHTML(true);
         $mailer->Body = $copy->body;
         $mailer->Subject = $copy->subject;
         if ($config->get('multiple_part', false)) {
             $mailer->AltBody = $copy->altbody;
         }
         $mailer->send();
     }
     return $this->edit();
 }
Example #23
0
 function remove()
 {
     JRequest::checkToken() or die('Invalid Token');
     $app = JFactory::getApplication();
     $config = acymailing_config();
     $deleteBehaviour = $config->get('frontend_delete_button', 'delete');
     $subscriberIds = JRequest::getVar('cid', array(), '', 'array');
     if ($app->isAdmin() || $deleteBehaviour == 'delete') {
         if (!$this->isAllowed('subscriber', 'delete')) {
             return;
         }
         $subscriberObject = acymailing_get('class.subscriber');
         $num = $subscriberObject->delete($subscriberIds);
         acymailing_enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $num), 'message');
     } else {
         if (!$this->isAllowed('subscriber', 'manage')) {
             return;
         }
         $listId = JRequest::getInt('filter_lists', 0);
         if (empty($listId)) {
             acymailing_enqueueMessage('List not found', 'error');
         } else {
             $listsubClass = acymailing_get('class.listsub');
             foreach ($subscriberIds as $subid) {
                 $listsubClass->removeSubscription($subid, array($listId));
             }
             $listClass = acymailing_get('class.list');
             $list = $listClass->get($listId);
             acymailing_enqueueMessage(JText::sprintf('IMPORT_REMOVE', count($subscriberIds), $list->name), 'message');
         }
     }
     JRequest::setVar('layout', 'listing');
     return parent::display();
 }
    function display($tpl = null)
    {
        JHTML::_('behavior.modal', 'a.modal');
        $toggleClass = acymailing_get('helper.toggle');
        $config = acymailing_config();
        $db = JFactory::getDBO();
        $doc = JFactory::getDocument();
        $app = JFactory::getApplication();
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        $lg = JFactory::getLanguage();
        $language = $lg->getTag();
        $styleRemind = 'float:right;margin-right:30px;position:relative;';
        $loadLink = '<a onclick="window.document.getElementById(\'acymailing_messages_warning\').style.display = \'none\';return true;" class="modal" rel="{handler: \'iframe\', size:{x:800, y:500}}" href="index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=file&amp;task=latest&amp;code=' . $language . '">' . JText::_('LOAD_LATEST_LANGUAGE') . '</a>';
        if (!file_exists(ACYMAILING_ROOT . 'language' . DS . $language . DS . $language . '.com_acymailing.ini')) {
            if ($config->get('errorlanguagemissing', 1)) {
                $notremind = '<small style="' . $styleRemind . '">' . $toggleClass->delete('acymailing_messages_warning', 'errorlanguagemissing_0', 'config', false, JText::_('DONT_REMIND')) . '</small>';
                acymailing_enqueueMessage(JText::_('MISSING_LANGUAGE') . ' ' . $loadLink . ' ' . $notremind, 'warning');
            }
        } elseif (version_compare(JText::_('ACY_LANG_VERSION'), $config->get('version'), '<')) {
            if ($config->get('errorlanguageupdate', 1)) {
                $notremind = '<small style="' . $styleRemind . '">' . $toggleClass->delete('acymailing_messages_warning', 'errorlanguageupdate_0', 'config', false, JText::_('DONT_REMIND')) . '</small>';
                acymailing_enqueueMessage(JText::_('UPDATE_LANGUAGE') . ' ' . $loadLink . ' ' . $notremind, 'warning');
            }
        }
        if (ACYMAILING_J30 && $app->getTemplate() == 'hathor') {
            if ($config->get('errortemplatenotisis', 1)) {
                $message = ' You can change the default Back-end template <a href="index.php?option=com_templates&view=styles">Here</a> or change your personnal default Back-end template by editing your user profile <a href="index.php?option=com_users&view=users">Here</a>, tab "Basic Settings".';
                $personalTemplate = JFactory::getUser()->getParam('admin_style');
                if (!empty($personalTemplate)) {
                    $message = ' You can change your personnal default Back-end template by editing your user profile <a href="index.php?option=com_users&view=users">Here</a>, tab "Basic Settings".';
                }
                $notremind = '<small style="' . $styleRemind . '">' . $toggleClass->delete('acymailing_messages_warning', 'errortemplatenotisis_0', 'config', false, JText::_('DONT_REMIND')) . '</small>';
                acymailing_enqueueMessage('You should rather use the isis template in the Back-End which suits more AcyMailing.' . $message . $notremind, 'warning');
            }
        }
        $indexes = array('listsub', 'stats', 'list', 'mail', 'userstats', 'urlclick', 'history', 'template', 'queue', 'subscriber');
        $addIndexes = array('We recenty optimized our database...');
        foreach ($indexes as $oneTable) {
            if ($config->get('optimize_' . $oneTable, 1)) {
                continue;
            }
            $addIndexes[] = 'Please ' . $toggleClass->toggleText('addindex', $oneTable, 'config', 'click here') . ' to add indexes on the ' . $oneTable . ' table';
        }
        if (count($addIndexes) > 1) {
            acymailing_enqueueMessage($addIndexes, 'warning');
        }
        $acyToolbar = acymailing::get('helper.toolbar');
        $acyToolbar->custom('test', JText::_('SEND_TEST'), 'send', false);
        $acyToolbar->divider();
        $acyToolbar->addButtonOption('apply', JText::_('ACY_APPLY'), 'apply', false);
        $acyToolbar->save();
        $acyToolbar->cancel();
        $acyToolbar->divider();
        $acyToolbar->help('config');
        $acyToolbar->setTitle(JText::_('ACY_CONFIGURATION'), 'cpanel');
        $acyToolbar->display();
        $elements = new stdClass();
        $elements->add_names = JHTML::_('acyselect.booleanlist', "config[add_names]", '', $config->get('add_names', true));
        $elements->embed_images = JHTML::_('acyselect.booleanlist', "config[embed_images]", '', $config->get('embed_images', 0));
        $elements->embed_files = JHTML::_('acyselect.booleanlist', "config[embed_files]", '', $config->get('embed_files', 1));
        $elements->multiple_part = JHTML::_('acyselect.booleanlist', "config[multiple_part]", '', $config->get('multiple_part', 0));
        $mailerMethods = array('elasticemail', 'smtp', 'sendmail');
        $js = "function updateMailer(mailermethod){" . "\n";
        foreach ($mailerMethods as $oneMethod) {
            $js .= " window.document.getElementById('" . $oneMethod . "_config').style.display = 'none'; " . "\n";
        }
        $js .= "if(window.document.getElementById(mailermethod+'_config')) {window.document.getElementById(mailermethod+'_config').style.display = 'block';} }";
        $js .= 'window.addEvent(\'domready\', function(){ updateMailer(\'' . $config->get('mailer_method', 'phpmail') . '\'); });';
        $doc->addScriptDeclaration($js);
        $encodingval = array();
        $encodingval[] = JHTML::_('select.option', 'binary', 'Binary');
        $encodingval[] = JHTML::_('select.option', 'quoted-printable', 'Quoted-printable');
        $encodingval[] = JHTML::_('select.option', '7bit', '7 Bit');
        $encodingval[] = JHTML::_('select.option', '8bit', '8 Bit');
        $encodingval[] = JHTML::_('select.option', 'base64', 'Base 64');
        $elements->encoding_format = JHTML::_('select.genericlist', $encodingval, "config[encoding_format]", 'size="1" style="width:150px;"', 'value', 'text', $config->get('encoding_format', 'base64'));
        $charset = acymailing_get('type.charset');
        $elements->charset = $charset->display("config[charset]", $config->get('charset', 'UTF-8'));
        $securedVals = array();
        $securedVals[] = JHTML::_('select.option', '', '- - -');
        $securedVals[] = JHTML::_('select.option', 'ssl', 'SSL');
        $securedVals[] = JHTML::_('select.option', 'tls', 'TLS');
        $elements->smtp_secured = JHTML::_('select.genericlist', $securedVals, "config[smtp_secured]", 'size="1" style="width:100px;"', 'value', 'text', $config->get('smtp_secured'));
        $elements->smtp_auth = JHTML::_('acyselect.booleanlist', "config[smtp_auth]", '', $config->get('smtp_auth', 0));
        $elements->smtp_keepalive = JHTML::_('acyselect.booleanlist', "config[smtp_keepalive]", '', $config->get('smtp_keepalive', 1));
        $elements->allow_visitor = JHTML::_('acyselect.booleanlist', "config[allow_visitor]", '', $config->get('allow_visitor', 1));
        $editorType = acymailing_get('type.editor');
        $elements->editor = $editorType->display('config[editor]', $config->get('editor'));
        $elements->subscription_message = JHTML::_('acyselect.booleanlist', "config[subscription_message]", '', $config->get('subscription_message', 1));
        $elements->confirmation_message = JHTML::_('acyselect.booleanlist', "config[confirmation_message]", '', $config->get('confirmation_message', 1));
        $elements->unsubscription_message = JHTML::_('acyselect.booleanlist', "config[unsubscription_message]", '', $config->get('unsubscription_message', 1));
        $elements->welcome_message = JHTML::_('acyselect.booleanlist', "config[welcome_message]", '', $config->get('welcome_message', 1));
        $elements->unsub_message = JHTML::_('acyselect.booleanlist', "config[unsub_message]", '', $config->get('unsub_message', 1));
        $elements->confirm_message = JHTML::_('acyselect.booleanlist', "config[confirm_message]", '', $config->get('confirm_message', 0));
        if (acymailing_level(1)) {
            $forwardValues = array();
            $forwardValues[] = JHTML::_('select.option', 0, JTEXT::_('JOOMEXT_NO'));
            $forwardValues[] = JHTML::_('select.option', 1, JTEXT::_('JOOMEXT_YES'));
            $forwardValues[] = JHTML::_('select.option', 2, JTEXT::_('JOOMEXT_YES_FORWARD'));
            $elements->forward = JHTML::_('acyselect.radiolist', $forwardValues, "config[forward]", '', 'value', 'text', $config->get('forward', 0));
        } else {
            $elements->forward = acymailing_getUpgradeLink('essential');
        }
        if (acymailing_level(1)) {
            $js = "function updateDKIM(dkimval){\n\t\t\t\t\t\tif(dkimval == 1){document.getElementById('dkim_config').style.display = 'block';}\n\t\t\t\t\t\telse{document.getElementById('dkim_config').style.display = 'none';}\n\t\t\t\t\t\t};";
            $doc->addScriptDeclaration($js);
            if (function_exists('openssl_sign')) {
                $elements->dkim = JHTML::_('acyselect.booleanlist', "config[dkim]", 'onclick="updateDKIM(this.value)"', $config->get('dkim', 0));
            } else {
                $elements->dkim = '<input type="hidden" name="config[dkim]" value="0" />PHP Extension openssl not enabled';
            }
            $js = "function updateQueueProcess(newvalue){";
            $js .= "if(newvalue == 'onlyauto') {window.document.getElementById('method_auto').style.display = ''; window.document.getElementById('method_manual').style.display = 'none';}";
            $js .= "if(newvalue == 'auto') {window.document.getElementById('method_auto').style.display = ''; window.document.getElementById('method_manual').style.display = '';}";
            $js .= "if(newvalue == 'manual') {window.document.getElementById('method_auto').style.display = 'none'; window.document.getElementById('method_manual').style.display = '';}";
            $js .= '};';
            $doc->addScriptDeclaration($js);
            $queueType = array();
            $queueType[] = JHTML::_('select.option', 'onlyauto', JText::_('AUTO_ONLY'));
            $queueType[] = JHTML::_('select.option', 'auto', JText::_('AUTO_MAN'));
            $queueType[] = JHTML::_('select.option', 'manual', JText::_('MANUAL_ONLY'));
            $elements->queue_type = JHTML::_('acyselect.radiolist', $queueType, "config[queue_type]", 'onclick="updateQueueProcess(this.value);"', 'value', 'text', $config->get('queue_type', 'auto'));
        } else {
            $elements->dkim = acymailing_getUpgradeLink('essential');
        }
        $js = 'var selectedHTTPS = ' . ($config->get('ssl_links', 0) == 0 ? 'false;' : 'true;') . '
		function confirmHTTPS(element){
			var clickedHTTPS = (element == 1);
			if(clickedHTTPS == selectedHTTPS) return true;
			if(clickedHTTPS){
				var cnfrm = confirm(\'' . str_replace("'", "\\'", JText::_('ACY_SSLCHOICE_CONFIRMATION')) . '\');
				if(!cnfrm){';
        if (ACYMAILING_J30) {
            $js .= 'var labels = document.getElementById(\'config_ssl_linksfieldset\').getElementsByTagName(\'label\');
					if(labels[0].hasClass(\'btn-success\')){
						labels[1].click();
						return true;
					}else{
						labels[0].click();
						return true;
					}';
        } else {
            $js .= 'return false;';
        }
        $js .= '}
			}
			selectedHTTPS = clickedHTTPS;
			return true;
		}';
        $doc->addScriptDeclaration($js);
        $elements->ssl_links = JHTML::_('acyselect.booleanlist', "config[ssl_links]", 'onclick="return confirmHTTPS(this.value);"', $config->get('ssl_links', 0));
        $delayTypeManual = acymailing_get('type.delay');
        $elements->queue_pause = $delayTypeManual->display('config[queue_pause]', $config->get('queue_pause'), 0);
        $delayTypeAuto = acymailing_get('type.delay');
        $delayTypeAuto->onChange = "window.document.getElementById('autoFrequencyWarning').style.display='inline';";
        $onChangeMsg = '<span style="display:none;color:red;" id="autoFrequencyWarning">' . JText::_('ACY_CRON_CHANGE_FREQUENCY_WARNING') . '</span>';
        $elements->cron_frequency = $delayTypeAuto->display('config[cron_frequency]', $config->get('cron_frequency'), 2) . $onChangeMsg;
        $js = "function detectTimeout(id){\n\t\t\t\ttry{\n\t\t\t\t\twindow.document.getElementById(id).className = 'onload';\n\t\t\t\t\twindow.document.getElementById(id).innerHTML = '" . str_replace("'", "\\'", JText::_('ACY_CLOSE_TIMEOUT')) . "';\n\n\t\t\t\t\ttry{\n\t\t\t\t\t\tnew Ajax('" . rtrim(JURI::root(), '/') . "/index.php?option=com_acymailing&tmpl=component&ctrl=stats&task=detecttimeout&seckey=" . $config->get('security_key') . "',{ method: 'get', onComplete: function() { document.id(id).innerHTML = 'Done!'; window.document.getElementById(id).className = 'loading'; }}).request();\n\t\t\t\t\t}catch(err){\n\t\t\t\t\t\tnew Request({url:'" . rtrim(JURI::root(), '/') . "/index.php?option=com_acymailing&tmpl=component&ctrl=stats&task=detecttimeout&seckey=" . $config->get('security_key') . "',method: 'get', onComplete: function(response) { document.id(id).innerHTML = 'Done!'; window.document.getElementById(id).className = 'loading'; }}).send();\n\t\t\t\t\t}\n\t\t\t\t}catch(err){alert('Could not load the max execution time value : '+err);}\n\t\t\t\treturn;\n\t\t}";
        $maxexecutiontime = $config->get('max_execution_time');
        if (empty($maxexecutiontime) && intval($config->get('last_maxexec_check')) < time() - 60) {
            $js .= 'window.addEvent(\'domready\', function(){ detectTimeout(\'timeoutcheck\');return; });';
        }
        $doc = JFactory::getDocument();
        $doc->addScriptDeclaration($js);
        $cssval = array('css_frontend' => 'component', 'css_module' => 'module', 'css_backend' => 'backend');
        foreach ($cssval as $configval => $type) {
            $myvals = array();
            $myvals[] = JHTML::_('select.option', '', JText::_('ACY_NONE'));
            if ($configval == 'css_backend') {
                $myvals[] = JHTML::_('select.option', 'backend_custom', JText::_('ACY_CUSTOM'));
                $editFileName = $config->get('css_backend', 'default');
            } else {
                $regex = '^' . $type . '_([-_a-z0-9]*)\\.css$';
                $allCSSFiles = JFolder::files(ACYMAILING_MEDIA . 'css', $regex);
                $family = '';
                foreach ($allCSSFiles as $oneFile) {
                    preg_match('#' . $regex . '#i', $oneFile, $results);
                    $fileName = str_replace('default_', '', $results[1]);
                    $fileNameArray = explode('_', $fileName);
                    if (count($fileNameArray) == 2) {
                        if ($fileNameArray[0] != $family) {
                            if (!empty($family)) {
                                $myvals[] = JHTML::_('select.option', '</OPTGROUP>');
                            }
                            $family = $fileNameArray[0];
                            $myvals[] = JHTML::_('select.option', '<OPTGROUP>', ucfirst($family));
                        }
                        unset($fileNameArray[0]);
                        $fileName = implode('_', $fileNameArray);
                    }
                    $fileName = ucwords(str_replace('_', ' ', $fileName));
                    $myvals[] = JHTML::_('select.option', $results[1], $fileName);
                }
                if (!empty($family)) {
                    $myvals[] = JHTML::_('select.option', '</OPTGROUP>');
                }
                $editFileName = $type . '_' . $config->get($configval, 'default');
            }
            $currentVal = $config->get($configval, 'default');
            $aStyle = empty($currentVal) ? 'style="display:none"' : '';
            $js = 'onchange="updateCSSLink(\'' . $configval . '\',\'' . $type . '\',this.value);"';
            $elements->{$configval} = JHTML::_('select.genericlist', $myvals, 'config[' . $configval . ']', 'class="inputbox" size="1" ' . $js, 'value', 'text', $config->get($configval, 'default'), $configval . '_choice');
            $linkEdit = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=file&amp;task=css&amp;var=' . $configval . '&amp;file=' . $editFileName;
            $elements->{$configval} .= ' <a id="' . $configval . '_link" ' . $aStyle . ' class="modal" title="' . JText::_('ACY_EDIT', true) . '"  href="' . $linkEdit . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><i class="acyicon-edit" style="margin: 5px 5px 0px 5px; display: inline-block;"></i></a>';
        }
        $js = "function updateCSSLink(myid,type,newval){\n\t\t\tif(newval){document.getElementById(myid+'_link').style.display = '';}else{document.getElementById(myid+'_link').style.display = 'none'}\n\t\t\tif(myid == 'css_backend') filename = newval;\n\t\t\telse filename = type+'_'+newval;\n\t\t\tdocument.getElementById(myid+'_link').href = 'index.php?option=com_acymailing&tmpl=component&ctrl=file&task=css&var='+myid+'&file='+filename;\n\t\t}";
        $doc->addScriptDeclaration($js);
        $bootstrapFrontValues = array();
        $bootstrapFrontValues[] = JHTML::_('select.option', 0, JTEXT::_('JOOMEXT_NO'));
        $bootstrapFrontValues[] = JHTML::_('select.option', 1, 'Bootstrap 2');
        $bootstrapFrontValues[] = JHTML::_('select.option', 2, 'Bootstrap 3');
        $elements->bootstrap_frontend = JHTML::_('acyselect.radiolist', $bootstrapFrontValues, "config[bootstrap_frontend]", '', 'value', 'text', $config->get('bootstrap_frontend', 0));
        $elements->colortype = acymailing_get('type.color');
        $elements->use_sef = JHTML::_('acyselect.booleanlist', "config[use_sef]", '', $config->get('use_sef', 0));
        if (acymailing_level(1)) {
            $trackingMode = $config->get('trackingsystem', 'acymailing');
            $tracking_system = '<input type="checkbox" name="config[trackingsystem][]" id="trackingsystem[0]" value="acymailing" style="margin-left:10px" ' . (stripos($trackingMode, 'acymailing') !== false ? 'checked="checked"' : '') . '/> <label for="trackingsystem[0]">Acymailing</label>';
            $tracking_system .= '<input type="checkbox" name="config[trackingsystem][]" id="trackingsystem[1]" value="google" style="margin-left:10px;" ' . (stripos($trackingMode, 'google') !== false ? 'checked="checked"' : '') . '/> <label for="trackingsystem[1]">Google Analytics</label>';
            $tracking_system .= '<input type="hidden" name="config[trackingsystem][]" value="1"/>';
            $tracking_system_external_website = JHTML::_('acyselect.booleanlist', "config[trackingsystemexternalwebsite]", ' id="trackingsystemexternalwebsite"', $config->get('trackingsystemexternalwebsite', 1));
        } else {
            $tracking_system = acymailing_getUpgradeLink('essential');
            $tracking_system_external_website = acymailing_getUpgradeLink('essential');
        }
        $elements->tracking_system = $tracking_system;
        $elements->tracking_system_external_website = $tracking_system_external_website;
        $indexType = $config->get('indexFollow', '');
        $indexFollow = '<div style="float: left;"><input type="checkbox" name="config[indexFollow][]" id="indexFollow[0]" value="noindex" style="margin-left:10px" ' . (stripos($indexType, 'noindex') !== false ? 'checked="checked"' : '') . '/> <label for="indexFollow[0]">noindex</label></div>';
        $indexFollow .= '<div style="float: left;"><input type="checkbox" name="config[indexFollow][]" id="indexFollow[1]" value="nofollow" style="margin-left:10px" ' . (stripos($indexType, 'nofollow') !== false ? 'checked="checked"' : '') . '/> <label for="indexFollow[1]">nofollow</label></div>';
        $indexFollow .= '<input type="hidden" name="config[indexFollow][]" value="1"/>';
        $elements->indexFollow = $indexFollow;
        if (acymailing_level(3)) {
            $geolocAvailable = true;
            $geolocation = '<input type="hidden" name="config[geolocation]" value="0"/>';
            $geoloc_api_key = '';
            if (!function_exists('curl_init')) {
                $geolocAvailable = false;
                $geolocation .= 'The AcyMailing geolocation plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.';
            }
            if (!function_exists('json_decode')) {
                if (!$geolocAvailable) {
                    $geolocation .= '<br />';
                }
                $geolocAvailable = false;
                $geolocation .= 'The AcyMailing geolocation plugin can only work with PHP 5.2 at least. Please ask your web hosting to update your PHP version.';
            }
            if ($geolocAvailable) {
                $geoloc = $config->get('geolocation', '');
                $geolocation = '<span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_0" value="creation" style="margin-left:10px" ' . (stripos($geoloc, 'creation') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_0">' . JText::_('ON_USER_CREATE') . '</label></span>';
                $geolocation .= ' <span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_1" value="modify" style="margin-left:10px;" ' . (stripos($geoloc, 'modify') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_1">' . JText::_('ON_USER_CHANGE') . '</label></span>';
                $geolocation .= ' <span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_2" value="confirm" style="margin-left:10px;" ' . (stripos($geoloc, 'confirm') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_2">' . JText::_('GEOLOC_CONFIRM_SUB') . '</label></span>';
                $geolocation .= ' <span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_3" value="clic" style="margin-left:10px;" ' . (stripos($geoloc, 'clic') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_3">' . JText::_('ON_USER_CLICK') . '</label></span>';
                $geolocation .= ' <span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_4" value="open" style="margin-left:10px;" ' . (stripos($geoloc, 'open') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_4">' . JText::_('ON_OPEN_NEWS') . '</label></span>';
                $geolocation .= ' <span style="white-space:nowrap"><input type="checkbox" name="config[geolocation][]" id="geolocation_5" value="unsubscription" style="margin-left:10px;" ' . (stripos($geoloc, 'unsubscription') !== false ? 'checked="checked"' : '') . '/> <label for="geolocation_5">' . JText::_('GEOLOC_UNSUB') . '</label></span>';
                $geolocation .= '<input type="hidden" name="config[geolocation][]" value="1"/>';
                $geoloc_api_key = '<input class="inputbox" type="text" id="geoloc_api_key" name="config[geoloc_api_key]" style="width:450px" value="' . $this->escape($config->get('geoloc_api_key', '')) . '">';
            }
        } else {
            $geolocation = acymailing_getUpgradeLink('enterprise');
            $geoloc_api_key = false;
        }
        $elements->geolocation = $geolocation;
        $elements->geoloc_api_key = $geoloc_api_key;
        if (!ACYMAILING_J16) {
            $query = 'SELECT a.name, a.id as itemid, b.title  FROM `#__menu` as a JOIN `#__menu_types` as b on a.menutype = b.menutype WHERE a.access = 0 ORDER BY b.title ASC,a.ordering ASC';
        } else {
            $orderby = ACYMAILING_J30 ? 'a.lft' : 'a.ordering';
            $query = 'SELECT a.alias as name, a.id as itemid, b.title  FROM `#__menu` as a JOIN `#__menu_types` as b on a.menutype = b.menutype WHERE a.access NOT IN (2, 3) AND a.client_id=0 AND a.parent_id != 0 ORDER BY b.title ASC,' . $orderby . ' ASC';
        }
        $db->setQuery($query);
        $joomMenus = $db->loadObjectList();
        $menuvalues = array();
        $menuvalues[] = JHTML::_('select.option', '0', JText::_('ACY_NONE'));
        $lastGroup = '';
        foreach ($joomMenus as $oneMenu) {
            if ($oneMenu->title != $lastGroup) {
                if (!empty($lastGroup)) {
                    $menuvalues[] = JHTML::_('select.option', '</OPTGROUP>');
                }
                $menuvalues[] = JHTML::_('select.option', '<OPTGROUP>', $oneMenu->title);
                $lastGroup = $oneMenu->title;
            }
            $menuvalues[] = JHTML::_('select.option', $oneMenu->itemid, $oneMenu->name);
        }
        $elements->acymailing_menu = JHTML::_('select.genericlist', $menuvalues, 'config[itemid]', 'size="1"', 'value', 'text', $config->get('itemid'));
        $acyrss_format = array();
        $acyrss_format[] = JHTML::_('select.option', '', JText::_('ACY_NONE'));
        $acyrss_format[] = JHTML::_('select.option', 'rss', 'RSS feed');
        $acyrss_format[] = JHTML::_('select.option', 'atom', 'Atom feed');
        $acyrss_format[] = JHTML::_('select.option', 'both', JText::_('ACY_ALL'));
        $elements->acyrss_format = JHTML::_('select.genericlist', $acyrss_format, "config[acyrss_format]", 'size="1"', 'value', 'text', $config->get('acyrss_format', ''));
        $acyrss_order = array();
        $acyrss_order[] = JHTML::_('select.option', 'senddate', JText::_('SEND_DATE'));
        $acyrss_order[] = JHTML::_('select.option', 'mailid', JText::_('ACY_ID'));
        $acyrss_order[] = JHTML::_('select.option', 'subject', JText::_('ACY_TITLE'));
        $elements->acyrss_order = JHTML::_('select.genericlist', $acyrss_order, "config[acyrss_order]", 'size="1"', 'value', 'text', $config->get('acyrss_order', 'senddate'));
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=confirmation';
        $elements->editConfEmail = '<a class="modal" id="confirmemail"  href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_CONF_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_created';
        $elements->edit_notification_created = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_refuse';
        $elements->edit_notification_refuse = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_unsuball';
        $elements->edit_notification_unsuball = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_unsub';
        $elements->edit_notification_unsub = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_contact';
        $elements->edit_notification_contact = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_contact_menu';
        $elements->edit_notification_contact_menu = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=notification_confirm';
        $elements->edit_notification_confirm = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=email&amp;task=edit&amp;mailid=modif';
        $elements->editModifEmail = '<a class="modal" id="modifemail"  href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('EDIT_NOTIFICATION_MAIL') . '</button></a>';
        $link = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=cpanel&amp;task=checkDB';
        $elements->checkDB = '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><button class="acymailing_button_grey" onclick="return false">' . JText::_('DATABASE_INTEGRITY') . '</button></a>';
        $js = "function addUnsubReason(){\n\t\t\tvar input = document.createElement('input');\n\t\t\tinput.name = 'unsub_reasons[]';\n\t\t\tinput.style.width = '300px';\n\t\t\tinput.style.margin = '3px 0px';\n\t\t\tinput.type = 'text';\n\t\t\tdocument.getElementById('unsub_reasons').appendChild(input);\n\t\t\tvar br = document.createElement('br');\n\t\t\tdocument.getElementById('unsub_reasons').appendChild(br);\n\t\t}\n\t\tfunction displaySurvey(surveyval){\n\t\t\tif(surveyval == 1){\n\t\t\t\tdocument.getElementById('unsub_reasons_area').style.display = 'block';\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('unsub_reasons_area').style.display = 'none';\n\t\t\t}\n\t\t}\n\t\t";
        $doc->addScriptDeclaration($js);
        $path = JLanguage::getLanguagePath(JPATH_ROOT);
        $dirs = JFolder::folders($path);
        $languages = array();
        foreach ($dirs as $dir) {
            if (strlen($dir) != 5 || $dir == "xx-XX") {
                continue;
            }
            $xmlFiles = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
            $xmlFile = reset($xmlFiles);
            if (empty($xmlFile)) {
                $data = array();
            } else {
                $data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $xmlFile);
            }
            $oneLanguage = new stdClass();
            $oneLanguage->language = $dir;
            $oneLanguage->name = empty($data['name']) ? $dir : $data['name'];
            $languageFiles = JFolder::files($path . DS . $dir, '^(.*)\\.com_acymailing\\.ini$');
            $languageFile = reset($languageFiles);
            if (!empty($languageFile)) {
                $linkEdit = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=file&amp;task=language&amp;code=' . $oneLanguage->language;
                $oneLanguage->edit = ' <a class="modal" title="' . JText::_('EDIT_LANGUAGE_FILE', true) . '"  href="' . $linkEdit . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><i class="acyicon-edit" id="image' . $oneLanguage->language . '"></i></a>';
            } else {
                $linkEdit = 'index.php?option=com_acymailing&amp;tmpl=component&amp;ctrl=file&amp;task=language&amp;code=' . $oneLanguage->language;
                $oneLanguage->edit = ' <a class="modal" title="' . JText::_('ADD_LANGUAGE_FILE', true) . '"  href="' . $linkEdit . '" rel="{handler: \'iframe\', size:{x:800, y:500}}"><i class="acyicon-new" id="image' . $oneLanguage->language . '"></i></a>';
            }
            $languages[] = $oneLanguage;
        }
        $js = "function updateConfirmation(newvalue){";
        $js .= "if(newvalue == 0) {window.document.getElementById('confirmemail').style.display = 'none'; window.document.getElementById('confirm_redirect').disabled = true;}else{window.document.getElementById('confirmemail').style.display = 'inline'; window.document.getElementById('confirm_redirect').disabled = false;}";
        $js .= '}';
        $js .= "function updateModification(newvalue){ if(newvalue != 'none') {window.document.getElementById('modifemail').style.display = 'none';}else{window.document.getElementById('modifemail').style.display = 'inline';}} ";
        $js .= 'window.addEvent(\'load\', function(){ updateModification(\'' . $config->get('allow_modif', 'data') . '\'); updateConfirmation(' . $config->get('require_confirmation', 0) . '); });';
        $doc->addScriptDeclaration($js);
        $elements->require_confirmation = JHTML::_('acyselect.booleanlist', "config[require_confirmation]", 'onclick="updateConfirmation(this.value)"', $config->get('require_confirmation', 0));
        $allowmodif = array();
        $allowmodif[] = JHTML::_('select.option', "none", JText::_('JOOMEXT_NO'));
        $allowmodif[] = JHTML::_('select.option', "data", JText::_('ONLY_SUBSCRIPTION'));
        $allowmodif[] = JHTML::_('select.option', "all", JText::_('JOOMEXT_YES'));
        $elements->allow_modif = JHTML::_('acyselect.radiolist', $allowmodif, "config[allow_modif]", 'size="1" onclick="updateModification(this.value)"', 'value', 'text', $config->get('allow_modif', 'data'));
        if (!ACYMAILING_J16) {
            $db->setQuery("SELECT name,published,id FROM `#__plugins` WHERE `folder` = 'acymailing' AND `element` NOT LIKE 'plg%' ORDER BY published DESC, ordering ASC");
        } else {
            $db->setQuery("SELECT name,enabled as published,extension_id as id FROM `#__extensions` WHERE `state` <> -1 AND `folder` = 'acymailing' AND `type`= 'plugin' AND `element` NOT LIKE 'plg%' ORDER BY enabled DESC, ordering ASC");
        }
        $plugins = $db->loadObjectList();
        if (!ACYMAILING_J16) {
            $db->setQuery("SELECT name,published,id FROM `#__plugins` WHERE (`folder` != 'acymailing' OR `element` LIKE 'plg%') AND (`name` LIKE '%acymailing%' OR `element` LIKE '%acymailing%') ORDER BY published DESC, ordering ASC");
        } else {
            $db->setQuery("SELECT name,enabled as published ,extension_id as id FROM `#__extensions` WHERE `state` <> -1 AND (`folder` != 'acymailing' OR `element` LIKE 'plg%') AND `type` = 'plugin' AND (`name` LIKE '%acymailing%' OR `element` LIKE '%acymailing%') ORDER BY enabled DESC, ordering ASC");
        }
        $integrationplugins = $db->loadObjectList();
        if (ACYMAILING_J16) {
            $db->setQuery("SELECT COUNT(*) FROM #__extensions WHERE `enabled` = 1 AND `state` = -1 AND `type` = 'plugin' AND (`folder` = 'acymailing' OR `name` LIKE '%acymailing%' OR `element` LIKE '%acymailing%')");
            $discoveredPlugins = $db->loadResult();
            if (!empty($discoveredPlugins)) {
                acymailing_display('Some AcyMailing plugins are placed in the Joomla "Discover" feature and will not work, you should install them through the "Discover" menu in the Extension manager.', 'warning');
            }
        }
        $bounceaction = acymailing_get('type.bounceaction');
        $this->assignRef('bounceaction', $bounceaction);
        $this->assignRef('config', $config);
        $this->assignRef('languages', $languages);
        $this->assignRef('elements', $elements);
        $this->assignRef('plugins', $plugins);
        $this->assignRef('integrationplugins', $integrationplugins);
        $tabs = acymailing_get('helper.acytabs');
        $tabs->setOptions(array('useCookie' => true));
        $this->assignRef('tabs', $tabs);
        $this->assignRef('toggleClass', $toggleClass);
        if (!ACYMAILING_J16 and !file_exists(rtrim(JPATH_SITE, DS) . DS . 'plugins' . DS . 'acymailing' . DS . 'tagsubscriber.php') or ACYMAILING_J16 and !file_exists(rtrim(JPATH_SITE, DS) . DS . 'plugins' . DS . 'acymailing' . DS . 'tagsubscriber' . DS . 'tagsubscriber.php')) {
            acymailing_checkPluginsFolders();
        }
        return parent::display($tpl);
    }
Example #25
0
 function store()
 {
     if (!$this->isAllowed('lists', 'filter')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     $class = acymailing_get('class.filter');
     $status = $class->saveForm();
     if ($status) {
         acymailing_enqueueMessage(JText::_('JOOMEXT_SUCC_SAVED'), 'message');
     } else {
         acymailing_enqueueMessage(JText::_('ERROR_SAVING'), 'error');
         if (!empty($class->errors)) {
             foreach ($class->errors as $oneError) {
                 acymailing_enqueueMessage($oneError, 'error');
             }
         }
     }
 }
 function identify($onlyvalue = false)
 {
     $subid = JRequest::getInt("subid", 0);
     $key = JRequest::getString("key", '');
     if (empty($subid) or empty($key)) {
         $user = JFactory::getUser();
         if (!empty($user->id)) {
             $userIdentified = $this->get($user->email);
             return $userIdentified;
         }
         if (!$onlyvalue) {
             acymailing_enqueueMessage(JText::_('ASK_LOG'), 'error');
         }
         return false;
     }
     $this->database->setQuery('SELECT * FROM ' . acymailing_table('subscriber') . ' WHERE `subid` = ' . $this->database->Quote($subid) . ' AND `key` = ' . $this->database->Quote($key) . ' LIMIT 1');
     $userIdentified = $this->database->loadObject();
     if (empty($userIdentified)) {
         if (!$onlyvalue) {
             acymailing_enqueueMessage(JText::_('INVALID_KEY'), 'error');
         }
         return false;
     }
     return $userIdentified;
 }
Example #27
0
 function test()
 {
     if (!$this->isAllowed('configuration', 'manage')) {
         return;
     }
     $this->store();
     acymailing_displayErrors();
     $config = acymailing_config();
     $user = JFactory::getUser();
     $mailClass = acymailing_get('helper.mailer');
     $addedName = $config->get('add_names', true) ? $mailClass->cleanText($user->name) : '';
     $mailClass->AddAddress($user->email, $addedName);
     $mailClass->Subject = 'Test e-mail from ' . ACYMAILING_LIVE;
     $mailClass->Body = JText::_('TEST_EMAIL');
     $mailClass->SMTPDebug = 1;
     if (defined('JDEBUG') and JDEBUG) {
         $mailClass->SMTPDebug = 2;
     }
     $result = $mailClass->send();
     if (!$result) {
         $bounce = $config->get('bounce_email');
         if ($config->get('mailer_method') == 'smtp' && $config->get('smtp_secured') == 'ssl' && !function_exists('openssl_sign')) {
             acymailing_enqueueMessage('The PHP Extension openssl is not enabled on your server, this extension is required to use an SSL connection, please enable it', 'notice');
         } elseif (!empty($bounce) and !in_array($config->get('mailer_method'), array('smtp', 'elasticemail'))) {
             acymailing_enqueueMessage(JText::sprintf('ADVICE_BOUNCE', '<b><i>' . $bounce . '</i></b>'), 'notice');
         } elseif ($config->get('mailer_method') == 'smtp' and !$config->get('smtp_auth') and strlen($config->get('smtp_password')) > 1) {
             acymailing_enqueueMessage(JText::_('ADVICE_SMTP_AUTH'), 'notice');
         } elseif ((strpos(ACYMAILING_LIVE, 'localhost') or strpos(ACYMAILING_LIVE, '127.0.0.1')) and in_array($config->get('mailer_method'), array('sendmail', 'qmail', 'mail'))) {
             acymailing_enqueueMessage(JText::_('ADVICE_LOCALHOST'), 'notice');
         } elseif ($config->get('mailer_method') == 'smtp' and $config->get('smtp_port') and !in_array($config->get('smtp_port'), array(25, 2525, 465, 587))) {
             acymailing_enqueueMessage(JText::sprintf('ADVICE_PORT', $config->get('smtp_port')), 'notice');
         }
     }
     return $this->display();
 }
Example #28
0
 private function _publishfollowup(&$mail)
 {
     $listmailClass = acymailing_get('class.listmail');
     $mycampaign = $listmailClass->getCampaign($mail->mailid);
     if (empty($mycampaign->listid)) {
         return;
     }
     $db = JFactory::getDBO();
     $toggleHelper = acymailing_get('helper.toggle');
     $startdate = time() - $mail->senddate;
     $db->setQuery('SELECT COUNT(subid) as total FROM `#__acymailing_listsub` as b WHERE b.`status` = 1 AND b.`listid` = ' . intval($mycampaign->listid) . ' AND b.`subdate` > ' . intval($startdate));
     $total = $db->loadResult();
     $db->setQuery('SELECT COUNT(subid) as total FROM `#__acymailing_listsub` as b WHERE b.`status` = 1 AND b.`listid` = ' . intval($mycampaign->listid));
     $totalall = $db->loadResult();
     if (empty($total) && empty($totalall)) {
         return;
     }
     $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED');
     $text .= '<ul>';
     if (!empty($total)) {
         $text .= '<li>' . $toggleHelper->toggleText('add', $mail->mailid, 'followup', JText::sprintf('FOLLOWUP_ADDQUEUE_USERS', acymailing_getDate($startdate)) . ' ( ' . JText::sprintf('SELECTED_USERS', $total) . ' )') . '</li>';
     }
     if (!empty($totalall)) {
         $text .= '<li>' . $toggleHelper->toggleText('addall', $mail->mailid, 'followup', JText::_('FOLLOWUP_ADDQUEUE_ALLUSERS') . ' ( ' . JText::sprintf('SELECTED_USERS', $totalall) . ' )') . '</li>';
     }
     acymailing_enqueueMessage($text, 'notice');
 }
Example #29
0
 function sobipro()
 {
     $config = acymailing_config();
     $db = JFactory::getDBO();
     $sobiproImport = JRequest::getVar('config', array(), 'POST', 'array');
     $newConfig = new stdClass();
     $affectedRows = 0;
     $newConfig->sobipro_import = serialize($sobiproImport);
     $config->save($newConfig);
     foreach ($sobiproImport as $oneImport => $oneValue) {
         $query = 'SELECT fid, nid FROM #__sobipro_field WHERE fid="' . $oneValue['sobiEmail'] . '" OR fid="' . $oneValue['sobiName'] . '"';
         $db->setQuery($query);
         $nidResult = $db->loadObjectList("fid");
         if (empty($nidResult[$oneValue['sobiEmail']]) or empty($nidResult[$oneValue['sobiName']])) {
             continue;
         }
         $time = time();
         $query = 'INSERT IGNORE INTO ' . acymailing_table('subscriber') . ' (`email`,`name`,`confirmed`,`created`,`enabled`,`accept`,`html`) SELECT b.baseData AS email, a.baseData AS name, 1 as confirmed, ' . $time . ' as created, 1 as enabled, 1 as accept, 1 as html FROM #__sobipro_field_data AS a LEFT JOIN #__sobipro_field_data AS b ON a.sid=b.sid WHERE a.`fid` = ' . $nidResult[$oneValue["sobiName"]]->fid . ' AND b.`fid` = ' . $nidResult[$oneValue["sobiEmail"]]->fid . ' AND b.baseData LIKE "%@%" AND b.baseData IS NOT NULL AND a.baseData IS NOT NULL ORDER by a.sid ';
         $db->setQuery($query);
         $db->query();
         $affectedRows += $db->getAffectedRows();
     }
     acymailing_enqueueMessage(JText::sprintf('IMPORT_NEW', $affectedRows));
     $query = 'SELECT b.subid FROM `#__sobipro_field_data` as a JOIN ' . acymailing_table('subscriber') . ' as b on a.baseData = b.email';
     $this->db->setQuery($query);
     $this->allSubid = acymailing_loadResultArray($this->db);
     $this->_subscribeUsers();
     $this->_displaySubscribedResult();
     return true;
 }