function saveForm() { $app =& JFactory::getApplication(); $template = null; $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')) { $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,10})#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>'; } } $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; }
function saveForm() { $object = null; $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(){\r\r\n\t\t\t\tvar allLinks = window.parent.document.getElements('a[id^=urlink_" . $urlid . "_]');\r\r\n\t\t\t\ti=0;\r\r\n\t\t\t\twhile(allLinks[i]){\r\r\n\t\t\t\t\tallLinks[i].innerHTML = '" . str_replace(array("'", '"'), array("'", '"'), $object->name) . "';\r\r\n\t\t\t\t\ti++;\r\r\n\t\t\t\t}\r\r\n\t\t\t\twindow.parent.document.getElementById('sbox-window').close();\r\r\n\t\t\t\t})"; $doc =& JFactory::getDocument(); $doc->addScriptDeclaration($js); return true; }
function saveForm() { $app =& JFactory::getApplication(); $list = null; $list->listid = acymailing::getCID('listid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['list'] as $column => $value) { if ($app->isAdmin() or $this->allowedField('list', $column)) { acymailing::secureField($column); $list->{$column} = strip_tags($value); } } $list->description = JRequest::getVar('editor_description', '', '', 'string', JREQUEST_ALLOWRAW); $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; }
function saveForm() { $app =& JFactory::getApplication(); $mail = null; $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); $mail->attach = array(); $attachments = JRequest::getVar('attachments', array(), 'files', 'array'); if (!empty($attachments['name'][0]) or !empty($attachments['name'][1])) { jimport('joomla.filesystem.file'); $config =& acymailing::config(); $allowedFiles = explode(',', strtolower($config->get('allowedfiles'))); $uploadFolder = JPath::clean(html_entity_decode($config->get('uploadfolder'))); $uploadFolder = trim($uploadFolder, DS . ' ') . DS; $uploadPath = JPath::clean(ACYMAILING_ROOT . $uploadFolder); if (!is_dir($uploadPath)) { jimport('joomla.filesystem.folder'); JFolder::create($uploadPath); } 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 = null; $attachment->filename = strtolower(JFile::makeSafe($filename)); $attachment->size = $attachments['size'][$id]; $attachment->extension = strtolower(substr($attachment->filename, strrpos($attachment->filename, '.') + 1)); if (!in_array($attachment->extension, $allowedFiles)) { $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $attachment->extension, $config->get('allowedfiles')), 'notice'); continue; } if (!move_uploaded_file($attachments['tmp_name'][$id], $uploadPath . $attachment->filename)) { if (!JFile::upload($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; } } $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); } return $status; }
function acymailing_generateautonews(&$email) { $return = null; $return->status = true; $return->message = ''; $time = time(); $match = '#{autovmproduct:(.*)}#Ui'; $variables = array('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; } $arguments = explode('|', $allresults[1][$i]); $allcats = explode('-', $arguments[0]); $parameter = null; for ($i = 1; $i < count($arguments); $i++) { $args = explode(':', $arguments[$i]); $arg0 = $args[0]; if (isset($args[1])) { $parameter->{$arg0} = $args[1]; } else { $parameter->{$arg0} = true; } } $selectedArea = array(); foreach ($allcats as $oneCat) { if (empty($oneCat)) { continue; } $selectedArea[] = (int) $oneCat; } $query = 'SELECT DISTINCT b.`product_id` FROM `#__vm_product_category_xref` as a LEFT JOIN `#__vm_product` as b ON a.product_id = b.product_id'; $where = array(); if ($this->params->get('stock', 0) == '1') { $where[] = 'b.product_in_stock > 0'; } if (!empty($selectedArea)) { $where[] = 'a.category_id IN (' . implode(',', $selectedArea) . ')'; } $where[] = "b.`product_publish` = 'Y'"; if (!empty($parameter->filter) and !empty($email->params['lastgenerateddate'])) { $condition = 'b.`cdate` >\'' . $email->params['lastgenerateddate'] . '\''; if ($parameter->filter == 'modify') { $condition .= ' OR b.`mdate` >\'' . $email->params['lastgenerateddate'] . '\''; } $where[] = $condition; } $query .= ' WHERE (' . implode(') AND (', $where) . ')'; if (!empty($parameter->order)) { $ordering = explode(',', $parameter->order); $query .= ' ORDER BY b.`' . acymailing::secureField($ordering[0]) . '` ' . acymailing::secureField($ordering[1]); } if (!empty($parameter->max)) { $query .= ' LIMIT ' . (int) $parameter->max; } $db->setQuery($query); $allArticles = $db->loadResultArray(); if (!empty($parameter->min) and 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 . 'autovmproduct.php')) { ob_start(); require ACYMAILING_TEMPLATE . 'plugins' . DS . 'autovmproduct.php'; $stringTag = ob_get_clean(); } else { $stringTag .= '<table>'; foreach ($allArticles as $oneArticleId) { $stringTag .= '<tr><td>'; $args = array(); $args[] = 'vmproduct:' . $oneArticleId; if (!empty($parameter->type)) { $args[] = 'type:' . $parameter->type; } if (!empty($parameter->lang)) { $args[] = 'lang:' . $parameter->lang; } $stringTag .= '{' . implode('|', $args) . '}'; $stringTag .= '</td></tr>'; } $stringTag .= '</table>'; } } $this->tags[$oneTag] = $stringTag; } } return $return; }
function listing() { global $Itemid; $app =& JFactory::getApplication(); $my =& JFactory::getUser(); $pathway =& $app->getPathway(); $values = null; $menus =& JSite::getMenu(); $menu = $menus->getActive(); if (empty($menu) and !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } if (is_object($menu)) { $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)) { 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 (acymailing::level(3)) { if (!empty($my->id) and (int) $my->id == (int) $oneList->userid) { $access->frontEndManament = true; } if (!empty($my->gid) and !empty($my->id)) { if ($oneList->access_manage == 'all' or in_array($my->gid, explode(',', $oneList->access_manage))) { $access->frontEndManament = true; } } if ($oneList->access_sub != 'all' and ($oneList->access_sub == 'none' or empty($my->gid) or empty($my->id) or !in_array($my->gid, explode(',', $oneList->access_sub)))) { $access->frontEndAccess = false; } if ($access->frontEndManament) { JHTML::_('behavior.modal', 'a.modal'); } } if (!$access->frontEndManament and (!$oneList->published or !$oneList->visible or !$access->frontEndAccess)) { return JError::raiseError(404, 'Mailing List not accessible : ' . $listid); } 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; } $config = acymailing::config(); $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); $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.visible', 'a.published', 'a.fromname', 'a.fromemail', 'a.replyname', 'a.replyemail', 'a.userid')); $query = 'SELECT SQL_CALC_FOUND_ROWS ' . 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); $db->setQuery($query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $db->loadObjectList(); if (!empty($pageInfo->search)) { $rows = acymailing::search($pageInfo->search, $rows); } $db->setQuery('SELECT FOUND_ROWS()'); $pageInfo->elements->total = $db->loadResult(); $pageInfo->elements->page = count($rows); 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); }
function saveForm() { $app =& JFactory::getApplication(); $db =& JFactory::getDBO(); $config =& acymailing::config(); $mail = null; $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]*<img[^>]*>[ \\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'); $allowedFiles = explode(',', strtolower($config->get('allowedfiles'))); $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 = null; $attachment->filename = strtolower(JFile::makeSafe($filename)); $attachment->size = $attachments['size'][$id]; $attachment->extension = strtolower(substr($attachment->filename, strrpos($attachment->filename, '.') + 1)); if (!in_array($attachment->extension, $allowedFiles)) { $app->enqueueMessage(JText::sprintf('ACCEPTED_TYPE', $attachment->extension, $config->get('allowedfiles')), 'notice'); continue; } 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; } } $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; }
function acymailing_generateautonews(&$email) { $return = null; $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; } $arguments = explode('|', strip_tags($allresults[1][$i])); $allcats = explode('-', $arguments[0]); $parameter = null; for ($i = 1; $i < count($arguments); $i++) { $args = explode(':', $arguments[$i]); $arg0 = $args[0]; if (isset($args[1])) { $parameter->{$arg0} = $args[1]; } else { $parameter->{$arg0} = true; } } $selectedArea = array(); foreach ($allcats as $oneCat) { if (version_compare(JVERSION, '1.6.0', '<')) { $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)) { $query .= 'LEFT JOIN `#__content_frontpage` as b ON a.id = b.content_id '; $where[] = 'b.content_id IS NOT NULL'; } if (!empty($selectedArea)) { if (version_compare(JVERSION, '1.6.0', '<')) { $where[] = implode(' OR ', $selectedArea); } else { $where[] = '`catid` IN (' . implode(',', $selectedArea) . ')'; } } 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 `modified` > \'' . date('Y-m-d H:i:s', $email->params['lastgenerateddate'] - date('Z')) . '\''; } $where[] = $condition; } if (!empty($parameter->meta)) { $allMetaTags = explode(',', $parameter->meta); $metaWhere = array(); foreach ($allMetaTags as $oneMeta) { if (empty($oneMeta)) { continue; } $metaWhere[] = "`metakey` LIKE '%" . $db->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 (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'; } } $query .= ' WHERE (' . implode(') AND (', $where) . ')'; if (!empty($parameter->order)) { $ordering = explode(',', $parameter->order); $query .= ' ORDER BY a.`' . acymailing::secureField($ordering[0]) . '` ' . acymailing::secureField($ordering[1]); } $start = ''; if (!empty($parameter->start)) { $start = intval($parameter->start) . ','; } if (!empty($parameter->max)) { $query .= ' LIMIT ' . $start . (int) $parameter->max; } elseif (empty($email->params['lastgenerateddate'])) { $query .= ' LIMIT ' . $start . '20'; } $db->setQuery($query); $allArticles = $db->loadResultArray(); 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 = ''; 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 { $stringTag .= '<table>'; foreach ($allArticles as $oneArticleId) { $stringTag .= '<tr><td>'; $args = array(); $args[] = 'joomlacontent:' . $oneArticleId; if (!empty($parameter->type)) { $args[] = 'type:' . $parameter->type; } if (!empty($parameter->link)) { $args[] = 'link'; } if (!empty($parameter->author)) { $args[] = 'author'; } if (!empty($parameter->lang)) { $args[] = 'lang:' . $parameter->lang; } if (!empty($parameter->notitle)) { $args[] = 'notitle'; } if (!empty($parameter->created)) { $args[] = 'created'; } 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; } $stringTag .= '{' . implode('|', $args) . '}'; $stringTag .= '</td></tr>'; } $stringTag .= '</table>'; } } $this->tags[$oneTag] = $stringTag; } } return $return; }
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('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); } $value = $this->db->Quote($value); if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) { $value = ''; } return $as . '.`' . acymailing::secureField($column) . '` ' . $operator . ' ' . $value; }
function checkFields(&$data, &$subscriber) { $app =& JFactory::getApplication(); foreach ($data as $column => $value) { $column = trim(strtolower($column)); if ($app->isAdmin() or !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' : intval($value['month'])) . '-' . (empty($value['day']) ? '00' : intval($value['day'])); } else { $value = implode(',', $value); } } $subscriber->{$column} = strip_tags($value); if (!is_numeric($subscriber->{$column}) and !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}); } } } }
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'); 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); } } $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 LEFT 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']) . ')'; } $query = $querySelect; if (!empty($where)) { $query .= ' WHERE (' . implode(') AND (', $where) . ')'; } $db =& JFactory::getDBO(); $db->setQuery($query); $allData = $db->loadAssocList(); $exportFormat = JRequest::getString('exportformat'); $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; }
function checkFields(&$data, &$subscriber) { $app =& JFactory::getApplication(); foreach ($data as $column => $value) { $column = trim(strtolower($column)); if ($app->isAdmin() or !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' : intval($value['month'])) . '-' . (empty($value['day']) ? '00' : intval($value['day'])); } else { $value = implode(',', $value); } } $subscriber->{$column} = strip_tags($value); } } }
function saveForm() { $field = null; $field->fieldid = acymailing::getCID('fieldid'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['fields'] as $column => $value) { acymailing::secureField($column); $field->{$column} = strip_tags($value); } $fieldsOptions = JRequest::getVar('fieldsoptions', array(), '', 'array'); foreach ($fieldsOptions as $column => $value) { $fieldsOptions[$column] = strip_tags($value); } $field->options = serialize($fieldsOptions); $fieldValues = JRequest::getVar('fieldvalues', array(), '', 'array'); if (!empty($fieldValues)) { $field->value = array(); foreach ($fieldValues['title'] as $i => $title) { if (strlen($title) < 1 and strlen($fieldValues['value'][$i]) < 1) { continue; } $value = strlen($fieldValues['value'][$i]) < 1 ? $title : $fieldValues['value'][$i]; $field->value[] = strip_tags($title) . '::' . strip_tags($value); } $field->value = implode("\n", $field->value); } if (empty($field->fieldid)) { if (empty($field->namekey)) { $field->namekey = $field->fieldname; } $field->namekey = preg_replace('#[^a-z0-9_\\-]#i', '', strtolower($field->namekey)); if (empty($field->namekey)) { $this->errors[] = 'Please specify a namekey'; return false; } $columnsTable = $this->database->getTableFields(acymailing::table('subscriber')); $columns = reset($columnsTable); if (isset($columns[$field->namekey])) { $this->errors[] = 'The field "' . $field->namekey . '" already exists'; return false; } $query = 'ALTER TABLE `#__acymailing_subscriber` ADD `' . $field->namekey . '` VARCHAR ( 250 ) NULL'; $this->database->setQuery($query); $this->database->query(); } $fieldid = $this->save($field); if (!$fieldid) { return false; } if (empty($field->fieldid)) { $orderClass = acymailing::get('helper.order'); $orderClass->pkey = 'fieldid'; $orderClass->table = 'fields'; $orderClass->reOrder(); } JRequest::setVar('fieldid', $fieldid); return true; }
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('IS NULL', 'IS NOT NULL', 'NOT LIKE', 'LIKE', '=', '!=', '>', '<', '>=', '<='))) { die('Operator not safe : ' . $operator); } $value = $this->db->Quote($value); if (in_array($operator, array('IS NULL', 'IS NOT NULL'))) { $value = ''; } return $as . '.`' . acymailing::secureField($column) . '` ' . $operator . ' ' . $value; }