예제 #1
0
 function saveForm()
 {
     $rule = new stdClass();
     $rule->ruleid = acymailing_getCID('ruleid');
     if (empty($rule->ruleid)) {
         $this->database->setQuery('SELECT max(ordering) FROM `#__acymailing_rules`');
         $rule->ordering = intval($this->database->loadResult()) + 1;
     }
     $rule->executed_on = '';
     $rule->action_message = '';
     $rule->action_user = '';
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['rule'] as $column => $value) {
         acymailing_secureField($column);
         if (is_array($value)) {
             $rule->{$column} = serialize($value);
         } else {
             $rule->{$column} = strip_tags($value);
         }
     }
     $ruleid = $this->save($rule);
     if (!$ruleid) {
         return false;
     }
     JRequest::setVar('ruleid', $ruleid);
     return true;
 }
예제 #2
0
 function saveForm()
 {
     $app = JFactory::getApplication();
     $template = new stdClass();
     $template->tempid = acymailing_getCID('tempid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['template'] as $column => $value) {
         acymailing_secureField($column);
         $template->{$column} = strip_tags($value);
     }
     $styles = JRequest::getVar('styles', array(), '', 'array');
     foreach ($styles as $class => $oneStyle) {
         $styles[$class] = str_replace('"', "'", $oneStyle);
         if (empty($oneStyle)) {
             unset($styles[$class]);
         }
     }
     $newStyles = JRequest::getVar('otherstyles', array(), '', 'array');
     if (!empty($newStyles)) {
         foreach ($newStyles['classname'] as $id => $className) {
             if (!empty($className) and $className != JText::_('CLASS_NAME') and !empty($newStyles['style'][$id]) and $newStyles['style'][$id] != JText::_('CSS_STYLE')) {
                 $className = str_replace(array(',', ' ', ':', '.', '#'), '', $className);
                 $styles[$className] = str_replace('"', "'", $newStyles['style'][$id]);
             }
         }
     }
     $template->styles = serialize($styles);
     $template->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     if (!empty($styles['color_bg'])) {
         $pat1 = '#^([^<]*<[^>]*background-color:)([^;">]{1,30})#i';
         $found = false;
         if (preg_match($pat1, $template->body)) {
             $template->body = preg_replace($pat1, '$1' . $styles['color_bg'], $template->body);
             $found = true;
         }
         $pat2 = '#^([^<]*<[^>]*bgcolor=")([^;">]{1,10})#i';
         if (preg_match($pat2, $template->body)) {
             $template->body = preg_replace($pat2, '$1' . $styles['color_bg'], $template->body);
             $found = true;
         }
         if (!$found) {
             $template->body = '<div style="background-color:' . $styles['color_bg'] . ';" width="100%">' . $template->body . '</div>';
         }
     }
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $acypluginsHelper->cleanHtml($template->body);
     $template->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWRAW);
     $tempid = $this->save($template);
     if (!$tempid) {
         return false;
     }
     if (empty($template->tempid)) {
         $orderClass = acymailing_get('helper.order');
         $orderClass->pkey = 'tempid';
         $orderClass->table = 'template';
         $orderClass->reOrder();
     }
     JRequest::setVar('tempid', $tempid);
     return true;
 }
예제 #3
0
 function saveForm()
 {
     $app = JFactory::getApplication();
     $action = new stdClass();
     $action->action_id = acymailing_getCID('action_id');
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['action'] as $column => $value) {
         if ($app->isAdmin() || $this->allowedField('action', $column)) {
             acymailing_secureField($column);
             $action->{$column} = strip_tags($value);
         }
     }
     if (empty($action->action_id)) {
         $action->nextdate = time() + intval($action->frequency);
     }
     if ($action->password == '********') {
         unset($action->password);
     }
     $action->conditions = json_encode($formData['conditions']);
     $action->actions = json_encode($formData['actions']);
     if (isset($action->published) && $action->published != 1) {
         $action->published = 0;
     }
     $action_id = $this->save($action);
     if (!$action_id) {
         return false;
     }
     JRequest::setVar('action_id', $action_id);
     return true;
 }
예제 #4
0
파일: list.php 프로젝트: Roma48/abazherka
 function saveForm()
 {
     $app = JFactory::getApplication();
     $list = new stdClass();
     $list->listid = acymailing_getCID('listid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     if (!empty($formData['list']['category']) && $formData['list']['category'] == -1) {
         $formData['list']['category'] = JRequest::getString('newcategory', '');
     }
     foreach ($formData['list'] as $column => $value) {
         if ($app->isAdmin() || $this->allowedField('list', $column)) {
             acymailing_secureField($column);
             $list->{$column} = strip_tags($value);
         }
     }
     $list->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWHTML);
     if (isset($list->published) && $list->published != 1) {
         $list->published = 0;
     }
     $listid = $this->save($list);
     if (!$listid) {
         return false;
     }
     if (empty($list->listid)) {
         $orderClass = acymailing_get('helper.order');
         $orderClass->pkey = 'listid';
         $orderClass->table = 'list';
         $orderClass->groupMap = 'type';
         $orderClass->groupVal = empty($list->type) ? $this->type : $list->type;
         $orderClass->reOrder();
         $this->newlist = true;
     }
     if (!empty($formData['listcampaign'])) {
         $affectedLists = array();
         foreach ($formData['listcampaign'] as $affectlistid => $receiveme) {
             if (!empty($receiveme)) {
                 $affectedLists[] = $affectlistid;
             }
         }
         $listCampaignClass = acymailing_get('class.listcampaign');
         $listCampaignClass->save($listid, $affectedLists);
     }
     JRequest::setVar('listid', $listid);
     return true;
 }
예제 #5
0
 public function acymailing_generateautonews(&$email)
 {
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $return = new stdClass();
     $return->status = true;
     $return->message = '';
     $time = time();
     $match = '#{autocontent:(.*)}#Ui';
     $variables = array('subject', 'body', 'altbody');
     $found = false;
     foreach ($variables as $var) {
         if (empty($email->{$var})) {
             continue;
         }
         $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found;
         if (empty($results[$var][0])) {
             unset($results[$var]);
         }
     }
     if (!$found) {
         return $return;
     }
     $this->tags = array();
     $db = JFactory::getDBO();
     foreach ($results as $var => $allresults) {
         foreach ($allresults[0] as $i => $oneTag) {
             if (isset($this->tags[$oneTag])) {
                 continue;
             }
             $parameter = $acypluginsHelper->extractTag($allresults[1][$i]);
             $allcats = explode('-', $parameter->id);
             $selectedArea = array();
             foreach ($allcats as $oneCat) {
                 if (!ACYMAILING_J16) {
                     $sectype = substr($oneCat, 0, 3);
                     $num = substr($oneCat, 3);
                     if (empty($num)) {
                         continue;
                     }
                     if ($sectype == 'cat') {
                         $selectedArea[] = 'catid = ' . (int) $num;
                     } elseif ($sectype == 'sec') {
                         $selectedArea[] = 'sectionid = ' . (int) $num;
                     }
                 } else {
                     if (empty($oneCat)) {
                         continue;
                     }
                     $selectedArea[] = (int) $oneCat;
                 }
             }
             $query = 'SELECT a.id FROM `#__content` as a ';
             $where = array();
             if (!empty($parameter->featured)) {
                 if (ACYMAILING_J16) {
                     $where[] = 'a.featured = 1';
                 } else {
                     $query .= 'JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                     $where[] = 'b.content_id IS NOT NULL';
                 }
             }
             if (!empty($parameter->nofeatured)) {
                 if (ACYMAILING_J16) {
                     $where[] = 'a.featured = 0';
                 } else {
                     $query .= 'LEFT JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                     $where[] = 'b.content_id IS NULL';
                 }
             }
             if (ACYMAILING_J16 && !empty($parameter->subcats) && !empty($selectedArea)) {
                 $db->setQuery('SELECT lft,rgt FROM #__categories WHERE id IN (' . implode(',', $selectedArea) . ')');
                 $catinfos = $db->loadObjectList();
                 if (!empty($catinfos)) {
                     $whereCats = array();
                     foreach ($catinfos as $onecat) {
                         $whereCats[] = 'lft > ' . $onecat->lft . ' AND rgt < ' . $onecat->rgt;
                     }
                     $db->setQuery('SELECT id FROM #__categories WHERE (' . implode(') OR (', $whereCats) . ')');
                     $othercats = acymailing_loadResultArray($db);
                     $selectedArea = array_merge($selectedArea, $othercats);
                 }
             }
             if (!empty($selectedArea)) {
                 if (!ACYMAILING_J16) {
                     $where[] = implode(' OR ', $selectedArea);
                 } else {
                     $where[] = '`catid` IN (' . implode(',', $selectedArea) . ')';
                 }
             }
             if (!empty($parameter->excludedcats)) {
                 $excludedCats = explode('-', $parameter->excludedcats);
                 JArrayHelper::toInteger($excludedCats);
                 $where[] = '`catid` NOT IN ("' . implode('","', $excludedCats) . '")';
             }
             if (!empty($parameter->filter) and !empty($email->params['lastgenerateddate'])) {
                 $condition = '`publish_up` >\'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\'';
                 $condition .= ' OR `created` >\'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\'';
                 if ($parameter->filter == 'modify') {
                     $condition .= ' OR (';
                     $condition .= ' `modified` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\'';
                     if (!empty($parameter->maxpublished)) {
                         $condition .= ' AND `publish_up` > \'' . date('Y-m-d H:i:s', time() - date('Z') - (int) $parameter->maxpublished * 60 * 60 * 24) . '\'';
                     }
                     $condition .= ')';
                 }
                 $where[] = $condition;
             }
             if (!empty($parameter->maxcreated)) {
                 $date = strtotime($parameter->maxcreated);
                 if (empty($date)) {
                     acymailing_display('Wrong date format (' . $parameter->maxcreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
                 }
                 $where[] = '`created` < ' . $db->Quote(date('Y-m-d H:i:s', $date));
             }
             if (!empty($parameter->mincreated)) {
                 $date = strtotime($parameter->mincreated);
                 if (empty($date)) {
                     acymailing_display('Wrong date format (' . $parameter->mincreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
                 }
                 $where[] = '`created` > ' . $db->Quote(date('Y-m-d H:i:s', $date));
             }
             if (!empty($parameter->meta)) {
                 $allMetaTags = explode(',', $parameter->meta);
                 $metaWhere = array();
                 foreach ($allMetaTags as $oneMeta) {
                     if (empty($oneMeta)) {
                         continue;
                     }
                     $metaWhere[] = "`metakey` LIKE '%" . acymailing_getEscaped($oneMeta, true) . "%'";
                 }
                 if (!empty($metaWhere)) {
                     $where[] = implode(' OR ', $metaWhere);
                 }
             }
             $where[] = '`publish_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\'';
             $where[] = '`publish_down` > \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\' OR `publish_down` = 0';
             $where[] = 'state = 1';
             if (!ACYMAILING_J16) {
                 if (isset($parameter->access)) {
                     $where[] = 'access <= ' . intval($parameter->access);
                 } else {
                     if ($this->params->get('contentaccess', 'registered') == 'registered') {
                         $where[] = 'access <= 1';
                     } elseif ($this->params->get('contentaccess', 'registered') == 'public') {
                         $where[] = 'access = 0';
                     }
                 }
             } elseif (isset($parameter->access)) {
                 $where[] = 'access = ' . intval($parameter->access);
             }
             if (!empty($parameter->language)) {
                 $allLanguages = explode(',', $parameter->language);
                 $langWhere = 'language IN (';
                 foreach ($allLanguages as $oneLanguage) {
                     $langWhere .= $db->Quote(trim($oneLanguage)) . ',';
                 }
                 $where[] = trim($langWhere, ',') . ')';
             }
             $query .= ' WHERE (' . implode(') AND (', $where) . ')';
             if (!empty($parameter->order)) {
                 if ($parameter->order == 'rand') {
                     $query .= ' ORDER BY rand()';
                 } else {
                     $ordering = explode(',', $parameter->order);
                     $query .= ' ORDER BY `' . acymailing_secureField($ordering[0]) . '` ' . acymailing_secureField($ordering[1]) . ' , a.`id` DESC';
                 }
             }
             $start = '';
             if (!empty($parameter->start)) {
                 $start = intval($parameter->start) . ',';
             }
             if (empty($parameter->max)) {
                 $parameter->max = 100;
             }
             $query .= ' LIMIT ' . $start . (int) $parameter->max;
             $db->setQuery($query);
             $allArticles = acymailing_loadResultArray($db);
             if (!empty($parameter->min) and count($allArticles) < $parameter->min) {
                 $return->status = false;
                 $return->message = 'Not enough articles for the tag ' . $oneTag . ' : ' . count($allArticles) . ' / ' . $parameter->min . ' between ' . acymailing_getDate($email->params['lastgenerateddate']) . ' and ' . acymailing_getDate($time);
             }
             $stringTag = empty($parameter->noentrytext) ? '' : $parameter->noentrytext;
             if (!empty($allArticles)) {
                 if (file_exists(ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php')) {
                     ob_start();
                     require ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php';
                     $stringTag = ob_get_clean();
                 } else {
                     $arrayElements = array();
                     $numArticle = 1;
                     foreach ($allArticles as $oneArticleId) {
                         $args = array();
                         $args[] = 'joomlacontent:' . $oneArticleId;
                         $args[] = 'num:' . $numArticle++;
                         if (!empty($parameter->type)) {
                             $args[] = 'type:' . $parameter->type;
                         }
                         if (!empty($parameter->link)) {
                             $args[] = 'link';
                         }
                         if (!empty($parameter->author)) {
                             $args[] = 'author';
                         }
                         if (!empty($parameter->autologin)) {
                             $args[] = 'autologin';
                         }
                         if (!empty($parameter->cattitle)) {
                             $args[] = 'cattitle';
                         }
                         if (!empty($parameter->lang)) {
                             $args[] = 'lang:' . $parameter->lang;
                         }
                         if (!empty($parameter->theme)) {
                             $args[] = 'theme';
                         }
                         if (!empty($parameter->clean)) {
                             $args[] = 'clean';
                         }
                         if (!empty($parameter->notitle)) {
                             $args[] = 'notitle';
                         }
                         if (!empty($parameter->created)) {
                             $args[] = 'created';
                         }
                         if (!empty($parameter->noattach)) {
                             $args[] = 'noattach';
                         }
                         if (!empty($parameter->itemid)) {
                             $args[] = 'itemid:' . $parameter->itemid;
                         }
                         if (!empty($parameter->noreadmore)) {
                             $args[] = 'noreadmore';
                         }
                         if (isset($parameter->pict)) {
                             $args[] = 'pict:' . $parameter->pict;
                         }
                         if (!empty($parameter->wrap)) {
                             $args[] = 'wrap:' . $parameter->wrap;
                         }
                         if (!empty($parameter->maxwidth)) {
                             $args[] = 'maxwidth:' . $parameter->maxwidth;
                         }
                         if (!empty($parameter->maxheight)) {
                             $args[] = 'maxheight:' . $parameter->maxheight;
                         }
                         if (!empty($parameter->readmore)) {
                             $args[] = 'readmore:' . $parameter->readmore;
                         }
                         if (!empty($parameter->dateformat)) {
                             $args[] = 'dateformat:' . $parameter->dateformat;
                         }
                         if (!empty($parameter->textafter)) {
                             $args[] = 'textafter:' . $parameter->textafter;
                         }
                         if (!empty($parameter->maxchar)) {
                             $args[] = 'maxchar:' . $parameter->maxchar;
                         }
                         if (!empty($parameter->share)) {
                             $args[] = 'share:' . $parameter->share;
                         }
                         if (!empty($parameter->sharetxt)) {
                             $args[] = 'sharetxt:' . $parameter->sharetxt;
                         }
                         $arrayElements[] = '{' . implode('|', $args) . '}';
                     }
                     $stringTag = $acypluginsHelper->getFormattedResult($arrayElements, $parameter);
                 }
             }
             $this->tags[$oneTag] = $stringTag;
         }
     }
     return $return;
 }
예제 #6
0
 function onAcyTriggerFct_displayUserValues()
 {
     $num = JRequest::getInt('num');
     $map = JRequest::getCmd('map');
     $cond = JRequest::getVar('cond', '', '', 'string', JREQUEST_ALLOWRAW);
     $value = JRequest::getVar('value', '', '', 'string', JREQUEST_ALLOWRAW);
     $emptyInputReturn = '<input onchange="countresults(' . $num . ')" class="inputbox" type="text" name="filter[' . $num . '][joomlafield][value]" id="filter' . $num . 'joomlafieldvalue" style="width:200px" value="' . $value . '">';
     $dateInput = '<input onclick="displayDatePicker(this,event)" onchange="countresults(' . $num . ')" class="inputbox" type="text" name="filter[' . $num . '][joomlafield][value]" id="filter' . $num . 'joomlafieldvalue" style="width:200px" value="' . $value . '">';
     if (in_array($map, array('registerDate', 'lastvisitDate', 'lastResetTime'))) {
         return $dateInput;
     }
     if (empty($map) || in_array($map, array('password', 'params', 'optKey', 'otep')) || !in_array($cond, array('=', '!='))) {
         return $emptyInputReturn;
     }
     $db = JFactory::getDBO();
     $db->setQuery('SELECT DISTINCT `' . acymailing_secureField($map) . '` AS value FROM #__users LIMIT 100');
     $prop = $db->loadObjectList();
     if (empty($prop) || count($prop) >= 100 || count($prop) == 1 && (empty($prop[0]->value) || $prop[0]->value == '-')) {
         return $emptyInputReturn;
     }
     return JHTML::_('select.genericlist', $prop, "filter[{$num}][joomlafield][value]", 'onchange="countresults(' . $num . ')" class="inputbox" size="1" style="width:200px"', 'value', 'value', $value, 'filter' . $num . 'joomlafieldvalue');
 }
예제 #7
0
파일: fields.php 프로젝트: utopszkij/lmp
 private function _getDataFromDB($field, $valueField, $titleField)
 {
     $tableName = acymailing_secureField($field->options['tableName']);
     $dbName = acymailing_secureField($field->options['dbName']);
     $whereCond = !empty($field->options['whereCond']) ? $field->options['whereCond'] : '';
     $whereOp = !empty($field->options['whereOperator']) ? $field->options['whereOperator'] : '';
     $whereValue = !empty($field->options['whereValue']) ? $field->options['whereValue'] : '';
     $orderByField = !empty($field->options['orderField']) ? acymailing_secureField($field->options['orderField']) : '';
     $orderByValue = !empty($field->options['orderValue']) ? acymailing_secureField($field->options['orderValue']) : '';
     if ($dbName == 'current') {
         $this->database->setQuery('SELECT DATABASE()');
         $dbName = $this->database->loadResult();
     }
     $query = 'SELECT `' . $valueField . '`, `' . $titleField . '` FROM `' . $dbName . '`.`' . $tableName . '`';
     $query .= ' WHERE `' . $valueField . '`<>\'\' AND `' . $titleField . '`<>\'\'';
     if (!empty($whereValue) && !empty($whereCond)) {
         $filterClass = acymailing_get('class.filter');
         $queryClass = new acyQuery();
         $query .= ' AND ' . $queryClass->convertQuery($tableName, $whereCond, $whereOp, $whereValue);
     }
     $query .= ' GROUP BY `' . $valueField . '`, `' . $titleField . '`';
     $query .= !empty($orderByField) ? ' ORDER BY `' . $orderByField . '` ' . $orderByValue : '';
     try {
         $this->database->setQuery($query);
         $res = $this->database->loadObjectList();
     } catch (Exception $e) {
         acymailing_display($e->getMessage(), 'error');
         $res = array();
     }
     return $res;
 }
예제 #8
0
파일: data.php 프로젝트: alesconti/FF_2015
 function doexport()
 {
     if (!$this->isAllowed('subscriber', 'export')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     acymailing_increasePerf();
     $filtersExport = JRequest::getVar('exportfilter');
     $listsToExport = JRequest::getVar('exportlists');
     $fieldsToExport = JRequest::getVar('exportdata');
     $inseparator = JRequest::getString('exportseparator');
     $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator);
     $exportFormat = JRequest::getString('exportformat');
     if (!in_array($inseparator, array(',', ';'))) {
         $inseparator = ';';
     }
     $exportLists = array();
     if (!empty($filtersExport['subscribed'])) {
         foreach ($listsToExport as $listid => $checked) {
             if (!empty($checked)) {
                 $exportLists[] = (int) $listid;
             }
         }
     }
     $exportFields = array();
     foreach ($fieldsToExport as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFields[] = acymailing_secureField($fieldName);
         }
     }
     $config = acymailing_config();
     $newConfig = new stdClass();
     $newConfig->export_fields = implode(',', $exportFields);
     $newConfig->export_lists = implode(',', $exportLists);
     $newConfig->export_separator = JRequest::getString('exportseparator');
     $newConfig->export_format = $exportFormat;
     $config->save($newConfig);
     $where = array();
     if (empty($exportLists)) {
         $querySelect = 'SELECT s.`' . implode('`,s.`', $exportFields) . '` FROM ' . acymailing_table('subscriber') . ' as s';
     } else {
         $querySelect = 'SELECT DISTINCT s.`' . implode('`,s.`', $exportFields) . '` FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid';
         $where[] = 'a.listid IN (' . implode(',', $exportLists) . ')';
         $where[] = 'a.status = 1';
     }
     if (!empty($filtersExport['confirmed'])) {
         $where[] = 's.confirmed = 1';
     }
     if (!empty($filtersExport['registered'])) {
         $where[] = 's.userid > 0';
     }
     if (!empty($filtersExport['enabled'])) {
         $where[] = 's.enabled = 1';
     }
     if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) {
         $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')';
     }
     if (JRequest::getInt('sessionquery')) {
         $currentSession = JFactory::getSession();
         $exportQuery = $currentSession->get('acyexportquery');
         if (!empty($exportQuery)) {
             $where[] = 's.subid IN (' . $exportQuery . ')';
         }
     }
     $query = $querySelect;
     if (!empty($where)) {
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
     }
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $allData = $db->loadAssocList();
     $encodingClass = acymailing_get('helper.encoding');
     $exportHelper = acymailing_get('helper.export');
     $exportHelper->addHeaders('acymailingexport');
     $eol = "\r\n";
     $before = '"';
     $separator = '"' . $inseparator . '"';
     $after = '"';
     echo $before . implode($separator, $exportFields) . $after . $eol;
     for ($i = 0, $a = count($allData); $i < $a; $i++) {
         if (!empty($allData[$i]['created'])) {
             $allData[$i]['created'] = acymailing_getDate($allData[$i]['created'], '%Y-%m-%d %H:%M:%S');
         }
         echo $before . $encodingClass->change(implode($separator, $allData[$i]), 'UTF-8', $exportFormat) . $after . $eol;
     }
     exit;
 }
예제 #9
0
 function doexport()
 {
     if (!$this->isAllowed('subscriber', 'export')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     acymailing_increasePerf();
     $filtersExport = JRequest::getVar('exportfilter');
     $listsToExport = JRequest::getVar('exportlists');
     $fieldsToExport = JRequest::getVar('exportdata');
     $inseparator = JRequest::getString('exportseparator');
     $exportFormat = JRequest::getString('exportformat');
     if (!in_array($inseparator, array(',', ';'))) {
         $inseparator = ';';
     }
     $exportLists = array();
     if (!empty($filtersExport['subscribed'])) {
         foreach ($listsToExport as $listid => $checked) {
             if (!empty($checked)) {
                 $exportLists[] = (int) $listid;
             }
         }
     }
     $exportFields = array();
     foreach ($fieldsToExport as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFields[] = acymailing_secureField($fieldName);
         }
     }
     $config = acymailing_config();
     $newConfig = new stdClass();
     $newConfig->export_fields = implode(',', $exportFields);
     $newConfig->export_separator = $inseparator;
     $newConfig->export_format = $exportFormat;
     $config->save($newConfig);
     $where = array();
     if (empty($exportLists)) {
         $querySelect = 'SELECT s.`' . implode('`,s.`', $exportFields) . '` FROM ' . acymailing_table('subscriber') . ' as s';
     } else {
         $querySelect = 'SELECT DISTINCT s.`' . implode('`,s.`', $exportFields) . '` FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid';
         $where[] = 'a.listid IN (' . implode(',', $exportLists) . ')';
         $where[] = 'a.status = 1';
     }
     if (!empty($filtersExport['confirmed'])) {
         $where[] = 's.confirmed = 1';
     }
     if (!empty($filtersExport['registered'])) {
         $where[] = 's.userid > 0';
     }
     if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) {
         $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')';
     }
     if (JRequest::getInt('sessionquery')) {
         $currentSession =& JFactory::getSession();
         $exportQuery = $currentSession->get('acyexportquery');
         if (!empty($exportQuery)) {
             $where[] = 's.subid IN (' . $exportQuery . ')';
         }
     }
     $query = $querySelect;
     if (!empty($where)) {
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
     }
     $db =& JFactory::getDBO();
     $db->setQuery($query);
     $allData = $db->loadAssocList();
     $encodingClass = acymailing_get('helper.encoding');
     @ob_clean();
     header("Pragma: public");
     header("Expires: 0");
     // set expiration time
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Content-Type: application/force-download");
     header("Content-Type: application/octet-stream");
     header("Content-Type: application/download");
     header("Content-Disposition: attachment; filename=acymailingexport.csv;");
     header("Content-Transfer-Encoding: binary");
     $eol = "\r\n";
     $before = '"';
     $separator = '"' . $inseparator . '"';
     $after = '"';
     echo $before . implode($separator, $exportFields) . $after . $eol;
     for ($i = 0, $a = count($allData); $i < $a; $i++) {
         if (!empty($allData[$i]['created'])) {
             $allData[$i]['created'] = acymailing_getDate($allData[$i]['created'], '%Y-%m-%d %H:%M:%S');
         }
         echo $before . $encodingClass->change(implode($separator, $allData[$i]), 'UTF-8', $exportFormat) . $after . $eol;
     }
     exit;
 }
예제 #10
0
 function checkFields(&$data, &$subscriber)
 {
     foreach ($data as $column => $value) {
         $column = trim(strtolower($column));
         if ($this->allowModif || !in_array($column, $this->restrictedFields)) {
             acymailing_secureField($column);
             if (is_array($value)) {
                 if (isset($value['day']) || isset($value['month']) || isset($value['year'])) {
                     $value = (empty($value['year']) ? '0000' : intval($value['year'])) . '-' . (empty($value['month']) ? '00' : $value['month']) . '-' . (empty($value['day']) ? '00' : $value['day']);
                 } else {
                     $value = implode(',', $value);
                 }
             }
             $subscriber->{$column} = trim(strip_tags($value));
             if (!is_numeric($subscriber->{$column})) {
                 if (function_exists('mb_detect_encoding') && mb_detect_encoding($subscriber->{$column}, 'UTF-8', true) != 'UTF-8') {
                     $subscriber->{$column} = utf8_encode($subscriber->{$column});
                 } elseif (!function_exists('mb_detect_encoding') && !preg_match('%^(?:[\\x09\\x0A\\x0D\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$%xs', $subscriber->{$column})) {
                     $subscriber->{$column} = utf8_encode($subscriber->{$column});
                 }
             }
         }
     }
     if (!acymailing_level(3) || empty($_FILES)) {
         return;
     }
     jimport('joomla.filesystem.file');
     $config = acymailing_config();
     $uploadFolder = trim(JPath::clean(html_entity_decode(acymailing_getFilesFolder())), DS . ' ') . DS;
     $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder . 'userfiles' . DS);
     acymailing_createDir(JPath::clean(ACYMAILING_ROOT . $uploadFolder), true);
     acymailing_createDir($uploadPath, true);
     foreach ($_FILES as $typename => $type) {
         $type2 = isset($type['name']['subscriber']) ? $type['name']['subscriber'] : $type['name'];
         if (empty($type2)) {
             continue;
         }
         foreach ($type2 as $fieldname => $filename) {
             if (empty($filename)) {
                 continue;
             }
             acymailing_secureField($fieldname);
             $attachment = new stdClass();
             $filename = JFile::makeSafe(strtolower(strip_tags($filename)));
             $attachment->filename = time() . rand(1, 999) . '_' . $filename;
             while (file_exists($uploadPath . $attachment->filename)) {
                 $attachment->filename = time() . rand(1, 999) . '_' . $filename;
             }
             if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) {
                 echo "<script>alert('" . JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')) . "');window.history.go(-1);</script>";
                 exit;
             }
             $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
             $tmpFile = isset($type['name']['subscriber']) ? $_FILES[$typename]['tmp_name']['subscriber'][$fieldname] : $_FILES[$typename]['tmp_name'][$fieldname];
             if (!JFile::upload($tmpFile, $uploadPath . $attachment->filename)) {
                 echo "<script>alert('" . JText::sprintf('FAIL_UPLOAD', '<b><i>' . $tmpFile . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>') . "');window.history.go(-1);</script>";
                 exit;
             }
             $subscriber->{$fieldname} = $attachment->filename;
         }
     }
 }
예제 #11
0
파일: helper.php 프로젝트: ForAEdesWeb/AEW1
 static function secureField($fieldName)
 {
     return acymailing_secureField($fieldName);
 }
예제 #12
0
 function acymailing_generateautonews(&$email)
 {
     $tags = $this->acypluginsHelper->extractTags($email, 'hikashop_auto_product');
     $return = new stdClass();
     $return->status = true;
     $return->message = '';
     $this->tags = array();
     if (empty($tags)) {
         return $return;
     }
     foreach ($tags as $oneTag => $parameter) {
         if (isset($this->tags[$oneTag])) {
             continue;
         }
         $allcats = explode('-', $parameter->id);
         $selectedArea = array();
         foreach ($allcats as $oneCat) {
             if (empty($oneCat)) {
                 continue;
             }
             $selectedArea[] = intval($oneCat);
         }
         $query = 'SELECT DISTINCT b.`product_id` FROM ' . acymailing_table('hikashop_product_category', false) . ' as a LEFT JOIN ' . acymailing_table('hikashop_product', false) . ' as b ON a.product_id = b.product_id';
         $where = array();
         if ($this->params->get('stock', 0) == '1') {
             $where[] = '(b.product_quantity = -1 || b.product_quantity > 0)';
         }
         if (!empty($selectedArea)) {
             $where[] = 'a.category_id IN (' . implode(',', $selectedArea) . ')';
         }
         $where[] = "b.`product_published` = 1";
         if (!empty($parameter->filter) and !empty($email->params['lastgenerateddate'])) {
             $condition = 'b.`product_created` >\'' . $email->params['lastgenerateddate'] . '\'';
             if ($parameter->filter == 'modify') {
                 $condition .= ' OR b.`product_modified` >\'' . $email->params['lastgenerateddate'] . '\'';
             }
             $where[] = $condition;
         }
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
         if (!empty($parameter->order)) {
             $ordering = explode(',', $parameter->order);
             if ($ordering[0] == 'rand') {
                 $query .= ' ORDER BY rand()';
             } else {
                 $query .= ' ORDER BY b.`' . acymailing_secureField(trim($ordering[0])) . '` ' . acymailing_secureField(trim($ordering[1]));
             }
         }
         if (!empty($parameter->max)) {
             $query .= ' LIMIT ' . (int) $parameter->max;
         }
         $this->db->setQuery($query);
         $allArticles = acymailing_loadResultArray($this->db);
         if (!empty($parameter->min) && count($allArticles) < $parameter->min) {
             $return->status = false;
             $return->message = 'Not enough products for the tag ' . $oneTag . ' : ' . count($allArticles) . ' / ' . $parameter->min;
         }
         $stringTag = '';
         if (!empty($allArticles)) {
             if (file_exists(ACYMAILING_TEMPLATE . 'plugins' . DS . 'hikashop_auto_product.php')) {
                 ob_start();
                 require ACYMAILING_TEMPLATE . 'plugins' . DS . 'hikashop_auto_product.php';
                 $stringTag = ob_get_clean();
             } else {
                 $arrayElements = array();
                 foreach ($allArticles as $oneArticleId) {
                     $args = array();
                     $args[] = 'hikashop_product:' . $oneArticleId;
                     if (!empty($parameter->type)) {
                         $args[] = 'type:' . $parameter->type;
                     }
                     if (!empty($parameter->lang)) {
                         $args[] = 'lang:' . $parameter->lang;
                     }
                     $arrayElements[] = '{' . implode('|', $args) . '}';
                 }
                 $stringTag = $this->acypluginsHelper->getFormattedResult($arrayElements, $parameter);
             }
         }
         $this->tags[$oneTag] = $stringTag;
     }
     return $return;
 }
예제 #13
0
 function delete($elements)
 {
     if (!is_array($elements)) {
         $elements = array($elements);
     }
     if (empty($elements)) {
         return 0;
     }
     $column = is_numeric(reset($elements)) ? $this->pkey : $this->namekey;
     foreach ($elements as $key => $val) {
         $elements[$key] = $this->database->Quote($val);
     }
     if (empty($column) || empty($this->pkey) || empty($this->tables) || empty($elements)) {
         return false;
     }
     $whereIn = ' WHERE ' . acymailing_secureField($column) . ' IN (' . implode(',', $elements) . ')';
     $result = true;
     JPluginHelper::importPlugin('acymailing');
     $dispatcher = JDispatcher::getInstance();
     foreach ($this->tables as $oneTable) {
         $dispatcher->trigger('onAcyBefore' . ucfirst($oneTable) . 'Delete', array(&$elements));
         $query = 'DELETE FROM ' . acymailing_table($oneTable) . $whereIn;
         $this->database->setQuery($query);
         $result = $this->database->query() && $result;
     }
     if (!$result) {
         return false;
     }
     return $this->database->getAffectedRows();
 }
예제 #14
0
 function saveForm()
 {
     $app = JFactory::getApplication();
     $config = acymailing_config();
     $template = new stdClass();
     $template->tempid = acymailing_getCID('tempid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['template'] as $column => $value) {
         acymailing_secureField($column);
         $template->{$column} = strip_tags($value);
     }
     $styles = JRequest::getVar('styles', array(), '', 'array');
     foreach ($styles as $class => $oneStyle) {
         $styles[$class] = str_replace('"', "'", $oneStyle);
         if (empty($oneStyle)) {
             unset($styles[$class]);
         }
     }
     $newStyles = JRequest::getVar('otherstyles', array(), '', 'array');
     if (!empty($newStyles)) {
         foreach ($newStyles['classname'] as $id => $className) {
             if (!empty($className) and $className != JText::_('CLASS_NAME') and !empty($newStyles['style'][$id]) and $newStyles['style'][$id] != JText::_('CSS_STYLE')) {
                 $className = str_replace(array(',', ' ', ':', '.', '#'), '', $className);
                 $styles[$className] = str_replace('"', "'", $newStyles['style'][$id]);
             }
         }
     }
     $template->styles = serialize($styles);
     $files = JRequest::getVar('pictures', array(), 'files', 'array');
     if (!empty($files)) {
         jimport('joomla.filesystem.file');
         $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
         $uploadFolder = trim($uploadFolder, DS . ' ') . DS;
         $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
         acymailing_createDir($uploadPath, true);
         if (!is_writable($uploadPath)) {
             @chmod($uploadPath, '0755');
             if (!is_writable($uploadPath)) {
                 $app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
             }
         }
         $allowedExtensions = array('jpg', 'png', 'gif', 'jpeg');
         foreach ($files['name'] as $id => $filename) {
             if (empty($filename)) {
                 continue;
             }
             $extension = strtolower(substr($filename, strrpos($filename, '.') + 1));
             if (!in_array($extension, $allowedExtensions)) {
                 $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $extension, implode(', ', $allowedExtensions)), 'notice');
                 continue;
             }
             $pictname = strtolower(substr(JFile::makeSafe($filename), 0, strrpos($filename, '.') + 1));
             $pictname = preg_replace('#[^0-9a-z]#i', '_', $pictname);
             $pictfullname = $pictname . '.' . $extension;
             if (file_exists($uploadPath . $pictfullname)) {
                 $pictfullname = $pictname . time() . '.' . $extension;
             }
             if (!JFile::upload($files['tmp_name'][$id], $uploadPath . $pictfullname)) {
                 if (!move_uploaded_file($files['tmp_name'][$id], $uploadPath . $pictfullname)) {
                     $app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', '<b><i>' . $files['tmp_name'][$id] . '</i></b>', '<b><i>' . $uploadPath . $pictfullname . '</i></b>'), 'error');
                     continue;
                 }
             }
             $template->{$id} = str_replace(DS, '/', $uploadFolder) . $pictfullname;
         }
     }
     $template->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     if (!empty($styles['color_bg'])) {
         $pat1 = '#^([^<]*<[^>]*background-color:)([^;">]{1,30})#i';
         $found = false;
         if (preg_match($pat1, $template->body)) {
             $template->body = preg_replace($pat1, '$1' . $styles['color_bg'], $template->body);
             $found = true;
         }
         $pat2 = '#^([^<]*<[^>]*bgcolor=")([^;">]{1,10})#i';
         if (preg_match($pat2, $template->body)) {
             $template->body = preg_replace($pat2, '$1' . $styles['color_bg'], $template->body);
             $found = true;
         }
         if (!$found) {
             $template->body = '<div style="background-color:' . $styles['color_bg'] . ';" width="100%">' . $template->body . '</div>';
         }
     }
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $acypluginsHelper->cleanHtml($template->body);
     $template->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWRAW);
     $tempid = $this->save($template);
     if (!$tempid) {
         return false;
     }
     if (empty($template->tempid)) {
         $orderClass = acymailing_get('helper.order');
         $orderClass->pkey = 'tempid';
         $orderClass->table = 'template';
         $orderClass->reOrder();
     }
     $this->createTemplateFile($tempid);
     JRequest::setVar('tempid', $tempid);
     return true;
 }
예제 #15
0
파일: url.php 프로젝트: utopszkij/lmp
	function saveForm(){

		$object = new stdClass();
		$object->urlid = acymailing_getCID('urlid');

		$formData = JRequest::getVar( 'data', array(), '', 'array' );

		foreach($formData['url'] as $column => $value){
			acymailing_secureField($column);
			$object->$column = strip_tags($value);
		}

		$urlid = $this->save($object);
		if(!$urlid) return false;

		$js = "window.addEvent('domready', function(){
				var allLinks = window.parent.document.getElements('a[id^=urlink_".$urlid."_]');
				i=0;
				while(allLinks[i]){
					allLinks[i].innerHTML = '".str_replace(array("'",'"'),array("&#039;",'&quot;'),$object->name)."';
					i++;
				}
				acymailing_js.closeBox(true);
				})";

		$doc = JFactory::getDocument();
		$doc->addScriptDeclaration( $js );

		return true;

	}
예제 #16
0
 function convertQuery($as, $column, $operator, $value)
 {
     if ($operator == 'CONTAINS') {
         $operator = 'LIKE';
         $value = '%' . $value . '%';
     } elseif ($operator == 'BEGINS') {
         $operator = 'LIKE';
         $value = $value . '%';
     } elseif ($operator == 'END') {
         $operator = 'LIKE';
         $value = '%' . $value;
     } elseif (!in_array($operator, array('REGEXP', 'NOT REGEXP', 'IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='))) {
         die('Operator not safe : ' . $operator);
     }
     if (strpos($value, '{time}') !== false) {
         $value = acymailing_replaceDate($value);
         $value = strftime('%Y-%m-%d %H:%M:%S', $value);
     }
     if (!is_numeric($value) or in_array($operator, array('REGEXP', 'NOT REGEXP', 'NOT LIKE', 'LIKE'))) {
         $value = $this->db->Quote($value);
     }
     if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) {
         $value = '';
     }
     return $as . '.`' . acymailing_secureField($column) . '` ' . $operator . ' ' . $value;
 }
예제 #17
0
 function onAcyTriggerFct_displaySubscriberValues()
 {
     $num = JRequest::getInt('num');
     $map = JRequest::getCmd('map');
     $cond = JRequest::getVar('cond', '', '', 'string', JREQUEST_ALLOWHTML);
     $value = JRequest::getVar('value', '', '', 'string', JREQUEST_ALLOWHTML);
     $emptyInputReturn = '<input onchange="countresults(' . $num . ')" class="inputbox" type="text" name="filter[' . $num . '][acymailingfield][value]" id="filter' . $num . 'acymailingfieldvalue" style="width:200px" value="' . $value . '">';
     $dateInput = '<input onClick="displayDatePicker(this,event)" onchange="countresults(' . $num . ')" class="inputbox" type="text" name="filter[' . $num . '][acymailingfield][value]" id="filter' . $num . 'acymailingfieldvalue" style="width:200px" value="' . $value . '">';
     if (in_array($map, array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date'))) {
         return $dateInput;
     }
     if (empty($map) || $map == 'key' || !in_array($cond, array('=', '!='))) {
         return $emptyInputReturn;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT DISTINCT `' . acymailing_secureField($map) . '` AS value FROM #__acymailing_subscriber LIMIT 100';
     $db->setQuery($query);
     $prop = $db->loadObjectList();
     if (empty($prop) || count($prop) >= 100 || count($prop) == 1 && (empty($prop[0]->value) || $prop[0]->value == '-')) {
         return $emptyInputReturn;
     }
     return JHTML::_('select.genericlist', $prop, "filter[{$num}][acymailingfield][value]", 'onchange="countresults(' . $num . ')" class="inputbox" size="1" style="width:200px"', 'value', 'value', $value, 'filter' . $num . 'acymailingfieldvalue');
 }
예제 #18
0
파일: data.php 프로젝트: madcsaba/li-de
 function doexport()
 {
     if (!$this->isAllowed('subscriber', 'export')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     acymailing_increasePerf();
     $filtersExport = JRequest::getVar('exportfilter', array(), '', 'array');
     $listsToExport = JRequest::getVar('exportlists');
     $fieldsToExport = JRequest::getVar('exportdata');
     $fieldsToExportList = JRequest::getVar('exportdatalist');
     $fieldsToExportOthers = JRequest::getVar('exportdataother');
     $fieldsToExportGeoloc = JRequest::getVar('exportdatageoloc');
     $inseparator = JRequest::getString('exportseparator');
     $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator);
     $exportFormat = JRequest::getString('exportformat');
     if (!in_array($inseparator, array(',', ';'))) {
         $inseparator = ';';
     }
     $exportUnsubLists = array();
     $exportWaitLists = array();
     $exportLists = array();
     if (!empty($filtersExport['subscribed'])) {
         foreach ($listsToExport as $listid => $status) {
             if ($status == -1) {
                 $exportUnsubLists[] = (int) $listid;
             } elseif ($status == 2) {
                 $exportWaitLists[] = (int) $listid;
             } elseif (!empty($status)) {
                 $exportLists[] = (int) $listid;
             }
         }
     }
     $app = JFactory::getApplication();
     if (!$app->isAdmin() && (empty($filtersExport['subscribed']) || empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists))) {
         $listClass = acymailing_get('class.list');
         $frontLists = $listClass->getFrontendLists();
         foreach ($frontLists as $frontList) {
             $exportLists[] = (int) $frontList->listid;
         }
     }
     $exportFields = array();
     $exportFieldsList = array();
     $exportFieldsOthers = array();
     $exportFieldsGeoloc = array();
     foreach ($fieldsToExport as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFields[] = acymailing_secureField($fieldName);
         }
     }
     foreach ($fieldsToExportList as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFieldsList[] = acymailing_secureField($fieldName);
         }
     }
     if (!empty($fieldsToExportOthers)) {
         foreach ($fieldsToExportOthers as $fieldName => $checked) {
             if (!empty($checked)) {
                 $exportFieldsOthers[] = acymailing_secureField($fieldName);
             }
         }
     }
     if (!empty($fieldsToExportGeoloc)) {
         foreach ($fieldsToExportGeoloc as $fieldName => $checked) {
             if (!empty($checked)) {
                 $exportFieldsGeoloc[] = acymailing_secureField($fieldName);
             }
         }
     }
     $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`';
     $config = acymailing_config();
     $newConfig = new stdClass();
     $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList, $exportFieldsGeoloc));
     $newConfig->export_lists = implode(',', $exportLists);
     $newConfig->export_separator = JRequest::getString('exportseparator');
     $newConfig->export_format = $exportFormat;
     $filterActive = array();
     foreach ($filtersExport as $filterKey => $value) {
         if ($value == 1) {
             $filterActive[] = $filterKey;
         }
     }
     $newConfig->export_filters = implode(',', $filterActive);
     $config->save($newConfig);
     $where = array();
     if (empty($exportLists) && empty($exportUnsubLists) && empty($exportWaitLists)) {
         $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s';
     } else {
         $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid';
         if (!empty($exportLists)) {
             $conditions[] = 'a.status = 1 AND a.listid IN (' . implode(',', $exportLists) . ')';
         }
         if (!empty($exportUnsubLists)) {
             $conditions[] = 'a.status = -1 AND a.listid IN (' . implode(',', $exportUnsubLists) . ')';
         }
         if (!empty($exportWaitLists)) {
             $conditions[] = 'a.status = 2 AND a.listid IN (' . implode(',', $exportWaitLists) . ')';
         }
         if (count($conditions) == 1) {
             $where[] = $conditions[0];
         } else {
             $where[] = '(' . implode(') OR (', $conditions) . ')';
         }
     }
     if (!empty($filtersExport['confirmed'])) {
         $where[] = 's.confirmed = 1';
     }
     if (!empty($filtersExport['registered'])) {
         $where[] = 's.userid > 0';
     }
     if (!empty($filtersExport['enabled'])) {
         $where[] = 's.enabled = 1';
     }
     if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) {
         $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')';
     }
     if (JRequest::getInt('fieldfilters')) {
         foreach ($_SESSION['acymailing']['fieldfilter'] as $field => $value) {
             $where[] = 's.' . acymailing_secureField($field) . ' LIKE "%' . acymailing_getEscaped($value, true) . '%"';
         }
     }
     $query = $querySelect;
     if (!empty($where)) {
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
     }
     if (JRequest::getInt('sessionquery')) {
         $currentSession = JFactory::getSession();
         $selectOthers = '';
         if (!empty($exportFieldsOthers)) {
             foreach ($exportFieldsOthers as $oneField) {
                 $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField);
             }
         }
         $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery');
     }
     $query .= ' ORDER BY s.subid';
     $db = JFactory::getDBO();
     $encodingClass = acymailing_get('helper.encoding');
     $exportHelper = acymailing_get('helper.export');
     $fileName = 'export_' . date('Y-m-d');
     if (!empty($exportLists)) {
         $fileName = '';
         $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')');
         $allExportedLists = $db->loadObjectList();
         foreach ($allExportedLists as $oneList) {
             $fileName .= '__' . $oneList->name;
         }
         $fileName = trim($fileName, '__');
     }
     $exportHelper->addHeaders($fileName);
     acymailing_displayErrors();
     $eol = "\r\n";
     $before = '"';
     $separator = '"' . $inseparator . '"';
     $after = '"';
     $allFields = array_merge($exportFields, $exportFieldsOthers);
     if (!empty($exportFieldsList)) {
         $allFields = array_merge($allFields, $exportFieldsList);
         $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`';
         $selectFields = str_replace('listname', 'name', $selectFields);
     }
     if (!empty($exportFieldsGeoloc)) {
         $allFields = array_merge($allFields, $exportFieldsGeoloc);
     }
     $titleLine = $before . implode($separator, $allFields) . $after . $eol;
     $titleLine = str_replace('listid', 'listids', $titleLine);
     echo $titleLine;
     if (acymailing_bytes(ini_get('memory_limit')) > 150000000) {
         $nbExport = 50000;
     } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) {
         $nbExport = 15000;
     } else {
         $nbExport = 5000;
     }
     if (!empty($exportFieldsList)) {
         $nbExport = 500;
     }
     $valDep = 0;
     $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date');
     do {
         $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport);
         $valDep += $nbExport;
         $allData = $db->loadAssocList('subid');
         if ($allData === false) {
             echo $eol . $eol . 'Error : ' . $db->getErrorMsg();
         }
         if (empty($allData)) {
             break;
         }
         foreach ($allData as $subid => &$oneUser) {
             if (!in_array('subid', $exportFields)) {
                 unset($allData[$subid]['subid']);
             }
             foreach ($dateFields as &$fieldName) {
                 if (isset($allData[$subid][$fieldName])) {
                     $allData[$subid][$fieldName] = acymailing_getDate($allData[$subid][$fieldName], '%Y-%m-%d %H:%M:%S');
                 }
             }
         }
         if (!empty($exportFieldsList) && !empty($allData)) {
             $queryList = 'SELECT ' . $selectFields . ', ls.subid FROM #__acymailing_listsub as ls JOIN #__acymailing_list as l ON ls.listid=l.listid JOIN #__acymailing_subscriber as s on ls.subid = s.subid WHERE (ls.status = 1) and ls.subid IN (' . implode(',', array_keys($allData)) . ')';
             if (!empty($exportLists)) {
                 $queryList .= ' AND ls.listid IN (' . implode(',', $exportLists) . ')';
             }
             $db->setQuery($queryList);
             $resList = $db->loadObjectList();
             foreach ($resList as &$listsub) {
                 if (in_array('listid', $exportFieldsList)) {
                     $allData[$listsub->subid]['listid'] = empty($allData[$listsub->subid]['listid']) ? $listsub->listid : $allData[$listsub->subid]['listid'] . ' - ' . $listsub->listid;
                 }
                 if (in_array('listname', $exportFieldsList)) {
                     $allData[$listsub->subid]['listname'] = empty($allData[$listsub->subid]['listname']) ? $listsub->name : $allData[$listsub->subid]['listname'] . ' - ' . $listsub->name;
                 }
             }
             unset($resList);
         }
         if (!empty($exportFieldsGeoloc) && !empty($allData)) {
             $orderGeoloc = JRequest::getCmd('exportgeolocorder');
             if (strtolower($orderGeoloc) !== 'desc') {
                 $orderGeoloc = 'asc';
             }
             $db->setQuery('SELECT geolocation_subid,' . implode(', ', $exportFieldsGeoloc) . ' FROM (SELECT * FROM #__acymailing_geolocation WHERE geolocation_subid IN (' . implode(',', array_keys($allData)) . ') ORDER BY geolocation_id ' . $orderGeoloc . ') as geoloc GROUP BY geolocation_subid');
             $resGeol = $db->loadObjectList();
             foreach ($resGeol as $geolData) {
                 foreach ($exportFieldsGeoloc as $geolField) {
                     $allData[$geolData->geolocation_subid][$geolField] = $geolField == 'geolocation_created' ? acymailing_getDate($geolData->{$geolField}, '%Y-%m-%d %H:%M:%S') : $geolData->{$geolField};
                 }
             }
             unset($resGeol);
         }
         foreach ($allData as $subid => &$oneUser) {
             $dataexport = implode($separator, $oneUser);
             echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol;
         }
         unset($allData);
     } while (true);
     exit;
 }
예제 #19
0
 public function acymailing_generateautonews(&$email)
 {
     $time = time();
     $tags = $this->acypluginsHelper->extractTags($email, 'autocontent');
     $return = new stdClass();
     $return->status = true;
     $return->message = '';
     $this->tags = array();
     if (empty($tags)) {
         return $return;
     }
     foreach ($tags as $oneTag => $parameter) {
         if (isset($this->tags[$oneTag])) {
             continue;
         }
         $allcats = explode('-', $parameter->id);
         $selectedArea = array();
         foreach ($allcats as $oneCat) {
             if (!ACYMAILING_J16) {
                 $sectype = substr($oneCat, 0, 3);
                 $num = substr($oneCat, 3);
                 if (empty($num)) {
                     continue;
                 }
                 if ($sectype == 'cat') {
                     $selectedArea[] = 'catid = ' . (int) $num;
                 } elseif ($sectype == 'sec') {
                     $selectedArea[] = 'sectionid = ' . (int) $num;
                 }
             } else {
                 if (empty($oneCat)) {
                     continue;
                 }
                 $selectedArea[] = intval($oneCat);
             }
         }
         $query = 'SELECT a.id FROM `#__content` as a ';
         $where = array();
         if (!empty($parameter->tags) && version_compare(JVERSION, '3.1.0', '>=')) {
             $tagsArray = explode(',', $parameter->tags);
             JArrayHelper::toInteger($tagsArray);
             if (!empty($tagsArray)) {
                 foreach ($tagsArray as $oneTagId) {
                     $query .= 'JOIN #__contentitem_tag_map AS tagsmap' . $oneTagId . ' ON (a.id = tagsmap' . $oneTagId . '.content_item_id AND tagsmap' . $oneTagId . '.type_alias LIKE "com_content.article" AND tagsmap' . $oneTagId . '.tag_id = ' . $oneTagId . ') ';
                 }
             }
         }
         if (!empty($parameter->featured)) {
             if (ACYMAILING_J16) {
                 $where[] = 'a.featured = 1';
             } else {
                 $query .= 'JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                 $where[] = 'b.content_id IS NOT NULL';
             }
         }
         if (!empty($parameter->nofeatured)) {
             if (ACYMAILING_J16) {
                 $where[] = 'a.featured = 0';
             } else {
                 $query .= 'LEFT JOIN `#__content_frontpage` as b ON a.id = b.content_id ';
                 $where[] = 'b.content_id IS NULL';
             }
         }
         if (ACYMAILING_J16 && !empty($parameter->subcats) && !empty($selectedArea)) {
             $this->db->setQuery('SELECT lft,rgt FROM #__categories WHERE id IN (' . implode(',', $selectedArea) . ')');
             $catinfos = $this->db->loadObjectList();
             if (!empty($catinfos)) {
                 $whereCats = array();
                 foreach ($catinfos as $onecat) {
                     $whereCats[] = 'lft > ' . $onecat->lft . ' AND rgt < ' . $onecat->rgt;
                 }
                 $this->db->setQuery('SELECT id FROM #__categories WHERE (' . implode(') OR (', $whereCats) . ')');
                 $othercats = acymailing_loadResultArray($this->db);
                 $selectedArea = array_merge($selectedArea, $othercats);
             }
         }
         if (!empty($selectedArea)) {
             if (!ACYMAILING_J16) {
                 $where[] = implode(' OR ', $selectedArea);
             } else {
                 $filter_cat = '`catid` IN (' . implode(',', $selectedArea) . ')';
                 if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_multicats')) {
                     $filter_cat = '`catid` REGEXP "^([0-9]+,)*' . implode('(,[0-9]+)*$" OR `catid` REGEXP "^([0-9]+,)*', $selectedArea) . '(,[0-9]+)*$"';
                 }
                 $where[] = $filter_cat;
             }
         }
         if (!empty($parameter->excludedcats)) {
             $excludedCats = explode('-', $parameter->excludedcats);
             JArrayHelper::toInteger($excludedCats);
             $filter_cat = '`catid` NOT IN ("' . implode('","', $excludedCats) . '")';
             if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_multicats')) {
                 $filter_cat = '`catid` NOT REGEXP "^([0-9]+,)*' . implode('(,[0-9]+)*$" AND `catid` NOT REGEXP "^([0-9]+,)*', $excludedCats) . '(,[0-9]+)*$"';
             }
             $where[] = $filter_cat;
         }
         if (!empty($parameter->filter) && !empty($email->params['lastgenerateddate'])) {
             $condition = '(`publish_up` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `publish_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
             $condition .= ' OR (`created` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `created` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
             if ($parameter->filter == 'modify') {
                 $modify = '(`modified` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\' AND `modified` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\')';
                 if (!empty($parameter->maxpublished)) {
                     $modify = '(' . $modify . ' AND `publish_up` > \'' . date('Y-m-d H:i:s', time() - date('Z') - (int) $parameter->maxpublished * 60 * 60 * 24) . '\')';
                 }
                 $condition .= ' OR ' . $modify;
             }
             $where[] = $condition;
         }
         if (!empty($parameter->maxcreated)) {
             $date = $parameter->maxcreated;
             if (strpos($parameter->maxcreated, '[time]') !== false) {
                 $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->maxcreated));
             }
             if (!is_numeric($date)) {
                 $date = strtotime($parameter->maxcreated);
             }
             if (empty($date)) {
                 acymailing_display('Wrong date format (' . $parameter->maxcreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
             }
             $where[] = '`created` < ' . $this->db->Quote(date('Y-m-d H:i:s', $date)) . ' OR `publish_up` < ' . $this->db->Quote(date('Y-m-d H:i:s', $date));
         } else {
             $where[] = '`publish_up` < \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\'';
         }
         if (!empty($parameter->mincreated)) {
             $date = $parameter->mincreated;
             if (strpos($parameter->mincreated, '[time]') !== false) {
                 $date = acymailing_replaceDate(str_replace('[time]', '{time}', $parameter->mincreated));
             }
             if (!is_numeric($date)) {
                 $date = strtotime($parameter->mincreated);
             }
             if (empty($date)) {
                 acymailing_display('Wrong date format (' . $parameter->mincreated . ' in ' . $oneTag . '), please use YYYY-MM-DD', 'warning');
             }
             $where[] = '`created` > ' . $this->db->Quote(date('Y-m-d H:i:s', $date)) . ' OR `publish_up` > ' . $this->db->Quote(date('Y-m-d H:i:s', $date));
         }
         if (!empty($parameter->meta)) {
             $allMetaTags = explode(',', $parameter->meta);
             $metaWhere = array();
             foreach ($allMetaTags as $oneMeta) {
                 if (empty($oneMeta)) {
                     continue;
                 }
                 $metaWhere[] = "`metakey` LIKE '%" . acymailing_getEscaped($oneMeta, true) . "%'";
             }
             if (!empty($metaWhere)) {
                 $where[] = implode(' OR ', $metaWhere);
             }
         }
         $where[] = '`publish_down` > \'' . date('Y-m-d H:i:s', $time - date('Z')) . '\' OR `publish_down` = 0';
         if (empty($parameter->unpublished)) {
             $where[] = 'state = 1';
         } else {
             $where[] = 'state = 0';
         }
         if (!ACYMAILING_J16) {
             if (isset($parameter->access)) {
                 $where[] = 'access <= ' . intval($parameter->access);
             } else {
                 if ($this->params->get('contentaccess', 'registered') == 'registered') {
                     $where[] = 'access <= 1';
                 } elseif ($this->params->get('contentaccess', 'registered') == 'public') {
                     $where[] = 'access = 0';
                 }
             }
         } elseif (isset($parameter->access)) {
             if (strpos($parameter->access, ',')) {
                 $allAccess = explode(',', $parameter->access);
                 JArrayHelper::toInteger($allAccess);
                 $where[] = 'access IN (' . implode(',', $allAccess) . ')';
             } else {
                 $where[] = 'access = ' . intval($parameter->access);
             }
         }
         if (ACYMAILING_J16 && !empty($parameter->language)) {
             $allLanguages = explode(',', $parameter->language);
             $langWhere = 'language IN (';
             foreach ($allLanguages as $oneLanguage) {
                 $langWhere .= $this->db->Quote(trim($oneLanguage)) . ',';
             }
             $where[] = trim($langWhere, ',') . ')';
         }
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
         if (!empty($parameter->order)) {
             $ordering = explode(',', $parameter->order);
             if ($ordering[0] == 'rand') {
                 $query .= ' ORDER BY rand()';
             } else {
                 $query .= ' ORDER BY `' . acymailing_secureField($ordering[0]) . '` ' . acymailing_secureField($ordering[1]) . ' , a.`id` DESC';
             }
         }
         $start = '';
         if (!empty($parameter->start)) {
             $start = intval($parameter->start) . ',';
         }
         if (empty($parameter->max)) {
             $parameter->max = 100;
         }
         $query .= ' LIMIT ' . $start . (int) $parameter->max;
         $this->db->setQuery($query);
         $allArticles = acymailing_loadResultArray($this->db);
         if (!empty($parameter->min) && count($allArticles) < $parameter->min) {
             $return->status = false;
             $return->message = 'Not enough articles for the tag ' . $oneTag . ' : ' . count($allArticles) . ' / ' . $parameter->min . ' between ' . acymailing_getDate($email->params['lastgenerateddate']) . ' and ' . acymailing_getDate($time);
         }
         $stringTag = empty($parameter->noentrytext) ? '' : $parameter->noentrytext;
         if (!empty($allArticles)) {
             if (file_exists(ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php')) {
                 ob_start();
                 require ACYMAILING_MEDIA . 'plugins' . DS . 'autocontent.php';
                 $stringTag = ob_get_clean();
             } else {
                 $arrayElements = array();
                 $numArticle = 1;
                 foreach ($allArticles as $oneArticleId) {
                     $args = array();
                     $args[] = 'joomlacontent:' . $oneArticleId;
                     $args[] = 'num:' . $numArticle++;
                     if (!empty($parameter->invert) && $numArticle % 2 == 1) {
                         $args[] = 'invert';
                     }
                     if (!empty($parameter->type)) {
                         $args[] = 'type:' . $parameter->type;
                     }
                     if (!empty($parameter->format)) {
                         $args[] = 'format:' . $parameter->format;
                     }
                     if (!empty($parameter->template)) {
                         $args[] = 'template:' . $parameter->template;
                     }
                     if (!empty($parameter->jtags)) {
                         $args[] = 'jtags';
                     }
                     if (!empty($parameter->link)) {
                         $args[] = 'link';
                     }
                     if (!empty($parameter->author)) {
                         $args[] = 'author';
                     }
                     if (!empty($parameter->autologin)) {
                         $args[] = 'autologin';
                     }
                     if (!empty($parameter->cattitle)) {
                         $args[] = 'cattitle';
                     }
                     if (!empty($parameter->cattitlelink)) {
                         $args[] = 'cattitlelink';
                     }
                     if (!empty($parameter->lang)) {
                         $args[] = 'lang:' . $parameter->lang;
                     }
                     if (!empty($parameter->theme)) {
                         $args[] = 'theme';
                     }
                     if (!empty($parameter->clean)) {
                         $args[] = 'clean';
                     }
                     if (!empty($parameter->notitle)) {
                         $args[] = 'notitle';
                     }
                     if (!empty($parameter->nopictstyle)) {
                         $args[] = 'nopictstyle';
                     }
                     if (!empty($parameter->nopictlink)) {
                         $args[] = 'nopictlink';
                     }
                     if (!empty($parameter->created)) {
                         $args[] = 'created';
                     }
                     if (!empty($parameter->noattach)) {
                         $args[] = 'noattach';
                     }
                     if (!empty($parameter->itemid)) {
                         $args[] = 'itemid:' . $parameter->itemid;
                     }
                     if (!empty($parameter->noreadmore)) {
                         $args[] = 'noreadmore';
                     }
                     if (isset($parameter->pict)) {
                         $args[] = 'pict:' . $parameter->pict;
                     }
                     if (!empty($parameter->wrap)) {
                         $args[] = 'wrap:' . $parameter->wrap;
                     }
                     if (!empty($parameter->maxwidth)) {
                         $args[] = 'maxwidth:' . $parameter->maxwidth;
                     }
                     if (!empty($parameter->maxheight)) {
                         $args[] = 'maxheight:' . $parameter->maxheight;
                     }
                     if (!empty($parameter->readmore)) {
                         $args[] = 'readmore:' . $parameter->readmore;
                     }
                     if (!empty($parameter->dateformat)) {
                         $args[] = 'dateformat:' . $parameter->dateformat;
                     }
                     if (!empty($parameter->textafter)) {
                         $args[] = 'textafter:' . $parameter->textafter;
                     }
                     if (!empty($parameter->maxchar)) {
                         $args[] = 'maxchar:' . $parameter->maxchar;
                     }
                     if (!empty($parameter->share)) {
                         $args[] = 'share:' . $parameter->share;
                     }
                     if (!empty($parameter->sharetxt)) {
                         $args[] = 'sharetxt:' . $parameter->sharetxt;
                     }
                     if (!empty($parameter->catpict)) {
                         $args[] = 'catpict';
                     }
                     if (!empty($parameter->catmaxwidth)) {
                         $args[] = 'catmaxwidth:' . $parameter->catmaxwidth;
                     }
                     if (!empty($parameter->catmaxheight)) {
                         $args[] = 'catmaxheight:' . $parameter->catmaxheight;
                     }
                     $arrayElements[] = '{' . implode('|', $args) . '}';
                 }
                 $stringTag = $this->acypluginsHelper->getFormattedResult($arrayElements, $parameter);
             }
         }
         $this->tags[$oneTag] = $stringTag;
     }
     return $return;
 }
예제 #20
0
 function saveForm()
 {
     $app = JFactory::getApplication();
     $config =& acymailing_config();
     $mail = new stdClass();
     $mail->mailid = acymailing_getCID('mailid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     if (!empty($formData['mail']['subject'])) {
         $formData['mail']['subject'] = str_replace(chr(226) . chr(128) . chr(168), '', $formData['mail']['subject']);
     }
     foreach ($formData['mail'] as $column => $value) {
         if (!$app->isAdmin() && !in_array($column, $this->allowedFields)) {
             continue;
         }
         acymailing_secureField($column);
         if (in_array($column, array('params', 'summary'))) {
             $mail->{$column} = $value;
         } else {
             $mail->{$column} = strip_tags($value, '<ADV>');
         }
     }
     $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     if (ACYMAILING_J25) {
         $mail->body = JComponentHelper::filterText($mail->body);
     }
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $acypluginsHelper->cleanHtml($mail->body);
     $mail->attach = array();
     $attachments = JRequest::getVar('attachments', array(), '', 'array');
     if (!empty($attachments)) {
         foreach ($attachments as $id => $filepath) {
             if (empty($filepath)) {
                 continue;
             }
             $attachment = new stdClass();
             $attachment->filename = strtolower($filepath);
             $attachment->size = filesize(JPATH_SITE . '/' . $filepath);
             $extension = substr($attachment->filename, strrpos($attachment->filename, '.'));
             if (preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) {
                 acymailing_enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice');
                 continue;
             }
             $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension))) . $extension;
             $mail->attach[] = $attachment;
         }
     }
     if (isset($mail->filter)) {
         $mail->filter = array();
         $filterData = JRequest::getVar('filter');
         foreach ($filterData['type'] as $num => $oneType) {
             if (empty($oneType)) {
                 continue;
             }
             $mail->filter['type'][$num] = $oneType;
             $mail->filter[$num][$oneType] = $filterData[$num][$oneType];
         }
     }
     $toggleHelper = acymailing_get('helper.toggle');
     if (!empty($mail->type) && $mail->type == 'followup' && !empty($mail->mailid)) {
         $oldMail = $this->get($mail->mailid);
         if (!empty($mail->published) and !$oldMail->published) {
             $this->_publishfollowup($mail);
         }
         if ($oldMail->senddate != $mail->senddate) {
             $text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED');
             $text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY'));
             acymailing_enqueueMessage($text, 'notice');
         }
     }
     if (preg_match('#<a[^>]*subid=[0-9].*</a>#Uis', $mail->body, $pregResult)) {
         acymailing_enqueueMessage('There is a personal link in your Newsletter ( ' . $pregResult[0] . ' ) instead of a tag...<br />Please make sure to not copy/paste the link you received in your e-mail as it may break your unsubscribe or confirmation links.<br />Use our tags instead!', 'notice');
     }
     if (empty($mail->thumb)) {
         unset($mail->thumb);
     } elseif ($mail->thumb == 'delete') {
         $mail->thumb = '';
     }
     $mailid = $this->save($mail);
     if (!$mailid) {
         return false;
     }
     JRequest::setVar('mailid', $mailid);
     $status = true;
     if (!empty($formData['listmail'])) {
         $receivers = array();
         $remove = array();
         foreach ($formData['listmail'] as $listid => $receiveme) {
             if (!empty($receiveme)) {
                 $receivers[] = $listid;
             } else {
                 $remove[] = $listid;
             }
         }
         $listMailClass = acymailing_get('class.listmail');
         $status = $listMailClass->save($mailid, $receivers, $remove);
     }
     if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) {
         $mail->mailid = $mailid;
         $this->_publishfollowup($mail);
     }
     return $status;
 }
예제 #21
0
    function listing()
    {
        global $Itemid;
        $app = JFactory::getApplication();
        $my = JFactory::getUser();
        $values = new stdClass();
        $jsite = JFactory::getApplication('site');
        $menus = $jsite->getMenu();
        $menu = $menus->getActive();
        if (empty($menu) and !empty($Itemid)) {
            $menus->setActive($Itemid);
            $menu = $menus->getItem($Itemid);
        }
        $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
        $this->assignRef('item', $myItem);
        if (is_object($menu)) {
            jimport('joomla.html.parameter');
            $menuparams = new acyParameter($menu->params);
        }
        $pageInfo = new stdClass();
        $pageInfo->filter = new stdClass();
        $pageInfo->filter->order = new stdClass();
        $pageInfo->limit = new stdClass();
        $pageInfo->elements = new stdClass();
        $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName();
        $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".ordering_dir", 'ordering_dir', 'DESC', 'word');
        $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".ordering", 'ordering', 'senddate', 'cmd');
        if (strtolower($pageInfo->filter->order->dir) !== 'desc') {
            $pageInfo->filter->order->dir = 'asc';
        }
        $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string');
        $pageInfo->search = JString::strtolower(trim($pageInfo->search));
        $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
        $pageInfo->limit->start = JRequest::getInt('limitstart', 0);
        $listClass = acymailing_get('class.list');
        $listid = acymailing_getCID('listid');
        if (empty($listid) and !empty($menuparams)) {
            $listid = $menuparams->get('listid');
        }
        if (empty($listid)) {
            $allLists = $listClass->getLists('listid');
        } else {
            $oneList = $listClass->get($listid);
            if (empty($oneList->listid)) {
                return JError::raiseError(404, 'Mailing List not found : ' . $listid);
            }
            $allLists = array($oneList->listid => $oneList);
            if ($oneList->access_sub != 'all' && ($oneList->access_sub == 'none' || empty($my->id) || !acymailing_isAllowed($oneList->access_sub))) {
                $allLists = array();
            }
        }
        if (empty($allLists)) {
            if (empty($my->id)) {
                $usercomp = ACYMAILING_J16 ? 'com_users' : 'com_user';
                $uri = JFactory::getURI();
                $app->redirect('index.php?option=' . $usercomp . '&view=login&return=' . base64_encode($uri->toString()), JText::_('ACY_NOTALLOWED'));
            } else {
                $app->enqueueMessage(JText::_('ACY_NOTALLOWED'), 'error');
                $app->redirect(acymailing_completeLink('lists', false, true));
            }
            return false;
        }
        $doc = JFactory::getDocument();
        $db = JFactory::getDBO();
        $pathway = $app->getPathway();
        $config = acymailing_config();
        if (!empty($menuparams)) {
            $values->suffix = $menuparams->get('pageclass_sfx', '');
            $values->page_title = $menuparams->get('page_title');
            $values->page_heading = ACYMAILING_J16 ? $menuparams->get('page_heading') : $menuparams->get('page_title');
            $values->show_page_heading = ACYMAILING_J16 ? $menuparams->get('show_page_heading', 1) : $menuparams->get('show_page_title', 1);
        } else {
            $values->suffix = '';
            $values->show_page_heading = 1;
        }
        $values->show_description = $config->get('show_description', 1);
        $values->show_senddate = $config->get('show_senddate', 1);
        $values->show_receiveemail = $config->get('show_receiveemail', 0) && acymailing_level(1);
        $values->filter = $config->get('show_filter', 1);
        if (empty($values->page_title)) {
            $values->page_title = count($allLists) > 1 || empty($listid) ? JText::_('NEWSLETTERS') : $allLists[$listid]->name;
        }
        if (empty($values->page_heading)) {
            $values->page_heading = count($allLists) > 1 || empty($listid) ? JText::_('NEWSLETTERS') : $allLists[$listid]->name;
        }
        if (empty($menuparams)) {
            $pathway->addItem(JText::_('MAILING_LISTS'), acymailing_completeLink('lists'));
            $pathway->addItem($values->page_title);
        } elseif (!$menuparams->get('listid')) {
            $pathway->addItem($values->page_title);
        }
        acymailing_setPageTitle($values->page_title);
        $this->addFeed();
        $searchMap = array('a.mailid', 'a.subject', 'a.alias');
        $filters = array();
        if (!empty($pageInfo->search)) {
            $searchVal = '\'%' . acymailing_getEscaped($pageInfo->search, true) . '%\'';
            $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
        }
        $filters[] = 'a.type = \'news\'';
        $noManageableLists = array();
        foreach ($allLists as &$oneList) {
            if (empty($my->id)) {
                $noManageableLists[] = $oneList->listid;
            }
            if ((int) $my->id == (int) $oneList->userid) {
                continue;
            }
            if ($oneList->access_manage == 'all' || acymailing_isAllowed($oneList->access_manage)) {
                continue;
            }
            $noManageableLists[] = $oneList->listid;
        }
        $accessFilter = '';
        $manageableLists = array_diff(array_keys($allLists), $noManageableLists);
        if (!empty($manageableLists)) {
            $accessFilter = 'c.listid IN (' . implode(',', $manageableLists) . ')';
        }
        if (!empty($noManageableLists)) {
            if (empty($accessFilter)) {
                $accessFilter = 'c.listid IN (' . implode(',', $noManageableLists) . ') AND a.published = 1 AND a.visible = 1';
            } else {
                $accessFilter .= ' OR (c.listid IN (' . implode(',', $noManageableLists) . ') AND a.published = 1 AND a.visible = 1)';
            }
        }
        if (!empty($accessFilter)) {
            $filters[] = $accessFilter;
        }
        if ($config->get('open_popup', 1) || !empty($manageableLists)) {
            JHTML::_('behavior.modal', 'a.modal');
        }
        $selection = array_merge($searchMap, array('a.senddate', 'a.created', 'a.visible', 'a.published', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid', 'a.summary', 'a.thumb', 'c.listid'));
        $query = 'SELECT "" AS body, "" AS altbody, html AS sendHTML, ' . implode(',', $selection);
        $query .= ' FROM ' . acymailing_table('listmail') . ' as c';
        $query .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid ';
        $query .= ' WHERE (' . implode(') AND (', $filters) . ')';
        $query .= ' GROUP BY c.mailid';
        $query .= ' ORDER BY a.' . acymailing_secureField($pageInfo->filter->order->value) . ' ' . acymailing_secureField($pageInfo->filter->order->dir) . ', c.mailid DESC';
        $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value);
        $rows = $db->loadObjectList();
        $pageInfo->elements->page = count($rows);
        if ($pageInfo->limit->value > $pageInfo->elements->page) {
            $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page;
        } else {
            $queryCount = 'SELECT COUNT(DISTINCT c.mailid) FROM ' . acymailing_table('listmail') . ' as c';
            $queryCount .= ' JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid ';
            $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')';
            $db->setQuery($queryCount);
            $pageInfo->elements->total = $db->loadResult();
        }
        if (!empty($my->email)) {
            $userClass = acymailing_get('class.subscriber');
            $receiver = $userClass->get($my->email);
        }
        if (empty($receiver)) {
            $receiver = new stdClass();
            $receiver->name = JText::_('VISITOR');
        }
        JPluginHelper::importPlugin('acymailing');
        $dispatcher = JDispatcher::getInstance();
        foreach ($rows as $mail) {
            if (strpos($mail->subject, "{") !== false) {
                $dispatcher->trigger('acymailing_replacetags', array(&$mail, false));
                $dispatcher->trigger('acymailing_replaceusertags', array(&$mail, &$receiver, false));
            }
        }
        jimport('joomla.html.pagination');
        $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
        $js = 'function tableOrdering( order, dir, task ){
			var form = document.adminForm;

			form.filter_order.value 	= order;
			form.filter_order_Dir.value	= dir;
			document.adminForm.submit( task );
		}

		function changeReceiveEmail(checkedbox){
			var form = document.adminForm;
			if(checkedbox){
				form.nbreceiveemail.value++;
			}else{
				form.nbreceiveemail.value--;
			}

			if(form.nbreceiveemail.value > 0 ){
				document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_visible\';
			}else{
				document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_hidden\';
			}
		}
		';
        $doc->addScriptDeclaration($js);
        $orderValues = array();
        $orderValues[] = JHTML::_('select.option', 'senddate', JText::_('SEND_DATE'));
        $orderValues[] = JHTML::_('select.option', 'subject', JText::_('JOOMEXT_SUBJECT'));
        $orderValues[] = JHTML::_('select.option', 'created', JText::_('CREATED_DATE'));
        $orderValues[] = JHTML::_('select.option', 'mailid', JText::_('ACY_ID'));
        $ordering = '<span style="float:right;" id="orderingoption">';
        $ordering .= JHTML::_('select.genericlist', $orderValues, 'ordering', 'size="1" style="width:100px;" onchange="this.form.submit();"', 'value', 'text', $pageInfo->filter->order->value);
        $orderDir = array();
        $orderDir[] = JHTML::_('select.option', 'ASC', 'ASC');
        $orderDir[] = JHTML::_('select.option', 'DESC', 'DESC');
        $ordering .= ' ' . JHTML::_('select.genericlist', $orderDir, 'ordering_dir', 'size="1" style="width:75px;" onchange="this.form.submit();"', 'value', 'text', $pageInfo->filter->order->dir);
        $ordering .= '</span>';
        $this->assignRef('ordering', $ordering);
        $this->assignRef('rows', $rows);
        $this->assignRef('values', $values);
        if (count($allLists) > 1) {
            $list = new stdClass();
            $list->listid = 0;
            $list->description = '';
        } else {
            $list = array_pop($allLists);
        }
        $this->assignRef('list', $list);
        $this->assignRef('manageableLists', $manageableLists);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('pageInfo', $pageInfo);
        $this->assignRef('config', $config);
        $this->assignRef('my', $my);
    }
예제 #22
0
파일: filter.php 프로젝트: ForAEdesWeb/AEW1
 function convertQuery($as, $column, $operator, $value, $type = '')
 {
     $operator = str_replace(array('&lt;', '&gt;'), array('<', '>'), $operator);
     if ($operator == 'CONTAINS') {
         $operator = 'LIKE';
         $value = '%' . $value . '%';
     } elseif ($operator == 'BEGINS') {
         $operator = 'LIKE';
         $value = $value . '%';
     } elseif ($operator == 'END') {
         $operator = 'LIKE';
         $value = '%' . $value;
     } elseif ($operator == 'NOTCONTAINS') {
         $operator = 'NOT LIKE';
         $value = '%' . $value . '%';
     } elseif (!in_array($operator, array('REGEXP', 'NOT REGEXP', 'IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='))) {
         die('Operator not safe : ' . $operator);
     }
     if (strpos($value, '{time}') !== false) {
         $value = acymailing_replaceDate($value);
         $value = strftime('%Y-%m-%d %H:%M:%S', $value);
     }
     $replace = array('{year}', '{month}', '{weekday}', '{day}');
     $replaceBy = array(date('Y'), date('m'), date('N'), date('d'));
     $value = str_replace($replace, $replaceBy, $value);
     if (!is_numeric($value) or in_array($operator, array('REGEXP', 'NOT REGEXP', 'NOT LIKE', 'LIKE', '=', '!='))) {
         $value = $this->db->Quote($value);
     }
     if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) {
         $value = '';
     }
     if ($type == 'datetime' && in_array($operator, array('=', '!='))) {
         return 'DATE_FORMAT(' . $as . '.`' . acymailing_secureField($column) . '`, "%Y-%m-%d") ' . $operator . ' ' . 'DATE_FORMAT(' . $value . ', "%Y-%m-%d")';
     }
     if ($type == 'timestamp' && in_array($operator, array('=', '!='))) {
         return 'FROM_UNIXTIME(' . $as . '.`' . acymailing_secureField($column) . '`, "%Y-%m-%d") ' . $operator . ' ' . 'FROM_UNIXTIME(' . $value . ', "%Y-%m-%d")';
     }
     return $as . '.`' . acymailing_secureField($column) . '` ' . $operator . ' ' . $value;
 }
예제 #23
0
 function finalizeImport()
 {
     $config = acymailing_config();
     $this->forceconfirm = JRequest::getInt('import_confirmed');
     $this->generatename = JRequest::getInt('generatename');
     $this->importblocked = JRequest::getInt('importblocked');
     $this->overwrite = JRequest::getInt('overwriteexisting');
     $newConfig = new stdClass();
     $paramTmp = array();
     if ($this->forceconfirm == 1) {
         $paramTmp[] = 'import_confirmed';
     }
     if ($this->generatename == 1) {
         $paramTmp[] = 'generatename';
     }
     if ($this->importblocked == 1) {
         $paramTmp[] = 'importblocked';
     }
     if ($this->overwrite == 1) {
         $paramTmp[] = 'overwriteexisting';
     }
     $importParams = 'import_params';
     $newConfig->{$importParams} = implode(',', $paramTmp);
     $config->save($newConfig);
     $filename = strtolower(JRequest::getCmd('filename'));
     $extension = '.' . JFile::getExt($filename);
     $filename = str_replace(array('.', ' '), '_', substr($filename, 0, strpos($filename, $extension))) . $extension;
     $uploadPath = ACYMAILING_MEDIA . 'import' . DS . $filename;
     if (!file_exists($uploadPath)) {
         acymailing_enqueueMessage('Uploaded file not found: ' . $uploadPath, 'error');
         return;
     }
     $importColumns = JRequest::getString('import_columns');
     if (empty($importColumns)) {
         acymailing_enqueueMessage('Columns not found', 'error');
         return false;
     }
     $columns = explode(',', $importColumns);
     $db = JFactory::getDBO();
     $acyColumns = acymailing_getColumns('#__acymailing_subscriber');
     foreach ($columns as $oneColumn) {
         if ($oneColumn == 1 || $oneColumn == 'listids' || isset($acyColumns[$oneColumn])) {
             continue;
         }
         // Ignored or existing column
         $checkColumn = preg_replace('#[^A-Za-z0-9_]#Uis', '', $oneColumn);
         if (empty($checkColumn)) {
             acymailing_enqueueMessage('Invalid field name: ' . $oneColumn, 'error');
             return false;
         }
         $oneColumn = $checkColumn;
         if (!acymailing_level(3)) {
             // Make sure we can't create a custom field
             acymailing_enqueueMessage(JText::_('EXTRA_FIELDS') . ' ' . JText::_('ONLY_FROM_ENTERPRISE'), 'error');
             return false;
         }
         if (empty($ordering)) {
             $db->setQuery('SELECT MAX(ordering) FROM #__acymailing_fields');
             $ordering = $db->loadResult();
         }
         $ordering++;
         $db->setQuery('ALTER TABLE `#__acymailing_subscriber` ADD `' . acymailing_secureField(strtolower($oneColumn)) . '` VARCHAR ( 250 ) NOT NULL DEFAULT ""');
         $db->query();
         $query = "INSERT INTO `#__acymailing_fields` (`fieldname`, `namekey`, `type`, `value`, `published`, `ordering`, `options`, `core`, `required`, `backend`, `frontcomp`, `default`, `listing`, `frontlisting`) VALUES\n\t\t\t(" . $db->quote($oneColumn) . ", " . $db->quote(strtolower($oneColumn)) . ", 'text', '', 1, " . intval($ordering) . ", '', 0, 0, 1, 0, '',0,0);";
         $db->setQuery($query);
         $db->query();
     }
     $contentFile = file_get_contents($uploadPath);
     if (JRequest::getCmd('charsetconvert', '') != '') {
         $encodingHelper = acymailing_get('helper.encoding');
         $contentFile = $encodingHelper->change($contentFile, JRequest::getCmd('charsetconvert'), 'UTF-8');
     }
     $cutContent = str_replace(array("\r\n", "\r"), "\n", $contentFile);
     $allLines = explode("\n", $cutContent);
     $listSeparators = array("\t", ';', ',');
     $separator = ',';
     foreach ($listSeparators as $sep) {
         if (strpos($allLines[0], $sep) !== false) {
             $separator = $sep;
             break;
         }
     }
     $importColumns = str_replace(',', $separator, $importColumns);
     if (strpos($allLines[0], '@')) {
         $contentFile = $importColumns . "\n" . $contentFile;
     } else {
         $allLines[0] = $importColumns;
         $contentFile = implode("\n", $allLines);
     }
     $this->_handleContent($contentFile);
     $this->_displaySubscribedResult();
     unlink($uploadPath);
     $this->_cleanImportFolder();
 }
예제 #24
0
 function saveForm()
 {
     $app =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     $config =& acymailing_config();
     $mail = new stdClass();
     $mail->mailid = acymailing_getCID('mailid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['mail'] as $column => $value) {
         if ($app->isAdmin() or in_array($column, $this->allowedFields)) {
             acymailing_secureField($column);
             if ($column == 'params') {
                 $mail->{$column} = $value;
             } else {
                 $mail->{$column} = strip_tags($value);
             }
         }
     }
     $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     $pregreplace = array();
     $pregreplace['#<tr([^>"]*>([^<]*<td[^>]*>[ \\n\\s]*<img[^>]*>[ \\n\\s]*</ *td[^>]*>[ \\n\\s]*)*</ *tr)#Uis'] = '<tr style="line-height: 0px;" $1';
     $pregreplace['#<td(((?!style|>).)*>[ \\n\\s]*(<a[^>]*>)?[ \\n\\s]*<img[^>]*>[ \\n\\s]*(</a[^>]*>)?[ \\n\\s]*</ *td)#Uis'] = '<td style="line-height: 0px;" $1';
     $pregreplace['#<xml>.*</xml>#Uis'] = '';
     $newbody = preg_replace(array_keys($pregreplace), $pregreplace, $mail->body);
     if (!empty($newbody)) {
         $mail->body = $newbody;
     }
     $mail->attach = array();
     $attachments = JRequest::getVar('attachments', array(), 'files', 'array');
     if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) {
         jimport('joomla.filesystem.file');
         $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
         $uploadFolder = trim($uploadFolder, DS . ' ') . DS;
         $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
         acymailing_createDir($uploadPath, true);
         if (!is_writable($uploadPath)) {
             @chmod($uploadPath, '0755');
             if (!is_writable($uploadPath)) {
                 $app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
             }
         }
         foreach ($attachments['name'] as $id => $filename) {
             if (empty($filename)) {
                 continue;
             }
             $attachment = new stdClass();
             $attachment->filename = strtolower(JFile::makeSafe($filename));
             $attachment->size = $attachments['size'][$id];
             if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)$#Ui', $attachment->filename)) {
                 $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice');
                 continue;
             }
             $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
             if (!JFile::upload($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
                 if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
                     $app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', $attachments['tmp_name'][$id], $uploadPath . $attachment->filename), 'error');
                     continue;
                 }
             }
             $mail->attach[] = $attachment;
         }
     }
     if (isset($mail->filter)) {
         $mail->filter = array();
         $filterData = JRequest::getVar('filter');
         foreach ($filterData['type'] as $num => $oneType) {
             if (empty($oneType)) {
                 continue;
             }
             $mail->filter['type'][$num] = $oneType;
             $mail->filter[$num][$oneType] = $filterData[$num][$oneType];
         }
     }
     $toggleHelper = acymailing_get('helper.toggle');
     if (!empty($mail->type) && $mail->type == 'followup' && !empty($mail->mailid)) {
         $oldMail = $this->get($mail->mailid);
         if (!empty($mail->published) and !$oldMail->published) {
             $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED');
             $text .= ' ' . $toggleHelper->toggleText('add', $mail->mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED'));
             $app->enqueueMessage($text, 'notice');
         }
         if ($oldMail->senddate != $mail->senddate) {
             $text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED');
             $text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY'));
             $app->enqueueMessage($text, 'notice');
         }
     }
     $mailid = $this->save($mail);
     if (!$mailid) {
         return false;
     }
     JRequest::setVar('mailid', $mailid);
     if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) {
         $text = JText::_('FOLLOWUP_PUBLISHED_INFORMED');
         $text .= ' ' . $toggleHelper->toggleText('add', $mailid, 'followup', JText::_('FOLLOWUP_PUBLISHED'));
         $app->enqueueMessage($text, 'notice');
     }
     $status = true;
     if (!empty($formData['listmail'])) {
         $receivers = array();
         $remove = array();
         foreach ($formData['listmail'] as $listid => $receiveme) {
             if (!empty($receiveme)) {
                 $receivers[] = $listid;
             } else {
                 $remove[] = $listid;
             }
         }
         $listMailClass = acymailing_get('class.listmail');
         $status = $listMailClass->save($mailid, $receivers, $remove);
     }
     return $status;
 }
예제 #25
0
파일: queue.php 프로젝트: Roma48/abazherka
 public function getReady($limit, $mailid = 0)
 {
     if (empty($limit)) {
         return array();
     }
     $config = acymailing_config();
     $order = $config->get('sendorder');
     if (empty($order)) {
         $order = 'a.`subid` ASC';
     } else {
         if ($order == 'rand') {
             $order = 'RAND()';
         } else {
             $ordering = explode(',', $order);
             $order = 'a.`' . acymailing_secureField(trim($ordering[0])) . '` ' . acymailing_secureField(trim($ordering[1]));
         }
     }
     $query = 'SELECT a.* FROM ' . acymailing_table('queue') . ' as a';
     $query .= ' JOIN ' . acymailing_table('mail') . ' as b on a.`mailid` = b.`mailid` ';
     $query .= ' WHERE a.`senddate` <= ' . time() . ' AND b.`published` = 1';
     if (!empty($mailid)) {
         $query .= ' AND a.`mailid` = ' . $mailid;
     }
     $query .= ' ORDER BY a.`priority` ASC, a.`senddate` ASC, ' . $order;
     $query .= ' LIMIT ' . JRequest::getInt('startqueue', 0) . ',' . intval($limit);
     $this->database->setQuery($query);
     try {
         $results = $this->database->loadObjectList();
     } catch (Exception $e) {
         $results = null;
     }
     if ($results === null) {
         $this->database->setQuery('REPAIR TABLE #__acymailing_queue, #__acymailing_subscriber, #__acymailing_mail');
         $this->database->query();
     }
     if (empty($results)) {
         return array();
     }
     if (!empty($results)) {
         $firstElementQueued = reset($results);
         $this->database->setQuery('UPDATE #__acymailing_queue SET senddate = senddate + 1 WHERE mailid = ' . $firstElementQueued->mailid . ' AND subid = ' . $firstElementQueued->subid . ' LIMIT 1');
         $this->database->query();
     }
     $subids = array();
     foreach ($results as $oneRes) {
         $subids[$oneRes->subid] = intval($oneRes->subid);
     }
     $cleanQueue = false;
     if (!empty($subids)) {
         $this->database->setQuery('SELECT * FROM #__acymailing_subscriber WHERE subid IN (' . implode(',', $subids) . ')');
         $allusers = $this->database->loadObjectList('subid');
         foreach ($results as $oneId => $oneRes) {
             if (empty($allusers[$oneRes->subid])) {
                 $cleanQueue = true;
                 continue;
             }
             foreach ($allusers[$oneRes->subid] as $oneVar => $oneVal) {
                 $results[$oneId]->{$oneVar} = $oneVal;
             }
         }
     }
     if ($cleanQueue) {
         $this->database->setQuery('DELETE a.* FROM #__acymailing_queue as a LEFT JOIN #__acymailing_subscriber as b ON a.subid = b.subid WHERE b.subid IS NULL');
         $this->database->query();
     }
     return $results;
 }
예제 #26
0
 function onAcyProcessAction_acymailingfieldval($cquery, $action, $num)
 {
     $value = is_array($action['value']) ? implode(',', $action['value']) : $action['value'];
     $replace = array('{year}', '{month}', '{weekday}', '{day}');
     $replaceBy = array(date('Y'), date('m'), date('N'), date('d'));
     $value = str_replace($replace, $replaceBy, $value);
     if (empty($action['operator'])) {
         $action['operator'] = '=';
     }
     preg_match_all('#(?:{|%7B)field:(.*)(?:}|%7D)#Ui', $value, $tags);
     $fields = array_keys(acymailing_getColumns('#__acymailing_subscriber'));
     if (!in_array($action['map'], $fields)) {
         return 'Unexisting field: ' . $action['map'] . ' | The available fields are: ' . implode(', ', $fields);
     }
     if (in_array($action['operator'], array('+', '-'))) {
         if (empty($tags) || empty($tags[1])) {
             $value = intval($value);
         } else {
             if (count($tags[1]) > 1 || substr($value, 0, 1) != '{' || substr($value, strlen($value) - 1, 1) != '}') {
                 return 'You can\'t use more than one tag for the + and - operators (you also can\'t add or remove a value from the inserted tag for these two operators)';
             }
             if (!in_array($tags[1][0], $fields)) {
                 return 'Unexisting field: ' . $tags[1][0] . ' | The available fields are: ' . implode(', ', $fields);
             }
             $value = 'sub.`' . acymailing_secureField($tags[1][0]) . '`';
         }
     } else {
         $value = $cquery->db->Quote($value);
         if (!empty($tags)) {
             foreach ($tags[1] as $i => $oneField) {
                 if (!in_array($oneField, $fields)) {
                     return 'Unexisting field: ' . $oneField . ' | The available fields are: ' . implode(', ', $fields);
                 }
                 $value = str_replace($tags[0][$i], "', sub.`" . acymailing_secureField($oneField) . "`, '", $value);
             }
             $value = "CONCAT(" . $value . ")";
         }
     }
     $query = 'UPDATE #__acymailing_subscriber AS sub';
     if (!empty($cquery->join)) {
         $query .= ' JOIN ' . implode(' JOIN ', $cquery->join);
     }
     if (!empty($cquery->leftjoin)) {
         $query .= ' LEFT JOIN ' . implode(' LEFT JOIN ', $cquery->leftjoin);
     }
     if ($action['operator'] == '=') {
         $newValue = $value;
     } elseif (in_array($action['operator'], array('+', '-'))) {
         $newValue = "sub.`" . acymailing_secureField($action['map']) . "` " . $action['operator'] . " " . $value;
     } elseif ($action['operator'] == 'addend') {
         $newValue = "CONCAT(sub.`" . acymailing_secureField($action['map']) . "`, " . $value . ")";
     } elseif ($action['operator'] == 'addbegin') {
         $newValue = "CONCAT(" . $value . ", sub.`" . acymailing_secureField($action['map']) . "`)";
     } else {
         return 'Non existing operator: ' . $action['operator'];
     }
     $query .= " SET sub.`" . acymailing_secureField($action['map']) . "` = " . $newValue;
     if (!empty($cquery->where)) {
         $query .= ' WHERE (' . implode(') AND (', $cquery->where) . ')';
     }
     $cquery->db->setQuery($query);
     $cquery->db->query();
     $nbAffected = $cquery->db->getAffectedRows();
     return JText::sprintf('NB_MODIFIED', $nbAffected);
 }
예제 #27
0
파일: view.html.php 프로젝트: utopszkij/lmp
	function listing(){
		global $Itemid;

		$app = JFactory::getApplication();

		$my = JFactory::getUser();
		$pathway = $app->getPathway();

		$values = new stdClass();
		$jsite = JFactory::getApplication('site');
		$menus = $jsite->getMenu();
		$menu	= $menus->getActive();
		$config = acymailing_config();

		if(empty($menu) AND !empty($Itemid)){
			$menus->setActive($Itemid);
			$menu	= $menus->getItem($Itemid);
		}

		$myItem = empty($Itemid) ? '' : '&Itemid='.$Itemid;
		$this->assignRef('item',$myItem);

		if (is_object( $menu )) {
			jimport('joomla.html.parameter');
			$menuparams = new acyParameter( $menu->params );
		}

		$pageInfo = new stdClass();
		$pageInfo->filter = new stdClass();
		$pageInfo->filter->order  = new stdClass();
		$pageInfo->limit = new stdClass();
		$pageInfo->elements = new stdClass();

		$paramBase = ACYMAILING_COMPONENT.'.'.$this->getName();
		$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';
		$pageInfo->search = $app->getUserStateFromRequest( $paramBase.".search", 'search', '', 'string' );
		$pageInfo->search = JString::strtolower(trim($pageInfo->search));

		$pageInfo->limit->value = $app->getUserStateFromRequest( $paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
		$pageInfo->limit->start = JRequest::getInt('limitstart',0);

		$listClass = acymailing_get('class.list');
		$listid = acymailing_getCID('listid');

		if(empty($listid) AND !empty($menuparams)){
			$listid = $menuparams->get('listid');
		}

		if(empty($listid) AND acymailing_level(3)){
			$listClass = acymailing_get('class.list');
			$allAllowedLists = $listClass->getFrontendLists();
			if(!empty($allAllowedLists)){
				$firstList = reset($allAllowedLists);
				$listid = $firstList->listid;
				JRequest::setVar('listid',$listid);
			}
		}

		if(empty($listid)){
			return JError::raiseError( 404, 'Mailing List not found' );
		}
		$oneList = $listClass->get($listid);

		if(empty($oneList->listid)){
			return JError::raiseError( 404, 'Mailing List not found : '.$listid );
		}

		$access = new stdClass();
		$access->frontEndManagement = false;
		$access->frontEndAccess = true;
		if(acymailing_level(3)){
			if(!empty($my->id) AND (int)$my->id == (int)$oneList->userid){
				$access->frontEndManagement = true;
			}
			if(!empty($my->id)){
				if($oneList->access_manage == 'all' OR acymailing_isAllowed($oneList->access_manage)){
					 $access->frontEndManagement = true;
				}
			}
			if($oneList->access_sub != 'all' AND ($oneList->access_sub == 'none' OR empty($my->id) OR !acymailing_isAllowed($oneList->access_sub))){
				$access->frontEndAccess = false;
			}

			if($access->frontEndManagement) JHTML::_('behavior.modal','a.modal');
		}

		$doc = JFactory::getDocument();
		$js = "function refreshCaptcha(){
				var captchaLink = document.getElementById('captcha_picture').src;
				myregexp = new RegExp('val[-=]([0-9]+)');
				valToChange=captchaLink.match(myregexp)[1];
				document.getElementById('captcha_picture').src = captchaLink.replace(valToChange,valToChange+'0');
			}";
		$doc->addScriptDeclaration( $js );

		if(!$access->frontEndManagement AND (!$oneList->published OR !$oneList->visible OR !$access->frontEndAccess)){
			if(empty($my->id)){
				$usercomp = !ACYMAILING_J16 ? 'com_user' : 'com_users';
				$uri = JFactory::getURI();
				$url = 'index.php?option='.$usercomp.'&view=login&return='.base64_encode($uri->toString());
				$app->redirect($url, JText::_('ACY_NOTALLOWED') );
				return false;
			}else{
				$app->enqueueMessage(JText::_('ACY_NOTALLOWED'),'error');
				$app->redirect(acymailing_completeLink('lists',false,true));
				return false;
			}
		}

		if($config->get('open_popup',1)) JHTML::_('behavior.modal','a.modal');

		if(!empty($menuparams)){
			$values->suffix = $menuparams->get('pageclass_sfx','');
			$values->page_title = $menuparams->get('page_title');
			$values->page_heading = ACYMAILING_J16 ? $menuparams->get('page_heading') : $menuparams->get('page_title');
			$values->show_page_heading = ACYMAILING_J16 ? $menuparams->get('show_page_heading',1) : $menuparams->get('show_page_title',1);
		}else{
			$values->suffix = '';
			$values->show_page_heading = 1;
		}

		$values->show_description = $config->get('show_description',1);
		$values->show_senddate = $config->get('show_senddate',1);
		$values->show_receiveemail = $config->get('show_receiveemail',0) && acymailing_level(1);
		$values->filter = $config->get('show_filter',1);

		if(empty($values->page_title)) $values->page_title = $oneList->name;
		if(empty($values->page_heading)) $values->page_heading = $oneList->name;

		if(empty($menuparams)){
			$pathway->addItem(JText::_('MAILING_LISTS'),acymailing_completeLink('lists'));
			$pathway->addItem($values->page_title);
		}elseif(!$menuparams->get('listid')){
			$pathway->addItem($values->page_title);
		}

		$document = JFactory::getDocument();
		acymailing_setPageTitle($values->page_title);

		$this->addFeed();

		$db = JFactory::getDBO();

		$pageInfo->filter->order->value = $app->getUserStateFromRequest( $paramBase.".filter_order", 'filter_order', $access->frontEndManagement ? 'a.mailid' : 'a.senddate','cmd' );

		$searchMap = array('a.mailid','a.subject','a.alias');
		$filters = array();
		if(!empty($pageInfo->search)){
			$searchVal = '\'%'.acymailing_getEscaped($pageInfo->search,true).'%\'';
			$filters[] = implode(" LIKE $searchVal OR ",$searchMap)." LIKE $searchVal";
		}

		$filters[] = 'a.type = \'news\'';
		if(!$access->frontEndManagement){
			$filters[] = 'a.published = 1';
			$filters[] = 'a.visible = 1';
		}
		$filters[] = 'c.listid = '.$oneList->listid;

		$selection = array_merge($searchMap,array('a.senddate','a.created','a.visible','a.published','a.fromname','a.fromemail','a.replyname','a.replyemail','a.userid','a.summary','a.thumb'));

		$query = 'SELECT "" AS body, "" AS altbody, html AS sendHTML, '.implode(',',$selection);
		$query .= ' FROM '.acymailing_table('listmail').' as c';
		$query .= ' JOIN '.acymailing_table('mail').' as a on a.mailid = c.mailid ';
		$query .= ' WHERE ('.implode(') AND (',$filters).')';
		$query .= ' ORDER BY '.acymailing_secureField($pageInfo->filter->order->value).' '.acymailing_secureField($pageInfo->filter->order->dir).', c.mailid DESC';

		$db->setQuery($query,$pageInfo->limit->start,$pageInfo->limit->value);
		$rows = $db->loadObjectList();
		$pageInfo->elements->page = count($rows);

		if($pageInfo->limit->value > $pageInfo->elements->page){
			$pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page;
		}else{
			$queryCount = 'SELECT COUNT(c.mailid) FROM '.acymailing_table('listmail').' as c';
			$queryCount .= ' JOIN '.acymailing_table('mail').' as a on a.mailid = c.mailid ';
			$queryCount .= ' WHERE ('.implode(') AND (',$filters).')';
			$db->setQuery($queryCount);
			$pageInfo->elements->total = $db->loadResult();
		}

		if(!empty($my->email)){
			$userClass = acymailing_get('class.subscriber');
			$receiver = $userClass->get($my->email);
		}
		if(empty($receiver)){
			$receiver = new stdClass();
			$receiver->name = JText::_('VISITOR');
		}
		JPluginHelper::importPlugin('acymailing');
		$dispatcher = JDispatcher::getInstance();
		foreach($rows as $mail){
			if(strpos($mail->subject, "{") !== false){
				$dispatcher->trigger('acymailing_replacetags',array(&$mail, false));
				$dispatcher->trigger('acymailing_replaceusertags',array(&$mail,&$receiver, false));
			}
		}

		jimport('joomla.html.pagination');
		$pagination = new JPagination( $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value );

	$js = 'function tableOrdering( order, dir, task ){
			var form = document.adminForm;

			form.filter_order.value 	= order;
			form.filter_order_Dir.value	= dir;
			document.adminForm.submit( task );
		}

		function changeReceiveEmail(checkedbox){
			var form = document.adminForm;
			if(checkedbox){
				form.nbreceiveemail.value++;
			}else{
				form.nbreceiveemail.value--;
			}

			if(form.nbreceiveemail.value > 0 ){
				document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_visible\';
			}else{
				document.getElementById(\'receiveemailbox\').className = \'receiveemailbox receiveemailbox_hidden\';
			}
		}
		';


		$doc = JFactory::getDocument();
		$doc->addScriptDeclaration( $js);


		$this->assignRef('access',$access);
		$this->assignRef('rows',$rows);
		$this->assignRef('values',$values);
		$this->assignRef('list',$oneList);
		$this->assignRef('pagination',$pagination);
		$this->assignRef('pageInfo',$pageInfo);
		$this->assignRef('config',$config);
		$this->assignRef('my',$my);

	}
예제 #28
0
 function saveForm()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config =& acymailing_config();
     $mail = new stdClass();
     $mail->mailid = acymailing_getCID('mailid');
     $formData = JRequest::getVar('data', array(), '', 'array');
     foreach ($formData['mail'] as $column => $value) {
         if ($app->isAdmin() or in_array($column, $this->allowedFields)) {
             acymailing_secureField($column);
             if ($column == 'params') {
                 $mail->{$column} = $value;
             } else {
                 $mail->{$column} = strip_tags($value, '<ADV>');
             }
         }
     }
     $mail->body = JRequest::getVar('editor_body', '', '', 'string', JREQUEST_ALLOWRAW);
     $acypluginsHelper = acymailing_get('helper.acyplugins');
     $acypluginsHelper->cleanHtml($mail->body);
     $mail->attach = array();
     $attachments = JRequest::getVar('attachments', array(), 'files', 'array');
     if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) {
         jimport('joomla.filesystem.file');
         $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder')));
         $uploadFolder = trim($uploadFolder, DS . ' ') . DS;
         $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder);
         acymailing_createDir($uploadPath, true);
         if (!is_writable($uploadPath)) {
             @chmod($uploadPath, '0755');
             if (!is_writable($uploadPath)) {
                 $app->enqueueMessage(JText::sprintf('WRITABLE_FOLDER', $uploadPath), 'notice');
             }
         }
         foreach ($attachments['name'] as $id => $filename) {
             if (empty($filename)) {
                 continue;
             }
             $attachment = new stdClass();
             $attachment->filename = strtolower(JFile::makeSafe($filename));
             $attachment->size = $attachments['size'][$id];
             if (!preg_match('#\\.(' . str_replace(array(',', '.'), array('|', '\\.'), $config->get('allowedfiles')) . ')$#Ui', $attachment->filename, $extension) || preg_match('#\\.(php.?|.?htm.?|pl|py|jsp|asp|sh|cgi)#Ui', $attachment->filename)) {
                 $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', substr($attachment->filename, strrpos($attachment->filename, '.') + 1), $config->get('allowedfiles')), 'notice');
                 continue;
             }
             $attachment->filename = str_replace(array('.', ' '), '_', substr($attachment->filename, 0, strpos($attachment->filename, $extension[0]))) . $extension[0];
             if (!JFile::upload($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
                 if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) {
                     $app->enqueueMessage(JText::sprintf('FAIL_UPLOAD', '<b><i>' . $attachments['tmp_name'][$id] . '</i></b>', '<b><i>' . $uploadPath . $attachment->filename . '</i></b>'), 'error');
                     continue;
                 }
             }
             $mail->attach[] = $attachment;
         }
     }
     if (isset($mail->filter)) {
         $mail->filter = array();
         $filterData = JRequest::getVar('filter');
         foreach ($filterData['type'] as $num => $oneType) {
             if (empty($oneType)) {
                 continue;
             }
             $mail->filter['type'][$num] = $oneType;
             $mail->filter[$num][$oneType] = $filterData[$num][$oneType];
         }
     }
     $toggleHelper = acymailing_get('helper.toggle');
     if (!empty($mail->type) && $mail->type == 'followup' && !empty($mail->mailid)) {
         $oldMail = $this->get($mail->mailid);
         if (!empty($mail->published) and !$oldMail->published) {
             $this->_publishfollowup($mail);
         }
         if ($oldMail->senddate != $mail->senddate) {
             $text = JText::_('FOLLOWUP_CHANGED_DELAY_INFORMED');
             $text .= ' ' . $toggleHelper->toggleText('update', $mail->mailid, 'followup', JText::_('FOLLOWUP_CHANGED_DELAY'));
             $app->enqueueMessage($text, 'notice');
         }
     }
     if (preg_match('#<a[^>]*subid=[0-9].*</a>#Uis', $mail->body, $pregResult)) {
         $app->enqueueMessage('There is a personal link in your Newsletter ( ' . $pregResult[0] . ' ) instead of a tag...<br/>Please make sure to not copy/paste the link you received in your e-mail as it may break your unsubscribe or confirmation links.<br/>Use our tags instead!', 'notice');
     }
     $mailid = $this->save($mail);
     if (!$mailid) {
         return false;
     }
     JRequest::setVar('mailid', $mailid);
     $status = true;
     if (!empty($formData['listmail'])) {
         $receivers = array();
         $remove = array();
         foreach ($formData['listmail'] as $listid => $receiveme) {
             if (!empty($receiveme)) {
                 $receivers[] = $listid;
             } else {
                 $remove[] = $listid;
             }
         }
         $listMailClass = acymailing_get('class.listmail');
         $status = $listMailClass->save($mailid, $receivers, $remove);
     }
     if (!empty($mail->type) && $mail->type == 'followup' && empty($mail->mailid) && !empty($mail->published)) {
         $mail->mailid = $mailid;
         $this->_publishfollowup($mail);
     }
     return $status;
 }
예제 #29
0
 function doexport()
 {
     if (!$this->isAllowed('subscriber', 'export')) {
         return;
     }
     JRequest::checkToken() or die('Invalid Token');
     acymailing_increasePerf();
     $filtersExport = JRequest::getVar('exportfilter');
     $listsToExport = JRequest::getVar('exportlists');
     $fieldsToExport = JRequest::getVar('exportdata');
     $fieldsToExportList = JRequest::getVar('exportdatalist');
     $fieldsToExportOthers = JRequest::getVar('exportdataother');
     $inseparator = JRequest::getString('exportseparator');
     $inseparator = str_replace(array('semicolon', 'colon', 'comma'), array(';', ',', ','), $inseparator);
     $exportFormat = JRequest::getString('exportformat');
     if (!in_array($inseparator, array(',', ';'))) {
         $inseparator = ';';
     }
     $exportLists = array();
     if (!empty($filtersExport['subscribed'])) {
         foreach ($listsToExport as $listid => $checked) {
             if (!empty($checked)) {
                 $exportLists[] = (int) $listid;
             }
         }
     }
     $exportFields = array();
     $exportFieldsList = array();
     $exportFieldsOthers = array();
     $selectOthers = '';
     foreach ($fieldsToExport as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFields[] = acymailing_secureField($fieldName);
         }
     }
     foreach ($fieldsToExportList as $fieldName => $checked) {
         if (!empty($checked)) {
             $exportFieldsList[] = acymailing_secureField($fieldName);
         }
     }
     if (!empty($fieldsToExportOthers)) {
         foreach ($fieldsToExportOthers as $fieldName => $checked) {
             if (!empty($checked)) {
                 $exportFieldsOthers[] = acymailing_secureField($fieldName);
             }
         }
     }
     $selectFields = 's.`' . implode('`, s.`', $exportFields) . '`';
     $config = acymailing_config();
     $newConfig = new stdClass();
     $newConfig->export_fields = implode(',', array_merge($exportFields, $exportFieldsOthers, $exportFieldsList));
     $newConfig->export_lists = implode(',', $exportLists);
     $newConfig->export_separator = JRequest::getString('exportseparator');
     $newConfig->export_format = $exportFormat;
     $filterActive = array();
     foreach ($filtersExport as $filterKey => $value) {
         if ($value == 1) {
             $filterActive[] = $filterKey;
         }
     }
     $newConfig->export_filters = implode(',', $filterActive);
     $config->save($newConfig);
     $where = array();
     if (empty($exportLists)) {
         $querySelect = 'SELECT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('subscriber') . ' as s';
     } else {
         $querySelect = 'SELECT DISTINCT s.`subid`, ' . $selectFields . ' FROM ' . acymailing_table('listsub') . ' as a JOIN ' . acymailing_table('subscriber') . ' as s on a.subid = s.subid';
         $where[] = 'a.listid IN (' . implode(',', $exportLists) . ')';
         $where[] = 'a.status = 1';
     }
     if (!empty($filtersExport['confirmed'])) {
         $where[] = 's.confirmed = 1';
     }
     if (!empty($filtersExport['registered'])) {
         $where[] = 's.userid > 0';
     }
     if (!empty($filtersExport['enabled'])) {
         $where[] = 's.enabled = 1';
     }
     if (JRequest::getInt('sessionvalues') and !empty($_SESSION['acymailing']['exportusers'])) {
         $where[] = 's.subid IN (' . implode(',', $_SESSION['acymailing']['exportusers']) . ')';
     }
     $query = $querySelect;
     if (!empty($where)) {
         $query .= ' WHERE (' . implode(') AND (', $where) . ')';
     }
     if (JRequest::getInt('sessionquery')) {
         $currentSession = JFactory::getSession();
         $selectOthers = '';
         if (!empty($exportFieldsOthers)) {
             foreach ($exportFieldsOthers as $oneField) {
                 $selectOthers .= ' , ' . $oneField . ' AS ' . str_replace('.', '_', $oneField);
             }
         }
         $query = 'SELECT DISTINCT s.`subid`, ' . $selectFields . $selectOthers . ' ' . $currentSession->get('acyexportquery');
     }
     $query .= ' ORDER BY s.subid';
     $db = JFactory::getDBO();
     $encodingClass = acymailing_get('helper.encoding');
     $exportHelper = acymailing_get('helper.export');
     $fileName = 'export_' . date('Y-m-d');
     if (!empty($exportLists)) {
         $fileName = '';
         $db->setQuery('SELECT name FROM #__acymailing_list WHERE listid IN (' . implode(',', $exportLists) . ')');
         $allExportedLists = $db->loadObjectList();
         foreach ($allExportedLists as $oneList) {
             $fileName .= '__' . $oneList->name;
         }
         $fileName = trim($fileName, '__');
     }
     $exportHelper->addHeaders($fileName);
     $eol = "\r\n";
     $before = '"';
     $separator = '"' . $inseparator . '"';
     $after = '"';
     $allFields = array_merge($exportFields, $exportFieldsOthers);
     if (!empty($exportFieldsList)) {
         $allFields = array_merge($allFields, $exportFieldsList);
         $selectFields = 'l.`' . implode('`, l.`', $exportFieldsList) . '`';
         $selectFields = str_replace('listname', 'name', $selectFields);
     }
     echo $before . implode($separator, $allFields) . $after . $eol;
     if (acymailing_bytes(ini_get('memory_limit')) > 150000000) {
         $nbExport = 50000;
     } elseif (acymailing_bytes(ini_get('memory_limit')) > 80000000) {
         $nbExport = 15000;
     } else {
         $nbExport = 5000;
     }
     if (!empty($exportFieldsList)) {
         $nbExport = 500;
     }
     $valDep = 0;
     $dateFields = array('created', 'confirmed_date', 'lastopen_date', 'lastclick_date', 'lastsent_date', 'userstats_opendate', 'userstats_senddate', 'urlclick_date', 'hist_date');
     do {
         $db->setQuery($query . ' LIMIT ' . $valDep . ', ' . $nbExport);
         $valDep += $nbExport;
         $allData = $db->loadAssocList();
         if (empty($allData)) {
             break;
         }
         $dataUser = array();
         $subids = array();
         for ($i = 0, $a = count($allData); $i < $a; $i++) {
             $subids[] = (int) $allData[$i]['subid'];
             if (!in_array('subid', $exportFields)) {
                 array_shift($allData[$i]);
             }
             foreach ($allData[$i] as $fieldName => $oneUser) {
                 if (!in_array($fieldName, $dateFields)) {
                     $dataUser[$subids[$i]][$fieldName] = $oneUser;
                 } else {
                     $dataUser[$subids[$i]][$fieldName] = acymailing_getDate($oneUser, '%Y-%m-%d %H:%M:%S');
                 }
             }
         }
         if (!empty($exportFieldsList) && !empty($subids)) {
             $queryList = 'SELECT ' . $selectFields . ', ls.subid FROM #__acymailing_listsub as ls JOIN #__acymailing_list as l ON ls.listid=l.listid JOIN #__acymailing_subscriber as s on ls.subid = s.subid WHERE (ls.status = 1) and ls.subid IN (' . implode(',', $subids) . ')';
             if (!empty($exportLists)) {
                 $queryList .= ' AND ls.listid IN (' . implode(',', $exportLists) . ')';
             }
             $db->setQuery($queryList);
             $resList = $db->loadObjectList();
             $userListid = array();
             $userListname = array();
             foreach ($resList as $listsub) {
                 if (in_array('listid', $exportFieldsList)) {
                     $userListid[$listsub->subid] = empty($userListid[$listsub->subid]) ? $listsub->listid : $userListid[$listsub->subid] . ' - ' . $listsub->listid;
                 }
                 if (in_array('listname', $exportFieldsList)) {
                     $userListname[$listsub->subid] = empty($userListname[$listsub->subid]) ? $listsub->name : $userListname[$listsub->subid] . ' - ' . $listsub->name;
                 }
             }
         }
         foreach ($subids as $subid) {
             if (!empty($exportFieldsList)) {
                 $listDetail = array();
                 if (in_array('listid', $exportFieldsList)) {
                     $listDetail[] = !empty($userListid[$subid]) ? $userListid[$subid] : '';
                 }
                 if (in_array('listname', $exportFieldsList)) {
                     $listDetail[] = !empty($userListname[$subid]) ? $userListname[$subid] : '';
                 }
                 $dataexport = implode($separator, $dataUser[$subid]) . $separator . implode($separator, $listDetail);
             } else {
                 $dataexport = implode($separator, $dataUser[$subid]);
             }
             echo $before . $encodingClass->change($dataexport, 'UTF-8', $exportFormat) . $after . $eol;
         }
     } while (!empty($allData));
     exit;
 }
예제 #30
0
    function listing()
    {
        global $Itemid;
        $app =& JFactory::getApplication();
        $my =& JFactory::getUser();
        $pathway =& $app->getPathway();
        $values = null;
        $menus =& JSite::getMenu();
        $menu = $menus->getActive();
        $config = acymailing_config();
        if (empty($menu) and !empty($Itemid)) {
            $menus->setActive($Itemid);
            $menu = $menus->getItem($Itemid);
        }
        $myItem = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
        $this->assignRef('item', $myItem);
        if (is_object($menu)) {
            jimport('joomla.html.parameter');
            $menuparams = new JParameter($menu->params);
        }
        $pageInfo = null;
        $paramBase = ACYMAILING_COMPONENT . '.' . $this->getName();
        $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . ".filter_order", 'filter_order', 'a.senddate', 'cmd');
        $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
        $pageInfo->search = $app->getUserStateFromRequest($paramBase . ".search", 'search', '', 'string');
        $pageInfo->search = JString::strtolower($pageInfo->search);
        $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
        $pageInfo->limit->start = JRequest::getInt('limitstart', 0);
        $listClass = acymailing_get('class.list');
        $listid = acymailing_getCID('listid');
        if (empty($listid) and !empty($menuparams)) {
            $listid = $menuparams->get('listid');
        }
        if (empty($listid) and acymailing_level(3)) {
            $listClass = acymailing_get('class.list');
            $allAllowedLists = $listClass->getFrontendLists();
            if (!empty($allAllowedLists)) {
                $firstList = reset($allAllowedLists);
                $listid = $firstList->listid;
                JRequest::setVar('listid', $listid);
            }
        }
        if (empty($listid)) {
            return JError::raiseError(404, 'Mailing List not found');
        }
        $oneList = $listClass->get($listid);
        if (empty($oneList->listid)) {
            return JError::raiseError(404, 'Mailing List not found : ' . $listid);
        }
        $access = null;
        $access->frontEndManament = false;
        $access->frontEndAccess = true;
        if (!$access->frontEndManament and (!$oneList->published or !$oneList->visible or !$access->frontEndAccess)) {
            if (empty($my->id)) {
                $uri = JFactory::getURI();
                $url = 'index.php?option=com_user&view=login';
                $url .= '&return=' . base64_encode($uri->toString());
                $app->redirect($url, JText::_('ACY_NOTALLOWED'));
                return false;
            } else {
                $app->enqueueMessage(JText::_('ACY_NOTALLOWED'), 'error');
                $app->redirect(acymailing_completeLink('lists', false, true));
                return false;
            }
        }
        if ($config->get('open_popup')) {
            JHTML::_('behavior.modal', 'a.modal');
        }
        if (!empty($menuparams)) {
            $values->suffix = $menuparams->get('pageclass_sfx', '');
            $values->page_title = $menuparams->get('page_title');
            $values->show_page_title = $menuparams->get('show_page_title', 1);
        } else {
            $values->suffix = '';
            $values->show_page_title = 1;
        }
        $values->show_description = $config->get('show_description', 1);
        $values->show_headings = $config->get('show_headings', 1);
        $values->show_senddate = $config->get('show_senddate', 1);
        $values->filter = $config->get('show_filter', 1);
        if (empty($values->page_title)) {
            $values->page_title = $oneList->name;
        }
        if (empty($menuparams)) {
            $pathway->addItem(JText::_('MAILING_LISTS'), acymailing_completeLink('lists'));
            $pathway->addItem($values->page_title);
        } else {
            $pathway->addItem($values->page_title);
        }
        $document =& JFactory::getDocument();
        $document->setTitle($values->page_title);
        $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);
        }
        $db =& JFactory::getDBO();
        $searchMap = array('a.mailid', 'a.subject', 'a.alias');
        $filters = array();
        if (!empty($pageInfo->search)) {
            $searchVal = '\'%' . $db->getEscaped($pageInfo->search, true) . '%\'';
            $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
        }
        $filters[] = 'a.type = \'news\'';
        if (!$access->frontEndManament) {
            $filters[] = 'a.published = 1';
            $filters[] = 'a.visible = 1';
        }
        $filters[] = 'c.listid = ' . $oneList->listid;
        $selection = array_merge($searchMap, array('a.senddate', 'a.created', 'a.visible', 'a.published', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid'));
        $query = 'SELECT ' . implode(',', $selection);
        $query .= ' FROM ' . acymailing_table('listmail') . ' as c';
        $query .= ' LEFT JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid ';
        $query .= ' WHERE (' . implode(') AND (', $filters) . ')';
        $query .= ' ORDER BY ' . acymailing_secureField($pageInfo->filter->order->value) . ' ' . acymailing_secureField($pageInfo->filter->order->dir) . ', c.mailid DESC';
        $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value);
        $rows = $db->loadObjectList();
        $pageInfo->elements->page = count($rows);
        if (!empty($pageInfo->search)) {
            $rows = acymailing_search($pageInfo->search, $rows);
        }
        if ($pageInfo->limit->value > $pageInfo->elements->page) {
            $pageInfo->elements->total = $pageInfo->limit->start + $pageInfo->elements->page;
        } else {
            $queryCount = 'SELECT COUNT(c.mailid) FROM ' . acymailing_table('listmail') . ' as c';
            $queryCount .= ' LEFT JOIN ' . acymailing_table('mail') . ' as a on a.mailid = c.mailid ';
            $queryCount .= ' WHERE (' . implode(') AND (', $filters) . ')';
            $db->setQuery($queryCount);
            $pageInfo->elements->total = $db->loadResult();
        }
        jimport('joomla.html.pagination');
        $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
        $js = 'function tableOrdering( order, dir, task ){
		var form = document.adminForm;
		form.filter_order.value 	= order;
		form.filter_order_Dir.value	= dir;
		document.adminForm.submit( task );
	}';
        $doc =& JFactory::getDocument();
        $doc->addScriptDeclaration($js);
        $this->assignRef('access', $access);
        $this->assignRef('rows', $rows);
        $this->assignRef('values', $values);
        $this->assignRef('list', $oneList);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('pageInfo', $pageInfo);
        $this->assignRef('config', $config);
        $this->assignRef('my', $my);
    }