示例#1
0
文件: api.php 项目: Ruud68/cjblog
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
defined('_JEXEC') or die('Restricted access');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
defined('CJBLOG') or define('CJBLOG', 'com_cjblog');
require_once JPATH_ROOT . '/components/' . CJBLOG . '/helpers/constants.php';
/* *************************************************************** */
/* ************************** CJLIB Includes ********************* */
$cjlib = JPATH_ROOT . '/components/com_cjlib/framework.php';
if (!file_exists($cjlib)) {
    die('CJLib (CoreJoomla API Library) component not found. Please download and install it to continue.');
}
require_once $cjlib;
CJLib::import('corejoomla.framework.core');
/* ************************** CJLIB Includes ********************* */
// Load Language
JFactory::getLanguage()->load(CJBLOG, JPATH_ROOT);
// Add logger
$date = JFactory::getDate()->format('Y.m.d');
JLog::addLogger(array('text_file' => CJBLOG . '.' . $date . '.log.php'), JLog::ALL, CJBLOG);
/* *************************************************************** */
class CjBlogApi
{
    private static $_users = array();
    private static $_badge_rules = array();
    private static $_errors = array();
    private static $_enable_logging = false;
    /**
     * Sets the debug logging enabled or disabled 
示例#2
0
    die('CJLib (CoreJoomla API Library) component not found. Please download and install it to continue.');
}
CJLib::import('corejoomla.framework.core');
// Get the properties
$show_latest = intval($params->get('show_latest', '1'));
$show_popular = intval($params->get('show_most_popular', '1'));
$show_tabs = intval($params->get('show_tabs', '1'));
$tab_order = trim($params->get('tab_order', 'L,M'));
// Get the item id for community answers
$itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
$document = JFactory::getDocument();
$document->addStyleSheet(JURI::base(true) . '/modules/mod_communitysurveys/assets/communitysurveys.css');
// get the items to display from the helper
$order = explode(',', $tab_order);
if ($show_tabs == 1) {
    CJLib::import('corejoomla.ui.bootstrap', true);
    echo '<div id="cj-wrapper">';
    echo '<ul class="nav nav-tabs" data-tabs="tabs">';
    foreach ($order as $i => $tab) {
        if (strcmp($tab, "L") == 0 && $show_latest) {
            echo '<li' . ($i == 0 ? ' class="active"' : '') . '><a href="#cstab-1" data-toggle="tab">' . JText::_('LBL_LATEST_SURVEYS') . '</a></li>';
        }
        if (strcmp($tab, 'M') == 0 && $show_popular) {
            echo '<li' . ($i == 0 ? ' class="active"' : '') . '><a href="#cstab-2" data-toggle="tab">' . JText::_('LBL_MOST_POPULAR_SURVEYS') . '</a></li>';
        }
    }
    echo '</ul>';
    foreach ($order as $i => $tab) {
        if (strcmp($tab, 'L') == 0 && $show_latest) {
            $latest_surveys = modCommunitySurveysHelper::getLatestSurveys($params);
            echo '<div id="cstab-1" class="tab-pane fade' . ($i == 0 ? ' in active' : '') . '">';
示例#3
0
    public function onContentPrepare($context, &$article, &$params, $page = 0)
    {
        $app = JFactory::getApplication();
        $menu = $app->getMenu();
        if ($menu->getActive() == $menu->getDefault() || $context != 'com_content.article' || $page > 0 || empty($article->id)) {
            return true;
        }
        $db = JFactory::getDbo();
        $document = JFactory::getDocument();
        $user = JFactory::getUser();
        $api = new CjLibApi();
        $article_url = JRoute::_(ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid . ':' . $article->category_alias));
        /******************************** TRIGGER BADGE RULE ******************************************/
        CjBlogApi::trigger_badge_rule('com_content.num_hits', array('num_hits' => $article->hits, 'ref_id' => $article->id), $article->created_by);
        /******************************* TRIGGER POINTS RULES ******************************************/
        $appparams = JComponentHelper::getParams('com_cjblog');
        if ($appparams->get('enable_points')) {
            CjBlogApi::award_points('com_content.hits', $user->id, 0, $article->id, JHtml::link($article_url, $article->title));
            CjBlogApi::award_points('com_content.popular_articles', $article->created_by, 0, $article->id, JHtml::link($article_url, $article->title), array('hits' => $article->hits));
        }
        // Check if the plugin is disabled for the article category
        $include_categories = $this->params->get('include_categories');
        $exclude_categories = $this->params->get('exclude_categories');
        $about_length = $this->params->get('about_length', 180);
        if (!empty($include_categories)) {
            $include_categories = explode(',', $include_categories);
            if (!in_array($article->catid, $include_categories)) {
                return true;
            }
        } else {
            if (!empty($exclude_categories)) {
                $exclude_categories = explode(',', $exclude_categories);
                if (in_array($article->catid, $exclude_categories)) {
                    return true;
                }
            }
        }
        $print = $app->input->getInt('print', 0);
        if ($print) {
            return true;
        }
        /********************************** CONTENT HEADER *********************************************/
        require_once JPATH_ROOT . '/components/com_cjblog/router.php';
        $CjLib = JPATH_ROOT . '/components/com_cjlib/framework.php';
        CJLib::import('corejoomla.framework.core');
        $custom_tag = false;
        JHtml::_('jquery.framework');
        CJLib::behavior('bscore', array('customtag' => $custom_tag));
        CJFunctions::load_jquery(array('libs' => array('rating', 'social', 'fontawesome'), 'custom_tag' => $custom_tag));
        $document->addScript(JUri::root(true) . '/media/com_cjblog/js/cjblog.min.js');
        $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/cjblog.min.css');
        $articles_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=com_cjblog&view=articles');
        $profile = CjBlogApi::get_user_profile($article->created_by);
        // 		$params->merge($appparams);
        $meta_header = '';
        $meta_stats = '';
        $meta_rating = '';
        $meta_rating_readonly = '';
        $social_buttons = '';
        $tags_html = '';
        $show_category = $appparams->get('show_category', 1);
        $show_date = $appparams->get('show_create_date', 1);
        $date_format = JText::_($appparams->get('date_format', 'd F Y'));
        $show_hits = $appparams->get('show_hits', 1);
        $show_author = $appparams->get('show_author', 1);
        $show_favoured = $appparams->get('show_favoured', 1);
        $show_rating = $appparams->get('show_rating', 1);
        $user_name = $appparams->get('user_display_name', 'name');
        $hot_hits = $appparams->get('hot_article_num_hits', 250);
        $social_buttons = $appparams->get('display_social_buttons', 1);
        $sharing_buttons_customtag = $appparams->get('sharing_buttons_customtag', '');
        $sharing_buttons_customtext = $appparams->get('sharing_buttons_customtext', '');
        $social_buttons_theme = $appparams->get('social_buttons_theme', 'jssocials-theme-classic.css');
        $sharing_position = $appparams->get('sharing_buttons_position', 'bottom');
        $jssocial_label = $appparams->get('jssocial_button_label', 'true');
        $jssocial_count = $appparams->get('jssocial_button_count', 'true');
        $social_buttons_via = $appparams->get('tweet_button_via', '');
        $social_buttons_hashtag = $appparams->get('tweet_button_hashtag', '');
        $jssocial_email = $appparams->get('jssocial_button_email', '1');
        $jssocial_twitter = $appparams->get('jssocial_button_twitter', '1');
        $jssocial_facebook = $appparams->get('jssocial_button_facebook', '1');
        $jssocial_googleplus = $appparams->get('jssocial_button_googleplus', '1');
        $jssocial_linkedin = $appparams->get('jssocial_button_linkedin', '1');
        $jssocial_pinterest = $appparams->get('jssocial_button_pinterest', '1');
        $profileApp = $appparams->get('profile_component', 'cjblog');
        $avatarApp = $appparams->get('avatar_component', 'cjblog');
        $showProfile = JFactory::getUser($article->created_by)->authorise('core.showprofile', 'com_cjblog');
        $bbcode = $appparams->get('default_editor', 'wysiwygbb') == 'wysiwygbb' ? true : false;
        $about = !empty($profile['about']) ? '<div>' . CJFunctions::preprocessHtml($profile['about'], false, $bbcode) . '</div>' : '';
        if ($about_length > 0) {
            $about = CJFunctions::substrws($about, $about_length);
        }
        if ($show_category && $show_date) {
            $cat_url = JRoute::_('index.php?option=com_cjblog&view=articles&task=latest&id=' . $article->catid . ':' . $article->category_alias . $articles_itemid);
            $cat_link = JHtml::link($cat_url, CJFunctions::escape($article->category_title));
            $formatted_date = CJFunctions::get_localized_date($article->created, $date_format);
            $meta_header = JText::sprintf('TXT_POSTED_IN_CATEGORY_ON', $cat_link, $formatted_date);
        } else {
            if ($show_category) {
                $cat_url = JRoute::_('index.php?option=com_cjblog&view=articles&task=latest&id=' . $article->catid . ':' . $article->category_alias . $articles_itemid);
                $cat_link = JHtml::link($cat_url, CJFunctions::escape($article->category_title));
                $meta_header = JText::sprintf('TXT_POSTED_IN_CATEGORY', $cat_link);
            } else {
                if ($show_date) {
                    $meta_header = JText::sprintf('TXT_POSTED_ON', CJFunctions::get_localized_date($article->created, $date_format));
                }
            }
        }
        if ($article->hits > $hot_hits) {
            $meta_stats = $meta_stats . '<span class="label label-important hot-article">' . JText::_('LBL_HOT') . '</span> ';
        }
        if ($show_hits) {
            $meta_stats = $meta_stats . '<span class="label label-info">' . JText::sprintf('TXT_NUM_HITS', $article->hits) . '</span> ';
        }
        if ($show_favoured) {
            $query = 'select favorites from ' . T_CJBLOG_CONTENT . ' where id = ' . $article->id;
            $db->setQuery($query);
            $favored = (int) $db->loadResult();
            if (!$user->guest) {
                $query = 'select count(*) from ' . T_CJBLOG_FAVORITES . ' where content_id = ' . $article->id . ' and user_id = ' . $user->id;
                $db->setQuery($query);
                $count = $db->loadResult();
                if ($count == 0) {
                    $meta_stats = $meta_stats . '
						<span class="label label-info favorites">' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '</span>
						<a id="btn-add-to-favorites"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=favorite&id=' . $article->id . $articles_itemid) . '"
							onclick="return false;"
							title="' . JText::_('LBL_ADD_TO_FAVORITES') . '">
							<i class="fa fa-star"></i>
						</a>';
                } else {
                    $meta_stats = $meta_stats . '
						<span class="label label-info favorites tooltip-hover" title="' . JText::_('LBL_YOU_ADDED_TO_FAVORITES') . '">
							<i class="fa fa-star"></i> ' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '
						</span>
						<a id="btn-remove-favorite"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=remove_favorite&id=' . $article->id . $articles_itemid) . '"
							onclick="return false;"
							title="' . JText::_('LBL_REMOVE_FAVORITE') . '">
							<i class="icon-remove"></i>
						</a>';
                }
            } else {
                $meta_stats = $meta_stats . '<span class="label label-info favorites">' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '</span>';
            }
        }
        $asset = 'com_content.article.' . $article->id;
        $redirect_url = base64_encode($article_url);
        if ($user->authorise('core.edit.own', $asset) && $article->created_by == $user->id || $user->authorise('core.manage')) {
            $meta_stats = $meta_stats . '
						<a id="btn-edit-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_(CjBlogHelperRoute::getFormRoute($article->id) . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_EDIT_ARTICLE') . '">
							<i class="fa fa-pencil"></i>
						</a>';
        }
        if ($user->authorise('core.edit.state')) {
            if ($article->state == 1) {
                $meta_stats = $meta_stats . '
						<a id="btn-publish-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=unpublish&id=' . $article->id . $articles_itemid . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_PUBLISHED') . '">
							<i class="fa fa-check"></i>
						</a>';
            } else {
                $meta_stats = $meta_stats . '
						<a id="btn-publish-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=publish&id=' . $article->id . $articles_itemid . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_UNPUBLISHED') . '">
							<i class="fa fa-ban"></i>
						</a>';
            }
        }
        if ($show_rating && $user->authorise('articles.rate', 'com_cjblog')) {
            $rating = CJFunctions::get_rating(CJBLOG_ASSET_ID, $article->id);
            $meta_rating_readonly = '
				<div class="pull-right">
					<span class="article-star-rating-readonly"
						data-rating-score="' . $rating['rating'] . '"
						data-rating-hints="' . JText::_('LBL_RATING_HINTS') . '"
						data-rating-noratemsg="' . JText::_('LBL_RATING_NORATE_HINT') . '"
						data-rating-cancelhint="' . JText::_('LBL_RATING_CANCEL_HINT') . '"></span>
					(' . JText::sprintf('TXT_RATINGS', $rating['total_ratings']) . ')
				</div>';
            $readonly = false;
            $hash = CJFunctions::get_hash('com_content.article.rating.item_' . $article->id);
            $cookie = $app->input->cookie->get($hash, null);
            if ($cookie) {
                $readonly = true;
            } else {
                if (!$user->guest) {
                    $query = 'select count(*) from ' . T_CJ_RATING_DETAILS . ' where item_id = ' . $article->id . ' and asset_id = 1 and created_by = ' . $user->id;
                    $db->setQuery($query);
                    $count = (int) $db->loadResult();
                    if ($count > 0) {
                        $app->input->cookie->set($hash, 1, time() + 60 * 60 * 24 * 365, $article_url);
                        $readonly = true;
                    }
                }
            }
            if (!$readonly) {
                $meta_rating = '
					<div>' . JText::_('LBL_RATE_THIS_ARTICLE') . ':</div>
					<span class="article-star-rating"
						data-rating-score="' . $rating['rating'] . '"
						data-rating-url="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=rate&id=' . $article->id . $articles_itemid) . '"
						data-rating-hints="' . JText::_('LBL_RATING_HINTS') . '"
						data-rating-noratemsg="' . JText::_('LBL_RATING_NORATE_HINT') . '"
						data-rating-cancelhint="' . JText::_('LBL_RATING_CANCEL_HINT') . '"></span>
					(<span id="article-rating-info">' . JText::sprintf('TXT_RATING_INFO', $rating['rating'], $rating['total_ratings']) . '</span>)
					<hr>';
            }
        }
        if ($social_buttons == 1) {
            $params_image = new JRegistry();
            $params_image->loadString($article->images);
            $intro = $params_image->get('image_intro');
            $pinterest_image = false;
            if (!empty($intro)) {
                $pinterest_image = JUri::root() . $intro;
            } else {
                preg_match_all('/<img .*src=["|\']([^"|\']+)/i', $article->introtext . $article->fulltext, $matches);
                foreach ($matches[1] as $key => $file_path) {
                    $pinterest_image = JUri::root() . $file_path;
                    break;
                }
            }
            $document->addScript(JUri::root(true) . '/media/com_cjblog/js/jssocials.min.js');
            $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/jssocials.css');
            $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/' . $social_buttons_theme . '');
        }
        if ($social_buttons == 1 || $social_buttons == 2) {
            if ($sharing_buttons_customtext == '') {
                $sharing_buttons_customtext = JText::_('LBL_SOCIAL_SHARING_DESC');
            }
            $social_buttons_construct = '<div class="social-sharing"><p>' . $sharing_buttons_customtext . '</p></div>';
            if ($social_buttons == 1) {
                $social_buttons_jssocials = '
								showLabel: ' . $jssocial_label . ',
								showCount: ' . $jssocial_count . ',
								shares: [';
                if ($jssocial_twitter == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "twitter",
										via: "' . $social_buttons_via . '",
										hashtags: "' . $social_buttons_hashtag . '",
										text: "' . $article->title . '"},';
                }
                if ($jssocial_facebook == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "facebook"},';
                }
                if ($jssocial_googleplus == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "googleplus"},';
                }
                if ($jssocial_linkedin == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "linkedin"},';
                }
                if ($jssocial_pinterest == "1" && $pinterest_image) {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
                                                                        { share: "pinterest",
                                                                                media: "' . $pinterest_image . '"},';
                }
                if ($jssocial_email == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "email",
										text: "' . $article->title . '"},';
                }
                $social_buttons_jssocials = $social_buttons_jssocials . '
								]';
                $social_buttons_top = $social_buttons_construct . '
						<div id="share-top">
							<script type="text/javascript">
								jQuery("#share-top").jsSocials({' . $social_buttons_jssocials . '
								});
							</script>
						</div>';
                $social_buttons_bottom = $social_buttons_construct . '
						<div id="share-bottom">
							<script type="text/javascript">
								jQuery("#share-bottom").jsSocials({' . $social_buttons_jssocials . '
								});
							</script>
						</div>';
            } else {
                $social_buttons_top = $social_buttons_construct . $sharing_buttons_customtag;
                $social_buttons_bottom = $social_buttons_top;
            }
        }
        JLoader::import('joomla.application.component.model');
        JLoader::import('articles', JPATH_ROOT . '/components/com_cjblog/models');
        $model = JModelLegacy::getInstance('articles', 'CjBlogModel');
        $tags = $model->get_tags_by_itemids(array($article->id));
        if (!empty($tags)) {
            $tags_html = '<div class="tags-list margin-top-10">';
            foreach ($tags as $tag) {
                $tags_html .= '
						<a title="' . JText::sprintf('TXT_TAGGED_ARTICLES', CJFunctions::escape($tag->tag_text)) . ' - ' . CJFunctions::escape($tag->description) . '" class="tooltip-hover label tag-item"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=tag&id=' . $tag->tag_id . ':' . $tag->alias . $articles_itemid) . '">
							<i class="fa fa-tags"></i> ' . CJFunctions::escape($tag->tag_text) . '
						</a>';
            }
            $tags_html .= '</div>';
        }
        $avatar = $api->getUserAvatarImage($avatarApp, $article->created_by, $profile['email'], 48);
        if ($showProfile) {
            $profileUrl = $api->getUserProfileUrl($profileApp, $article->created_by);
        } else {
            $profileUrl = "#";
        }
        $html_top = '
		<div class="well well-small">
			<div class="media clearfix" style="overflow: visible">
				<div class="pull-left"><a href="' . $profileUrl . '" class="thumbnail nomargin-bottom">
					<img class="img-avatar" src="' . $avatar . '" alt="' . CjLibUtils::escape($profile[$user_name]) . '" style="max-width: 48px;"></a>
				</div>
				<div class="media-body">
					<div class="muted">' . ($show_author == 1 ? JText::sprintf('TXT_WRITTEN_BY', JHtml::link($profileUrl, CjLibUtils::escape($profile[$user_name]))) . ' ' : '') . $meta_header . '</div>
					<div style="margin-top: 5px;" class="clearfix">
						<div class="pull-left">' . $meta_stats . '</div>
						' . $meta_rating_readonly . '
					</div>
				</div>
				' . ($sharing_position == 'top' || $sharing_position == 'both' ? '<hr/>' . $social_buttons_top : '') . '
			</div>
		</div>';
        $html_bottom = $tags_html . '
		<div class="panel panel-default">
			<div class="panel-body">
				<div class="media clearfix" style="overflow: visible">
					' . $meta_rating . '
					' . ($sharing_position == 'bottom' || $sharing_position == 'both' ? $social_buttons_bottom . '<hr/>' : '') . '
					<div class="pull-left"><a href="' . $profileUrl . '" class="thumbnail nomargin-bottom"><img class="img-avatar" src="' . $avatar . '" alt="' . $profile[$user_name] . '" style="max-width: 48px;"></a></div>
					<div class="media-body">
						<h4 class="media-heading">' . JText::sprintf('TXT_AUTHOR', CjLibUtils::escape($profile[$user_name])) . '</h4>
						<div style="margin: 5px 0;">' . CjBlogApi::get_user_badges_markup($profile) . '</div>
						' . (!empty($profile[$user_name] && $showProfile) ? $about : '') . '
					</div>
				</div>
				<input id="cjblog_page_id" value="article" type="hidden">
			</div>
		</div>';
        $article->text = '<div id="cj-wrapper">' . $html_top . $article->text . $html_bottom . '</div>';
    }
示例#4
0
 public static function send_messages_from_queue($records = 60, $delay = 0, $simulated = true, $force_ids = array())
 {
     if ($simulated) {
         $cjconfig = CJLib::get_cjconfig();
         if ($cjconfig['manual_cron'] == '1') {
             require_once CJLIB_PATH . DS . 'framework' . DS . 'virtualcron.php';
             $delay = $delay > 0 ? $delay : intval($cjconfig['cron_delay']);
             $vcron = new virtualcron($delay, 'virtualcron.txt');
             if (!$vcron->allowAction()) {
                 return false;
             }
         } else {
             return false;
         }
     }
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $from = $app->getCfg('mailfrom');
     $fromname = $app->getCfg('fromname');
     $message_ids = array();
     $sent = array();
     $query = $db->getQuery(true);
     $query->select('id, to_addr, cc_addr, bcc_addr, html, message_id, params')->from('#__corejoomla_messagequeue');
     if (!empty($force_ids)) {
         $query->where('id in (' . implode(',', $force_ids) . ') and status = 0');
     } else {
         $query->where('status = 0');
     }
     $db->setQuery($query, 0, $records);
     $queue_items = array();
     try {
         $queue_items = $db->loadObjectList();
     } catch (Exception $e) {
         return false;
     }
     if (!empty($queue_items)) {
         foreach ($queue_items as $item) {
             $message_ids[] = $item->message_id;
         }
         $message_ids = array_unique($message_ids);
         $query = $db->getQuery(true);
         $query->select('id, asset_id, asset_name, subject, description, params')->from('#__corejoomla_messages')->where('id in (' . implode(',', $message_ids) . ')');
         $db->setQuery($query);
         $messages = array();
         try {
             $messages = $db->loadObjectList('id');
         } catch (Exception $e) {
             return false;
         }
         if (!empty($messages)) {
             $template_path = CJLIB_PATH . DS . 'framework' . DS . 'mail_templates' . DS;
             foreach ($messages as &$message) {
                 $params = json_decode($message->params);
                 if (!empty($params->template) && JFile::exists($template_path . $params->template)) {
                     $template = file_get_contents($template_path . $params->template);
                     if (!empty($params->placeholders)) {
                         foreach ($params->placeholders as $key => $value) {
                             $template = str_replace($key, $value, $template);
                         }
                     }
                     $message->description = str_replace('{description}', $message->description, $template);
                 }
             }
             $ids = array();
             foreach ($queue_items as $item) {
                 $ids[] = $item->id;
                 if (!empty($messages[$item->message_id])) {
                     $description = $messages[$item->message_id]->description;
                     if (!empty($item->params)) {
                         $params = json_decode($item->params);
                         if (!empty($params->placeholders)) {
                             foreach ($params->placeholders as $key => $value) {
                                 $description = str_replace($key, $value, $description);
                             }
                         }
                     }
                     try {
                         $return = CJFunctions::send_email($from, $fromname, $item->to_addr, $messages[$item->message_id]->subject, $description, $item->html, $item->cc_addr, $item->bcc_addr);
                         if ($return === true) {
                             $sent[] = $item->id;
                         }
                     } catch (Exception $e) {
                         // Add logger
                         $date = JFactory::getDate()->format('Y.m.d');
                         JLog::addLogger(array('text_file' => 'com_cjlib.' . $date . '.log.php'), JLog::ALL, 'com_cjlib');
                         JLog::add('Send Messages From Queue - Error: ' . print_r($e, true), JLog::ERROR, 'com_cjlib');
                     }
                 }
             }
             if (!empty($ids)) {
                 $created = JFactory::getDate()->toSql();
                 $query = $db->getQuery(true);
                 $query->update($db->qn('#__corejoomla_messagequeue'))->set($db->qn('status') . ' = 1, processed = ' . $db->q($created))->where('id in (' . implode(',', $ids) . ')');
                 $db->setQuery($query);
                 try {
                     $db->execute();
                 } catch (Exception $e) {
                     return false;
                 }
             }
         }
     }
     return $sent;
 }
示例#5
0
 function postflight($type, $parent)
 {
     // CJLib includes
     $cjlib = JPATH_ROOT . DS . 'components' . DS . 'com_cjlib' . DS . 'framework.php';
     $db = JFactory::getDBO();
     $update_queries = array();
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_messages` ADD COLUMN `asset_id` int(10) unsigned NOT NULL';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_messagequeue` ADD COLUMN `created` DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\'';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_messagequeue` ADD COLUMN `processed` DATETIME NOT NULL DEFAULT \'0000-00-00 00:00:00\'';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_messagequeue` ADD INDEX `idx_corejoomla_message_queue_status`(`status`)';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_messagequeue` ADD INDEX `idx_corejoomla_message_queue_created`(`created`)';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_countries` ADD COLUMN `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, DROP PRIMARY KEY, ADD PRIMARY KEY (`id`)';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_countries` ADD COLUMN `language` VARCHAR(6) NOT NULL DEFAULT \'*\'';
     $update_queries[] = 'ALTER IGNORE TABLE `#__corejoomla_countries` ADD UNIQUE INDEX `idx_corejoomla_countries_uniq`(`country_code`, `language`)';
     $update_queries[] = 'ALTER IGNORE TABLE `#__cjblog_users` MODIFY COLUMN `about` MEDIUMTEXT DEFAULT NULL';
     $update_queries[] = "insert into #__corejoomla_countries(country_name, country_code) values\n\t\t\t('Afghanistan','AF'), ('Åland Islands','AX'), ('Albania','AL'), ('Algeria','DZ'), ('American Samoa','AS'), ('Andorra','AD'), ('Angola','AO'),\n\t\t\t('Anguilla','AI'), ('Antarctica','AQ'), ('Antigua And Barbuda','AG'), ('Argentina','AR'), ('Armenia','AM'), ('Aruba','AW'), ('Australia','AU'),\n\t\t\t('Austria','AT'), ('Azerbaijan','AZ'), ('Bahamas','BS'), ('Bahrain','BH'), ('Bangladesh','BD'), ('Barbados','BB'), ('Belarus','BY'),\n\t\t\t('Belgium','BE'), ('Belize','BZ'), ('Benin','BJ'), ('Bermuda','BM'), ('Bhutan','BT'), ('Bolivia','BO'), ('Bosnia And Herzegovina','BA'),\n\t\t\t('Botswana','BW'), ('Bouvet Island','BV'), ('Brazil','BR'), ('British Indian Ocean Territory','IO'),('Brunei Darussalam','BN'), ('Bulgaria','BG'),\n\t\t\t('Burkina Faso','BF'), ('Burundi','BI'), ('Cambodia','KH'), ('Cameroon','CM'), ('Canada','CA'), ('Cape Verde','CV'), ('Cayman Islands','KY'),\n\t\t\t('Central African Republic','CF'), ('Chad','TD'), ('Chile','CL'), ('China','CN'), ('Christmas Island','CX'), ('Cocos Keeling Islands','CC'),\n\t\t\t('Colombia','CO'), ('Comoros','KM'), ('Congo','CG'), ('Congo','CD'), ('Cook Islands','CK'), ('Costa Rica','CR'), ('Côte D\\'ivoire','CI'),\n\t\t\t('Croatia','HR'), ('Cuba','CU'), ('Cyprus','CY'), ('Czech Republic','CZ'), ('Denmark','DK'), ('Djibouti','DJ'), ('Dominica','DM'),\n\t\t\t('Dominican Republic','DO'), ('Ecuador','EC'), ('Egypt','EG'), ('El Salvador','SV'), ('Equatorial Guinea','GQ'), ('Eritrea','ER'), ('Estonia','EE'),\n\t\t\t('Ethiopia','ET'), ('Falkland Islands Malvinas','FK'),('Faroe Islands','FO'), ('Fiji','FJ'), ('Finland','FI'), ('France','FR'), ('French Guiana','GF'),\n\t\t\t('French Polynesia','PF'), ('French Southern Territories','TF'), ('Gabon','GA'), ('Gambia','GM'), ('Georgia','GE'), ('Germany','DE'), ('Ghana','GH'),\n\t\t\t('Gibraltar','GI'), ('Greece','GR'), ('Greenland','GL'), ('Grenada','GD'), ('Guadeloupe','GP'), ('Guam','GU'), ('Guatemala','GT'), ('Guernsey','GG'),\n\t\t\t('Guinea','GN'), ('Guinea-Bissau','GW'), ('Guyana','GY'), ('Haiti','HT'), ('Heard Island And Mcdonald Islands','HM'), ('Honduras','HN'),\n\t\t\t('Hong Kong','HK'), ('Hungary','HU'), ('Iceland','IS'), ('India','IN'), ('Indonesia','ID'), ('Iran','IR'), ('Iraq','IQ'), ('Ireland','IE'),\n\t\t\t('Isle Of Man','IM'), ('Israel','IL'), ('Italy','IT'), ('Jamaica','JM'), ('Japan','JP'), ('Jersey','JE'), ('Jordan','JO'), ('Kazakhstan','KZ'),\n\t\t\t('Kenya','KE'), ('Kiribati','KI'), ('Korea','KP'), ('Korea','KR'), ('Kuwait','KW'), ('Kyrgyzstan','KG'), ('Lao People\\'s Democratic Republic','LA'),\n\t\t\t('Latvia','LV'), ('Lebanon','LB'), ('Lesotho','LS'), ('Liberia','LR'), ('Libyan Arab Jamahiriya','LY'), ('Liechtenstein','LI'),\n\t\t\t('Lithuania','LT'), ('Luxembourg','LU'), ('Macao','MO'), ('Macedonia','MK'), ('Madagascar','MG'), ('Malawi','MW'), ('Malaysia','MY'),\n\t\t\t('Maldives','MV'), ('Mali','ML'), ('Malta','MT'), ('Marshall Islands','MH'), ('Martinique','MQ'), ('Mauritania','MR'), ('Mauritius','MU'),\n\t\t\t('Mayotte','YT'), ('Mexico','MX'), ('Micronesia','FM'), ('Moldova','MD'), ('Monaco','MC'), ('Mongolia','MN'), ('Montenegro','ME'),\n\t\t\t('Montserrat','MS'), ('Morocco','MA'), ('Mozambique','MZ'), ('Myanmar','MM'), ('Namibia','NA'),('Nauru','NR'), ('Nepal','NP'), ('Netherlands','NL'),\n\t\t\t('Netherlands Antilles','AN'), ('New Caledonia','NC'), ('New Zealand','NZ'), ('Nicaragua','NI'), ('Niger','NE'), ('Nigeria','NG'), ('Niue','NU'),\n\t\t\t('Norfolk Island','NF'), ('Northern Mariana Islands','MP'), ('Norway','NO'), ('Oman','OM'), ('Pakistan','PK'), ('Palau','PW'),\n\t\t\t('Palestinian Territory','PS'), ('Panama','PA'), ('Papua New Guinea','PG'), ('Paraguay','PY'), ('Peru','PE'), ('Philippines','PH'), ('Pitcairn','PN'),\n\t\t\t('Poland','PL'), ('Portugal','PT'), ('Puerto Rico','PR'), ('Qatar','QA'), ('Réunion','RE'), ('Romania','RO'), ('Russian Federation','RU'),\n\t\t\t('Rwanda','RW'), ('Saint Barth�lemy','BL'), ('Saint Helena','SH'), ('Saint Kitts And Nevis','KN'), ('Saint Lucia','LC'), ('Saint Martin','MF'),\n\t\t\t('Saint Pierre And Miquelon','PM'), ('Saint Vincent And The Grenadines','VC'), ('Samoa','WS'), ('San Marino','SM'), ('Sao Tome And Principe','ST'),\n\t\t\t('Saudi Arabia','SA'), ('Senegal','SN'),  ('Serbia','RS'), ('Seychelles','SC'), ('Sierra Leone','SL'), ('Singapore','SG'), ('Slovakia','SK'),\n\t\t\t('Slovenia','SI'), ('Solomon Islands','SB'),  ('Somalia','SO'), ('South Africa','ZA'),  ('South Georgia And The South Sandwich Islands','GS'),\n\t\t\t('Spain','ES'), ('Sri Lanka','LK'), ('Sudan','SD'), ('Suriname','SR'), ('Svalbard And Jan Mayen','SJ'), ('Swaziland','SZ'), ('Sweden','SE'),\n\t\t\t('Switzerland','CH'), ('Syrian Arab Republic','SY'), ('Taiwan','TW'), ('Tajikistan','TJ'), ('Tanzania','TZ'), ('Thailand','TH'), ('Timor-Leste','TL'),\n\t\t\t('Togo','TG'), ('Tokelau','TK'), ('Tonga','TO'), ('Trinidad And Tobago','TT'), ('Tunisia','TN'), ('Turkey','TR'), ('Turkmenistan','TM'),\n\t\t\t('Turks And Caicos Islands','TC'), ('Tuvalu','TV'), ('Uganda','UG'), ('Ukraine','UA'), ('United Arab Emirates','AE'), ('United Kingdom','GB'),\n\t\t\t('United States','US'), ('United States Minor Outlying Islands','UM'), ('Uruguay','UY'), ('Uzbekistan','UZ'), ('Vanuatu','VU'), ('Vatican City State','VA'),\n\t\t\t('Venezuela','VE'), ('Viet Nam','VN'), ('Virgin Islands British','VG'), ('Virgin Islands U.S.','VI'), ('Wallis And Futuna','WF'), ('Western Sahara','EH'),\n\t\t\t('Yemen','YE'), ('Zambia','ZM'), ('Zimbabwe','ZW'), ('European Union','EU'), ('United Kingdom', 'UK'), ('Ascension Island', 'AC'), ('Clipperton Island', 'CP'),\n\t\t\t('Diego Garcia','DG'), ('Ceuta, Melilla','EA'), ('France, Metropolitan','FX'), ('Canary Islands','IC'), ('USSR','SU'), ('Tristan da Cunha','TA'),\n\t\t\t('Unknown','XX') ON duplicate key update country_name=values(country_name)";
     foreach ($update_queries as $query) {
         $db->setQuery($query);
         try {
             $db->query();
         } catch (Exception $e) {
         }
     }
     if (file_exists($cjlib)) {
         require_once $cjlib;
     } else {
         die('CJLib (CoreJoomla API Library) component files not found. Please check if the component installed properly and try again.');
     }
     CJLib::import('corejoomla.framework.core');
     CJFunctions::download_geoip_databases();
     echo '<p>CJLib component successfully installed.</p>';
 }
示例#6
0
 function acymailing_replaceusertags(&$email, &$user, $send = true)
 {
     if (!$send) {
         return;
     }
     $match = '#{surveyurl:(.*)}#Ui';
     $variables = array('body', 'altbody');
     $found = false;
     $results = array();
     foreach ($variables as $var) {
         if (empty($email->{$var})) {
             continue;
         }
         $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found;
         if (empty($results[$var][0])) {
             unset($results[$var]);
         }
     }
     if (!$found) {
         return;
     }
     // CJLib includes
     $cjlib = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_cjlib' . DIRECTORY_SEPARATOR . 'framework.php';
     if (file_exists($cjlib)) {
         require_once $cjlib;
     } else {
         die('CJLib (CoreJoomla API Library) component not found. Please download and install it to continue.');
     }
     CJLib::import('corejoomla.framework.core');
     $htmlreplace = array();
     $textreplace = array();
     $db = JFactory::getDbo();
     $mailerHelper = acymailing_get('helper.mailer');
     foreach ($results as $var => $allresults) {
         foreach ($allresults[0] as $i => $oneTag) {
             if (isset($htmlreplace[$oneTag])) {
                 continue;
             }
             $start = strpos($oneTag, ':') + 1;
             $length = strpos($oneTag, '}') - strpos($oneTag, ':') - 1;
             $sid = intval(substr($oneTag, $start, $length));
             if ($sid > 0) {
                 $keys = array();
                 $key = CJFunctions::generate_random_key();
                 $query = 'insert into #__survey_keys(key_name, survey_id, response_id) values (' . $db->quote($key) . ',' . $sid . ', 0)';
                 $db->setQuery($query);
                 if ($db->query()) {
                     $itemid = CJFunctions::get_active_menu_id();
                     $link = JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=take_survey&key=' . $key . $itemid, false, -1);
                     $link = str_replace('/administrator/', '/', $link);
                     $link = '<a href="' . $link . '">' . $link . '</a>';
                 }
                 $htmlreplace[$oneTag] = $link;
                 $textreplace[$oneTag] = $mailerHelper->textVersion($link);
             }
         }
     }
     $email->body = str_replace(array_keys($htmlreplace), $htmlreplace, $email->body);
     $email->altbody = str_replace(array_keys($textreplace), $textreplace, $email->altbody);
 }
示例#7
0
<?php

/**
 * @version		$Id: default.php 01 2012-08-13 11:37:09Z maverick $
 * @package		CoreJoomla.CjLib
 * @subpackage	Components
 * @copyright	Copyright (C) 2009 - 2012 corejoomla.com. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$config = CJLib::get_cjconfig(true);
$link = JRoute::_('index.php?option=com_cjlib&task=process&secret=' . $config['cron_secret'], false, -1);
$link = str_replace('/administrator/', '/', $link);
?>

<h1>CoreJoomla Framework API Library</h1>
<p><strong>Version:</strong> <?php 
echo CJLIB_VER;
?>
</p>

<div id="cjlib-configuration" style="margin: 0 10px;">
	<div style="border: 1px solid #ccc; padding: 5px; ">
		<div><strong><?php 
echo JText::_('LBL_CRON_URL');
?>
</strong></div>
		<div><?php 
示例#8
0
文件: cjblog.php 项目: Ruud68/cjblog
require_once JPATH_COMPONENT . '/helpers/route.php';
$app = JFactory::getApplication();
$view = $app->input->get('view');
$task = $app->input->get('task');
if ($view == 'form' || $task == 'article.add' || $task == 'article.edit') {
    $controller = JControllerLegacy::getInstance('CjBlog');
    $controller->execute($app->input->get('task'));
    $controller->redirect();
} else {
    $path = JPATH_COMPONENT . '/controllers/' . $view . '.php';
    if (!file_exists($path)) {
        CJFunctions::throw_error('View ' . JString::ucfirst($view) . ' not found!', 500);
    }
    require_once $path;
    $custom_tag = false;
    JHtml::_('jquery.framework');
    $params = JComponentHelper::getParams('com_cjblog');
    CJLib::behavior('bscore', array('customtag' => $custom_tag));
    CJFunctions::load_jquery(array('libs' => array('fontawesome'), 'custom_tag' => $custom_tag));
    /**************************** MEDIA **************************************/
    $document = JFactory::getDocument();
    $document->addStyleSheet(CJBLOG_MEDIA_URI . 'css/cjblog.min.css');
    CJFunctions::add_script_to_document($document, 'cjblog.min.js', true, CJBLOG_MEDIA_URI . 'js/');
    /**************************** MEDIA **************************************/
    $class = 'CjBlogController' . JString::ucfirst($view);
    $controller = new $class();
    $controller->execute($task);
    echo '<input id="cjblog_page_id" value="' . $view . '" type="hidden">';
    echo '<div style="text-align: center; margin-top: 20px;" class="text-center muted">Powered by <a href="http://www.corejoomla.com" rel="follow">CjBlog</a></div>';
    $controller->redirect();
}
示例#9
0
CJLib::import('corejoomla.template.core');
require_once JPATH_COMPONENT . '/controller.php';
require_once JPATH_COMPONENT . '/helpers/constants.php';
require_once JPATH_COMPONENT . '/helpers/helper.php';
$app = JFactory::getApplication();
$params = JComponentHelper::getParams(S_APP_NAME);
define('S_DEBUG_ENABLED', $params->get('enable_debugging', 0) == '1');
CJFunctions::load_component_language(S_APP_NAME);
$task = $app->input->getCmd('task');
if (strpos($task, '.') !== false) {
    $controller = JControllerLegacy::getInstance('CommunitySurveys');
    $controller->execute($task);
    $controller->redirect();
} else {
    if ($params->get('enable_bootstrap', true)) {
        CJLib::import('corejoomla.ui.bootstrap', false);
    }
    CJFunctions::load_jquery(array('libs' => array('fontawesome')));
    $view = $app->input->getCmd('view', 'survey');
    if (JFile::exists(JPATH_COMPONENT . '/controllers/' . $view . '.php')) {
        require_once JPATH_COMPONENT . '/controllers/' . $view . '.php';
    } else {
        return CJFunctions::throw_error('View ' . JString::ucfirst($view) . ' not found!', 500);
    }
    $controller = new CommunitySurveysController();
    $controller->execute();
    $format = $app->input->getCmd('format');
    if ($format != 'raw' && $format != 'json') {
        $return = CJFunctions::send_messages_from_queue();
        if ($params->get('enable_credits', 1) == '1') {
            echo '';
示例#10
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $active = $app->getMenu()->getActive();
     $itemid = CJFunctions::get_active_menu_id();
     $this->print = $app->input->getBool('print');
     $page_heading = '';
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(S_APP_NAME);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     switch ($this->action) {
         case 'survey_intro':
             $page_heading = JText::sprintf('TXT_INTRODUCTION', $this->escape($this->item->title));
             break;
         case 'response_form':
             $page_heading = JText::sprintf('TXT_SURVEY_RESPONSE', $this->escape($this->item->title));
             break;
         case 'survey_results':
             $id = $app->input->getInt('id', 0);
             $response_id = $app->input->getInt('rid', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_consolidated_report($id);
             if (empty($survey) || $survey->public_permissions != 1 && $survey->created_by != $user->id && !$user->authorise('core.manage', 'com_communitysurveys')) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $response_details = $model->get_response_details($response_id, $id, 0, true, true);
             if (!empty($response_details) && !empty($survey->questions)) {
                 foreach ($response_details as $response_detail) {
                     foreach ($survey->questions as &$question) {
                         if ($question->id == $response_detail->question_id) {
                             $question->response_details[] = $response_detail;
                         }
                     }
                 }
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             $this->assignRef('item', $survey);
             $this->assign('responseId', $response_id);
             break;
         case 'end_message':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id);
             if (isset($survey->catid) && !$user->authorise('core.respond', S_APP_NAME . '.category.' . $survey->catid)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
                 return;
             }
             if ($survey->private_survey != '1' && $this->params->get('enable_related_surveys', 1) == 1) {
                 $search_params = array('q' => $survey->title, 'u' => '', 'qt' => 0, 'm' => 0, 'type' => 0, 'all' => 0);
                 $options = array('catid' => 0, 'search_params' => $search_params, 'limit' => 5, 'limitstart' => 0, 'order' => 'a.created', 'order_dir' => 'desc');
                 $return = $model->get_surveys(7, $options, $this->params);
                 $survey->related = $return['surveys'];
             } else {
                 $survey->related = array();
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             $this->assignRef('item', $survey);
             break;
     }
     if ($this->is_hide_template($this->params->get('hide_template', 0), $this->item->display_template)) {
         $app->input->set('tmpl', 'component');
         $app->input->set('format', 'raw');
         CJLib::import('corejoomla.ui.bootstrap', true);
         $this->assign('hide_template', 1);
     } else {
         $this->assign('hide_template', 0);
     }
     $this->assign('brand', JText::_('LBL_HOME'));
     $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $pathway->addItem($page_heading);
     $title = $this->params->get('page_title', $app->getCfg('sitename'));
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // set meta description
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     // set meta keywords
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     // set robots
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     // set nofollow if it is print
     if ($this->print) {
         $document->setMetaData('robots', 'noindex, nofollow');
     }
     parent::display($tpl);
 }
示例#11
0
/**
 * @version		$Id: cjlib.php 01 2011-01-11 11:37:09Z maverick $
 * @package		CoreJoomla.CJLib
 * @subpackage	Components.framework
 * @copyright	Copyright (C) 2009 - 2010 corejoomla.com. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once 'framework.php';
require_once JPATH_COMPONENT . DS . 'controller.php';
CJLib::import('corejoomla.framework.core');
$config = CJLib::get_cjconfig();
$task = JRequest::getCmd('task', '');
$secret = JRequest::getCmd('secret', null);
$component = 'com_cjlib';
if ($task == 'process' && !empty($secret) && strcmp($config['cron_secret'], $secret) == 0) {
    $emails = (int) $config['cron_emails'];
    $delay = (int) $config['cron_delay'];
    $sent = CJFunctions::send_messages_from_queue($emails, $delay, false);
    if (!empty($sent)) {
        echo json_encode($sent);
    }
} else {
    if ($task = 'socialcounts') {
        require_once CJLIB_PATH . DS . 'jquery' . DS . 'social' . DS . 'socialcounts.php';
        $url = base64_decode(JFactory::getApplication()->input->getString('url'));
        if (!SocialCount::REQUIRE_LOCAL_URL || SocialCount::isLocalUrl($url)) {