Exemple #1
0
 function _getCommentsQuery(&$options)
 {
     $acl =& JCommentsFactory::getACL();
     $db =& JCommentsFactory::getDBO();
     $object_id = @$options['object_id'];
     $object_group = @$options['object_group'];
     $parent = @$options['parent'];
     $published = @$options['published'];
     $orderBy = @$options['orderBy'];
     $limitStart = @$options['limitStart'];
     $limit = @$options['limit'];
     $where = array();
     if ($object_id) {
         $where[] = "c.object_id = " . $object_id;
     }
     if ($object_group != '') {
         $where[] = "c.object_group = '" . $db->getEscaped($object_group) . "'";
     }
     if ($parent !== null) {
         $where[] = "c.parent = " . $parent;
     }
     if ($published !== null) {
         $where[] = "c.published = " . $published;
     }
     if (JCommentsMultilingual::isEnabled()) {
         $where[] = "c.lang = '" . JCommentsMultilingual::getLanguage() . "'";
     }
     $query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n, c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n, c.isgood, c.ispoor" . "\n, v.value as voted" . "\n, case when c.userid = 0 then 'guest' else replace(lower(u.usertype), ' ', '-') end as usertype" . "\nFROM #__jcomments AS c" . "\nLEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($acl->getUserId() ? " AND  v.userid = " . $acl->getUserId() : " AND v.userid = 0 AND v.ip = '" . $acl->getUserIP() . "'") . "\nLEFT JOIN #__users AS u ON c.userid = u.id" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY " . $orderBy . ($limit > 0 ? "\nLIMIT {$limitStart}, {$limit}" : "");
     return $query;
 }
Exemple #2
0
 function getCategoryNewTree($object_id, $object_group = 'com_content')
 {
     global $my;
     $object_id = (int) $object_id;
     $object_group = trim($object_group);
     $acl =& JCommentsFactory::getACL();
     $config =& JCommentsFactory::getConfig();
     $canPublish = $acl->canPublish();
     $canComment = $acl->canComment();
 }
Exemple #3
0
 public static function getCommentsCount($object_id, $object_group = 'com_content', $filter = '')
 {
     $acl = JCommentsFactory::getACL();
     $options = array();
     $options['object_id'] = (int) $object_id;
     $options['object_group'] = trim($object_group);
     $options['published'] = $acl->canPublish() || $acl->canPublishForObject($object_id, $object_group) ? null : 1;
     $options['filter'] = $filter;
     return JCommentsModel::getCommentsCount($options);
 }
Exemple #4
0
 /**
  * Comments Search method
  *
  * @param string $text Target search string
  * @param string $phrase mathcing option, exact|any|all
  * @param string $ordering ordering option, newest|oldest|popular|alpha|category
  * @param mixed $areas An array if the search it to be restricted to areas, null if search all
  * @return array
  */
 function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $text = JString::strtolower(trim($text));
     $result = array();
     if ($text == '' || !defined('JCOMMENTS_JVERSION')) {
         return $result;
     }
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return $result;
         }
     }
     if (file_exists(JCOMMENTS_BASE . '/jcomments.php')) {
         require_once JCOMMENTS_BASE . '/jcomments.php';
         $db = JFactory::getDBO();
         $limit = $this->params->def('search_limit', 50);
         switch ($phrase) {
             case 'exact':
                 $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
                 $wheres2[] = "LOWER(c.name) LIKE " . $text;
                 $wheres2[] = "LOWER(c.comment) LIKE " . $text;
                 $wheres2[] = "LOWER(c.title) LIKE " . $text;
                 $where = '(' . implode(') OR (', $wheres2) . ')';
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
                     $wheres2 = array();
                     $wheres2[] = "LOWER(c.name) LIKE " . $word;
                     $wheres2[] = "LOWER(c.comment) LIKE " . $word;
                     $wheres2[] = "LOWER(c.title) LIKE " . $word;
                     $wheres[] = implode(' OR ', $wheres2);
                 }
                 $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
                 break;
         }
         switch ($ordering) {
             case 'oldest':
                 $order = 'date ASC';
                 break;
             case 'newest':
             default:
                 $order = 'date DESC';
                 break;
         }
         $acl = JCommentsFactory::getACL();
         $access = $acl->getUserAccess();
         if (is_array($access)) {
             $accessCondition = "AND jo.access IN (" . implode(',', $access) . ")";
         } else {
             $accessCondition = "AND jo.access <= " . (int) $access;
         }
         $query = "SELECT " . "  c.comment AS text" . ", c.date AS created" . ", '2' AS browsernav" . ", '" . JText::_('PLG_SEARCH_JCOMMENTS_COMMENTS') . "' AS section" . ", ''  AS href" . ", c.id" . ", jo.title AS object_title, jo.link AS object_link" . " FROM #__jcomments AS c" . " INNER JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group and jo.lang=c.lang" . " WHERE c.published=1" . " AND c.deleted=0" . " AND jo.link <> ''" . (JCommentsMultilingual::isEnabled() ? " AND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . " AND ({$where}) " . $accessCondition . " ORDER BY c.object_id, {$order}";
         $db->setQuery($query, 0, $limit);
         $rows = $db->loadObjectList();
         $cnt = count($rows);
         if ($cnt > 0) {
             $config = JCommentsFactory::getConfig();
             $enableCensor = $acl->check('enable_autocensor');
             $word_maxlength = $config->getInt('word_maxlength');
             for ($i = 0; $i < $cnt; $i++) {
                 $text = JCommentsText::cleanText($rows[$i]->text);
                 if ($enableCensor) {
                     $text = JCommentsText::censor($text);
                 }
                 if ($word_maxlength > 0) {
                     $text = JCommentsText::fixLongWords($text, $word_maxlength);
                 }
                 if ($text != '') {
                     $rows[$i]->title = $rows[$i]->object_title;
                     $rows[$i]->text = $text;
                     $rows[$i]->href = $rows[$i]->object_link . '#comment-' . $rows[$i]->id;
                     $result[] = $rows[$i];
                 }
             }
         }
         unset($rows);
     }
     return $result;
 }
Exemple #5
0
 protected static function _getCommentsQuery(&$options)
 {
     $acl = JCommentsFactory::getACL();
     $db = JFactory::getDbo();
     $object_id = @$options['object_id'];
     $object_group = @$options['object_group'];
     $parent = @$options['parent'];
     $level = @$options['level'];
     $published = @$options['published'];
     $userid = @$options['userid'];
     $filter = @$options['filter'];
     $orderBy = @$options['orderBy'];
     $limitStart = isset($options['limitStart']) ? $options['limitStart'] : 0;
     $limit = @$options['limit'];
     $votes = isset($options['votes']) ? $options['votes'] : true;
     $objectinfo = isset($options['objectinfo']) ? $options['objectinfo'] : false;
     $where = array();
     if (!empty($object_id)) {
         $where[] = "c.object_id = " . $object_id;
     }
     if (!empty($object_group)) {
         if (is_array($object_group)) {
             $where[] = "(c.object_group = '" . implode("' OR c.object_group = '", $object_group) . "')";
         } else {
             $where[] = "c.object_group = " . $db->Quote($object_group);
         }
     }
     if ($parent !== null) {
         $where[] = "c.parent = " . $parent;
     }
     if ($level !== null) {
         $where[] = "c.level = " . (int) $level;
     }
     if ($published !== null) {
         $where[] = "c.published = " . $published;
     }
     if ($userid !== null) {
         $where[] = "c.userid = " . $userid;
     }
     if (JCommentsMultilingual::isEnabled()) {
         $language = isset($options['lang']) ? $options['lang'] : JCommentsMultilingual::getLanguage();
         $where[] = "c.lang = " . $db->Quote($language);
     }
     if ($objectinfo && isset($options['access'])) {
         if (is_array($options['access'])) {
             $access = implode(',', $options['access']);
             $where[] = "jo.access IN (" . $access . ")";
         } else {
             $where[] = "jo.access <= " . (int) $options['access'];
         }
     }
     if ($filter != "") {
         $where[] = $filter;
     }
     $query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n, c.email, c.homepage, c.date, c.date as datetime, c.ip, c.published, c.deleted, c.checked_out, c.checked_out_time" . "\n, c.isgood, c.ispoor" . ($votes ? "\n, v.value as voted" : "\n, 1 as voted") . "\n, case when c.parent = 0 then unix_timestamp(c.date) else 0 end as threaddate" . ($objectinfo ? "\n, jo.title AS object_title, jo.link AS object_link, jo.access AS object_access" : ", '' AS object_title, '' AS object_link, 0 AS object_access, 0 AS object_owner") . "\nFROM #__jcomments AS c" . ($votes ? "\nLEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($acl->getUserId() ? " AND  v.userid = " . $acl->getUserId() : " AND v.userid = 0 AND v.ip = '" . $acl->getUserIP() . "'") : "") . ($objectinfo ? "\n LEFT JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group AND jo.lang=c.lang" : "") . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY " . $orderBy . ($limit > 0 ? "\nLIMIT {$limitStart}, {$limit}" : "");
     return $query;
 }
 function registerCode($str)
 {
     $acl = JCommentsFactory::getACL();
     $this->_codes[$str] = $acl->check('enable_bbcode_' . $str);
 }
Exemple #7
0
	function onPrepareContent(&$article, &$params, $limitstart = 0)
	{
		require_once (JCOMMENTS_HELPERS . '/content.php');

		// check whether plugin has been unpublished
		if (!JPluginHelper::isEnabled('content', 'jcomments')) {
			JCommentsContentPluginHelper::clear($article, true);
			return '';
		}

		$app = JFactory::getApplication('site');
		$option = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');

		if (!isset($article->id) || ($option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories')) {
			return '';
		}

		if (!isset($params) || $params == null) {
			jimport('joomla.html.parameter');
			$params = new JParameter('');
		} else if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) {
			return '';
		}

		if ($view == 'frontpage' || $view == 'featured') {
			if ($this->params->get('show_frontpage', 1) == 0) {
				return '';
			}
		}

		require_once (JCOMMENTS_BASE . '/jcomments.config.php');
		require_once (JCOMMENTS_BASE . '/jcomments.class.php');

		JCommentsContentPluginHelper::processForeignTags($article);

		$config = JCommentsFactory::getConfig();

		$categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
		$commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
		$commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
		$commentsLocked = JCommentsContentPluginHelper::isLocked($article);

		if ($article->state == -1 && $this->params->get('enable_for_archived', 0) == 0) {
			$commentsLocked = true;
		}

		$config->set('comments_on', intval($commentsEnabled));
		$config->set('comments_off', intval($commentsDisabled));
		$config->set('comments_locked', intval($commentsLocked));

		if ($view != 'article') {
			$user = JFactory::getUser();

			if (JCOMMENTS_JVERSION == '1.5') {
				$checkAccess = $article->access <= $user->get('aid', 0);
			} else {
				$authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
				$checkAccess = in_array($article->access, $authorised);
			}

			if ($checkAccess) {
				require_once(JPATH_ROOT . '/components/com_content/helpers/route.php');
				if (JCOMMENTS_JVERSION == '1.5') {
					$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
				} else {
					$readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
				}
				$readmore_register = 0;
			} else {
				if (JCOMMENTS_JVERSION == '1.5') {
					$readmore_link = JRoute::_('index.php?option=com_user&task=register');
				} else {
					$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug));

					$menu = JFactory::getApplication()->getMenu();
					$active = $menu->getActive();
					$itemId = $active->id;
					$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
					$link = new JURI($link1);
					$link->setVar('return', base64_encode($returnURL));
					$readmore_link = $link;
				}
				$readmore_register = 1;
			}

			// load template for comments & readmore links
			$tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false);
			$tmpl->load('tpl_links');

			$tmpl->addVar('tpl_links', 'comments_link_style', ($readmore_register ? -1 : 1));
			$tmpl->addVar('tpl_links', 'content-item', $article);
			$tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));

			$readmoreDisabled = false;

			if (($params->get('show_readmore') == 0) || (@$article->readmore == 0)) {
				$readmoreDisabled = true;
			} else if (@$article->readmore > 0) {
				$readmoreDisabled = false;
			}

			if ($this->params->get('readmore_link', 1) == 0) {
				$readmoreDisabled = true;
			}

			$tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));

			// don't fill any readmore variable if it disabled
			if (!$readmoreDisabled) {
				if ($readmore_register == 1) {
					$readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE');
				} else if (isset($params) && $readmore = $params->get('readmore')) {
					$readmore_text = $readmore;
				} else {
					$readmore_text = JText::_('LINK_READ_MORE');
				}
				$tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
				$tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
				$tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
				$tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
			}

			$commentsDisabled = false;

			if ($config->getInt('comments_off', 0) == 1) {
				$commentsDisabled = true;
			} else if ($config->getInt('comments_on', 0) == 1) {
				$commentsDisabled = false;
			}

			$tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));

			$count = 0;

			// do not query comments count if comments disabled and link hidden
			if (!$commentsDisabled) {
				require_once (JCOMMENTS_MODELS . '/jcomments.php');

				$anchor = "";

				if ($this->params->get('comments_count', 1) != 0) {

					$acl = JCommentsFactory::getACL();

					$options = array();
					$options['object_id'] = (int) $article->id;
					$options['object_group'] = 'com_content';
					$options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;

					$count = JCommentsModel::getCommentsCount($options);

					$tmpl->addVar('tpl_links', 'comments-count', $count);
					$anchor = $count == 0 ? '#addcomment' : '#comments';

					if ($count == 0) {
						$link_text = JText::_('LINK_ADD_COMMENT');
					} else {
						if (JCOMMENTS_JVERSION == '1.5') {
							require_once (JCOMMENTS_LIBRARIES.'/joomlatune/language.tools.php');
							$lang = JFactory::getLanguage();
							$suffix = JoomlaTuneLanguageTools::getPluralSuffix($lang->getTag(), $count);
							$string = 'LINK_READ_COMMENTS';
							$key = $string . '_' . $suffix;
							if (!$lang->hasKey($key)) {
								$key = $string;
							}
							$link_text = JText::sprintf($key, $count);

						} else {
							$link_text = JText::plural('LINK_READ_COMMENTS', $count);
						}
					}
				} else {
					$link_text = JText::_('LINK_ADD_COMMENT');
				}

				$tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor);
				$tmpl->addVar('tpl_links', 'link-comment-text', $link_text);
				$tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link'));
			}

			JCommentsContentPluginHelper::clear($article, true);

			// hide comments link if comments enabled but link disabled in plugin params
			if ((($this->params->get('comments_count', 1) == 0)
					|| ($count == 0 && $this->params->get('add_comments', 1) == 0)
					|| ($count == 0 && $readmore_register == 1))
					&& !$commentsDisabled) {
				$tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
			}

			//links_position
			if ($this->params->get('links_position', 1) == 1) {
				$article->text .= $tmpl->renderTemplate('tpl_links');
			} else {
				$article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
			}

			$tmpl->freeTemplate('tpl_links');

			if ($this->params->get('readmore_link', 1) == 1) {
				$article->readmore = 0;
				$article->readmore_link = '';
				$article->readmore_register = false;
			}
		} else {
			if ($this->params->get('show_comments_event') == 'onPrepareContent') {
				$isEnabled = ($config->getInt('comments_on', 0) == 1) && ($config->getInt('comments_off', 0) == 0);
				if ($isEnabled && $view == 'article') {
					require_once (JCOMMENTS_BASE . '/jcomments.php');

					$comments = JComments::show($article->id, 'com_content', $article->title);

					if (strpos($article->text, '{jcomments}') !== false) {
						$article->text = str_replace('{jcomments}', $comments, $article->text);
					} else {
						$article->text .= $comments;
					}
				}
			}
			JCommentsContentPluginHelper::clear($article, true);
		}
		return '';
	}
 function getCommentsTree($object_id, $object_group = 'com_content', $search_text = '')
 {
     global $my;
     $object_id = (int) $object_id;
     $object_group = trim($object_group);
     $acl =& JCommentsFactory::getACL();
     $dbo =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $canPublish = $acl->canPublish();
     $canComment = $acl->canComment();
     $where = '';
     if ($search_text) {
         $words = explode(' ', $search_text);
         $wheres = array();
         foreach ($words as $word) {
             $wheres2 = array();
             $wheres2[] = "LOWER(name) LIKE '%{$word}%'";
             $wheres2[] = "LOWER(comment) LIKE '%{$word}%'";
         }
         if (isset($wheres2) && count($wheres2)) {
             $where .= ' AND (';
             $where .= implode(' OR ', $wheres2);
             $where .= ' )';
         }
     }
     if ($canComment == 0) {
         $total = JLMS_JComments::getCommentsCount($object_id, $object_group, $where);
         if ($total == 0) {
             return '';
         }
     }
     $query = "SELECT c.id, c.parent, c.object_id, c.object_group, c.userid, c.name, c.username, c.title, c.comment" . "\n , c.email, c.homepage, c.date as datetime, c.ip, c.published, c.checked_out, c.checked_out_time" . "\n , c.isgood, c.ispoor" . "\n , v.value as voted" . "\n FROM #__jcomments AS c" . "\n LEFT JOIN #__jcomments_votes AS v ON c.id = v.commentid " . ($my->id ? " AND  v.userid = " . $my->id : " AND  v.ip = '" . $acl->getUserIP() . "'") . "\n WHERE c.object_id = " . $object_id . "\n AND c.object_group = '" . $object_group . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND c.lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . ($canPublish == 0 ? "\nAND c.published = 1" : "") . $where . "\n ORDER BY c.parent, c.date ASC";
     $dbo->setQuery($query);
     $rows = $dbo->loadObjectList();
     $tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
     $tmpl->load('tpl_tree');
     $tmpl->load('tpl_comment');
     if (count($rows)) {
         $isLocked = $config->getInt('object_locked', 0) == 1;
         $tmpl->addVar('tpl_tree', 'comments-refresh', intval(!$isLocked));
         $tmpl->addVar('tpl_tree', 'comments-rss', intval($config->getInt('enable_rss') && !$isLocked));
         $tmpl->addVar('tpl_tree', 'comments-can-subscribe', intval($my->id && $acl->check('enable_subscribe') && !$isLocked));
         if ($my->id && $acl->check('enable_subscribe')) {
             require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
             $manager =& JCommentsSubscriptionManager::getInstance();
             $isSubscribed = $manager->isSubscribed($object_id, $object_group, $my->id);
             $tmpl->addVar('tpl_tree', 'comments-user-subscribed', $isSubscribed);
         }
         $i = 1;
         if ($config->getInt('enable_mambots') == 1) {
             require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
             JCommentsPluginHelper::importPlugin('jcomments');
             JCommentsPluginHelper::trigger('onBeforeDisplayCommentsList', array(&$rows));
             if ($acl->check('enable_gravatar')) {
                 JCommentsPluginHelper::trigger('onPrepareAvatars', array(&$rows));
             }
         }
         require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'tree.php';
         $tree = new JoomlaTuneTree($rows);
         $items = $tree->get();
         foreach ($rows as $row) {
             if ($config->getInt('enable_mambots') == 1) {
                 JCommentsPluginHelper::trigger('onBeforeDisplayComment', array(&$row));
             }
             // run autocensor, replace quotes, smiles and other pre-view processing
             JComments::prepareComment($row);
             // setup toolbar
             if (!$acl->canModerate($row)) {
                 $tmpl->addVar('tpl_comment', 'comments-panel-visible', 0);
             } else {
                 $tmpl->addVar('tpl_comment', 'comments-panel-visible', 1);
                 $tmpl->addVar('tpl_comment', 'button-edit', $acl->canEdit($row));
                 $tmpl->addVar('tpl_comment', 'button-delete', $acl->canDelete($row));
                 $tmpl->addVar('tpl_comment', 'button-publish', $acl->canPublish($row));
                 $tmpl->addVar('tpl_comment', 'button-ip', $acl->canViewIP($row));
             }
             $tmpl->addVar('tpl_comment', 'comment-show-vote', $config->getInt('enable_voting'));
             $tmpl->addVar('tpl_comment', 'comment-show-email', $acl->canViewEmail($row));
             $tmpl->addVar('tpl_comment', 'comment-show-homepage', $acl->canViewHomepage($row));
             $tmpl->addVar('tpl_comment', 'comment-show-title', $config->getInt('comment_title'));
             $tmpl->addVar('tpl_comment', 'button-vote', $acl->canVote($row));
             $tmpl->addVar('tpl_comment', 'button-quote', $acl->canQuote($row));
             $tmpl->addVar('tpl_comment', 'button-reply', $acl->canReply($row));
             $tmpl->addVar('tpl_comment', 'avatar', $acl->check('enable_gravatar'));
             if (isset($items[$row->id])) {
                 $tmpl->addVar('tpl_comment', 'comment-number', '');
                 $tmpl->addObject('tpl_comment', 'comment', $row);
                 $items[$row->id]->html = $tmpl->renderTemplate('tpl_comment');
                 $i++;
             }
         }
         $tmpl->addObject('tpl_tree', 'comments-items', $items);
         unset($rows);
     }
     return $tmpl->renderTemplate('tpl_tree');
 }
Exemple #9
0
 public static function getList(&$params)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $source = $params->get('source', 'com_content');
     if (!is_array($source)) {
         $source = explode(',', $source);
     }
     $date = JFactory::getDate();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $now = $date->toSql();
         $access = array_unique(JAccess::getAuthorisedViewLevels($user->get('id')));
         $access[] = 0;
         // for backward compability
     } else {
         $now = $date->toMySQL();
         $access = $user->get('aid', 0);
     }
     switch ($params->get('ordering', '')) {
         case 'vote':
             $orderBy = '(c.isgood-c.ispoor) DESC';
             break;
         case 'date':
         default:
             $orderBy = 'c.date DESC';
             break;
     }
     $where = array();
     $interval = $params->get('interval', '');
     if (!empty($interval)) {
         $timestamp = $date->toUnix();
         switch ($interval) {
             case '1-day':
                 $timestamp = strtotime('-1 day', $timestamp);
                 break;
             case '1-week':
                 $timestamp = strtotime('-1 week', $timestamp);
                 break;
             case '2-week':
                 $timestamp = strtotime('-2 week', $timestamp);
                 break;
             case '1-month':
                 $timestamp = strtotime('-1 month', $timestamp);
                 break;
             case '3-month':
                 $timestamp = strtotime('-3 month', $timestamp);
                 break;
             case '6-month':
                 $timestamp = strtotime('-6 month', $timestamp);
                 break;
             case '1-year':
                 $timestamp = strtotime('-1 year', $timestamp);
                 break;
             default:
                 $timestamp = NULL;
                 break;
         }
         if ($timestamp !== NULL) {
             $dateFrom = JFactory::getDate($timestamp);
             $dateTo = $date;
             if (version_compare(JVERSION, '1.6.0', 'ge')) {
                 $where[] = 'c.date BETWEEN ' . $db->Quote($dateFrom->toSQL()) . ' AND ' . $db->Quote($dateTo->toSQL());
             } else {
                 $where[] = 'c.date BETWEEN ' . $db->Quote($dateFrom->toMySQL()) . ' AND ' . $db->Quote($dateTo->toMySQL());
             }
         }
     }
     $where[] = 'c.published = 1';
     $where[] = 'c.deleted = 0';
     $where[] = "o.link <> ''";
     $where[] = is_array($access) ? "o.access IN (" . implode(',', $access) . ")" : " o.access <= " . (int) $access;
     if (JCommentsMultilingual::isEnabled()) {
         $where[] = 'c.lang = ' . $db->Quote(JCommentsMultilingual::getLanguage());
     }
     $joins = array();
     if (count($source) == 1 && $source[0] == 'com_content') {
         $joins[] = 'JOIN #__content AS cc ON cc.id = o.object_id';
         $joins[] = 'LEFT JOIN #__categories AS ct ON ct.id = cc.catid';
         $where[] = "c.object_group = " . $db->Quote($source[0]);
         $where[] = "(cc.publish_up = '0000-00-00 00:00:00' OR cc.publish_up <= '{$now}')";
         $where[] = "(cc.publish_down = '0000-00-00 00:00:00' OR cc.publish_down >= '{$now}')";
         $categories = $params->get('catid', array());
         if (!is_array($categories)) {
             $categories = explode(',', $categories);
         }
         JArrayHelper::toInteger($categories);
         $categories = implode(',', $categories);
         if (!empty($categories)) {
             $where[] = "cc.catid IN (" . $categories . ")";
         }
     } else {
         if (count($source)) {
             $where[] = "c.object_group in ('" . implode("','", $source) . "')";
         }
     }
     $query = "SELECT c.id, c.userid, c.comment, c.title, c.name, c.username, c.email, c.date, c.object_id, c.object_group, '' as avatar" . ", o.title AS object_title, o.link AS object_link, o.access AS object_access, o.userid AS object_owner" . " FROM #__jcomments AS c" . " JOIN #__jcomments_objects AS o ON c.object_id = o.object_id AND c.object_group = o.object_group AND c.lang = o.lang" . (count($joins) ? ' ' . implode(' ', $joins) : '') . (count($where) ? ' WHERE  ' . implode(' AND ', $where) : '') . " ORDER BY " . $orderBy;
     $db->setQuery($query, 0, $params->get('count'));
     $list = $db->loadObjectList();
     if (!is_array($list)) {
         $list = array();
     }
     if (count($list)) {
         $show_date = $params->get('show_comment_date', 0);
         $date_type = $params->get('date_type', '');
         $date_format = $params->get('date_format', 'd.m.Y H:i');
         $show_author = $params->get('show_comment_author', 0);
         $show_object_title = $params->get('show_object_title', 0);
         $show_comment_title = $params->get('show_comment_title', 0);
         $show_smiles = $params->get('show_smiles', 0);
         $show_avatar = $params->get('show_avatar', 0);
         $limit_comment_text = (int) $params->get('limit_comment_text', 0);
         $config = JCommentsFactory::getConfig();
         $bbcode = JCommentsFactory::getBBCode();
         $smiles = JCommentsFactory::getSmiles();
         $acl = JCommentsFactory::getACL();
         if ($show_avatar) {
             JPluginHelper::importPlugin('jcomments');
             if (version_compare(JVERSION, '3.0', 'ge')) {
                 $dispatcher = JEventDispatcher::getInstance();
             } else {
                 $dispatcher = JDispatcher::getInstance();
             }
             $dispatcher->trigger('onPrepareAvatars', array(&$list));
         }
         foreach ($list as &$item) {
             $item->displayDate = '';
             if ($show_date) {
                 if ($date_type == 'relative') {
                     $item->displayDate = modJCommentsLatestHelper::getRelativeDate($item->date);
                 } else {
                     $item->displayDate = JHTML::_('date', $item->date, $date_format);
                 }
             }
             $item->displayAuthorName = '';
             if ($show_author) {
                 $item->displayAuthorName = JComments::getCommentAuthorName($item);
             }
             $item->displayObjectTitle = '';
             if ($show_object_title) {
                 $item->displayObjectTitle = $item->object_title;
             }
             $item->displayCommentTitle = '';
             if ($show_comment_title) {
                 $item->displayCommentTitle = $item->title;
             }
             $item->displayCommentLink = $item->object_link . '#comment-' . $item->id;
             $text = JCommentsText::censor($item->comment);
             $text = preg_replace('#\\[quote[^\\]]*?\\](((?R)|.)*?)\\[\\/quote\\]#ismu', '', $text);
             $text = $bbcode->filter($text, true);
             $text = JCommentsText::fixLongWords($text, $config->getInt('word_maxlength'), ' ');
             if ($acl->check('autolinkurls')) {
                 $text = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $text);
             }
             $text = JCommentsText::cleanText($text);
             if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) {
                 $text = self::truncateText($text, $limit_comment_text - 1);
             }
             switch ($show_smiles) {
                 case 1:
                     $text = $smiles->replace($text);
                     break;
                 case 2:
                     $text = $smiles->strip($text);
                     break;
             }
             $item->displayCommentText = $text;
             if ($show_avatar && empty($item->avatar)) {
                 $gravatar = md5(strtolower($item->email));
                 $item->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id=' . $gravatar . '&amp;default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars(JComments::getCommentAuthorName($item)) . '" />';
             }
             $item->readmoreText = JText::_('MOD_JCOMMENTS_LATEST_READMORE');
         }
     }
     return $list;
 }
Exemple #10
0
 public static function BanIP($id)
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $acl = JCommentsFactory::getACL();
     $response = JCommentsFactory::getAjaxResponse();
     if ($acl->canBan()) {
         $config = JCommentsFactory::getConfig();
         if ($config->getInt('enable_blacklist') == 1) {
             $id = (int) $id;
             $db = JCommentsFactory::getDBO();
             $comment = new JCommentsTableComment($db);
             if ($comment->load($id)) {
                 // we will not ban own IP ;)
                 if ($comment->ip != $acl->getUserIP()) {
                     $options = array();
                     $options['ip'] = $comment->ip;
                     // check if this IP already banned
                     if (JCommentsSecurity::checkBlacklist($options)) {
                         $result = JCommentsEvent::trigger('onJCommentsUserBeforeBan', array(&$comment, &$options));
                         if (!in_array(false, $result, true)) {
                             require_once JCOMMENTS_TABLES . '/blacklist.php';
                             $blacklist = new JCommentsTableBlacklist($db);
                             $blacklist->ip = $comment->ip;
                             $blacklist->created = JCommentsFactory::getDate();
                             $blacklist->created_by = $acl->getUserId();
                             if ($blacklist->store()) {
                                 JCommentsEvent::trigger('onJCommentsUserAfterBan', array(&$comment, $options));
                                 self::showInfoMessage(JText::_('SUCCESSFULLY_BANNED'), 'comment-item-' . $id);
                             }
                         }
                     } else {
                         self::showErrorMessage(JText::_('ERROR_IP_ALREADY_BANNED'), '', 'comment-item-' . $id);
                     }
                 } else {
                     self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP'), '', 'comment-item-' . $id);
                 }
             }
         }
     }
     return $response;
 }
Exemple #11
0
 public static function showUserComments()
 {
     $config = JCommentsFactory::getConfig();
     if ($config->get('enable_rss') == '1') {
         $app = JFactory::getApplication('site');
         $acl = JCommentsFactory::getACL();
         $userid = $app->input->getInt('userid', 0);
         $limit = $app->input->getInt('limit', $config->getInt('feed_limit', 100));
         $user = JFactory::getUser($userid);
         if (!isset($user->id)) {
             self::showNotFound();
             return;
         }
         $lm = $limit != $config->getInt('feed_limit') ? '&amp;limit=' . $limit : '';
         if (JCommentsMultilingual::isEnabled()) {
             $language = JCommentsMultilingual::getLanguage();
             $lp = '&amp;lang=' . $language;
         } else {
             $language = null;
             $lp = '';
         }
         $liveSite = trim(str_replace(JURI::root(true), '', str_replace('/administrator', '', JURI::root())), '/');
         $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&amp;task=rss_user&amp;userid=' . $userid . $lm . $lp . '&amp;tmpl=raw');
         $user->userid = $user->id;
         $username = JComments::getCommentAuthorName($user);
         $rss = new JoomlaTuneFeed();
         $rss->title = JText::sprintf('USER_FEED_TITLE', $username);
         $rss->link = str_replace('/administrator', '', JURI::root());
         $rss->syndicationURL = $syndicationURL;
         $rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username);
         $options = array();
         $options['lang'] = $language;
         $options['userid'] = $userid;
         $options['published'] = 1;
         $options['filter'] = 'c.deleted = 0';
         $options['orderBy'] = 'c.date DESC';
         $options['votes'] = false;
         $options['limit'] = $limit;
         $options['limitStart'] = 0;
         $options['objectinfo'] = true;
         $options['access'] = $acl->getUserAccess();
         $rows = JCommentsModel::getCommentsList($options);
         $word_maxlength = $config->getInt('word_maxlength');
         foreach ($rows as $row) {
             $comment = JCommentsText::cleanText($row->comment);
             if ($comment != '') {
                 // getting object's information (title and link)
                 $object_title = $row->object_title;
                 $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $row->object_link));
                 // apply censor filter
                 $object_title = JCommentsText::censor($object_title);
                 $comment = JCommentsText::censor($comment);
                 // fix long words problem
                 if ($word_maxlength > 0) {
                     $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' ');
                     if ($object_title != '') {
                         $object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' ');
                     }
                 }
                 $author = JComments::getCommentAuthorName($row);
                 $item = new JoomlaTuneFeedItem();
                 $item->title = $object_title;
                 $item->link = $object_link . '#comment-' . $row->id;
                 $item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment);
                 $item->source = $object_link;
                 $item->pubDate = $row->date;
                 $item->author = $author;
                 $rss->addItem($item);
             }
         }
         $rss->display();
         unset($rows, $rss);
         exit;
     }
 }
Exemple #12
0
 public static function showUserComments()
 {
     $config = JCommentsFactory::getConfig();
     if ($config->get('enable_rss') == '1') {
         $app = JCommentsFactory::getApplication('site');
         $acl = JCommentsFactory::getACL();
         $userid = (int) JCommentsInput::getVar('userid', 0);
         $limit = (int) JCommentsInput::getVar('limit', $config->getInt('feed_limit', 100));
         $user = JCommentsFactory::getUser($userid);
         if (!isset($user->id)) {
             self::showNotFound();
             return;
         }
         if (JCOMMENTS_JVERSION == '1.0') {
             $offset = $app->getCfg('offset') + date('O') / 100;
         } else {
             $offset = $app->getCfg('offset');
         }
         $lm = $limit != $config->getInt('feed_limit') ? '&amp;limit=' . $limit : '';
         if (JCommentsMultilingual::isEnabled()) {
             $language = JCommentsMultilingual::getLanguage();
             $lp = '&amp;lang=' . $language;
         } else {
             $language = null;
             $lp = '';
         }
         if (JCOMMENTS_JVERSION == '1.0') {
             $syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&amp;task=rss_user&amp;userid=' . $userid . $lm . $lp . '&amp;no_html=1';
         } else {
             $liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site'));
             $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&amp;task=rss_user&amp;userid=' . $userid . $lm . $lp . '&amp;tmpl=raw');
         }
         $user->userid = $user->id;
         $username = JComments::getCommentAuthorName($user);
         $rss = new JoomlaTuneFeed();
         $rss->setOffset($offset);
         $rss->encoding = JCOMMENTS_ENCODING;
         $rss->title = JText::sprintf('USER_FEED_TITLE', $username);
         $rss->link = $app->getCfg('live_site');
         $rss->syndicationURL = $syndicationURL;
         $rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username);
         $options = array();
         $options['lang'] = $language;
         $options['userid'] = $userid;
         $options['published'] = 1;
         $options['filter'] = 'c.deleted = 0';
         $options['orderBy'] = 'c.date DESC';
         $options['votes'] = false;
         $options['limit'] = $limit;
         $options['limitStart'] = 0;
         $options['objectinfo'] = true;
         $options['access'] = $acl->getUserAccess();
         $rows = JCommentsModel::getCommentsList($options);
         $word_maxlength = $config->getInt('word_maxlength');
         $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null;
         foreach ($rows as $row) {
             $comment = JCommentsText::cleanText($row->comment);
             if ($comment != '') {
                 // getting object's information (title and link)
                 $object_title = empty($row->object_title) ? JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang) : $row->object_title;
                 $object_link = empty($row->object_link) ? JCommentsObjectHelper::getLink($row->object_id, $row->object_group, $lang) : $row->object_link;
                 $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $object_link));
                 // apply censor filter
                 $object_title = JCommentsText::censor($object_title);
                 $comment = JCommentsText::censor($comment);
                 // fix long words problem
                 if ($word_maxlength > 0) {
                     $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' ');
                     if ($object_title != '') {
                         $object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' ');
                     }
                 }
                 $author = JComments::getCommentAuthorName($row);
                 $item = new JoomlaTuneFeedItem();
                 $item->title = $object_title;
                 $item->link = $object_link . '#comment-' . $row->id;
                 $item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment);
                 $item->source = $object_link;
                 if (JCOMMENTS_JVERSION == '1.0') {
                     $date = strtotime((string) $row->date) - $offset * 3600;
                     $item->pubDate = date('Y-m-d H:i:s', $date);
                 } else {
                     $item->pubDate = $row->date;
                 }
                 $item->author = $author;
                 $rss->addItem($item);
             }
         }
         $rss->display();
         unset($rows, $rss);
         exit;
     }
 }
Exemple #13
0
 function executeCmd()
 {
     global $mainframe;
     $cmd = strtolower(JCommentsInput::getVar('cmd', ''));
     $hash = JCommentsInput::getVar('hash', '');
     $id = (int) JCommentsInput::getVar('id', 0);
     $error = '';
     $link = $mainframe->getCfg('live_site') . '/index.php';
     $checkHash = JCommentsFactory::getCmdHash($cmd, $id);
     if ($hash == $checkHash) {
         $config =& JCommentsFactory::getConfig();
         if ($config->getInt('enable_quick_moderation') == 1) {
             $dbo =& JCommentsFactory::getDBO();
             $comment = new JCommentsDB($dbo);
             if ($comment->load($id)) {
                 $link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group);
                 $link = str_replace('&amp;', '&', $link);
                 switch ($cmd) {
                     case 'publish':
                         $comment->published = 1;
                         $comment->store();
                         $link .= '#comment-' . $comment->id;
                         break;
                     case 'unpublish':
                         $comment->published = 0;
                         $comment->store();
                         $acl =& JCommentsFactory::getACL();
                         if ($acl->canPublish()) {
                             $link .= '#comment-' . $comment->id;
                         } else {
                             $link .= '#comments';
                         }
                         break;
                     case 'delete':
                         $comment->delete();
                         $link .= '#comments';
                         break;
                 }
             }
         } else {
             $error = JText::_('Quick moderation function is disabled by administrator!');
         }
     } else {
         $error = JText::_('Incorrect hash for this operation!');
     }
     JCommentsRedirect($link, $error);
 }
Exemple #14
0
 function onPrepareContent(&$article, &$params, $limitstart = 0)
 {
     require_once JPATH_ROOT . '/components/com_jcomments/helpers/content.php';
     // check whether plugin has been unpublished
     if (!JPluginHelper::isEnabled('content', 'jcomments')) {
         JCommentsContentPluginHelper::clear($article, true);
         return '';
     }
     $app = JFactory::getApplication('site');
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     if (!isset($article->id) || $option != 'com_content' && $option != 'com_alphacontent' && $option != 'com_multicategories') {
         return '';
     }
     if (!isset($params) || $params == null) {
         $params = new JRegistry('');
     } else {
         if (isset($params->_raw) && strpos($params->_raw, 'moduleclass_sfx') !== false) {
             return '';
         }
     }
     if ($view == 'frontpage' || $view == 'featured') {
         if ($this->params->get('show_frontpage', 1) == 0) {
             return '';
         }
     }
     require_once JPATH_ROOT . '/components/com_jcomments/jcomments.class.php';
     JCommentsContentPluginHelper::processForeignTags($article);
     $config = JCommentsFactory::getConfig();
     $categoryEnabled = JCommentsContentPluginHelper::checkCategory($article->catid);
     $commentsEnabled = JCommentsContentPluginHelper::isEnabled($article) || $categoryEnabled;
     $commentsDisabled = JCommentsContentPluginHelper::isDisabled($article) || !$commentsEnabled;
     $commentsLocked = JCommentsContentPluginHelper::isLocked($article);
     $archivesState = 2;
     if (isset($article->state) && $article->state == $archivesState && $this->params->get('enable_for_archived', 0) == 0) {
         $commentsLocked = true;
     }
     $config->set('comments_on', intval($commentsEnabled));
     $config->set('comments_off', intval($commentsDisabled));
     $config->set('comments_locked', intval($commentsLocked));
     if ($view != 'article') {
         $user = JFactory::getUser();
         $authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
         $checkAccess = in_array($article->access, $authorised);
         $slug = isset($article->slug) ? $article->slug : $article->id;
         $language = isset($article->language) ? $article->language : 0;
         require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
         if ($checkAccess) {
             $readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language));
             $readmore_register = 0;
         } else {
             $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $article->catid, $language));
             $menu = JFactory::getApplication()->getMenu();
             $active = $menu->getActive();
             $itemId = $active->id;
             $link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
             $link = new JURI($link1);
             $link->setVar('return', base64_encode($returnURL));
             $readmore_link = $link;
             $readmore_register = 1;
         }
         // load template for comments & readmore links
         $tmpl = JCommentsFactory::getTemplate($article->id, 'com_content', false);
         $tmpl->load('tpl_links');
         $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1);
         $tmpl->addVar('tpl_links', 'content-item', $article);
         $tmpl->addVar('tpl_links', 'show_hits', intval($this->params->get('show_hits', 0) && $params->get('show_hits', 0)));
         $readmoreDisabled = false;
         if ($params->get('show_readmore') == 0 || @$article->readmore == 0) {
             $readmoreDisabled = true;
         } else {
             if (@$article->readmore > 0) {
                 $readmoreDisabled = false;
             }
         }
         if ($this->params->get('readmore_link', 1) == 0) {
             $readmoreDisabled = true;
         }
         $tmpl->addVar('tpl_links', 'readmore_link_hidden', intval($readmoreDisabled));
         // don't fill any readmore variable if it disabled
         if (!$readmoreDisabled) {
             if ($readmore_register == 1) {
                 $readmore_text = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
             } else {
                 if (isset($params) && ($readmore = $params->get('readmore'))) {
                     $readmore_text = $readmore;
                 } else {
                     if ($alternative_readmore = $article->alternative_readmore) {
                         $readmore_text = trim($alternative_readmore);
                         if ($params->get('show_readmore_title', 0) != 0) {
                             $readmore_text .= ' ' . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
                         }
                     } else {
                         $readmore_text = JText::_('COM_CONTENT_READ_MORE_TITLE');
                         if ($params->get('show_readmore_title', 0) == 1) {
                             $readmore_text = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $article->title, $params->get('readmore_limit'));
                         }
                     }
                 }
             }
             $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
             $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
             $tmpl->addVar('tpl_links', 'link-readmore-title', $article->title);
             $tmpl->addVar('tpl_links', 'link-readmore-class', $this->params->get('readmore_css_class', 'readmore-link'));
         }
         $commentsDisabled = false;
         if ($config->getInt('comments_off', 0) == 1) {
             $commentsDisabled = true;
         } else {
             if ($config->getInt('comments_on', 0) == 1) {
                 $commentsDisabled = false;
             }
         }
         $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));
         $count = 0;
         // do not query comments count if comments disabled and link hidden
         if (!$commentsDisabled) {
             require_once JPATH_ROOT . '/components/com_jcomments/models/jcomments.php';
             $anchor = "";
             if ($this->params->get('comments_count', 1) != 0) {
                 $acl = JCommentsFactory::getACL();
                 $options = array();
                 $options['object_id'] = (int) $article->id;
                 $options['object_group'] = 'com_content';
                 $options['published'] = $acl->canPublish() || $acl->canPublishForObject($article->id, 'com_content') ? null : 1;
                 $count = JCommentsModel::getCommentsCount($options);
                 $tmpl->addVar('tpl_links', 'comments-count', $count);
                 $anchor = $count == 0 ? '#addcomments' : '#comments';
                 if ($count == 0) {
                     $link_text = JText::_('LINK_ADD_COMMENT');
                 } else {
                     $link_text = JText::plural('LINK_READ_COMMENTS', $count);
                 }
             } else {
                 $link_text = JText::_('LINK_ADD_COMMENT');
             }
             $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor);
             $tmpl->addVar('tpl_links', 'link-comment-text', $link_text);
             $tmpl->addVar('tpl_links', 'link-comments-class', $this->params->get('comments_css_class', 'comments-link'));
         }
         JCommentsContentPluginHelper::clear($article, true);
         // hide comments link if comments enabled but link disabled in plugin params
         if (($this->params->get('comments_count', 1) == 0 || $count == 0 && $this->params->get('add_comments', 1) == 0 || $count == 0 && $readmore_register == 1) && !$commentsDisabled) {
             $tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
         }
         //links_position
         if ($this->params->get('links_position', 1) == 1) {
             $article->text .= $tmpl->renderTemplate('tpl_links');
         } else {
             $article->text = $tmpl->renderTemplate('tpl_links') . $article->text;
         }
         $tmpl->freeTemplate('tpl_links');
         if ($this->params->get('readmore_link', 1) == 1) {
             $article->readmore = 0;
             $article->readmore_link = '';
             $article->readmore_register = false;
         }
     } else {
         if ($this->params->get('show_comments_event') == 'onPrepareContent') {
             $isEnabled = $config->getInt('comments_on', 0) == 1 && $config->getInt('comments_off', 0) == 0;
             if ($isEnabled && $view == 'article') {
                 require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php';
                 $comments = JComments::show($article->id, 'com_content', $article->title);
                 if (strpos($article->text, '{jcomments}') !== false) {
                     $article->text = str_replace('{jcomments}', $comments, $article->text);
                 } else {
                     $article->text .= $comments;
                 }
             }
         }
         JCommentsContentPluginHelper::clear($article, true);
     }
     return '';
 }
Exemple #15
0
 function reportComment()
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $acl =& JCommentsFactory::getACL();
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     $response =& JCommentsFactory::getAjaxResponse();
     $values = JCommentsAJAX::prepareValues($_POST);
     $id = (int) $values['commentid'];
     $reason = trim(strip_tags($values['reason']));
     $name = trim(strip_tags($values['name']));
     $ip = $acl->getUserIP();
     if ($reason == '') {
         JCommentsAJAX::showErrorMessage(JText::_('Please enter the reason for your report!'), '', 'comments-report-form');
         return $response;
     }
     $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id;
     if ($acl->getUserId()) {
         $query .= ' AND userid = ' . $acl->getUserId();
     } else {
         $query .= ' AND ip = "' . $ip . '"';
     }
     $db->setQuery($query);
     $reported = $db->loadResult();
     if (!$reported) {
         $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id;
         $db->setQuery($query);
         $reported = $db->loadResult();
         if (!$reported) {
             $comment = new JCommentsDB($db);
             if ($comment->load($id)) {
                 if ($acl->canReport($comment)) {
                     $allowed = true;
                     if ($config->getInt('enable_mambots') == 1) {
                         require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                         JCommentsPluginHelper::importPlugin('jcomments');
                         JCommentsPluginHelper::trigger('onReportComment', array(&$comment, &$response, &$allowed, &$value));
                     }
                     if ($allowed !== false) {
                         if ($acl->getUserId()) {
                             $user = JCommentsFactory::getUser();
                             $name = $user->name;
                         } else {
                             if ($name == '') {
                                 $name = JText::_('Guest');
                             }
                         }
                         $query = "INSERT INTO `#__jcomments_reports`(`commentid`,`userid`, `name`,`ip`,`date`,`reason`)" . "VALUES('" . $comment->id . "', '" . $acl->getUserId() . "', '" . $db->getEscaped($name) . "', '" . $db->getEscaped($ip) . "', now(), '" . $db->getEscaped($reason) . "')";
                         $db->setQuery($query);
                         $db->query();
                         if ($config->getInt('enable_notification') == 1) {
                             if ($config->check('notification_type', 2)) {
                                 $comment->datetime = $comment->date;
                                 if (is_string($comment->datetime)) {
                                     $comment->datetime = strtotime($comment->datetime);
                                 }
                                 JComments::sendReport($comment, $name, $reason);
                             }
                         }
                         $html = JText::_('Report successfully sent!');
                         $html = str_replace("\n", '\\n', $html);
                         $html = str_replace('\\n', '<br />', $html);
                         $html = JCommentsText::jsEscape($html);
                         $response->addScript("jcomments.closeReport('{$html}');");
                     }
                 } else {
                     JCommentsAJAX::showErrorMessage(JText::_('You have no rights to report comment!'), '', 'comments-report-form');
                 }
             } else {
                 $response->addAlert(JText::_('ERROR_NOT_FOUND'));
             }
             unset($comment);
         } else {
             JCommentsAJAX::showErrorMessage(JText::_('Comment already reported to the site administrator'), '', 'comments-report-form');
         }
     } else {
         JCommentsAJAX::showErrorMessage(JText::_('You can\'t report the same comment more than once!'), '', 'comments-report-form');
     }
     return $response;
 }
Exemple #16
0
/**
* Comments Search method
*
* The sql must return the following fields that are used in a common display
* routine: href, title, section, created, text, browsernav
* @param string Target search string
* @param string matching option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if restricted to areas, null if search all
*/
function plgSearchJComments($text, $phrase = '', $ordering = '', $areas = null)
{
    $text = trim($text);
    if ($text == '') {
        return array();
    }
    if (is_array($areas)) {
        if (!array_intersect($areas, array_keys(plgSearchJCommentsAreas()))) {
            return array();
        }
    }
    if (file_exists(JCOMMENTS_BASE . DS . 'jcomments.php')) {
        require_once JCOMMENTS_BASE . DS . 'jcomments.php';
        require_once JCOMMENTS_BASE . DS . 'jcomments.class.php';
        require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
        require_once JCOMMENTS_HELPERS . DS . 'content.php';
        require_once JCOMMENTS_HELPERS . DS . 'object.php';
        $db =& JCommentsFactory::getDBO();
        $pluginParams = JCommentsPluginHelper::getParams('jcomments', 'search');
        $limit = $pluginParams->def('search_limit', 50);
        switch ($phrase) {
            case 'exact':
                $where = "LOWER(comment) LIKE '%{$text}%' OR LOWER(title) LIKE '%{$text}%'";
                break;
            case 'all':
            case 'any':
            default:
                $words = explode(' ', $text);
                $wheres = array();
                foreach ($words as $word) {
                    $wheres2 = array();
                    $wheres2[] = "LOWER(name) LIKE '%{$word}%'";
                    $wheres2[] = "LOWER(comment) LIKE '%{$word}%'";
                    $wheres2[] = "LOWER(title) LIKE '%{$word}%'";
                    $wheres[] = implode(' OR ', $wheres2);
                }
                $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
                break;
        }
        switch ($ordering) {
            case 'oldest':
                $order = 'date ASC';
                break;
            case 'newest':
            default:
                $order = 'date DESC';
                break;
        }
        $query = "SELECT " . "\n  comment AS text" . "\n, date AS created" . "\n, '2' AS browsernav" . "\n, '" . JText::_('Comments') . "' AS section" . "\n, ''  AS href" . "\n, id" . "\n, object_id" . "\n, object_group" . "\nFROM #__jcomments " . "\nWHERE published='1'" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . "\n AND ({$where}) " . "\nORDER BY object_id, {$order}";
        $db->setQuery($query, 0, $limit);
        $rows = $db->loadObjectList();
        $result = array();
        $cnt = count($rows);
        if ($cnt > 0) {
            $last_object_id = -1;
            $object_link = '';
            $acl =& JCommentsFactory::getACL();
            $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null;
            for ($i = 0; $i < $cnt; $i++) {
                if ($rows[$i]->object_id != $last_object_id) {
                    $last_object_id = $rows[$i]->object_id;
                    $object_link = JCommentsObjectHelper::getLink($rows[$i]->object_id, $rows[$i]->object_group);
                    $object_title = JCommentsObjectHelper::getTitle($rows[$i]->object_id, $rows[$i]->object_group, $lang);
                }
                $rows[$i]->href = $object_link . '#comment-' . $rows[$i]->id;
                $comment = JCommentsText::cleanText($rows[$i]->text);
                if ($acl->check('enable_autocensor')) {
                    $comment = JCommentsText::censor($comment);
                }
                if ($comment != '') {
                    $rows[$i]->title = $object_title;
                    $rows[$i]->text = $comment;
                    $result[] = $rows[$i];
                }
            }
        }
        unset($rows);
        return $result;
    }
    return array();
}
Exemple #17
0
function plgContentJCommentsLinksJ10($published, &$row, &$params, $page = 0)
{
    global $task, $option, $my;
    // disable comments link in 3rd party components (except Events and AlphaContent)
    if ($option != 'com_content' && $option != 'com_frontpage' && $option != 'com_alphacontent' && $option != 'com_events') {
        return;
    }
    require_once JCOMMENTS_HELPERS . '/content.php';
    require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php';
    if (!isset($params) || $params == null) {
        $params = new mosParameters('');
    }
    $pvars = array_keys(get_object_vars($params->_params));
    if (!$published || $params->get('popup') || in_array('moduleclass_sfx', $pvars)) {
        JCommentsContentPluginHelper::processForeignTags($row, true);
        JCommentsContentPluginHelper::clear($row, true);
        return;
    }
    /*
    if ($option == 'com_frontpage') {
    	$pluginParams = JCommentsPluginHelper::getParams('jcomments', 'content');
    	if ((int) $pluginParams->get('show_frontpage', 1) == 0) {
    		return;
    	}
    }
    */
    require_once JCOMMENTS_BASE . '/jcomments.config.php';
    require_once JCOMMENTS_BASE . '/jcomments.class.php';
    if ($task != 'view') {
        // replace other comment systems tags to JComments equivalents like {jcomments on}
        JCommentsContentPluginHelper::processForeignTags($row, false);
        // show link to comments only
        if ($row->access <= $my->gid) {
            $readmore_link = JCommentsObjectHelper::getLink($row->id, 'com_content');
            $readmore_register = 0;
        } else {
            $readmore_link = sefRelToAbs('index.php?option=com_registration&amp;task=register');
            $readmore_register = 1;
        }
        $tmpl = JCommentsFactory::getTemplate($row->id, 'com_content', false);
        $tmpl->load('tpl_links');
        $tmpl->addVar('tpl_links', 'comments_link_style', $readmore_register ? -1 : 1);
        $tmpl->addVar('tpl_links', 'link-readmore', $readmore_link);
        $tmpl->addVar('tpl_links', 'content-item', $row);
        if ($params->get('readmore') == 0 || @$row->readmore == 0) {
            $tmpl->addVar('tpl_links', 'readmore_link_hidden', 1);
        } else {
            if (@$row->readmore > 0) {
                $tmpl->addVar('tpl_links', 'readmore_link_hidden', 0);
            }
        }
        $config = JCommentsFactory::getConfig();
        $commentsDisabled = false;
        if (!JCommentsContentPluginHelper::checkCategory($row->catid)) {
            $commentsDisabled = true;
        }
        if ($config->getInt('comments_off', 0) == 1) {
            $commentsDisabled = true;
        } else {
            if ($config->getInt('comments_on', 0) == 1) {
                $commentsDisabled = false;
            }
        }
        $tmpl->addVar('tpl_links', 'comments_link_hidden', intval($commentsDisabled));
        $count = 0;
        // do not query comments count if comments disabled and link hidden
        if (!$commentsDisabled) {
            require_once JCOMMENTS_MODELS . '/jcomments.php';
            require_once JCOMMENTS_LIBRARIES . '/joomlatune/language.tools.php';
            $acl = JCommentsFactory::getACL();
            $options = array();
            $options['object_id'] = (int) $row->id;
            $options['object_group'] = 'com_content';
            $options['published'] = $acl->canPublish() || $acl->canPublishForObject($row->id, 'com_content') ? null : 1;
            $count = JCommentsModel::getCommentsCount($options);
            $anchor = $count == 0 ? '#addcomments' : '#comments';
            $link_text = $count == 0 ? JText::_('LINK_ADD_COMMENT') : JText::plural('LINK_READ_COMMENTS', $count);
            $tmpl->addVar('tpl_links', 'link-comment', $readmore_link . $anchor);
            $tmpl->addVar('tpl_links', 'link-comment-text', $link_text);
            $tmpl->addVar('tpl_links', 'link-comments-class', 'comments-link');
            $tmpl->addVar('tpl_links', 'comments-count', $count);
        }
        if ($readmore_register == 1 && $count == 0) {
            $tmpl->addVar('tpl_links', 'comments_link_hidden', 1);
        }
        if ($readmore_register == 1) {
            $readmore_text = JText::_('LINK_REGISTER_TO_READ_MORE');
        } else {
            $readmore_text = JText::_('LINK_READ_MORE');
        }
        $tmpl->addVar('tpl_links', 'link-readmore-text', $readmore_text);
        $tmpl->addVar('tpl_links', 'link-readmore-title', $row->title);
        $tmpl->addVar('tpl_links', 'link-readmore-class', 'readmore-link');
        JCommentsContentPluginHelper::clear($row, true);
        $row->text .= $tmpl->renderTemplate('tpl_links');
        $GLOBALS['jcomments_params_readmore'] = $params->get('readmore');
        $GLOBALS['jcomments_row_readmore'] = $row->readmore;
        $params->set('readmore', 0);
        $row->readmore = 0;
    } else {
        JCommentsContentPluginHelper::processForeignTags($row, true);
        JCommentsContentPluginHelper::clear($row, true);
    }
    return;
}
 function replace($str)
 {
     global $my;
     ob_start();
     $acl =& JCommentsFactory::getACL();
     $config =& JCommentsFactory::getConfig();
     $patterns = array();
     $replacements = array();
     // B
     $patterns[] = '/\\[b\\](.*?)\\[\\/b\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<b>\\1</b>';
     // I
     $patterns[] = '/\\[i\\](.*?)\\[\\/i\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<i>\\1</i>';
     // U
     $patterns[] = '/\\[u\\](.*?)\\[\\/u\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<u>\\1</u>';
     // S
     $patterns[] = '/\\[s\\](.*?)\\[\\/s\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<strike>\\1</strike>';
     // SUP
     $patterns[] = '/\\[sup\\](.*?)\\[\\/sup\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<sup>\\1</sup>';
     // SUB
     $patterns[] = '/\\[sub\\](.*?)\\[\\/sub\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<sub>\\1</sub>';
     // URL (local)
     global $mainframe;
     $liveSite = $mainframe->getCfg('live_site');
     $patterns[] = '#\\[url\\](' . preg_quote($liveSite, '#') . '[^\\s<\\"\']*?)\\[\\/url\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="\\1" target="_blank">\\1</a>';
     $patterns[] = '#\\[url=(' . preg_quote($liveSite, '#') . '[^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="\\1" target="_blank">\\2</a>';
     $patterns[] = '/\\[url=(\\#|\\/)([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="\\1\\2" target="_blank">\\3</a>';
     // URL (external)
     $patterns[] = '#\\[url\\](http:\\/\\/)?([^\\s<\\"\']*?)\\[\\/url\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="http://\\2" rel="external nofollow" target="_blank">\\2</a>';
     $patterns[] = '/\\[url=([a-z]*\\:\\/\\/)([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="\\1\\2" rel="external nofollow" target="_blank">\\3</a>';
     $patterns[] = '/\\[url=([^\\s<\\"\'\\]]*?)\\](.*?)\\[\\/url\\]/i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<a href="http://\\1" rel="external nofollow" target="_blank">\\2</a>';
     $patterns[] = '#\\[url\\](.*?)\\[\\/url\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '\\1';
     // EMAIL
     $patterns[] = '#\\[email\\]([^\\s\\<\\>\\(\\)\\"\'\\[\\]]*?)\\[\\/email\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '\\1';
     // IMG
     $patterns[] = '#\\[img\\](http:\\/\\/)?([^\\s\\<\\>\\(\\)\\"\']*?)\\[\\/img\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '<img class="img" src="http://\\2" alt="" border="0" />';
     $patterns[] = '#\\[img\\](.*?)\\[\\/img\\]#i' . JCOMMENTS_PCRE_UTF8;
     $replacements[] = '\\1';
     // HIDE
     $patterns[] = '/\\[hide\\](.*?)\\[\\/hide\\]/i' . JCOMMENTS_PCRE_UTF8;
     if ($my->id) {
         $replacements[] = '\\1';
     } else {
         $replacements[] = '<span class="hidden">' . JText::_('HIDDEN_TEXT') . '</span>';
     }
     // CODE
     $geshiEnabled = $config->getInt('enable_geshi', 0);
     $codePattern = '#\\[code\\=?([a-z0-9]*?)\\](.*?)\\[\\/code\\]#ism' . JCOMMENTS_PCRE_UTF8;
     if ($geshiEnabled) {
         if (JCOMMENTS_JVERSION == '1.0') {
             global $mainframe;
             include_once $mainframe->getCfg('absolute_path') . DS . 'mambots' . DS . 'content' . DS . 'geshi' . DS . 'geshi.php';
         } else {
             if (JCOMMENTS_JVERSION == '1.5') {
                 jimport('geshi.geshi');
             }
         }
         if (!function_exists('jcommentsProcessGeSHi')) {
             function jcommentsProcessGeSHi($matches)
             {
                 $lang = $matches[1] != '' ? $matches[1] : 'php';
                 $text = $matches[2];
                 $html_entities_match = array('#\\<br \\/\\>#', "#<#", "#>#", "|&#39;|", '#&quot;#', '#&nbsp;#');
                 $html_entities_replace = array("\n", '&lt;', '&gt;', "'", '"', ' ');
                 $text = preg_replace($html_entities_match, $html_entities_replace, $text);
                 $text = preg_replace('#(\\r|\\n)*?$#ism', '', $text);
                 $text = str_replace('&lt;', '<', $text);
                 $text = str_replace('&gt;', '>', $text);
                 $geshi = new GeSHi($text, $lang);
                 $text = $geshi->parse_code();
                 return '[code]' . $text . '[/code]';
             }
         }
         $patterns[] = $codePattern;
         $replacements[] = '<span class="code">' . JText::_('CODE') . '</span>\\2';
         $str = preg_replace_callback($codePattern, 'jcommentsProcessGeSHi', $str);
     } else {
         $patterns[] = $codePattern;
         $replacements[] = '<span class="code">' . JText::_('CODE') . '</span><code>\\2</code>';
         if (!function_exists('jcommentsProcessCode')) {
             function jcommentsProcessCode($matches)
             {
                 return htmlspecialchars(trim($matches[0]));
             }
         }
         $str = preg_replace_callback($codePattern, 'jcommentsProcessCode', $str);
     }
     $str = preg_replace($patterns, $replacements, $str);
     // QUOTE
     $quotePattern = '#\\[quote\\s?name=\\"([^\\"\'\\<\\>\\(\\)]+)+\\"\\](<br\\s?\\/?\\>)*(.*?)(<br\\s?\\/?\\>)*\\[\\/quote\\]#i' . JCOMMENTS_PCRE_UTF8;
     $quoteReplace = '<span class="quote">' . JText::sprintf('Quoting', '\\1') . '</span><blockquote>\\3</blockquote>';
     while (preg_match($quotePattern, $str)) {
         $str = preg_replace($quotePattern, $quoteReplace, $str);
     }
     $quotePattern = '#\\[quote[^\\]]*?\\](<br\\s?\\/?\\>)*([^\\[]+)(<br\\s?\\/?\\>)*\\[\\/quote\\]#i' . JCOMMENTS_PCRE_UTF8;
     $quoteReplace = '<span class="quote">' . JText::_('QUOTE_SINGLE') . '</span><blockquote>\\2</blockquote>';
     while (preg_match($quotePattern, $str)) {
         $str = preg_replace($quotePattern, $quoteReplace, $str);
     }
     // LIST
     $matches = array();
     $matchCount = preg_match_all('#\\[list\\](<br\\s?\\/?\\>)*(.*?)(<br\\s?\\/?\\>)*\\[\\/list\\]#is' . JCOMMENTS_PCRE_UTF8, $str, $matches);
     for ($i = 0; $i < $matchCount; $i++) {
         $textBefore = preg_quote($matches[2][$i]);
         $textAfter = preg_replace('#(<br\\s?\\/?\\>)*\\[\\*\\](<br\\s?\\/?\\>)*#is' . JCOMMENTS_PCRE_UTF8, "</li><li>", $matches[2][$i]);
         $textAfter = preg_replace("#^</?li>#" . JCOMMENTS_PCRE_UTF8, "", $textAfter);
         $textAfter = str_replace("\n</li>", "</li>", $textAfter . "</li>");
         $str = preg_replace('#\\[list\\](<br\\s?\\/?\\>)*' . $textBefore . '(<br\\s?\\/?\\>)*\\[/list\\]#is' . JCOMMENTS_PCRE_UTF8, "<ul>{$textAfter}</ul>", $str);
     }
     $matches = array();
     $matchCount = preg_match_all('#\\[list=(a|A|i|I|1)\\](<br\\s?\\/?\\>)*(.*?)(<br\\s?\\/?\\>)*\\[\\/list\\]#is' . JCOMMENTS_PCRE_UTF8, $str, $matches);
     for ($i = 0; $i < $matchCount; $i++) {
         $textBefore = preg_quote($matches[3][$i]);
         $textAfter = preg_replace('#(<br\\s?\\/?\\>)*\\[\\*\\](<br\\s?\\/?\\>)*#is' . JCOMMENTS_PCRE_UTF8, "</li><li>", $matches[3][$i]);
         $textAfter = preg_replace("#^</?li>#" . JCOMMENTS_PCRE_UTF8, '', $textAfter);
         $textAfter = str_replace("\n</li>", "</li>", $textAfter . "</li>");
         $str = preg_replace('#\\[list=(a|A|i|I|1)\\](<br\\s?\\/?\\>)*' . $textBefore . '(<br\\s?\\/?\\>)*\\[/list\\]#is' . JCOMMENTS_PCRE_UTF8, "<ol type=\\1>{$textAfter}</ol>", $str);
     }
     $str = preg_replace('#\\[\\/?(b|i|u|s|sup|sub|url|img|list|quote|code|hide)\\]#' . JCOMMENTS_PCRE_UTF8, '', $str);
     unset($matches);
     ob_end_clean();
     return $str;
 }