Esempio n. 1
0
/**
* <p>Templates controller</p>
* <p>This function is the controller to view the templates view</p>
* @author Joobi Limited <wwww.joobi.co>
*/
function templates($action, $task, $template_id)
{
    $my = JFactory::getUser();
    $css = '.icon-48-templates { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/templates.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'templates.png';
    $templatesearch = JRequest::getVar('templatesearch', '');
    $showTemplates = true;
    // defined toggle for publish and unpublish of mailings
    $willRedirect = false;
    $checkToggle = false;
    $cid = JRequest::getVar('cid');
    if (empty($template_id)) {
        if (!empty($cid) && is_array($cid)) {
            $template_id = $cid[key($cid)];
        }
    } else {
        if (empty($cid)) {
            $cid[] = $template_id;
        }
    }
    if (!empty($task) && $task == 'togle') {
        $checkToggle = true;
        //		$id = JRequest::getVar( 'templateid' );
        $id = $template_id;
        $col = JRequest::getVar('col');
        $template_id = !empty($id) && !empty($col) ? $id : $template_id;
        $task = !empty($template_id) && !empty($col) ? $col : $task;
        $willRedirect = true;
    }
    switch ($task) {
        case 'new':
        case 'add':
            $showTemplates = false;
            $template = null;
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\"> \n";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            backHTML::formEnd($go);
            break;
        case 'edit':
            $showTemplates = false;
            $template = jNews_Templates::loadOneTemplate('*', $template_id);
            $form['main'] = " <form action='index.php' method='post' name='adminForm' enctype='multipart/form-data' id=\"adminForm\">";
            $message = isset($message) ? $message : '';
            backHTML::_header(_JNEWS_TEMPLATES, 'templates.png', $message, $task, $action);
            backHTML::formStart('template', 0, '');
            echo jNews_TemplatesHTML::createTemplate($template, $form);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('template_id', $template_id);
            backHTML::formEnd($go);
            break;
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'apply':
            JRequest::checkToken() or die('Invalid Token');
            $message = '';
            $message .= jnews::printYN(jNews_Templates::saveTemplate($task, $template_id), _JNEWS_TEMPLATE_SAVED, _JNEWS_ERROR);
            $id = empty($template_id) ? jNews_Templates::loadOneTemplate('template_id', '', 'template_id', 'DESC') : $template_id;
            $converMessage = JRequest::getVar('message', '', '', 'string', JREQUEST_ALLOWRAW);
            if (!empty($converMessage)) {
                $message .= '<br/>';
                $message .= implode("", $converMessage);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $id, $message);
            break;
        case 'publish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $message = jnews::printYN(jNews_Templates::updateTemplate($cid, 'published', true), 'Successfully published template!', 'Error publishing the template!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'unpublish':
            if (!$checkToggle) {
                JRequest::checkToken() or die('Invalid Token');
            }
            $condition = jNews_Templates::updateTemplate($cid, 'published', false);
            if ($condition) {
                $message = jnews::printM('ok', 'Successfully unpublished template!');
            } else {
                $message = jnews::printM('defaulterror', 'Unable to unpublished default template!');
            }
            //	   		$message = jnews::defaultYN( jNews_Templates::updateTemplate($template_id,'published', false) ,  'Successfully unpublished template!' , 'Unable to unpublished default  template!' );
            if ($willRedirect) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            }
            break;
        case 'copy':
            JRequest::checkToken() or die('Invalid Token');
            $message = jnews::printYN(jNews_Templates::copyTemplate($template_id), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_COPIED, _JNEWS_ERROR);
            $showTemplates = true;
            break;
        case 'default':
            $success = false;
            //set all the templates to premium = 0
            if (jNews_Templates::updateTemplate($template_id, 'default', false, false)) {
                $success = true;
            }
            //set the template published and premium
            if ($success) {
                jNews_Templates::updateTemplate($template_id, 'default', true, true);
            }
            $message = jnews::printYN($success, 'Successfully set the template to default!', 'Unable to set template to default!');
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates', $message);
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            $showTemplates = true;
            $isDefault = jNews_Templates::loadOneTemplate('premium', $template_id);
            if (!$isDefault) {
                $message = jnews::printYN(jNews_Templates::deleteTemplate($cid), _JNEWS_TEMPLATE . _JNEWS_SUCCESS_DELETED, _JNEWS_ERROR);
            } else {
                $message = jnews::printM('red', _JNEWS_TEMPLATE_DEFAULT_NODEL);
            }
            break;
        case 'cpanel':
            backHTML::controlPanel();
            return true;
            break;
        case 'toggle':
            JRequest::checkToken() or die('Invalid Token');
            // main toggle for all usage
            $listid = JRequest::getVar('listid');
            $column = JRequest::getVar('col');
            if (!empty($listid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_lists';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $listid;
                jnews::toggle($passObj);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates');
            break;
        case 'tempupload':
            // HTML for upload template
            //			JRequest::checkToken() or die( 'Invalid Token' );
            $html = '<form action="index.php?option=' . JNEWS_OPTION . '&act=templates&task=upload" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm">';
            $html .= '<table style="width:100%;padding:100px;">';
            $html .= '<tr>';
            $html .= '<td style="text-align:center;"> <input type="FILE" name="tempupload"> </td>';
            $html .= '</tr><tr">';
            $html .= '<td style="text-align:center;padding:20px;"> <input type="submit" value="Upload Template" style="width:130px;height:25px;"> </td>';
            $html .= '</tr>';
            $html .= '</table>';
            if (version_compare(JVERSION, '3.0.0', '<')) {
                $html .= JHTML::_('form.token');
            } else {
                $html .= JHtml::_('form.token');
            }
            $html .= '</form><br/><br/>';
            echo $html;
            $showTemplates = false;
            break;
        case 'sendtest':
            JRequest::checkToken() or die('Invalid Token');
            //we save first the template
            $saveStatus = jNews_Templates::saveTemplate($task, $template_id);
            //then we send it if the template is successfully saved
            if ($saveStatus) {
                $message = jnews::printM('ok', _JNEWS_TEMPLATE_SAVED);
                $my = JFactory::getUser();
                $mailing = new stdClass();
                $receiver = new stdClass();
                $status = false;
                $mailing->id = 1;
                $mailing->html = 1;
                $mailing->images = '';
                $mailing->attachments = '';
                $mailing->subject = jNews_Templates::loadOneTemplate('name', $template_id);
                $mailing->htmlcontent = jNews_Templates::loadOneTemplate('body', $template_id);
                $mailing->template_id = $template_id;
                $receiver->name = $my->name;
                $receiver->email = $my->email;
                $receiver->receive_html = 1;
                $receiver->user_id = $my->id;
                $mailerC = new jNews_ProcessMail();
                $sendStatus = $mailerC->send($mailing, $receiver);
                $success = 'Template ' . $mailing->subject . ' successfully sent to ' . $receiver->email;
                $error = 'There is a problem in sending the template ' . $mailing->subject . ' <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
                $message = $sendStatus ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            } else {
                //otherwise we give an error message
                $message = jnews::printM('error', _JNEWS_ERROR);
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=templates&task=edit&template_id=' . $template_id, $message);
            break;
        case 'upload':
            JRequest::checkToken() or die('Invalid Token');
            $db = JFactory::getDBO();
            $fileName = $_FILES['tempupload']['name'];
            $folderName = substr($fileName, 0, -4);
            // explode to array to compare and check if the uploaded file is a zip file
            $type = $_FILES['tempupload']['type'];
            // if zip is not found then return to previous upload page
            if (strtolower($type) != 'application/zip') {
                if (strtolower(substr($fileName, -4)) != '.zip') {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); document.location.href='index.php?option='.JNEWS_OPTION.'&act=templates';</script>";
                    } else {
                        if (version_compare(JVERSION, '3.0.0', '<')) {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "'); window.parent.SqueezeBox.close();</script>";
                        } else {
                            echo "<script> alert('" . addslashes(_JNEWS_UPLOAD_ZIP_INVALID) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                        }
                    }
                    break;
                }
            }
            $result = jNews_Templates::uploadTemplate();
            if ($result) {
                // if success
                // read index.html of file for template body content
                $tempPath = JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'media' . DS . JNEWS_OPTION . DS . 'templates' . DS;
                $file = fopen($tempPath . $folderName . DS . 'index.html', "r") or exit("Unable to open file!");
                $tempbody = array();
                while (!feof($file)) {
                    $tempbody[] = fgets($file);
                }
                //endwhile
                fclose($file);
                $tempbody = implode(' ', $tempbody);
                $standardCSSA = array();
                $extraCSSStyles = '';
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package with style.css file
                    //we get here the css codes from the uploaded template
                    $cssfile = fopen($tempPath . $folderName . DS . 'css' . DS . 'style.css', "r") or exit("Unable to open file!");
                    $cssstyle = array();
                    while (!feof($cssfile)) {
                        $cssstyle[] = fgets($cssfile);
                    }
                    //endwhile
                    fclose($cssfile);
                    $cssstyle = implode(' ', $cssstyle);
                    $cleanCSSstyle = jNews_Templates::cleanCSSComments($cssstyle);
                    //cleancsscomments
                    @(require_once JNEWSPATH_CLASS . 'class.cssinlinestyles.php');
                    if (class_exists('CSSToInlineStyles')) {
                        $newCSSProcess = new CSSToInlineStyles();
                        $newCSSProcess->setCSS($cleanCSSstyle);
                        $newCSSProcess->processCSS();
                        //we define the predefined selectors for the css
                        $standardSelectorsA = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'ul', 'li', '.unsubscribe', '.subscriptions', '.content', '.title', '.readmore', '.online', '.aca_content', '.aca_title', '.aca_readmore', '.aca_online', '.aca_subscribe', '.aca_unsubscribe', '.aca_subscriptions');
                        $standardCSSA = $newCSSProcess->getStandardCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                        $extraCSSStyles = $newCSSProcess->getExtraCSSTag($newCSSProcess->cssRules, $standardSelectorsA);
                    }
                }
                // replace source image paths from 'images/' to 'media/.../templates/$FOLDERNAME/'
                $bodyImgA = JRequest::getVar('bodyImg');
                if (is_file($tempPath . $folderName . DS . 'css' . DS . 'style.css')) {
                    //new template package
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/' . $folderName .'/images/', $tempbody);
                    $origin = '"images/';
                    $destination = '"' . JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/images/';
                    $body = str_replace($origin, $destination, $tempbody);
                } else {
                    //					$body = preg_replace('#images\/#', JNEWS_JPATH_LIVE . '/media/'. JNEWS_OPTION . '/templates/'. $folderName.'/' , $tempbody);
                    $origin = 'media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $destination = JNEWS_JPATH_LIVE . '/media/' . JNEWS_OPTION . '/templates/' . $folderName . '/';
                    $body = str_replace($origin, $destination, $tempbody);
                }
                $template = null;
                $template->name = ucfirst($folderName);
                $template->description = '';
                $template->created = time();
                $template->body = addslashes($body);
                $template->altbody = '';
                $template->premium = 0;
                $template->namekey = $folderName;
                $template->published = 1;
                $template->styles = addslashes(serialize($standardCSSA));
                $template->csstyle = addslashes($extraCSSStyles);
                $template->thumbnail = '';
                $templateA = (array) $template;
                $query = 'SELECT * FROM `#__jnews_templates` WHERE `namekey` = \'' . $template->namekey . '\' ';
                $db->setQuery($query);
                $findresult = $db->loadObject();
                if (empty($findresult)) {
                    // store template
                    $status = jNews_Templates::storeTemplate($templateA);
                } else {
                    //update template
                    $query = 'UPDATE `#__jnews_templates` SET `body` = \'' . $template->body . '\' , `availability` = 1 WHERE `namekey`= \'' . $template->namekey . '\'  AND `template_id`=' . $findresult->template_id;
                    $db->setQuery($query);
                    $status = $db->query();
                }
                // upload success
                // display success message
                if ($status) {
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //j15
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                    } else {
                        //j16
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_SUCCESS) . "'); window.parent.location.reload();</script>";
                    }
                }
            } else {
                // failed uploading
                // display an error message
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); document.location.href='index.php?option=" . JNEWS_OPTION . "&act=templates';</script>";
                } else {
                    if (version_compare(JVERSION, '3.0.0', '<')) {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "'); window.parent.SqueezeBox.close();</script>";
                    } else {
                        echo "<script> alert('" . addslashes(_JNEWS_TEMPLATE_UPLOAD_FAIL) . "');   jQuery(window.top.document).find(\"div.modal-backdrop\").click(); </script>";
                    }
                }
            }
            $showTemplates = false;
            break;
        case 'preview':
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
            $id = JRequest::getInt('template_id', 0, 'request');
            $body = jNews_Templates::loadOneTemplate('body', $id);
            jNews_Templates::includeStyles($body, $id);
            jNews_TemplatesHTML::previewTemplate($body, $forms);
            $showTemplates = false;
            break;
        case 'assign':
            $templatesearch = JRequest::getVar('templatesearch', '');
            $linkTh = jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true);
            $forms['main'] = "<form action=" . $linkTh . " method='post' name='adminForm' id=\"adminForm\">";
            $paginationStart = JRequest::getVar('pg');
            if (!empty($paginationStart)) {
                $limitstart = 0;
                $limitend = $paginationStart;
            } else {
                $app = JFactory::getApplication();
                $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
                $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
            }
            $limittotal = jNews_Templates::countTemplates(1, 1);
            $setLimit = new stdClass();
            $setLimit->total = !empty($limittotal) ? $limittotal : 0;
            $setLimit->start = !empty($limitstart) ? $limitstart : 0;
            $setLimit->end = !empty($limitend) ? $limitend : 20;
            $templates = jNews_Templates::getTemplates(true, false, $templatesearch, $setLimit->start, $setLimit->end, null, 1);
            //first param to true to show only the published
            jNews_TemplatesHTML::assignTemplate($templates, $forms, $setLimit, $templatesearch);
            $showTemplates = false;
            break;
    }
    if ($showTemplates) {
        $start = JRequest::getVar('start', '0');
        $templatesearch = JRequest::getVar('templatesearch', '');
        $limit = -1;
        $message = isset($message) ? $message : '';
        backHTML::_header(_JNEWS_TEMPLATES, $img, $message, $task, $action);
        $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
        $forms['filter'] = " <form name='jnewsFilterForm' method='POST' action='index.php'> \n";
        backHTML::formStart('show_template', '', '');
        // added this code for pagination ===========================
        $paginationStart = JRequest::getVar('pg');
        $app = JFactory::getApplication();
        if (!empty($paginationStart)) {
            $limitstart = 0;
            $limitend = $paginationStart;
        } else {
            $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
            $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        }
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order', 'filter_order', 'premium', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.templates.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
        $limittotal = jNews_Templates::countTemplates();
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : $limittotal;
        // recheck start
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $templates = jNews_Templates::getTemplates(false, false, $templatesearch, $setLimit->start, $setLimit->end, $setSort);
        //recheck limit total [pagination]
        if (isset($setLimit->total) && !empty($templatesearch)) {
            $setLimit->total = !empty($temps) ? count($templates) : $setLimit->total;
        }
        jNews_TemplatesHTML::displayTemplateList($templates, $forms, $setLimit->start, $setLimit->end, $templatesearch, $action, $setLimit, $setSort);
        $go[] = jnews::makeObj('act', 'templates');
        $go[] = jnews::makeObj('filter_order', $setSort->orderValue);
        $go[] = jnews::makeObj('filter_order_Dir', $setSort->orderDir);
        backHTML::formEnd($go);
    }
    return true;
}
Esempio n. 2
0
 public static function importBis()
 {
     @set_time_limit(0);
     $returnMessage = '';
     //If memory_limit less than 128M
     $limit = jnews::convertToBytes(@ini_get('memory_limit'));
     if ($limit < jnews::convertToBytes('128M')) {
         @ini_set('memory_limit', '128M');
     }
     $allAvailableListsA = JRequest::getVar('sub_list_id', '');
     $list2SubcribeToA = JRequest::getVar('subscribed', '');
     $filename = $_FILES['importfile']['name'];
     if (!empty($filename)) {
         //if we import a file
         //the flag is true coz we add subscribers in frontend through rows
         $saveSubsInRows = true;
         $path = JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'];
         $path = str_replace(array('/', '\\'), DS, $path);
         if (!is_writable($path)) {
             $returnMessage .= '<br/>The file could not be imported because the folder is not writable.';
             $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable';
             return $returnMessage;
         }
         if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) {
             $path .= DS;
             if (!@move_uploaded_file($_FILES['importfile']['tmp_name'], $path . $filename)) {
                 $returnMessage .= _JNEWS_ERROR_MOVING_UPLOAD;
                 $returnMessage .= '<br/>Please make sure the path "' . JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url'] . '" is writable';
                 return $returnMessage;
             }
         }
         $import = file_get_contents($path . $filename);
         $import = str_replace(array("\r\n", "\r"), "\n", $import);
         $allLinesA = explode("\n", $import);
     } else {
         //if we add subscribers in frontend through rows
         //the flag is true coz we add subscribers in frontend through rows
         $saveSubsInRows = true;
         //we get the number of rows
         $rows = JRequest::getVar('count', '');
         $nRows = intval($rows) - 1;
         if ($nRows == 0) {
             $nRows = intval($GLOBALS[JNEWS . 'create_newsubsrows']);
         }
         //we get the value of each element from the rows
         for ($count = 1; $count <= $nRows; $count++) {
             $allLinesA[$count] = JRequest::getVar('name' . $count, '') . ', ' . JRequest::getVar('email' . $count, '') . ', ' . JRequest::getVar('receive_html' . $count, '') . ', ' . JRequest::getVar('confirmed' . $count, '') . ', ' . JRequest::getVar('column1' . $count, '') . ', ' . JRequest::getVar('column2' . $count, '') . ', ' . JRequest::getVar('column3' . $count, '') . ', ' . JRequest::getVar('column4' . $count, '') . ', ' . JRequest::getVar('column5' . $count, '');
         }
     }
     if (empty($allLinesA)) {
         return false;
     }
     $db = JFactory::getDBO();
     $insertQuery = '';
     $selectQuery = '';
     $firstValue = true;
     $time = time();
     $totalInsert = 0;
     $allSubscribersIDA = array();
     foreach ($allLinesA as $line) {
         $line = trim($line);
         if (empty($line)) {
             continue;
         }
         $line = str_replace(';', ',', $line);
         $subscriberA = explode(',', $line);
         $email = trim($subscriberA[1], ' "\'');
         if (!jNews_Subscribers::validEmail($email)) {
             if (!$saveSubsInRows) {
                 //if import of file is done
                 echo '<br />' . jnews::printM('red', _JNEWS_EMAIL_INVALID . ': ' . $email);
                 continue;
             } else {
                 continue;
             }
         }
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             $column4 = !empty($subscriberA[4]) ? mysql_escape_string(trim($subscriberA[4], '"')) : '';
             $column5 = !empty($subscriberA[5]) ? mysql_escape_string(trim($subscriberA[5], '"')) : '';
             $column6 = !empty($subscriberA[6]) ? mysql_escape_string(trim($subscriberA[6], '"')) : '';
             $column7 = !empty($subscriberA[7]) ? mysql_escape_string(trim($subscriberA[7], '"')) : '';
             $column8 = !empty($subscriberA[8]) ? mysql_escape_string(trim($subscriberA[8], '"')) : '';
             $ip = !empty($subscriberA[9]) ? mysql_escape_string(trim($subscriberA[9], '"')) : '';
         }
         $comfirmation = $GLOBALS[JNEWS . 'require_confirmation'] ? 0 : (int) trim($subscriberA[3], ' "\'');
         // i need to know if exist user
         $db = JFactory::getDBO();
         $quer = "SELECT id FROM `#__jnews_subscribers` WHERE `email` = '{$email}'";
         $db->setQuery($quer);
         $res = $db->loadResult();
         if ($res) {
             //i need to update
             $isResiveHtml = (int) trim($subscriberA[2], ' "\'');
             $querUpdate = "UPDATE `#__jnews_subscribers` SET confirmed = '{$comfirmation}', receive_html= '{$isResiveHtml}',column1 = '{$column4}', column2 = '{$column5}', column3 = '{$column5}', column4 = '{$column7}', column5= '{$column8}',ip = '{$ip}' WHERE `email` = '{$email}'";
             $db->setQuery($querUpdate);
             $db->query();
             if (!empty($allAvailableListsA) && !empty($list2SubcribeToA)) {
                 foreach ($list2SubcribeToA as $oneneedList => $noneed) {
                     $listId = $allAvailableListsA[$oneneedList];
                     //
                     $query = "INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ({$listId}, {$res}, {$time})";
                     $db->setQuery($query);
                     $db->query();
                 }
             }
             continue;
         }
         if (!$firstValue) {
             $insertQuery .= ',';
         }
         /*$insertQuery .= '(\''. htmlentities(trim($subscriberA[0],' "\'') ) . '\',\''.$email.'\','.$comfirmation.','.(int)trim($subscriberA[2],' "\'').',\''.$time.'\',\''.$column4.'\',\''.$column5.'\',\''.$column6.'' .
         		'\',\''.$column7.'\',\''.$column8.'\',\''.$ip.'\')';*/
         $insertQuery .= '(\'' . addslashes(trim($subscriberA[0], ' "\'')) . '\',\'' . $email . '\',' . $comfirmation . ',' . (int) trim($subscriberA[2], ' "\'') . ',\'' . $time . '\',\'' . $column4 . '\',\'' . $column5 . '\',\'' . $column6 . '' . '\',\'' . $column7 . '\',\'' . $column8 . '\',\'' . $ip . '\')';
         if (!$firstValue) {
             $selectQuery .= ',';
         }
         $selectQuery .= '\'' . $email . '\'';
         $firstValue = false;
         $totalInsert++;
         if ($totalInsert % 50 == 0) {
             if (empty($insertQuery)) {
                 continue;
             }
             $db = JFactory::getDBO();
             $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery;
             $db->setQuery($query);
             $db->query();
             $firstValue = true;
             $insertQuery = '';
             //get the id of the subscribers
             $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $resultsSubClA = jnews::convertObjectList2Array($loadResultArray);
             $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA);
             $selectQuery = '';
         } else {
             if (empty($insertQuery)) {
                 return false;
             }
             $db = JFactory::getDBO();
             $query = 'INSERT IGNORE `#__jnews_subscribers` (`name`,`email`,`confirmed`,`receive_html`,`subscribe_date`,`column1`,`column2`,`column3`,`column4`,`column5`,`ip`) VALUES ' . $insertQuery;
             $db->setQuery($query);
             $db->query();
         }
     }
     //send confirmation email if required
     if ($GLOBALS[JNEWS . 'require_confirmation'] && !empty($list2SubcribeToA)) {
         $list4Message = $allAvailableListsA[key($list2SubcribeToA)];
         $myList = jNews_Lists::getOneList($list4Message);
         $myList->subscribemessage = trim($myList->subscribemessage);
         if (empty($myList->subscribemessage) || substr_count($myList->subscribemessage, '{tag:confirm}') < 1) {
             $Sub_TAG = '{tag:confirm}';
             //'[CONFIRM]';
         } else {
             $Sub_TAG = '';
         }
         $mailing = new stdClass();
         if (!empty($myList->subscribemessage)) {
             $mailing->htmlcontent = $myList->subscribemessage;
             $mailing->textonly = $myList->subscribemessage;
         } else {
             // default message
             $mailing->textonly = 'Please confirm your subscription to our website by clicking on the following link.';
             $mailing->htmlcontent = '<br />' . $mailing->textonly . '<br /><br />';
         }
         $mailing->textonly .= $Sub_TAG;
         $mailing->htmlcontent .= $Sub_TAG;
         //insert the mailing in the mailing table
         $mailing->mailing_type = 1;
         $mailing->template_id = 0;
         $mailing->senddate = $time;
         $mailing->subject = _JNEWS_SUBSCRIBE_SUBJECT_MESS;
         $mailing->attachments = '';
         $mailing->images = '';
         $mailing->published = 1;
         $mailing->html = 1;
         $mailing->visible = 0;
         $mailing->fromname = '';
         $mailing->fromemail = '';
         $mailing->frombounce = '';
         $mailing->author_id = 0;
         $mailing->delay = 0;
         $mailing->follow_up = 0;
         $mailing->cat_id = 0;
         $mailing->delay_min = 0;
         $mailing->delay_max = 0;
         $mailing->notify_id = 0;
         $mailing->next_date = 0;
         $mailing->start_date = $time - 2;
         $mailing->issue_nb = 0;
         $mailing->createdate = $time;
         $mailing->acc_level = 0;
         $mailingID = jNews_Mailing::insertMailingData($mailing);
         //enter the emails in the queue
         $query = 'INSERT IGNORE INTO `#__jnews_queue` (`subscriber_id`,`mailing_id`,`send_date`,`priority`) ';
         $query .= 'SELECT `id`,' . intval($mailingID) . ',' . $time . ',1';
         $query .= ' FROM `#__jnews_subscribers` ';
         $query .= 'WHERE `subscribe_date`=' . $time . ' AND `confirmed`=0';
         $db->setQuery($query);
         $db->query();
     }
     if (!empty($selectQuery)) {
         //get the id of the subscribers
         $query = 'SELECT `id` FROM `#__jnews_subscribers` WHERE `email` IN (' . $selectQuery . ')';
         $db->setQuery($query);
         $loadResultArray = $db->loadObjectList();
         $resultsSubClA = jnews::convertObjectList2Array($loadResultArray);
         $allSubscribersIDA = array_merge($allSubscribersIDA, $resultsSubClA);
     }
     if (!empty($allAvailableListsA)) {
         //if lists in checkbox are not empty
         if (empty($list2SubcribeToA)) {
             jnews::printM('red', 'You need to select at least one list. Emails have been imported but not subscribed.');
             if ($GLOBALS[JNEWS . 'require_confirmation']) {
                 return 'The confirmation email cannot be sent because there is not list selected to subscribe the users.';
             } else {
                 return _JNEWS_IMPORT_FINISHED;
             }
         }
         foreach ($list2SubcribeToA as $oneselected => $vval) {
             $seleeected[] = $allAvailableListsA[$oneselected];
         }
         foreach ($list2SubcribeToA as $oneneedList => $noneed) {
             $listId = $allAvailableListsA[$oneneedList];
             //
             $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ';
             $firstTime = true;
             if (!empty($allSubscribersIDA)) {
                 foreach ($allSubscribersIDA as $oneSubcriber) {
                     if (!$firstTime) {
                         $query .= ',';
                     }
                     $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')';
                     $firstTime = false;
                     if (jNews_Lists::getListType($listId) == 2) {
                         //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list
                         jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId);
                         //
                     } else {
                         if (jNews_Lists::getListType($listId) == 1) {
                             $arrayFollowUp = jNews_Subscribers::followInSelected($listId);
                             if (!$arrayFollowUp) {
                                 continue;
                             }
                             foreach ($arrayFollowUp as $onefollow_id) {
                                 if (in_array($onefollow_id, $seleeected)) {
                                     continue;
                                 }
                                 $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')';
                                 jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id);
                             }
                         }
                     }
                 }
                 $db->setQuery($query);
                 $db->query();
             }
         }
     } else {
         //otherwise we get the value from dropdown box
         $listId = JRequest::getVar('opted_list', '');
         if ($listId) {
             $query = 'INSERT IGNORE `#__jnews_listssubscribers` (`list_id`,`subscriber_id`,`subdate`) VALUES ';
             $firstTime = true;
             if (!empty($allSubscribersIDA)) {
                 foreach ($allSubscribersIDA as $oneSubcriber) {
                     if (!$firstTime) {
                         $query .= ',';
                     }
                     $query .= '(' . $listId . ',' . $oneSubcriber . ',' . $time . ')';
                     $firstTime = false;
                     if (jNews_Lists::getListType($listId) == 2) {
                         //we add directly the imported subscribers to the queue if they are imported to an autoresponder type of list
                         jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $listId);
                     } else {
                         if (jNews_Lists::getListType($listId) == 1) {
                             $arrayFollowUp = jNews_Subscribers::followInSelected($listId);
                             if (!$arrayFollowUp) {
                                 continue;
                             }
                             foreach ($arrayFollowUp as $onefollow_id) {
                                 if (in_array($onefollow_id, $seleeected)) {
                                     continue;
                                 }
                                 $query .= ',(' . $onefollow_id . ',' . $oneSubcriber . ',' . $time . ')';
                                 jNews_ListsSubs::subscribeARtoQueue($oneSubcriber, $onefollow_id);
                             }
                         }
                     }
                 }
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     if ($saveSubsInRows) {
         //if adding subscribers in frontend through rows
         jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully added!');
     } else {
         //otherwise we import subscribers
         jnews::printM('green', count($allSubscribersIDA) . ' subscribers successfully imported!');
     }
     return _JNEWS_IMPORT_FINISHED;
 }
Esempio n. 3
0
                                //j15
                                $db->setQuery("SELECT `published` FROM `#__plugins` WHERE `element`='cache'  AND `folder`='system' ");
                            } else {
                                //j16
                                $db->setQuery("SELECT `enabled` FROM `#__extensions` WHERE `type` = 'plugin' AND `element`='cache' ");
                            }
                            $published = $db->loadResult();
                            if ($published) {
                                jNews::printM('warning', 'ONLY IF YOU USE YOUR OWN SERVER CRON TASK!');
                                jNews::printM('warning', 'You NEED to reduce the cache time on your website in order for the cron task to work properly!');
                                jNews::printM('warning', 'You need to put the cache time less than :' . $GLOBALS[JNEWS . 'cron_max_freq'] * 0.8 . ' minutes');
                                jNews::printM('warning', 'Or increase your jNews scheduler to :' . $cacheTime * 1.2 . ' minutes');
                            }
                        }
                    } else {
                        jnews::printM('error', _JNEWS_NOCRON_USED);
                    }
                    break;
                default:
                    $showPanel = true;
                    break;
            }
        } else {
            $showPanel = true;
        }
        break;
}
echo $message;
if ($showPanel) {
    frontEnd::introduction($subscriberId, $listId, $lisType);
}
Esempio n. 4
0
 public static function mailingEdit($subscriberId, $mailingId, $listId, $listType = '', $action, $grantCAnAccess = false)
 {
     global $my, $Itemid;
     $issue_nb = JRequest::getVar('issue_nb', '0');
     $my = JFactory::getUser();
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         //j16
         $usergid = JAccess::getGroupsByUser($my->id, false);
         $my->gid = $usergid[0];
     }
     $accessGrant = false;
     if (!empty($my->id)) {
         $ownedlists = jNews_Lists::getOwnedlists($my->id);
     }
     $new = 0;
     if (class_exists('jNews_Pro')) {
         if ($issue_nb == 0) {
             $issue_nb = jNews_Mailing::countMailings($listId, '');
             $issue_nb++;
         }
         if ($listId > 0) {
             $list = jNews_Lists::getOneList($listId);
             $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
             $acc_level = $list->acc_level;
         } else {
             if (!empty($ownedlists)) {
                 $list = jNews_Lists::getOneList($listId);
                 $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 $acc_level = $list->acc_level;
             } else {
                 $listId = jNews_Lists::getIDacclevel($my->gid);
                 $list = jNews_Lists::getOneList($listId);
                 $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 $acc_level = $list->acc_level;
             }
         }
         $id = 0;
         if ($GLOBALS[JNEWS . 'enable_jsub']) {
             if (!empty($my->id)) {
                 $ownedlists = jNews_Lists::getOwnedlists($my->id);
             }
             if (!empty($ownedlists)) {
                 $id = $my->id;
             }
         }
         if (jnews::checkPermissions($acc_level)) {
             $accessGrant = true;
         }
     } else {
         if ($subscriberId != 0 && jnews::checkPermissions('admin')) {
             $accessGrant = true;
         }
     }
     if (@(include_once JNEWSPATH_ADMIN . 'social' . DS . 'class.social.php')) {
         if (class_exists('jNews_Social') && !$GLOBALS[JNEWS . 'enable_jsub']) {
             $accessGrant = true;
         }
     }
     if ($accessGrant || $grantCAnAccess) {
         if ($issue_nb == 0) {
             $issue_nb = jNews_Mailing::countMailings($listId, '');
             $issue_nb++;
         }
         if (empty($mailing)) {
             if ($mailingId > 0) {
                 $mailing = jNews_Mailing::getOneMailing('', $mailingId, $issue_nb, $new);
             } else {
                 if ($listId > 0) {
                     $list = jNews_Lists::getOneList($listId);
                     $mailing = jNews_Mailing::getOneMailing($list, $mailingId, $issue_nb, $new);
                 } else {
                     return false;
                 }
             }
         }
         $mainLink = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=' . $listType . '&Itemid=' . $Itemid;
         $mainLink = jNews_Tools::completeLink($mainLink, false, false);
         $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION);
         //$forms['main'] = '<form method="post" enctype="multipart/form-data" action="'. $mainLink . '" onsubmit="submitbutton();return false;" name="adminForm" id="adminForm">'."\n\r";
         $forms['main'] = '<form method="post" enctype="multipart/form-data" action="' . $mainLink . '" name="adminForm" id="adminForm">' . "\n\r";
         $forms['main'] .= '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
         $show = jNews_ListType::showType($mailing->mailing_type, 'editmailing');
         $menuA = null;
         if ($GLOBALS[JNEWS . 'level'] > 1) {
             //menu object start here
             //to create the template menu
             $listype = JRequest::getInt('listype', 0, 'request');
             $menuTag = new stdClass();
             $menuTag->link = 'administrator/' . jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags', true, false, true);
             if ($listype == 7) {
                 $delaymax = JRequest::getInt('delay_max', 0, 'request');
                 $notifyID = JRequest::getInt('notify_id', 0, 'request');
                 $catid = JRequest::getVar('cat_id', 0, 'request');
                 $menuTag->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags&listype=' . $listype . '&cat_id=' . $catid . '&delay_max=' . $delaymax . '&notify_id=' . $notifyID, false, false, true);
             } else {
                 $menuTag->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=tags', false, false, true);
             }
             $menuTag->popup = new stdClass();
             $menuTag->popup->isPop = true;
             $menuTag->popup->rel = true;
             $menuTag->popup->x = 750;
             $menuTag->popup->y = 500;
             $menuTag->action = 'tags';
             $menuTag->title = _JNEWS_MAILING_TAG;
             //to create the template menu
             $menuTemplate = new stdClass();
             $menuTemplate->link = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=templates&task=assign', false, false, true);
             $menuTemplate->popup = new stdClass();
             $menuTemplate->popup->isPop = true;
             $menuTemplate->popup->rel = true;
             $menuTemplate->popup->x = 640;
             $menuTemplate->popup->y = 480;
             $menuTemplate->action = 'template';
             $menuTemplate->title = _JNEWS_LIST_T_TEMPLATE;
             //to create cancel menu
             $menuCancel = new stdClass();
             $menuCancel->popup = new stdClass();
             $menuCancel->popup->isPop = false;
             $menuCancel->link = '#';
             $menuCancel->action = 'cancel';
             $menuCancel->onclick = new stdClass();
             $menuCancel->onclick->custom = false;
             $menuCancel->onclick->js = '';
             $menuCancel->title = _JNEWS_CANCEL;
             //to create save menu
             $linksave = 'option=' . JNEWS_OPTION . '&act=mailing&listid=' . $listId . '&listype=' . $listType . '&Itemid=' . $Itemid;
             if ($listId == 0) {
                 $linksave = 'option=' . JNEWS_OPTION . '&act=mailing&listype=' . $listType . '&Itemid=' . $Itemid;
             }
             $linksave = jNews_Tools::completeLink($linksave, false);
             $menuSave = new stdClass();
             $menuSave->popup = new stdClass();
             $menuSave->popup->isPop = false;
             $menuSave->link = '#';
             $menuSave->action = 'save';
             $menuSave->onclick = new stdClass();
             $menuSave->onclick->custom = false;
             $menuSave->onclick->js = '';
             $menuSave->title = _JNEWS_SAVE;
             //to create preview menu
             $menuPreview = new stdClass();
             $menuPreview->popup = new stdClass();
             $menuPreview->popup->isPop = false;
             $menuPreview->link = '#';
             $menuPreview->action = 'savepreview';
             $menuPreview->onclick = new stdClass();
             $menuPreview->onclick->custom = false;
             $menuPreview->onclick->js = '';
             $menuPreview->title = 'Preview';
             //to create send menu
             $menuSend = new stdClass();
             $menuSend->popup = new stdClass();
             $menuSend->popup->isPop = true;
             $menuSend->popup->rel = true;
             $menuSend->popup->x = 750;
             $menuSend->popup->y = 500;
             $linkBut = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=sendready&mailingid=' . $mailingId . '&listype=' . $listType, true, false, true);
             $menuSend->link = $linkBut;
             $menuSend->action = 'sendready';
             $menuSend->onclick = new stdClass();
             $menuSend->onclick->custom = false;
             $menuSend->onclick->js = "";
             $menuSend->title = _JNEWS_MENU_SEND;
             //to create the divider
             $menuDivider = new stdClass();
             $menuDivider->divider = true;
             $menuA = array();
             if (empty($mailingId)) {
                 $menuA['template'] = $menuTemplate;
             }
             $menuA['tags'] = $menuTag;
             $menuA['divider1'] = $menuDivider;
             $menuA['preview'] = $menuPreview;
             $menuA['save'] = $menuSave;
             if ($listType == 1 && $mailingId != 0) {
                 $menuA['send'] = $menuSend;
             }
             $menuA['divider'] = $menuDivider;
             $menuA['cancel'] = $menuCancel;
         }
         frontHTML::formStart(_JNEWS_EDIT_A . @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]), $mailing->html, 'edit_mailing', $menuA);
         jNews_MailingsHTML::editMailing($mailing, $new, $listId, $forms, $show, $listType);
         $go[] = jnews::makeObj('act', $action);
         $go[] = jnews::makeObj('listype', $listType);
         frontHTML::formEnd(_CMN_SAVE . ' ' . @constant($GLOBALS[JNEWS . 'listname' . $mailing->mailing_type]), $go);
     } else {
         echo jnews::printM('red', _NOT_AUTH);
     }
     return true;
 }
Esempio n. 5
0
 function moveTo($dir_dest, $overwrite = true)
 {
     if (!$this->isValid()) {
         return jnews::printM('error', $this->upload['error']);
     }
     if (!$this->_evalValidExtensions()) {
         return jnews::printM('error', _JNEWS_NOT_ALLOWED_EXTENSION);
     }
     $err_code = $this->_chk_dir_dest($dir_dest);
     if ($err_code !== false) {
         return jnews::printM('error', $err_code);
     }
     if (!$this->mode_name_selected) {
         $this->setName('safe');
     }
     $name_dest = $dir_dest . DIRECTORY_SEPARATOR . $this->upload['name'];
     if (@is_file($name_dest)) {
         if ($overwrite !== true) {
             return jnews::printM('error', _JNEWS_FILE_EXISTS);
         } elseif (!is_writable($name_dest)) {
             return jnews::printM('error', _JNEWS_CANNOT_OVERWRITE);
         }
     }
     if (!@move_uploaded_file($this->upload['tmp_name'], $name_dest)) {
         return jnews::printM('error', _JNEWS_E_FAIL_MOVE);
     }
     @chmod($name_dest, $this->_chmod);
     return $this->getProp('name');
 }
Esempio n. 6
0
    public static function description($listEdit, $lists, $show, $html, $listType)
    {
        $editor = JFactory::getEditor();
        static $db = null;
        if (!isset($db)) {
            $db = JFactory::getDBO();
        }
        ?>
	<fieldset class="jnewscss">
	<table class="jnewstable" width="100%"  cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_PUB;
        $title = _JNEWS_PUBLISHED;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td><?php 
        echo $lists['published'];
        ?>
</td>
		</tr>
	<?php 
        if ($show['hide']) {
            ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_MAILING_VISIBLE;
            $title = _JNEWS_VISIBLE_FRONT;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			<td><?php 
            echo $lists['hidden'];
            ?>
</td>
			</tr>

	<?php 
        } else {
            echo '<input type="hidden" name="hidden" value="' . $listEdit->hidden . '" />';
        }
        ?>
	 		<?php 
        if ($listType == 2) {
            ?>
	 	<tr>
	 		<td width="185%" class="key">
	 			<span class="editlinktip">
	 			<?php 
            $tip = _JNEWS_SUBS_LIST_TIPS;
            $title = _JNEWS_SUBS_LIST2;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
	 			</span>
	 		</td>

			<td width="90%">
			<table width = "50%"><tr><td>
			<?php 
            require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'views' . DS . 'mailings.jnews.html.php';
            jNews_MailingsHTML::lists(null, $lists, $show, $listType, $listEdit->id, true);
            ?>
			 </td></tr></table>
			</td>	 	</tr>
			<?php 
        }
        ?>

		</tbody>
	</table>
	</fieldset>
	<fieldset class="jnewscss">
	<legend><?php 
        echo _JNEWS_LIST_T_GENERAL;
        ?>
</legend>
	<table class="jnewstable" width="100%" cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_NAME;
        $title = _JNEWS_LIST_NAME;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td>
			<?php 
        $text = str_replace('"', '&quot;', $listEdit->list_name);
        if (function_exists('htmlspecialchars_decode')) {
            $text = htmlspecialchars_decode($text, ENT_NOQUOTES);
        } elseif (function_exists('html_entity_decode')) {
            $text = html_entity_decode($text, ENT_NOQUOTES);
        }
        echo ' <input type="text" name="list_name" class="inputbox requiredd" size="50" maxlength="64" value="' . $text . '" />';
        ?>
			</td>
		</tr>
		<?php 
        if ($GLOBALS[JNEWS . 'listHTMLeditor'] == '1') {
            ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_DESC;
            $title = _JNEWS_LIST_DESC;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
			<?php 
            echo $editor->display('list_desc', $listEdit->list_desc, '100%', '200', '75', '10');
            ?>
			</td>
		</tr>
		<?php 
        } else {
            echo jnews::printM('notice', _JNEWS__LIST_HTML_EDITOR);
        }
        ?>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_ASSIGN_LIS_TEMPLATE_TIPS;
        $title = _JNEWS_ASSIGN_LIS_TEMPLATE;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td>
			<?php 
        echo $lists['list_templates'];
        ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
<?php 
        if ($show['sender_info']) {
            ?>
	<fieldset class="jnewscss">
	<legend><?php 
            echo _JNEWS_LIST_T_SENDER;
            ?>
</legend>
	<table class="jnewstable" width="100%" cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_NAME;
            $title = _JNEWS_SENDER_NAME;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
			<?php 
            //if empty sender name and sender email
            //				$userSender=jNews_Subscribers::getUsers( 'gid', '50',$listEdit->owner );
            //				if(empty($listEdit->sendername)) $listEdit->sendername=$userSender[0]->name;
            //				if(empty($listEdit->senderemail)) $listEdit->senderemail=$userSender[0]->email;
            $text = str_replace('"', '&quot;', $listEdit->sendername);
            if (function_exists('htmlspecialchars_decode')) {
                $text = htmlspecialchars_decode($text, ENT_NOQUOTES);
            } elseif (function_exists('html_entity_decode')) {
                $text = html_entity_decode($text, ENT_NOQUOTES);
            }
            echo ' <input type="text" name="sendername" class="inputbox" size="40" maxlength="64" value="' . $text . '" />';
            ?>

				&nbsp;<img src="components/<?php 
            echo JNEWS_OPTION;
            ?>
/images/16/profile.png" id="popbtn" name="popbtn" onClick="document.getElementById('poplist').style.display = 'inline'; document.getElementById('popbtn').style.display = 'none';" title="<?php 
            echo _JNEWS_SENDER_LIST_INFO;
            ?>
" style="position:absolute;">
				<select id="poplist" name="poplist" style="display:none;position:relative;" onChange="document.getElementById('poplist').style.display = 'none'; document.getElementById('popbtn').style.display = 'inline';">
				<option value="0" onClick="document.adminForm.sendername.value=''; document.adminForm.senderemail.value='';"> </option>
			<?php 
            // 2nd parameter of this public static function should be a preference
            // we need to limit it so that it wouldnt cause any problems when loading a bunch of datas e.g hundreds or thousands of users
            $usersA = jNews_Subscribers::getUsers('gid', '50');
            // create options for list
            if (!empty($usersA)) {
                foreach ($usersA as $user) {
                    $name = $user->name;
                    $email = $user->email;
                    $selected = isset($listEdit->sendername) && $listEdit->sendername == $name && (isset($listEdit->senderemail) && $listEdit->senderemail == $email) ? true : false;
                    ?>
						<option value="<?php 
                    echo $user->name;
                    ?>
" onClick="document.adminForm.sendername.value='<?php 
                    echo $name;
                    ?>
'; document.adminForm.senderemail.value='<?php 
                    echo $email;
                    ?>
';" <?php 
                    if ($selected) {
                        echo 'selected';
                    }
                    ?>
> <?php 
                    echo $user->name . ' (' . $user->email . ')';
                    ?>
 </option>
				<?php 
                }
            }
            ?>
			 	</select>
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_EMAIL;
            $title = _JNEWS_SENDER_EMAIL;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="senderemail" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->senderemail;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_SENDER_BOUNCED;
            $title = _JNEWS_SENDER_BOUNCE;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<input type="text" name="bounceadres" class="inputbox" size="40" maxlength="64" value="<?php 
            echo $listEdit->bounceadres;
            ?>
" />
			</td>
		</tr>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
            $tip = _JNEWS_INFO_LIST_JNEWS_OWNER;
            $title = _JNEWS_OWNER;
            echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
            ?>
				</span>
			</td>
			<td>
				<?php 
            echo $listEdit->owner;
            ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
	<?php 
        } else {
            echo '<input type="hidden" name="sendername" value="' . $listEdit->sendername . '" />';
            echo '<input type="hidden" name="senderemail" value="' . $listEdit->senderemail . '" />';
            echo '<input type="hidden" name="bounceadres" value="' . $listEdit->bounceadres . '" />';
        }
    }
Esempio n. 7
0
 /**
  * Export the generated file in csv format
  * @param $result - (array) data to be exported
  * 		  $fileNameExport - (string) temporary name of the file to be exported
  */
 public static function mailingExport($results, $fileNameExport)
 {
     //Inializing all the variables needed
     $headers = '';
     $data = '';
     $ctr = 0;
     $headers .= _JNEWS_LIST_SUB . "," . _JNEWS_MAILING_SENT_HTML . "," . _JNEWS_MAILING_SENT_TEXT . "," . _JNEWS_VIEWS_FROM_HTML . "," . _JNEWS_MAILING_FAILED . "," . _JNEWS_MAILING_PENDING . "," . _JNEWS_MAILING_BOUNCES . "," . _JNEWS_MAILING_SENT . "," . 'ID';
     if (!empty($results)) {
         foreach ($results as $key => $datas) {
             $data .= '"' . $datas->subject . '"';
             $data .= "," . $datas->html_sent;
             $data .= " ," . $datas->text_sent;
             $data .= " ," . $datas->html_views;
             $data .= " ," . $datas->pending;
             //				$data .= " ," . $datas->failed ;
             //				$data .= " ," . $datas->bounces ;
             $data .= " ," . $datas->sent;
             $data .= " ," . $datas->id;
             $data .= "\r\n";
         }
         $csvFormat = $headers . "\r\n" . $data;
         $fileNameTemp = _JNEWS_REPORTS_MAIL . $fileNameExport;
         $fileName = str_replace(' ', '_', $fileNameTemp);
         outputReportGraph::exportHeader($csvFormat, $fileName);
         //Call the public static function to export the csv file
     } else {
         echo jnews::printM('warning', _JNEWS_EXPORT_WARN_MESSAGE);
         return;
     }
 }
Esempio n. 8
0
 /**
  * This public static function is to get the listId(s) subscribed by users(s) during new subscription
  * @param redirect - this is a param passed from the module to do redirect of the page after subscription
  */
 public static function getListidsSubscribedInfo($subscriberId, $modlistids = null, $redirect = false)
 {
     $subscriber = '';
     $subsListInfo = new stdClass();
     $subsListInfo->user_id = $subscriberId;
     $status = true;
     $db = JFactory::getDBO();
     $acl = JFactory::getACL();
     $my = JFactory::getUser();
     $listIds = JRequest::getVar('listid', '0');
     if (!$redirect && $modlistids != null) {
         $listIds = $modlistids;
     }
     if (!empty($listIds)) {
         $accessName = '';
         $userid = JRequest::getInt('userid');
         $idslists = explode(",", $listIds);
         if ($modlistids != null) {
             unset($idslists[0]);
         }
         foreach ($idslists as $i => $listId) {
             $listId = intval($listId);
             if ($listId <= 0) {
                 break;
             }
             $list = jNews_Lists::getOneList($listId);
             if (empty($list)) {
                 echo jnews::printM('red', 'List not defined for ID:' . $listId);
                 continue;
             }
             $listIds = explode(',', $list->acc_id);
             if (version_compare(JVERSION, '1.6.0', '<')) {
                 //j15
                 $usergid = $my->gid;
             } else {
                 //j16
                 $usergid = JAccess::getGroupsByUser($my->id, false);
             }
             if (is_array($listIds)) {
                 if (is_array($usergid)) {
                     $canAccess = array_intersect($usergid, $listIds);
                     if (empty($canAccess)) {
                         $status = false;
                     }
                 } else {
                     if (!in_array($usergid, $listIds)) {
                         $status = false;
                     }
                 }
             } else {
                 if (is_array($usergid)) {
                     $canAccess = array_intersect($usergid, $listIds);
                     if (empty($canAccess)) {
                         $status = false;
                     }
                 } else {
                     if ($usergid != $listIds) {
                         $status = false;
                     }
                 }
             }
             //alex added !
             if (!$status) {
                 echo jnews::printM('red', JNEWS_NO_LIST_PERM);
             }
             $subsListInfo->sub_list_id[$i] = $listId;
             $subsListInfo->subscribed[$i] = 1;
             $subsListInfo->acc_level[$i] = $list->acc_id;
         }
     } else {
         $subsListInfo->sub_list_id = JRequest::getVar('sub_list_id', 0);
         $subsListInfo->subscribed = JRequest::getVar('subscribed', 0);
         if ($subsListInfo->subscribed == 0) {
             $subsListInfo->subscribed = array();
             if (!empty($subsListInfo->sub_list_id)) {
                 foreach ($subsListInfo->sub_list_id as $key => $value) {
                     $subsListInfo->subscribed[$key] = 0;
                 }
             }
         }
         $subsListInfo->acc_level = JRequest::getInt('acc_level', 29);
         if (!empty($subsListInfo->sub_list_id)) {
             foreach ($subsListInfo->sub_list_id as $key => $value) {
                 if (empty($subsListInfo->subscribed[$key]) || $subsListInfo->subscribed[$key] == 0) {
                     $subsListInfo->subscribed[$key] = 0;
                 }
             }
         }
     }
     if (!empty($subsListInfo->subscribed) && $subsListInfo->user_id > 0) {
         jNews_ListsSubs::updateSubscriptionToLists($subsListInfo);
     }
     return true;
 }
Esempio n. 9
0
 public static function updateList($listId, $listUpdated, $status, $new)
 {
     $total = 0;
     @set_time_limit(0);
     //If memory_limit less than 128M
     $limit = jnews::convertToBytes(@ini_get('memory_limit'));
     if ($limit < jnews::convertToBytes('128M')) {
         @ini_set('memory_limit', '128M');
     }
     if ($listUpdated->list_type != '7' and $listUpdated->delay_min > $listUpdated->delay_max) {
         $listUpdated->delay_min = $listUpdated->delay_max;
     }
     if (!jNews_Lists::updateListData($listUpdated)) {
         return false;
     } else {
         if ($listUpdated->auto_add == 2) {
             $subscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', 1, 1, '', '');
             //added one parameter for mailid
             $subId = jnews::convertObjectToIdList($subscribers, 'id');
             if (!empty($subId)) {
                 jNews_Queue::insertQueuesForNews($subId, $listId, $listUpdated->acc_id);
             }
         } elseif ($status == '' and $listUpdated->list_type == 2) {
             $queues = jNews_Queue::getAllOneList($listId);
             $qid = jnews::convertObjectToIdList($queues, 'qid');
             if (!jNews_Queue::updatePublished($qid, $status)) {
                 return false;
             }
         } else {
             if (class_exists('jNews_Auto')) {
                 jNews_Auto::updateListNb($listUpdated->list_type, $listUpdated->id);
             }
         }
     }
     if ($listUpdated->published == 0) {
         jnews::printM('blue', _JNEWS_LIST_UNPUBMSG);
     }
     if ($listUpdated->hidden == 0) {
         jnews::printM('blue', _JNEWS_LIST_INVIMSG);
     }
     return true;
 }
Esempio n. 10
0
 public static function upgrade_News3()
 {
     $my = JFactory::getUser();
     $db = JFactory::getDBO();
     $xf = new jNews_Config();
     $newLists = array();
     $idImportedList = array();
     $i = 0;
     $db->setQuery("SELECT * FROM #__yanc_letters");
     $newsletters = $db->loadObjectList();
     $error = $db->getErrorMsg();
     $newSubscriber = null;
     $list = null;
     $mailings = null;
     $subscriberId = 0;
     $total = 0;
     if (!empty($error)) {
         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error getting newsletters. Database error: <br />' . $error . '</p>';
         return false;
     } else {
         foreach ($newsletters as $newsletter) {
             $list->list_name = $newsletter->list_name;
             $list->list_desc = $newsletter->list_desc;
             $list->sendername = $newsletter->sendername;
             $list->senderemail = $newsletter->senderemail;
             $list->bounceadres = $newsletter->bounceadres;
             $list->layout = $newsletter->layout;
             $list->template = 0;
             $list->subscribemessage = $newsletter->subscribemessage;
             $list->unsubscribemessage = $newsletter->unsubscribemessage;
             $list->notifyadminmsg = $newsletter->notifyadminmsg;
             $list->html = $newsletter->html;
             $list->hidden = !$newsletter->hidden;
             $list->unsubscribesend = 1;
             $list->unsubscribenotifyadmin = 1;
             $list->list_type = '1';
             $list->auto_add = 0;
             $list->user_choose = 0;
             $list->cat_id = '0:0';
             $list->delay_min = 0;
             $list->delay_max = 0;
             $list->follow_up = 0;
             $list->owner = $my->id;
             $list->acc_level = $newsletter->aid;
             $list->acc_id = 29;
             $list->published = 1;
             $list->createdate = time();
             $list->footer = 1;
             $list->notify_id = 0;
             $list->notification = 0;
             $query = 'INSERT INTO `#__jnews_lists` (`list_name`) VALUES (\'' . $list->list_name . '\'  )';
             $db->setQuery($query);
             $db->query();
             $error = $db->getErrorMsg();
             if (!empty($error)) {
                 echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error adding list to database. Database error: <br />' . $error . '</p><br /><br />Are you trying to insert a list name which is already in use?    The list name has to be different for each list! <br /><br />';
             } else {
                 $query = 'SELECT * FROM `#__jnews_lists` WHERE `list_name`= \'' . $list->list_name . '\'';
                 $db->setQuery($query);
                 $mynewlist = $db->loadObject();
                 $error = $db->getErrorMsg();
                 $xf->plus('totallist0', 1);
                 $xf->plus('act_totallist0', 1);
                 $xf->plus('totallist1', 1);
                 $xf->plus('act_totallist1', 1);
                 if (!empty($error)) {
                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting listname. Database error: <br />' . $error . '</p>';
                     return false;
                 } else {
                     $idImportedList[$newsletter->id] = $mynewlist->list_id;
                     $newLists[$i] = $mynewlist->list_id;
                     $i++;
                     $list->id = $mynewlist->list_id;
                     $error = jNews_Lists::updateListData($list);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting list. Database error: <br />' . $error . '</p>';
                     } else {
                         echo '<br /><b>' . @constant($GLOBALS[JNEWS . 'listnames1']) . ': </b>' . $list->list_name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                         $db->setQuery("SELECT * FROM #__yanc_letters WHERE `list_id`=" . $newsletter->id);
                         $mailingsImports = $db->loadObjectList();
                         $error = $db->getErrorMsg();
                         if (!empty($error)) {
                             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting mailings. Database error: <br />' . $error . '</p>';
                             return false;
                         } else {
                             $issue_nb = 1;
                             foreach ($mailingsImports as $mailingsImport) {
                                 $mailings->list_id = $mynewlist->list_id;
                                 $mailings->list_type = '1';
                                 $mailings->send_date = $mailingsImport->send_date;
                                 $mailings->subject = $mailingsImport->subject;
                                 $mailings->htmlcontent = $mailingsImport->htmlcontent;
                                 $mailings->textonly = $mailingsImport->textonly;
                                 $mailings->attachments = $mailingsImport->attachments;
                                 $mailings->images = $mailingsImport->images;
                                 $mailings->published = $mailingsImport->published;
                                 $mailings->visible = $mailingsImport->visible;
                                 $mailings->html = $mynewlist->html;
                                 $mailings->fromname = $list->sendername;
                                 $mailings->fromemail = $list->senderemail;
                                 $mailings->frombounce = $list->bounceadres;
                                 $mailings->author_id = $my->id;
                                 $mailings->delay = 0;
                                 $mailings->issue_nb = $issue_nb;
                                 $mailings->acc_level = 25;
                                 $mailings->createdate = $list->createdate;
                                 $issue_nb++;
                                 $error = jNews_Mailing::insertMailingData($mailings);
                                 if (!$error) {
                                     echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error inserting mailing. Database error: <br />' . $error . '</p>';
                                 } else {
                                     echo '<br /><b>' . _JNEWS_MENU_MAILING_TITLE . ': </b>' . $mailingsImport->subject . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $db->setQuery("SELECT * FROM #__yanc_subscribers");
         $subscribers = $db->loadObjectList();
         $error = $db->getErrorMsg();
         if (!empty($error)) {
             echo '<p><b>Error (class.upgrade.php->upgrade_News3() line ' . __LINE__ . '):</b> Error getting subscribers. Database error: <br />' . $error . '</p>';
             return false;
         } else {
             foreach ($subscribers as $subscriber) {
                 $newSubs = true;
                 $jnewssubscribers = jNews_Subscribers::getSubscribers(-1, -1, '', $total, 0, '', '', '', '', '');
                 //added one parameter for mailid
                 foreach ($jnewssubscribers as $jnewssubscriber) {
                     if ($subscriber->subscriber_email == $jnewssubscriber->email) {
                         $newSubs = false;
                         $subId[0] = $jnewssubscriber->id;
                     }
                 }
                 if ($newSubs) {
                     $newSubscriber->user_id = $subscriber->userid;
                     $newSubscriber->name = $subscriber->subscriber_name;
                     $newSubscriber->email = $subscriber->subscriber_email;
                     $newSubscriber->ip = $subscriber->ip;
                     $newSubscriber->receive_html = $subscriber->receive_html;
                     $newSubscriber->confirmed = $subscriber->confirmed;
                     $newSubscriber->subscribe_date = $subscriber->subscribe_date;
                     $newSubscriber->blacklist = 0;
                     $newSubscriber->timezone = '00:00:00';
                     $newSubscriber->language_iso = 'eng';
                     $newSubscriber->params = '';
                     if ($GLOBALS[JNEWS . 'level'] > 2) {
                         //check if the version of jnews is pro
                         $newSubscriber->column1 = $newSubscriber->column1;
                         $newSubscriber->column2 = $newSubscriber->column2;
                         $newSubscriber->column3 = $newSubscriber->column3;
                         $newSubscriber->column4 = $newSubscriber->column4;
                         $newSubscriber->column5 = $newSubscriber->column5;
                     }
                     //end if for check version pro
                     $error = jNews_Subscribers::saveSubscriber($newSubscriber, $subscriberId, true);
                     if (!empty($error)) {
                         if ($subscriberId < 1) {
                             echo ' Error inserting subscriber:' . $newSubscriber->name;
                         }
                         $error = '';
                         $subId[0] = $subscriberId;
                     } else {
                         echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $newSubscriber->name . ': ' . jnews::printM('green', _JNEWS_IMPORT_SUCCESS);
                         $d['email'] = $subscriber->email;
                         jNews_Subscribers::getSubscriberIdFromEmail($d);
                         $subId[0] = $d['subscriberId'];
                     }
                 } else {
                     echo '<br /><b>' . _JNEWS_MENU_SUBSCRIBERS . ': </b>' . $subscriber->subscriber_name . ': ' . jnews::printM('red', _JNEWS_IMPORT_EXIST);
                 }
                 $j = 0;
                 $queue = jNews_ListsSubs::getListSubscriberInfo($subId[0], $idImportedList[$subscriber->list_id]);
                 if (empty($queue)) {
                     $error = jNews_Queue::insertQueuesForNews($subId, $idImportedList[$subscriber->list_id], 29);
                     if (!$error) {
                         echo '<p><b>Error (class.upgrade.php->upgrade_News3 () line ' . __LINE__ . '):</b> Error inserting queue. Database error: <br />' . $error . '</p>';
                     }
                 }
             }
         }
     }
     return true;
 }
Esempio n. 11
0
 function failMailReason($mail)
 {
     //check if the sender or bounce back are from the same domain as the website
     //otherwise some website might regect the email
     $sender = $mail->From;
     $bounceBackEmail = JRequest::getVar('bounceBackEmail');
     $web = substr(JNEWS_JPATH_LIVE, -1, 1) == '/' ? substr(JNEWS_JPATH_LIVE, 0, strlen(JNEWS_JPATH_LIVE) - 1) : JNEWS_JPATH_LIVE;
     $domain = str_replace(array('https://', 'http://', 'www.'), '', $web);
     $senderA = explode('@', $sender);
     if (isset($senderA[1]) && $senderA[1] != $domain) {
         jnews::printM('notice', 'The sender email is different than your domain name, some server do not accept that! Please try to use a sender email which is the same as your domain name.');
     } else {
         $bounceBackEmailA = explode('@', $bounceBackEmail);
         if (isset($bounceBackEmailA[1]) && $bounceBackEmailA[1] != $domain) {
             jnews::printM('no', 'The bounce back email is different than your domain name, some server do not accept that! Please try to use a bounce back email which is the same as your domain name.');
         } else {
             if ($sender != $bounceBackEmail) {
                 jnews::printM('no', 'The bounce back email and the sender email are different, some server do not accept that and consider it as spam! Please try to use the bounce back email as the same as the sender email.');
             }
         }
     }
 }
Esempio n. 12
0
function configuration($action, $task)
{
    $db = JFactory::getDBO();
    $config = array();
    $redirect = true;
    $xf = new jNews_Config();
    $message = JRequest::getVar('message', '');
    $clear_log = JRequest::getVar('clear_log', '0');
    switch ($task) {
        case 'syncUsers':
            echo jnews::printYN(jNews_Subscribers::syncSubscribers(), _JNEWS_SYNC_USERS_SUCCESS, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
        case 'sendtest':
            $my = JFactory::getUser();
            $mailing = new stdClass();
            $status = false;
            $mailing->id = 1;
            $mailing->images = '';
            $mailing->attachments = '';
            $mailing->fromname = trim($GLOBALS[JNEWS . 'sendmail_name']);
            $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_email']);
            if (empty($mailing->fromemail)) {
                $mailing->fromemail = trim($GLOBALS[JNEWS . 'sendmail_from']);
            }
            ### create the mail
            $mail = jNews_ProcessMail::getMailer($mailing);
            ### create content
            $mail->IsHTML(true);
            $mail->Body = '<p>This message has been sent at ' . date('l, j F Y h:i:s', jnews::getNow(0, true)) . ' from ' . JNEWS_JPATH_LIVE . ' to test your mail configuration.</p><br/><p style="color:green;">' . _JNEWS_SENDTEST_CONFIGSUCC . '</p>';
            $mail->AddAddress($my->email, $my->name);
            $mail->Subject = 'Test Email from ' . JNEWS_JPATH_LIVE;
            $status = $mail->Send();
            $success = 'Email "' . $mail->Subject . '" successfully sent to ' . $my->name . ' (' . $my->email . ')';
            $error = 'Failed sending "' . $mail->Subject . '" to ' . $my->name . ' (' . $my->email . '). <br/>' . _JNEWS_SENDTEST_CONFIGERROR;
            $message = is_bool($status) && $status ? jnews::printM('ok', $success) : jnews::printM('error', $error);
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            echo $message;
            break;
        case 'apply':
        case 'save':
            JRequest::checkToken() or die('Invalid Token');
            if ($clear_log != 0) {
                @unlink(JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'save_log_file']);
            }
            $config = JRequest::getVar('config');
            $message = jnews::printYN($xf->saveConfig($config), _JNEWS_CONFIG_UPDATED, _JNEWS_ERROR);
            $listCreator = JRequest::getVar('list_creatorfe', '', 'post');
            if (!empty($listCreator)) {
                $xf->update('list_creatorfe', $listCreator);
            }
            //we update the active list
            $xf->updateActiveList();
            if ($GLOBALS[JNEWS . 'level'] > 1) {
                //we require the cron controller
                require_once JNEWSPATH_ADMIN . 'controllers' . DS . 'cron.jnews.php';
                //we update the published/enabld of the jnews cron plugin according to what is selected
                if (version_compare(JVERSION, '1.6.0', '<')) {
                    //j15
                    $db->setQuery("UPDATE `#__plugins` SET `published` = " . $config['jnewscronplugin'] . " WHERE `element`='jnewscron' ");
                } else {
                    //j16
                    $db->setQuery("UPDATE `#__extensions` SET `enabled` = " . $config['jnewscronplugin'] . " WHERE `type` = 'plugin' AND `element`='jnewscron' ");
                }
                $db->query();
                //Joobi Cron System
                $cron = $GLOBALS[JNEWS . 'j_cron'];
                if ($cron == 2) {
                    joobiCron('Yes');
                } else {
                    joobiCron('No');
                }
            }
            if ($task == 'apply') {
                backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
                jNews_ConfigHTML::showConfigEdit();
                echo $message;
            } else {
                backHTML::controlPanel();
            }
            break;
        case 'cancel':
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        case 'acaupdate':
            // update jnews datas from acajoom
            $msg = jNews_TableUpdate::executeUpdate();
            echo $msg . '<br><br>';
        default:
            backHTML::_header(_JNEWS_MENU_CONF, 'configuration.png', $message, $task, $action);
            jNews_ConfigHTML::showConfigEdit();
            break;
    }
    return true;
}
Esempio n. 13
0
 public static function _upgrade()
 {
     $config['news1'] = false;
     $config['news2'] = false;
     $config['news3'] = false;
     $exist = jnews::checkExisting();
     if (!empty($exist['news1'])) {
         $config['news1'] = true;
     }
     if (!empty($exist['news2'])) {
         $config['news2'] = true;
     }
     if (!empty($exist['news3'])) {
         $config['news3'] = true;
     }
     $mess = '';
     if ($config['news1'] or $config['news2'] or $config['news3']) {
         $mess = jnews::printM('blue', _JNEWS_UPGRADE_MESS) . '<br />';
     }
     if ($config['news1']) {
         $mess .= '<a href="index.php?option=' . JNEWS_OPTION . '&act=update&task=new1">';
         $mess .= jnews::printM('ok', _JNEWS_UPGRADE_FROM . 'Anjel');
         $mess .= '</a><br />';
     }
     if ($config['news2']) {
         $mess .= '<a href="index.php?option=' . JNEWS_OPTION . '&act=update&task=new2">';
         $mess .= jnews::printM('ok', _JNEWS_UPGRADE_FROM . 'Letterman');
         $mess .= '</a><br />';
     }
     if ($config['news3']) {
         $mess .= '<a href="index.php?option=' . JNEWS_OPTION . '&act=update&task=new3">';
         $mess .= jnews::printM('ok', _JNEWS_UPGRADE_FROM . 'YaNC');
         $mess .= '</a><br />';
     }
     echo $mess;
 }
Esempio n. 14
0
    static function edit($listEdit, $lists, $show, $html)
    {
        ?>
	<fieldset class="jnewscss">
	<legend><?php 
        echo _JNEWS_AUTO_RESP_OPTION;
        ?>
</legend>
	<table class="jnewstable" cellspacing="1">
		<tbody>
		<tr>
			<td width="185" class="key">
				<span class="editlinktip">
				<?php 
        $tip = _JNEWS_INFO_LIST_FOLLOW_UP;
        $title = _JNEWS_FOLLOW_UP;
        echo jNews_Tools::toolTip($tip, '', 280, 'tooltip.png', $title, '', 0);
        ?>
				</span>
			</td>
			<td>
				<input type="text" name="follow_up" class="inputbox" size="6" maxlength="10" value="<?php 
        if (isset($listEdit->follow_up)) {
            echo $listEdit->follow_up;
        } else {
            echo '';
        }
        ?>
" />
			<?php 
        if (!jNews_Auto::good()) {
            echo jnews::printM('no', _JNEWS_NOTSO_GOOD_LIC);
            echo _JNEWS_PLEASE_LIC;
        }
        ?>
			</td>
		</tr>
		</tbody>
	</table>
	</fieldset>
	<?php 
    }
Esempio n. 15
0
 /** call this function if you want to execute this
  * this function is used for updating process of table datas for acajoom to jnews
 */
 function executeUpdate()
 {
     $nb = explode(',', jNews_TableUpdate::_getAcajoomActiveList());
     $size = sizeof($nb);
     for ($i = 0; $i < $size; $i++) {
         $index = $nb[$i];
         $akey = 'act_totallist' . $index;
         jNews_TableUpdate::_selectUpdate($akey);
         $akey = 'act_totalmailing' . $index;
         jNews_TableUpdate::_selectUpdate($akey);
         $akey = 'totalmailingsent' . $index;
         jNews_TableUpdate::_selectUpdate($akey);
     }
     $msg = '';
     $success = jNews_TableUpdate::_runInsert('lists');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('lists');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_LIST_UPDATED) . '<br>' : jnews::printM('red', _JNEWS_LIST_UPDATED_FAILED) . '<br>';
     $success = jNews_TableUpdate::_runInsert('mailings');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('mailings');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_MAILING_UPDATED) . '<br>' : jnews::printM('red', _JNEWS_MAILING_UPDATED_FAILED) . '<br>';
     $query = " INSERT IGNORE `#__jnews_stats_details` ( `id`, `mailing_id`, `subscriber_id`, `sentdate`, `html`, `read` ) ";
     $query .= " SELECT  `id`, `mailing_id`, `subscriber_id`, UNIX_TIMESTAMP(`sentdate`), `html`, `read`";
     $query .= " FROM `#__acajoom_stats_details` ";
     $success = jNews_TableUpdate::_getTableQuery($query, 'query');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('stats_details');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_DETAIL_UPDATED) . '<br>' : jnews::printM('red', _JNEWS_DETAIL_UPDATED_FAILED) . '<br>';
     $query = " INSERT IGNORE `#__jnews_stats_global` ( `mailing_id`, `sentdate`, `html_sent`, `text_sent`, `html_read` ) ";
     $query .= " SELECT  `mailing_id`, UNIX_TIMESTAMP(`sentdate`), `html_sent`, `text_sent`, `html_read`";
     $query .= " FROM `#__acajoom_stats_global` ";
     $success = jNews_TableUpdate::_getTableQuery($query, 'query');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('stats_global', 'mailing_id');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_GLOBAL_UPDATED) . '<br>' : jnews::printM('red', _JNEWS_GLOBAL_UPDATED_FAILED) . '<br>';
     // for #__jnews_subscribers update
     // we separate this from the function because we might be loading millions of subscribers and it may break the server
     // its a new installation for jnews
     // so we just need to delete the datas from jnews... just copy the datas from the old acajoom_subscribers
     // check acajoom columns
     $db = JFactory::getDBO();
     $tableFieldA = $db->getTableFields('#__acajoom_subscribers');
     $check = isset($tableFieldA['#__acajoom_subscribers']['column1']) ? true : false;
     // after deleting, insert datas from old acajoom_subscribers
     if ($check) {
         $query = " INSERT IGNORE `#__jnews_subscribers` (  `user_id`, `name`, `email`, `receive_html`, `confirmed`, `blacklist`, `timezone`, `language_iso`, `subscribe_date`, `params`, `column1`, `column2`, `column3`, `column4`, `column5` ) ";
         $query .= " SELECT  `user_id`, `name`,  TRIM(`email`), `receive_html`, `confirmed`, `blacklist`, `timezone`, `language_iso`, UNIX_TIMESTAMP(`subscribe_date`), `params`, `column1`, `column2`, `column3`, `column4`, `column5` ";
     } else {
         $query = " INSERT IGNORE `#__jnews_subscribers` ( `user_id`, `name`, `email`, `receive_html`, `confirmed`, `blacklist`, `timezone`, `language_iso`, `subscribe_date`, `params` ) ";
         $query .= " SELECT   `user_id`, `name`,  TRIM(`email`), `receive_html`, `confirmed`, `blacklist`, `timezone`, `language_iso`, UNIX_TIMESTAMP(`subscribe_date`), `params` ";
     }
     $query .= " FROM `#__acajoom_subscribers` ";
     $success = jNews_TableUpdate::_getTableQuery($query, 'query');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('subscribers');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_SUBSCRIBER_UPDATED) . '<br>' : jnews::printM('red', _JNEWS_SUBSCRIBER_UPDATED_FAILED) . '<br>';
     // for #__jnews_queue
     // we separate this from the function because we might be loading millions of queues and it may break the server
     // insert datas from old acajoom_queue to jnews_queue
     $query = " INSERT IGNORE `#__jnews_queue` ( `qid`, `type`, `subscriber_id`, `mailing_id`, `priority`, `issue_nb`, `send_date`, `delay`, `acc_level`, `published`) ";
     $query .= " SELECT `A`.`qid`, `B`.`list_type`, `A`.`subscriber_id`, `B`.`id`, `A`.`qid`, `A`.`issue_nb`, UNIX_TIMESTAMP(`B`.`send_date`), `B`.`delay`, `A`.`acc_level`, `A`.`published`";
     $query .= " FROM `#__acajoom_queue` AS `A`, `#__acajoom_mailings` AS `B` ";
     $query .= " WHERE `A`.`list_id` = `B`.`list_id` AND `A`.`send_date` != '0000-00-00 00:00:00' ";
     $success = jNews_TableUpdate::_getTableQuery($query, 'query');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('queue', 'qid');
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_QUEUE_UPDATED) . '<br>' : jnews::printM('blue', _JNEWS_QUEUE_UPDATED_FAILED) . '<br>';
     // for #_jnews_listssubscribers
     // we separate this from the function because we might be loading millions of queues and it may break the server
     $query = " INSERT IGNORE `#__jnews_listssubscribers` ( `list_id`, `subscriber_id`, `subdate` ) ";
     $query .= " SELECT `A`.`list_id`, `A`.`subscriber_id`, UNIX_TIMESTAMP(`B`.`subscribe_date`) ";
     $query .= " FROM `#__acajoom_queue` AS `A`, `#__acajoom_subscribers` AS `B` ";
     $query .= " WHERE `A`.`subscriber_id` = `B`.`id` ";
     $success = jNews_TableUpdate::_getTableQuery($query, 'query');
     $checkStatus = jNews_TableUpdate::_checkImportSuccess('listssubscribers', 'list_id', true);
     $msg .= $checkStatus ? jnews::printM('green', _JNEWS_LISTSUBSCRIBER_UPDATED) . '<br>' : jnews::printM('blue', _JNEWS_LISTSUBSCRIBER_UPDATED_FAILED) . '<br>';
     return $msg;
 }
Esempio n. 16
0
function statistics($listId, $listType, $mailingId, $message, $task, $action)
{
    //From Specified fieldset
    $sDate = JRequest::getVar('startdate');
    $eDate = JRequest::getVar('enddate');
    if ($task == 'cpanel') {
        jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
    }
    //Predefined fieldset
    $currentInterval = JRequest::getVar('rptinterval');
    $currentRange = JRequest::getVar('rptrange');
    if (empty($currentRange)) {
        $currentRange = 'this-month';
    }
    if (empty($currentInterval)) {
        $currentInterval = 'weekly';
    }
    if ($sDate == '0000-00-00' && $eDate == '0000-00-00') {
        $sDate = 0;
        $eDate = 0;
    }
    if (!empty($sDate) && !empty($eDate)) {
        if ($sDate != '0000-00-00' && $eDate != '0000-00-00') {
            $sDate = strtotime($sDate);
            $sDate = $sDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z');
            $eDate = strtotime($eDate);
            $eDate = $eDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z');
        } elseif ($sDate != '0000-00-00' && $eDate == '0000-00-00') {
            $sDate = strtotime($sDate);
            $sDate = $sDate - jnews::calculateOffset(JNEWS_TIME_OFFSET) + date('Z');
            $eDate = time();
            // - JNEWS_TIME_OFFSET * 3600 ;
        } elseif ($sDate == '0000-00-00' && $eDate != '0000-00-00') {
            echo jnews::printM('warning', _JNEWS_REPORT_WARN_MESSAGE);
            $sDate = 0;
            $eDate = 0;
        }
    } else {
        //Set the correct startDateTime and endDateTime
        //Set also the correct intervals appropriate for each range
        //current datetime base on the website setting configuration
        $currDate = $eDate = time();
        // - JNEWS_TIME_OFFSET * 3600 ;
        switch ($currentRange) {
            case 'today':
                //today
                $sDate = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
                $eDate = mktime(23, 59, 59, date('m'), date('d'), date('Y'));
                $currentInterval = 'daily';
                break;
            case 'yesterday':
                //yesterday
                $sDate = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
                $eDate = mktime(23, 59, 59, date('m'), date('d') - 1, date('Y'));
                $currentInterval = 'daily';
                break;
            case 'this-week':
                //this week
                $sDate = mktime(0, 0, 0, date('n'), date('j'), date('Y')) - (date('N') - 1) * 3600 * 24;
                //if selected intervals is monthly or yearly
                if ($currentInterval == 'monthly' || $currentInterval == 'yearly') {
                    $currentInterval = 'weekly';
                }
                break;
            case 'last-week':
                //last week..start of the week is Monday at 00:00:00 and will end on Sunday at 23:59:59:
                $sDate = mktime(0, 0, 0, date('n'), date('j') - 6, date('Y')) - date('N') * 3600 * 24;
                $eDate = mktime(23, 59, 59, date('n'), date('j'), date('Y')) - date('N') * 3600 * 24;
                //if selected intervals is monthly or yearly
                if ($currentInterval == 'monthly' || $currentInterval == 'yearly') {
                    $currentInterval = 'weekly';
                }
                break;
            case 'last-2-weeks':
                //last 2 weeks
                $sDate = mktime(0, 0, 0, date('n'), date('j') - 13, date('Y')) - date('N') * 3600 * 24;
                $eDate = mktime(23, 59, 59, date('n'), date('j'), date('Y')) - date('N') * 3600 * 24;
                //if selected intervals is monthly or yearly
                if ($currentInterval == 'monthly' || $currentInterval == 'yearly') {
                    $currentInterval = 'weekly';
                }
                break;
            case 'last-month':
                //last month..starts at the first day to the last day
                $sDate = strtotime(date('m') - 1 . '/01/' . date('Y'), $currDate);
                $eDate = $sDate + 30 * 24 * 3600;
                //mktime(23, 59, 59, date('m'));
                if ($currentInterval == 'yearly') {
                    $currentInterval = 'weekly';
                }
                break;
            case 'this-year':
                //this year..starts
                $sDate = strtotime('01/01/' . date('Y'), $currDate);
                break;
            case 'last-year':
                //last year...starts jan 1 and ends dec 31
                $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 1);
                $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 1);
                break;
            case '2-years-ago':
                //2 Years ago
                if ($currentInterval == 'yearly') {
                    //if the interval is yearly
                    $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 2);
                    //starts jan 1
                } else {
                    $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 2);
                    //ends dec 31
                    $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 2);
                    //starts jan 1
                }
                break;
            case '3-years-ago':
                //3 Years ago
                if ($currentInterval == 'yearly') {
                    //if the interval is yearly
                    $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 3);
                    //starts jan 1
                } else {
                    $eDate = mktime(23, 59, 59, 12, 31, date('Y') - 3);
                    //ends dec 31
                    $sDate = mktime(0, 0, 0, 1, 1, date('Y') - 3);
                    //starts jan 1
                }
                break;
            case 'this-month':
                //this month
            //this month
            default:
                $sDate = strtotime(date('m') . '/01/' . date('Y'), $currDate);
                if ($currentInterval == 'yearly') {
                    $currentInterval = 'weekly';
                }
                break;
        }
    }
    //Still need to double check if there's really values on the start and end date
    if (!empty($sDate) && !empty($eDate)) {
        //Title header
        $doc = JFactory::getDocument();
        $css = '.icon-48-statistics_header { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/statistics.png)}';
        $doc->addStyleDeclaration($css, $type = 'text/css');
        $img = 'statistics_header.png';
        $message = '';
        $start = date('F j, Y', jnews::getNow(0, true, $sDate));
        $end = date('F j, Y', jnews::getNow(0, true, $eDate));
        if ($currentRange == 'today' || $currentRange == 'yesterday') {
            $title = _JNEWS_REPORT_HEADER . ': ' . $start;
            $fileNameExport = $start;
        } else {
            $title = _JNEWS_REPORT_HEADER . ': ' . $start . ' ' . _JNEWS_REPORT_HEADER_TO . ' ' . $end;
            $fileNameExport = $start . ' ' . _JNEWS_REPORT_HEADER_TO . ' ' . $end;
        }
        backHTML::_header($title, $img, $message, $task, $action);
    }
    $dateFormat = 'FROM_UNIXTIME(';
    switch ($currentInterval) {
        case 'yearly':
            //yearly
            $specialFormat = ',\'%Y\'';
            $dateFormat4DateNumber = 'FROM_UNIXTIME(';
            //.$columnModif.', \'' .substr($special, 10).'\'))';
            $specialNo = ',\'%Y\')';
            break;
        case 'weekly':
            //weekly
            $specialFormat = ',\'%M %d, %Y\'';
            $dateFormat4DateNumber = 'WEEK(' . $dateFormat;
            $dateFormat4DateNumber = 'WEEK(FROM_UNIXTIME(';
            //'dtfrmtweek%Y-%m-%d';	// WEEK(DATE_FORMAT(cdate, '%Y-%m-%d'))
            $specialNo = ',\'%Y-%m-%d\'))';
            break;
        case 'daily':
            //daily
            $specialFormat = ',\'%M %d, %Y\'';
            $dateFormat4DateNumber = 'FROM_UNIXTIME(';
            //'dateformat%Y%m%d';
            $specialNo = ',\'%Y%m%d\')';
            break;
        case 'monthly':
            //monthly
        //monthly
        default:
            $specialFormat = ',\'%M, %Y\'';
            $dateFormat4DateNumber = 'FROM_UNIXTIME(';
            //'dateformat%Y%m%d';
            $specialNo = ',\'%Y%m\')';
            break;
    }
    $queryfilters = array();
    $queryfilters['enddate'] = '\'' . $eDate . '\'';
    $queryfilters['startdate'] = '\'' . $sDate . '\'';
    $queryfilters['dateFormat'] = $dateFormat;
    $queryfilters['specialFormat'] = $specialFormat;
    $queryfilters['dateFormat4DateNumber'] = $dateFormat4DateNumber;
    $queryfilters['specialNo'] = $specialNo;
    $queryfilters['mailingId'] = $mailingId;
    $queryfilters['task'] = $task;
    //go to class.stats to display the view of stats
    require_once JNEWSPATH_CLASS . 'class.statistics.php';
    outputReportGraph::initIncludes();
    echo '<form action="index.php" method="post" name="adminForm" id="adminForm">';
    if ($task == 'graph') {
        $results = array();
        $results['subject'] = JRequest::getVar('subject', '');
        $results['html_sent'] = JRequest::getVar('html_sent', '0');
        $results['text_sent'] = JRequest::getVar('text_sent', '0');
        $results['html_views'] = JRequest::getVar('html_views', '0');
        $results['html_unread'] = JRequest::getVar('html_unread', '0');
        $results['pending'] = JRequest::getVar('pending', '0');
        //		$results['failed'] = JRequest::getVar( 'failed', '0' );
        //		$results['bounces'] = JRequest::getVar( 'bounces', '0' );
        $results['sent'] = JRequest::getVar('sent', '0');
        //		$results['sent'] = intval( $results['html_sent'] + $results['text_sent'] ); //fixed
        $results['id'] = JRequest::getVar('id');
        $queryfilters['startdate'] = '\'' . JRequest::getInt('startdate') . '\'';
        $queryfilters['enddate'] = '\'' . JRequest::getVar('enddate') . '\'';
        outputReportGraph::mailingSpecificGraph($results, $queryfilters);
    } else {
        outputReportGraph::headerFilter($currentInterval);
        if (empty($fileNameExport)) {
            $fileNameExport = null;
        }
        outputReportGraph::tabReports($queryfilters, $task, $fileNameExport);
    }
    echo '</form>';
    return true;
}
Esempio n. 17
0
 /**
  * we check here the permission of a directory
  * @param path - the directory that we need to check
  * */
 public static function _checkpermission($path)
 {
     $return = true;
     if (empty($path)) {
         $return = false;
     }
     //we check if the path exists
     if (is_dir($path)) {
         if (!is_writable($path)) {
             @chmod($path, 0755);
         }
         //we change the permission of the directory
         if (!is_writable($path)) {
             echo jnews::printM('notice', 'The following directory is not writable: ' . $path);
             $return = false;
         }
     } else {
         //if the directory does not exist we create
         @mkdir($path, 0755);
         $return = true;
     }
     return $return;
 }