示例#1
0
function subscribers($action, $task, $userid, $listId, $cid, $front = false)
{
    $Itemid = JRequest::getInt('Itemid');
    $mainframe = JFactory::getApplication();
    $newSubscriber = null;
    $subscriberId = JRequest::getInt('subscriber_id');
    $message = JRequest::getVar('message', '');
    $css = '.icon-48-subscribers { background-image:url(' . JNEWS_PATH_ADMIN_IMAGES2 . 'header/subscribers.png)}';
    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration($css, $type = 'text/css');
    $img = 'subscribers.png';
    $emailField = JRequest::getVar('email', '');
    $new = true;
    //new subscriber
    $my = JFactory::getUser();
    //START OF DATA FROM REQUEST
    $subscriber = new stdClass();
    $subscriber->user_id = JRequest::getInt('user_id');
    $subscriber->name = JRequest::getVar('name', '');
    $subscriber->email = JRequest::getVar('email', '', '', 'STRING');
    if (!jNews_Subscribers::validEmail($subscriber->email)) {
        $subscriber->email = '';
    }
    $subscriber->receive_html = JRequest::getInt('receive_html', 0);
    if (empty($subscriberId)) {
        //if it is a new user the confirmed depends if the require confirmation is turned on
        if ($GLOBALS[JNEWS . 'require_confirmation'] == '1') {
            $subscriber->confirmed = 0;
        } else {
            $subscriber->confirmed = JRequest::getInt('confirmed');
        }
    } else {
        $subscriber->confirmed = JRequest::getInt('confirmed');
    }
    $subscriber->blacklist = JRequest::getVar('blacklist', 0);
    $subscriber->timezone = JRequest::getVar('timezone', '');
    $subscriber->language_iso = JRequest::getVar('language_iso', '');
    if (empty($subscriber->ip)) {
        $subscriber->ip = jNews_Subscribers::getIP();
    }
    if ($subscriber->ip == '0.0.0.0') {
        $subscriber->ip = '0';
    }
    $subscriber->subscribe_date = time();
    $subscriber->params = JRequest::getVar('params', '');
    //column
    if ($GLOBALS[JNEWS . 'level'] > 2) {
        $subscriber->column1 = JRequest::getVar('column1', '');
        $subscriber->column2 = JRequest::getVar('column2', '');
        $subscriber->column3 = JRequest::getVar('column3', '');
        $subscriber->column4 = JRequest::getVar('column4', '');
        $subscriber->column5 = JRequest::getVar('column5', '');
    }
    //end check of version pro
    //END OF DATA FROM REQUEST
    $doShowSubscribers = true;
    switch ($task) {
        case 'updateOneSub':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            $new = false;
            //we addslashes the name incase an ' is entered in the name
            $subscriber->name = addslashes($subscriber->name);
            $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_UPDATED_SUCCESSFULLY, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'deleteOneSub':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            $message = jnews::printYN(jNews_Subscribers::deleteSubscriber($subscriberId), _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'cancelSub':
            $doShowSubscribers = true;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'edit':
            foreach ($cid as $id) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&task=show&userid=' . $id);
            }
            break;
        case 'show':
            $doShowSubscribers = false;
            $qid[0] = $userid;
            $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
            $lists = jNews_Lists::getLists(0, 0, 1, '', false, false);
            $queues = jNews_ListsSubs::getSubscriberLists($userid);
            $forms['main'] = " <form action='index.php' method='post' name='adminForm' id=\"adminForm\">";
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            backHTML::formStart('', 0, '');
            echo jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('subscriber_id', $subscriber->id);
            $go[] = jnews::makeObj('user_id', $subscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'new':
        case 'add':
            $doShowSubscribers = false;
            $newSubscriber = new stdClass();
            $newSubscriber->id = '';
            $newSubscriber->user_id = 0;
            $newSubscriber->name = '';
            $newSubscriber->email = '';
            $newSubscriber->ip = jNews_Subscribers::getIP();
            $newSubscriber->receive_html = 1;
            $newSubscriber->confirmed = 1;
            $newSubscriber->blacklist = 0;
            $newSubscriber->timezone = '00:00:00';
            $newSubscriber->language_iso = 'eng';
            $newSubscriber->params = '';
            $newSubscriber->subscribe_date = time();
            //column
            if ($GLOBALS[JNEWS . 'level'] > 2) {
                //check if the version of jnews is pro
                $newSubscriber->column1 = '';
                $newSubscriber->column2 = '';
                $newSubscriber->column3 = '';
                $newSubscriber->column4 = '';
                $newSubscriber->column5 = '';
            }
            $lists = jNews_Lists::getLists(0, 0, 1, '', false, false);
            $queues = '';
            $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">";
            if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) {
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
                backHTML::formStart('addsubsback', 0, '');
                echo jNews_SubscribersHTML::editSubscriber($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            } else {
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
                backHTML::formStart('addsubsfront', 0, '');
                echo jNews_SubscribersHTML::editSubscriberFE($newSubscriber, $lists, $queues, $forms, jnews::checkPermissions('admin'), false, false);
            }
            $go[] = jnews::makeObj('act', $action);
            $go[] = jnews::makeObj('subscriber_id', $newSubscriber->id);
            $go[] = jnews::makeObj('user_id', $newSubscriber->user_id);
            backHTML::formEnd($go);
            break;
        case 'doNew':
            JRequest::checkToken() or die('Invalid Token');
            $doShowSubscribers = true;
            if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'use_backendview']) {
                $message = jnews::printYN(jNews_Subscribers::saveSubscriber($subscriber, $subscriberId, $new), _JNEWS_NEW_SUBSCRIBER, _JNEWS_ERROR);
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            } else {
                $status = jNews_Subscribers::importBis();
                if ($mainframe->isAdmin()) {
                    jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                } else {
                    $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                    jNews_Tools::redirect($mainLink);
                }
            }
            break;
        case 'delete':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
                return false;
            } else {
                $status = true;
                foreach ($cid as $id) {
                    if (!jNews_Subscribers::deleteSubscriber($id)) {
                        $status = false;
                    }
                }
                $message = jnews::printYN($status, _JNEWS_SUBSCRIBER_DELETED, _JNEWS_ERROR);
                backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            }
            break;
        case 'update':
            JRequest::checkToken() or die('Invalid Token');
            if (!is_array($cid) || count($cid) < 1) {
                echo "<script> alert('Select an item to update'); window.history.go(-1);</script>\n";
                return false;
            } else {
                foreach ($cid as $id) {
                    $changes = JRequest::getVar($id, array(0));
                    if (!isset($changes['receive_html'])) {
                        $changes['receive_html'] = 0;
                    }
                    if (!isset($changes['confirmed'])) {
                        $changes['confirmed'] = 0;
                    }
                }
            }
            $message = jnews::print_message(_JNEWS_UPDATED_SUCCESSFULLY, 1);
            break;
        case 'export':
            $doShowSubscribers = false;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            jNews_SubscribersHTML::export($action, $listId);
            break;
        case 'doExport':
            $message = jnews::printYN(jNews_Subscribers::export($listId), _EXPORT, _JNEWS_ERROR);
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'import':
            $doShowSubscribers = false;
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            $lists = jNews_Lists::getLists('', 0, '', '', false, true, true, false, false);
            jNews_SubscribersHTML::import($action, $lists, $listId);
            break;
        case 'doImport':
            JRequest::checkToken() or die('Invalid Token');
            $message = jNews_Subscribers::importBis();
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            $message = !empty($message) && $message !== true ? $message : ($message === false ? 'Import failed' : _JNEWS_IMPORT_FINISHED);
            if ($mainframe->isAdmin()) {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers', $message);
            } else {
                $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION . '&act=subscribers&mid=2');
                jNews_Tools::redirect($mainLink);
            }
            break;
        case 'subscribeAll':
        case 'unsubscribeAll':
            JRequest::checkToken() or die('Invalid Token');
            break;
        case 'cancel':
            if ($listId != 0) {
                $listId = 0;
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            }
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
        case 'cpanel':
            $mainframe = JFactory::getApplication();
            if ($mainframe->isAdmin()) {
                backHTML::controlPanel();
            } else {
                jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION);
            }
            $doShowSubscribers = 0;
            break;
        case 'toggle':
            $subid = JRequest::getVar('subid');
            $column = JRequest::getVar('col');
            if (!empty($subid) && !empty($column)) {
                $passObj = new stdClass();
                $passObj->tableName = '#__jnews_subscribers';
                $passObj->columnName = $column;
                $passObj->whereColumn = 'id';
                $passObj->whereColumnValue = $subid;
                jnews::toggle($passObj);
                // change suspend status if column toggled is confirmed
                if ($column == 'confirmed') {
                    $passObj = new stdClass();
                    $passObj->tableName = '#__jnews_queue';
                    $passObj->columnName = 'suspend';
                    $passObj->whereColumn = 'subscriber_id';
                    $passObj->whereColumnValue = $subid;
                    jnews::toggle($passObj);
                }
            }
            jNews_Tools::redirect('index.php?option=' . JNEWS_OPTION . '&act=subscribers&listid=' . $listId);
            break;
        default:
            backHTML::_header(_JNEWS_MENU_SUBSCRIBERS, $img, $message, $task, $action);
            break;
    }
    if ($doShowSubscribers) {
        $limit = -1;
        $emailsearch = JRequest::getVar('emailsearch', '', '', 'STRING');
        $emailsearch = htmlentities($emailsearch, ENT_COMPAT, "UTF-8");
        $paginationStart = JRequest::getVar('pg');
        $lll = JRequest::getVar('limitstart');
        if (empty($lll)) {
            JRequest::setVar('limitstart', 0, 'int');
        }
        $app = JFactory::getApplication();
        $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0, 'int');
        $limitend = $app->getUserStateFromRequest('limit', 'limit', 0, 'int');
        $subscirberTypeID = JRequest::getVar('subtype', 1);
        if (empty($listId) && in_array($subscirberTypeID, array(1, 2))) {
            $subscirberTypeID = 0;
        }
        if (!empty($listId) && in_array($subscirberTypeID, array(3, 4))) {
            $subscirberTypeID = 0;
        }
        if (!empty($my->id)) {
            $ownedlists = jNews_Lists::getOwnedlists($my->id);
        }
        $ztozto = null;
        $limittotal = jNews_Subscribers::getSubscribers(0, 0, $emailsearch, $ztozto, $listId, '', '', '', 'sub_dateD', '', $ownedlists, '', $subscirberTypeID, true);
        //added one parameter for mailid
        $setLimit = new stdClass();
        $setLimit->total = !empty($limittotal) ? $limittotal : 0;
        $setLimit->start = !empty($limitstart) ? $limitstart : 0;
        $setLimit->end = !empty($limitend) ? $limitend : 20;
        $setSort = new stdClass();
        $setSort->orderValue = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order', 'filter_order', 'subscribe_date', 'cmd');
        $setSort->orderDir = $app->getUserStateFromRequest(JNEWS_OPTION . '.subscribers.filter_order_Dir', 'filter_order_Dir', 'desc', 'word');
        if (empty($limitstart)) {
            $limitstart = 0;
        }
        if ($setLimit->end > 200) {
            $setLimit->end = 200;
        }
        if ($setLimit->total == $setLimit->end) {
            $setLimit->start = 0;
        }
        $subscribers = jNews_Subscribers::getSubscribers($setLimit->start, $setLimit->end, $emailsearch, $setLimit->total, $listId, '', '', '', 'sub_dateD', '', $ownedlists, $setSort, $subscirberTypeID);
        //added one parameter for mailid
        if ($listId != 0) {
            $showAdmin = true;
        } else {
            $showAdmin = false;
        }
        $dropDownList = jNews_ListType::getListsDropList(0, '', '');
        $subTypeA = array();
        $subTypeA[0] = new stdClass();
        $subTypeA[0]->id = 0;
        $subTypeA[0]->subtype = _JNEWS_SUB_LISTTYPE_ALL;
        if ($listId != 0) {
            $subTypeA[1] = new stdClass();
            $subTypeA[1]->id = 1;
            $subTypeA[1]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_SUBCRIBED;
            $subTypeA[2] = new stdClass();
            $subTypeA[2]->id = 2;
            $subTypeA[2]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_UNSUBCRIBED;
        } else {
            $subTypeA[3] = new stdClass();
            $subTypeA[3]->id = 3;
            $subTypeA[3]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_WAITINGCONF;
            $subTypeA[4] = new stdClass();
            $subTypeA[4]->id = 4;
            $subTypeA[4]->subtype = _JNEWS_SUB_LISTTYPE_ONLY_BLOCKED;
        }
        $lists['listid'] = jnews::HTML_GenericList($dropDownList, 'listid', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'list_name', $listId);
        $lists['subscirberType'] = jnews::HTML_GenericList($subTypeA, 'subtype', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'id', 'subtype', $subscirberTypeID);
        if ($mainframe->isAdmin()) {
            $forms['main'] = " <form action='index.php' method='post' name=\"adminForm\" id=\"adminForm\">";
        } else {
            if (empty($setLimit->start)) {
                $setLimit->start = 0;
            }
            $mainLink = JRoute::_('index.php?option=' . JNEWS_OPTION);
            $forms['main'] = "<form action='" . $mainLink . "' method='post' name=\"adminForm\" id=\"adminForm\">";
        }
        $forms['select'] = " <form method='post' name='jNewsFilterForm'> \n";
        backHTML::formStart('show_mailing', 0, '');
        jNews_SubscribersHTML::showSubscribers($subscribers, $action, $listId, $lists, $setLimit->start, $setLimit->end, $setLimit->total, $showAdmin, $listId, $emailsearch, $forms, $setLimit, $front, $setSort);
    }
    return true;
}
示例#2
0
    public static function editSubscriber($subscriber, $listings, $queues, $forms, $access = false, $frontEnd = false, $cb = false)
    {
        $mainframe = JFactory::getApplication();
        $my = JFactory::getUser();
        if (!$GLOBALS[JNEWS . 'disabletooltip']) {
            if (version_compare(JVERSION, '3.0.0', '<')) {
                JHTML::_('behavior.tooltip');
            } else {
                JHtml::_('behavior.tooltip');
            }
        }
        if (empty($subscriber->receive_html)) {
            $subscriber->receive_html = 0;
        }
        $lists['receive_html'] = jnews::HTML_BooleanList('receive_html', 'class="inputbox"', $subscriber->receive_html, JText::_(_CMN_YES), JText::_(_CMN_NO));
        //Fixed added by Lorenz Meyer for the Yes No Translation
        if (empty($subscriber->confirmed)) {
            $subscriber->confirmed = 0;
        }
        $lists['confirmed'] = jnews::HTML_BooleanList('confirmed', 'class="inputbox"', $subscriber->confirmed, JText::_(_CMN_YES), JText::_(_CMN_NO));
        if (empty($subscriber->blacklist)) {
            $subscriber->blacklist = 0;
        }
        $lists['blacklist'] = jnews::HTML_BooleanList('blacklist', 'class="inputbox"', $subscriber->blacklist, JText::_(_CMN_YES), JText::_(_CMN_NO));
        $br = "\n\r";
        $html = $forms['main'];
        $html .= '<div style="width:100%; align:left;">' . $br;
        $html .= '<fieldset class="jnewscss" style="padding: 10px; text-align: left">' . $br;
        $html .= '<legend><strong>' . _JNEWS_SUB_INFO . '</strong></legend>' . $br;
        $html .= '<table cellpadding="2" cellspacing="0" align="center"><tr><td>' . $br;
        if (empty($subscriber->name)) {
            $subscriber->name = '';
        }
        $text = str_replace('"', '&quot;', $subscriber->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);
        }
        if (!$cb) {
            $html .= jnews::miseEnHTML(_JNEWS_INPUT_NAME, _JNEWS_INPUT_NAME_TIPS, '<input type="text" name="name" size="30" value="' . $text . '" class="inputbox" />');
            if (empty($subscriber->email) || !jNews_Subscribers::validEmail($subscriber->email)) {
                $subscriber->email = '';
            }
            $html .= jnews::miseEnHTML(_JNEWS_INPUT_EMAIL, _JNEWS_INPUT_EMAIL_TIPS, '<input type="text" name="email" size="30" class="inputbox" value="' . $subscriber->email . '"  />');
            //additional columns
            if ($GLOBALS[JNEWS . 'level'] > 2) {
                //check if the version of jnews is pro
                if (empty($subscriber->column1)) {
                    $subscriber->column1 = '';
                }
                if (empty($subscriber->column2)) {
                    $subscriber->column2 = '';
                }
                if (empty($subscriber->column3)) {
                    $subscriber->column3 = '';
                }
                if (empty($subscriber->column4)) {
                    $subscriber->column4 = '';
                }
                if (empty($subscriber->column5)) {
                    $subscriber->column5 = '';
                }
                if ($GLOBALS[JNEWS . 'show_column1']) {
                    //show column1
                    $html .= jnews::miseEnHTML($GLOBALS[JNEWS . 'column1_name'], _JNEWS_INPUT_COLUMN_TIPS . '1', '<input type="text" name="column1" size="30" class="inputbox" value="' . $subscriber->column1 . '"  />');
                }
                if ($GLOBALS[JNEWS . 'show_column2']) {
                    //show column2
                    $html .= jnews::miseEnHTML($GLOBALS[JNEWS . 'column2_name'], _JNEWS_INPUT_COLUMN_TIPS . '2', '<input type="text" name="column2" size="30" class="inputbox" value="' . $subscriber->column2 . '"  />');
                }
                if ($GLOBALS[JNEWS . 'show_column3']) {
                    //show column3
                    $html .= jnews::miseEnHTML($GLOBALS[JNEWS . 'column3_name'], _JNEWS_INPUT_COLUMN_TIPS . '3', '<input type="text" name="column3" size="30" class="inputbox" value="' . $subscriber->column3 . '"  />');
                }
                if ($GLOBALS[JNEWS . 'show_column4']) {
                    //show column4
                    $html .= jnews::miseEnHTML($GLOBALS[JNEWS . 'column4_name'], _JNEWS_INPUT_COLUMN_TIPS . '4', '<input type="text" name="column4" size="30" class="inputbox" value="' . $subscriber->column4 . '"  />');
                }
                if ($GLOBALS[JNEWS . 'show_column5']) {
                    //show column5
                    $html .= jnews::miseEnHTML($GLOBALS[JNEWS . 'column5_name'], _JNEWS_INPUT_COLUMN_TIPS . '5', '<input type="text" name="column5" size="30" class="inputbox" value="' . $subscriber->column5 . '"  />');
                }
            }
        } else {
            $html .= '<input type="hidden" name="cb_integration" value="1"  />';
        }
        if (empty($subscriber->ip)) {
            $subscriber->ip = '';
        }
        //$mainframe = JFactory::getApplication();
        if ($mainframe->isAdmin() or $GLOBALS[JNEWS . 'sub_info_fields']) {
            $html .= jnews::miseEnHTML(_JNEWS_IP, _JNEWS_IP_TIPS, $subscriber->ip);
        }
        $html .= jnews::miseEnHTML(_JNEWS_RECEIVE_HTML, _JNEWS_RECEIVE_HTML_TIPS, $lists['receive_html']);
        if ($GLOBALS[JNEWS . 'time_zone'] == 1) {
            $html .= jnews::miseEnHTML(_JNEWS_TIME_ZONE_ASK, _JNEWS_TIME_ZONE_ASK_TIPS, ' <input type="text" name="timezone" size="30" class="inputbox" value="' . $subscriber->timezone . '"  />');
        } else {
            if (empty($subscriber->timezone)) {
                $subscriber->timezone = '';
            }
            $html .= '<input type="hidden" name="timezone" value="' . $subscriber->timezone . '"  />';
        }
        if ($access) {
            if (empty($subscriber->user_id)) {
                $subscriber->user_id = 0;
            }
            if ($subscriber->user_id == 0) {
                if ($mainframe->isAdmin() or $GLOBALS[JNEWS . 'confirm_html']) {
                    $html .= jnews::miseEnHTML(_JNEWS_CONFIRMED, '', $lists['confirmed']);
                }
            } else {
                if (!$cb || !$mainframe->isAdmin()) {
                    $html .= '<input type="hidden" name="confirmed" value="' . $subscriber->confirmed . '" />';
                }
            }
            //improvement added; blacklist will only be shown in the backend
            if ($mainframe->isAdmin() || $GLOBALS[JNEWS . 'sub_info_fields']) {
                $html .= jnews::miseEnHTML(_JNEWS_BLACK_LIST, '', $lists['blacklist']);
            }
            if (empty($subscriber->subscribe_date)) {
                $subscriber->subscribe_date = 0;
            }
            if ($mainframe->isAdmin() or $GLOBALS[JNEWS . 'sub_info_fields']) {
                $html .= jnews::miseEnHTML(_JNEWS_REGISTRATION_DATE, '', date('Y-m-d h:i', jnews::getNow(0, true, $subscriber->subscribe_date)));
                $html .= jnews::miseEnHTML(_JNEWS_USER_ID, '', $subscriber->user_id);
            }
        } else {
            $html .= '<input type="hidden" name="confirmed" value="' . $subscriber->confirmed . '" />';
            $html .= '<input type="hidden" name="blacklist" value="' . $subscriber->blacklist . '" />';
        }
        //captcha FE
        if (empty($my->id) && !$cb && !$mainframe->isAdmin() && class_exists('jNews_Captcha') && $GLOBALS[JNEWS . 'level'] > 2) {
            if (extension_loaded('gd') && extension_loaded('mcrypt')) {
                $gdinfo = gd_info();
                //					$captchaHTML='';
                $moduleParams = self::getModuleParams();
                $captcha_width = $moduleParams->get('captcha_width');
                $captcha_height = $moduleParams->get('captcha_height');
                $captcha_bgcolor = urlencode($moduleParams->get('captcha_bgcolor'));
                $captcha_ftcolor = urlencode($moduleParams->get('captcha_ftcolor'));
                if ($gdinfo['FreeType Support']) {
                    if (isset($_SESSION) && !isset($_SESSION['captcha'])) {
                        $code = jNews_Captcha::generateCode('5');
                        $_SESSION['captcha'] = $code;
                    } else {
                        $code = $_SESSION['captcha'];
                    }
                    //						$captchaHTML .= '<div class="subscriptionCaptcha" style="float:left;">';
                    //						$escaptcha = jNews_Captcha::encryptData($code, crypt( $GLOBALS[JNEWS.'captcha_code'], $GLOBALS[JNEWS.'captcha_code'] ) );
                    //						$esc = $escaptcha;
                    //						$decrypt=jNews_Captcha::decryptData( $esc, crypt( $GLOBALS[JNEWS.'captcha_code'], $GLOBALS[JNEWS.'captcha_code'] ) );
                    //						$path= JNEWS_JPATH_LIVE_NO_HTTPS.'/index.php?option='.JNEWS_OPTION.'&act=captcha&tmpl=component&width='.$captcha_width.'&height='.$captcha_height.'&bgcolor='.$captcha_bgcolor.'&ftcolor='.$captcha_ftcolor.'&characters=5&esc='. $esc.'&encpwd='.crypt($GLOBALS[JNEWS.'captcha_code'],$GLOBALS[JNEWS.'captcha_code'] );
                    //						$captchaHTML .= '<img alt="catchme" style="border: 0px;" src="'. $path .'" id="captcha_image1" />';
                    //						$url = htmlentities( jNews_Tools::completeLink( 'option='.JNEWS_OPTION.'&act=mailing&task=refreshcaptcha&captchawidth='.$captcha_width.'&captchaheight='.$captcha_height .'&captchabgcolor='.$captcha_bgcolor.'&captchaftcolor='.$captcha_ftcolor, false, false, true ) );
                    //						$captchaHTML .= '&nbsp;<img alt="refresh" style="border: 0px;" src="'. JURI::base().'components/'.JNEWS_OPTION.'/images/refresh.png" onclick="refreshCaptcha1(\''.$url.'\');" id="refreshButton" title="Refresh Captcha" />';
                    //						$captchaHTML .= '</div>';
                    //						$captchaHTML .='<div class="entered_captcha"><input class="inputbox" title ="'._JNEWS_CAPTCHA_TIPS.'" name="security_code" size="7" type="text" class="entered_captcha"/></div>';
                    //						$captchaHTML .= '</div>';
                    $captchaHTML = self::_showCaptcha($code);
                    $html .= jnews::miseEnHTML(_JNEWS_CAPTCHA_CAPTION, '', $captchaHTML);
                    //						$escaptcha = jNews_Captcha::encryptData($code, crypt($GLOBALS[JNEWS.'captcha_code'],$GLOBALS[JNEWS.'captcha_code']));
                    //				       $esc = $escaptcha;
                    //				       $newdecrypt = jNews_Captcha::decryptData($esc, crypt($GLOBALS[JNEWS.'captcha_code'],$GLOBALS[JNEWS.'captcha_code']));
                    //				       $html .='<input type="hidden" id="security_captcha1" name="security_captcha" value="'.$esc.'" />';
                    //				       $html .='<input type="hidden" id="captcode1" name="captcode" value="'.$newdecrypt.'" />';
                    $html .= self::_showCaptchaHidden($code, "2");
                    //checking of captcha
                    $captcha_width = (int) $captcha_width;
                    $captcha_height = (int) $captcha_height;
                    $js = '
	function insertNewCaptcha1(html){
				var form = document.adminForm;
				if(!form){
					form = document.mosForm;
				}
				var window = document.getElementById("sbox-content");
				var root = document.getElementById("captcha1");

				if(form.security_code.value == "") {alert( "' . addslashes(_JNEWS_REGWARN_CAPTCHA) . '" ); return false;}
				if(form.captcode.value != "version2" && form.security_code.value != form.captcode.value){
					alert( "' . addslashes(_JNEWS_CAPTCHA_MSG) . '" );return false;
				}

				if(root == null){
				 	root = document.createElement(\'div\');
					root.setAttribute("style", "width:10px;heigth:10px;display:none;");
					root.setAttribute("id", "captcha1");
					var body = document.getElementsByTagName(\'body\')[0].appendChild(root);
				}
				root.innerHTML = html;

				var newcode = document.getElementById(\'newcode\');
				var newesc = document.getElementById(\'newesc\');
				var newdecrypt = document.getElementById(\'newdecrypt\');
				var newpath = document.getElementById(\'newpath\');
				var newsecuritycaptcha = document.getElementById(\'security_captcha1\');
				var newcaptcode = document.getElementById(\'captcode1\');
				var image =  document.getElementById(\'captcha_image1\');
				var path = newpath.innerHTML;
      			var intIndexOfMatch = path.indexOf( "&amp;" );

     			while (intIndexOfMatch != -1){
       				path= path.replace( "&amp;", "&" );
       				intIndexOfMatch = path.indexOf( "&amp;" );
      			}

				image.setAttribute("src", path);
				image.setAttribute("width", ' . $captcha_width . ');
				image.setAttribute("height", ' . $captcha_height . ');
				newsecuritycaptcha.value = newesc.innerHTML;
				newcaptcode.value = newcode.innerHTML;

				if(window != null){

				windowImages = window.getElementsByTagName("img");
				windowInput = window.getElementsByTagName("input");

				var captcha_image = windowImages.captcha_image1;
				var captcode = windowInput.captcode1;
				var security_captcha = windowInput.security_captcha1;

				security_captcha.value = newesc.innerHTML;
					captcode.value = newcode.innerHTML;
				captcha_image.setAttribute("src", path);
			}
				document.getElementById(\'entered_captcha\').value=\'\';
				document.getElementsByTagName(\'body\')[0].removeChild(root);
			}

	';
                    if (version_compare(JVERSION, '1.6.0', '<')) {
                        //1.5
                        $js .= "function refreshCaptcha1(url){\n\t      var form = document.adminForm;\n\t\t\t\tif(!form){\n\t\t\t\t\tform = document.mosForm;\n\t\t\t\t}\n\t\t\tvar ajax = new Ajax(url,{data: 'height=1',method: 'POST',onComplete : function(result){insertNewCaptcha1(result); }});ajax.request();}";
                    } else {
                        $js .= "function refreshCaptcha1(url){\n\t      var ajax = new Request({url : url,data: 'height=1',method: 'POST',onComplete : function(result){insertNewCaptcha1(result); }});ajax.send();}";
                    }
                    $document = JFactory::getDocument();
                    $document->addScriptDeclaration($js, 'text/javascript');
                } else {
                    echo 'Your Server does not support GD Library FreeType Support do the captcha cannot be shown!';
                    echo '<br />Please enable the GD Library FreeType Support to see the captcha.';
                }
            }
        }
        $html .= '</table>';
        $html .= '</fieldset></div>';
        if (!$cb) {
            $lists = $mainframe->isAdmin() ? jNews_Lists::getLists(0, 1, '', '', false, true, true, false, false) : jNews_Lists::getLists('', 1, '', '', false, true, false, false, true);
            $listsAr = $mainframe->isAdmin() ? jNews_Lists::getLists(0, 2, '', '', false, true, true, false, false) : jNews_Lists::getLists('', 2, '', '', false, true, false, false, true);
        } else {
            $lists = $listings;
            $listsAr = array();
        }
        if (empty($listsAr)) {
            $listwidth = '100%';
        } else {
            $listwidth = '50%';
        }
        if (empty($lists)) {
            $listarwidth = '100%';
        } else {
            $listarwidth = '50%';
        }
        $html .= '<table width="100%"><tr>';
        $html .= '<td width="' . $listwidth . '">';
        $html .= jNews_SubscribersHTML::showSubscriberLists($subscriber, $lists, $queues, $frontEnd, $access);
        $html .= '</td>';
        $html .= '<td width="' . $listarwidth . '" valign="top">';
        $html .= jNews_SubscribersHTML::showSubscriberLists($subscriber, $listsAr, $queues, $frontEnd, $access);
        $html .= '</td>';
        $html .= '</tr></table>';
        return $html;
    }
示例#3
0
文件: frontend.php 项目: naka211/kkvn
 public static function showSubscriberLists($subscriberId, $action)
 {
     $lists = jNews_Lists::getLists(0, 0, $subscriberId, '', false, true, false);
     if ($subscriberId == 0) {
         $subscriber = '';
         $queues = '';
         jNews_SubscribersHTML::showSubscriberLists($subscriber, $lists, $queues, true);
     } else {
         frontEnd::subscriptions('', $subscriberId, 0, 'save');
     }
     return true;
 }
示例#4
0
文件: jnews_cb.php 项目: naka211/kkvn
 function getEditTab($tab, $user, $ui)
 {
     $Itemid = JRequest::getInt('Itemid');
     $my = JFactory::getUser();
     if ($my->get('id') < 1) {
         echo JText::_('ALERTNOTAUTH');
         echo "<br />" . JText::_('You need to login.');
         return false;
     }
     if (!getjNewsTab::checkInstalled()) {
         return _UE_NEWSLETTERNOTINSTALLED;
     }
     $html = '';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.jnews.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.listssubscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.lists.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'views' . DS . 'subscribers.jnews.html.php';
     if (!empty($my->id)) {
         $subscriberId = jNews_Subscribers::getSubscriberIdFromUserId($my->id);
         $qid[0] = $subscriberId;
         $subscriber = jNews_Subscribers::getSubscribersFromId($qid, false);
         $queues = jNews_ListsSubs::getSubscriberLists($subscriberId);
         $access = jnews::checkPermissions('admin', $my->id);
     } else {
         $userId = 0;
         $queues = '';
         $access = false;
         $subscriberId = 0;
         $subscriber = new stdClass();
         $subscriber->id = '';
         $subscriber->user_id = 0;
         $subscriber->name = '';
         $subscriber->email = '';
         $subscriber->ip = jNews_Subscribers::getIP();
         $subscriber->receive_html = 1;
         $subscriber->confirmed = 1;
         $subscriber->blacklist = 0;
         $subscriber->timezone = '00:00:00';
         $subscriber->language_iso = 'eng';
         $subscriber->params = '';
         $subscriber->subscribe_date = time();
         if ($GLOBALS[JNEWS . 'level'] > 2) {
             //check if the version of jnews is pro
             $subscriber->column1 = '';
             $subscriber->column2 = '';
             $subscriber->column3 = '';
             $subscriber->column4 = '';
             $subscriber->column5 = '';
         }
     }
     if (!empty($my->user_id)) {
         if ($my->user_id > 0) {
             $access = jnews::checkPermissions('admin');
         } else {
             $access = false;
         }
     }
     $query = 'SELECT * FROM `#__jnews_lists` WHERE `published`=1 AND `hidden`=1 ';
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $lists = $db->loadObjectList();
     $doShowSubscribers = false;
     $mainLink = 'option=' . JNEWS_OPTION;
     $selectLink = 'option=' . JNEWS_OPTION . '&act=subscriber';
     $mainLink = jNews_Tools::completeLink($mainLink, false);
     $selectLink = jNews_Tools::completeLink($selectLink, false);
     $forms['main'] = '<form method="post" action="' . $mainLink . '" onsubmit="submitbutton();return false;" name="mosForm" >' . "\n\r";
     $forms['select'] = '<form method="post" action="' . $selectLink . '"  name="jNewsFilterForm">';
     if (empty($access)) {
         $access = 29;
     }
     $html .= jNews_SubscribersHTML::editSubscriber($subscriber, $lists, $queues, $forms, $access, true, true);
     $html .= '<input type="hidden" name="subscriber_id" value="' . $subscriber->id . '" />';
     return $html;
 }