function feedLastCommentsGlobal() { global $mainframe; $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', ''))); $object_group = preg_replace('#[^0-9A-Za-z\\-\\_\\,\\.]#is', '', $object_group); $limit = (int) JCommentsInput::getVar('limit', 100); $config =& JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $iso = explode('=', _ISO); $charset = strtolower((string) $iso[1]); if (JCOMMENTS_JVERSION == '1.5') { $offset = $mainframe->getCfg('offset'); } else { $offset = $mainframe->getCfg('offset') + date('O') / 100; } $object_group = preg_replace('#[\'\\"]#ism', '', $object_group); $og = $object_group ? '&object_group=' . $object_group : ''; $lm = $limit != 100 ? '&limit=' . $limit : ''; if (JCOMMENTS_JVERSION == '1.5') { $syndicationURL = JoomlaTuneRoute::_('index.php?option=com_jcomments&task=rss_full' . $og . $lm . '&tmpl=component'); } else { $syndicationURL = $mainframe->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_full' . $og . $lm . '&no_html=1'; } $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = $charset; $rss->title = JText::_('Comments'); $rss->link = $mainframe->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::_('COMMENTS_FOR') . ' ' . $mainframe->getCfg('sitename'); if ($object_group != '') { $groups = explode(',', $object_group); } else { $groups = array(); } $db =& JCommentsFactory::getDBO(); $query = "SELECT id, title, object_id, object_group, userid, name, username, date, UNIX_TIMESTAMP(date) as date_ts, comment" . "\nFROM #__jcomments " . "\nWHERE published = '1'" . (count($groups) > 0 ? "\n AND (object_group = '" . implode("' OR object_group='", $groups) . "')" : '') . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . "\nORDER BY date DESC"; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); $author = JComments::getCommentAuthorName($row); if ($comment != '') { $object_title = JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang); $object_link = JCommentsObjectHelper::getLink($row->object_id, $row->object_group); $object_link = str_replace('amp;', '', $object_link); $object_link = JCommentsFactory::getAbsLink($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 ($comment != '') { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); } } $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = $author . ' ' . JText::_('Wrote') . ' "' . $comment . '"'; $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.5') { $item->pubDate = $row->date; } else { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
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') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&lang=' . $language; } else { $language = null; $lp = ''; } if (JCOMMENTS_JVERSION == '1.0') { $syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&no_html=1'; } else { $liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site')); $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&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; } }