Ejemplo n.º 1
0
 /**
  * Returns a reference to a language object.
  * 
  * @param string $language The language to use.
  * @param string $component The component name.
  * @return JCommentsCfg
  */
 public static function getInstance($language = '', $component = '')
 {
     static $instance = null;
     $app = JCommentsFactory::getApplication();
     if (JCOMMENTS_JVERSION == '1.7') {
         $multilingual_support = $app->isSite() && $app->getLanguageFilter();
     } else {
         $multilingual_support = $app->getCfg('multilingual_support') == 1;
     }
     if (!is_object($instance)) {
         $instance = new JCommentsCfg();
         if ($language == '') {
             $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : '';
         }
         $instance->load($language, $component);
     } else {
         if ($language != $instance->_current && $instance->_current == '') {
             if ($language != '') {
                 $instance->load($language, $component);
             } else {
                 $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : '';
                 if ($language != '') {
                     $instance->load($language, $component);
                 }
             }
         }
     }
     return $instance;
 }
Ejemplo n.º 2
0
 function store($updateNulls = false)
 {
     if ($this->userid != 0 && empty($this->email)) {
         $user = JFactory::getUser($this->userid);
         $this->email = $user->email;
     }
     if ($this->userid == 0 && !empty($this->email)) {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         $query->select('*');
         $query->from($db->quoteName('#__users'));
         $query->where($db->quoteName('email') . ' = ' . $db->Quote($db->escape($this->email, true)));
         $db->setQuery($query);
         $users = $db->loadObjectList();
         if (count($users)) {
             $this->userid = $users[0]->id;
             $this->name = $users[0]->name;
         }
     }
     if (empty($this->lang)) {
         $this->lang = JCommentsMultilingual::getLanguage();
     }
     $this->hash = $this->getHash();
     return parent::store($updateNulls);
 }
Ejemplo n.º 3
0
 /**
  * Returns a reference to a language object.
  * 
  * @static
  * @access public
  * @param string $language The language to use.
  * @return JCommentsCfg
  */
 function &getInstance($language = '', $component = '')
 {
     static $instance = null;
     global $mainframe;
     if (!is_object($instance)) {
         $instance = new JCommentsCfg();
         if ($language == '') {
             $multilingual_support = $mainframe->getCfg('multilingual_support') == 1;
             $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : '';
         }
         $instance->load($language, $component);
     } else {
         if ($language != $instance->_current && $instance->_current == '') {
             if ($language != '') {
                 $instance->load($language, $component);
             } else {
                 $multilingual_support = $mainframe->getCfg('multilingual_support') == 1;
                 $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : '';
                 if ($language != '') {
                     $instance->load($language, $component);
                 }
             }
         }
     }
     return $instance;
 }
Ejemplo n.º 4
0
 public static function checkFlood($ip)
 {
     $interval = JCommentsFactory::getConfig()->getInt('flood_time');
     if ($interval > 0) {
         $db = JFactory::getDbo();
         $now = JFactory::getDate()->toSql();
         $query = "SELECT COUNT(*) " . "\nFROM #__jcomments " . "\nWHERE ip = " . $db->Quote($ip) . "\nAND " . $db->Quote($now) . " < DATE_ADD(date, INTERVAL " . $interval . " SECOND)" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = " . $db->Quote(JCommentsMultilingual::getLanguage()) : '');
         $db->setQuery($query);
         return $db->loadResult() == 0 ? 0 : 1;
     }
     return 0;
 }
Ejemplo n.º 5
0
 function store($updateNulls = false)
 {
     if ($this->userid != 0 && empty($this->email)) {
         $user = JCommentsFactory::getUser($this->userid);
         $this->email = $user->email;
         unset($user);
     }
     if (empty($this->lang)) {
         $this->lang = JCommentsMultilingual::getLanguage();
     }
     $this->hash = $this->getHash();
     return parent::store($updateNulls);
 }
Ejemplo n.º 6
0
 /**
  * Returns a reference to a JCommentsCfg object.
  *
  * @param string $language The language code.
  * @param string $component The component name.
  * @return JCommentsCfg
  */
 public static function getInstance($language = '', $component = '')
 {
     static $instance = null;
     if ($language == '' && JCommentsMultilingual::isEnabled()) {
         $language = JCommentsMultilingual::getLanguage();
     }
     if (!is_object($instance)) {
         $instance = new JCommentsCfg();
         $instance->load($language, $component);
     } else {
         if ($language != $instance->_current && $instance->_current == '') {
             if ($language != '') {
                 $instance->load($language, $component);
             }
         }
     }
     return $instance;
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 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 ? '&amp;object_group=' . $object_group : '';
         $lm = $limit != 100 ? '&amp;limit=' . $limit : '';
         if (JCOMMENTS_JVERSION == '1.5') {
             $syndicationURL = JoomlaTuneRoute::_('index.php?option=com_jcomments&amp;task=rss_full' . $og . $lm . '&amp;tmpl=component');
         } else {
             $syndicationURL = $mainframe->getCfg('live_site') . '/index2.php?option=com_jcomments&amp;task=rss_full' . $og . $lm . '&amp;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') . ' &quot;' . $comment . '&quot;';
                 $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;
     }
 }
    function showImport()
    {
        global $mainframe;
        $CommentSystems = array();
        $CommentSystems[] = new JOtherCommentSystem('AkoComment', 'AkoComment', 'Arthur Konze', 'http://www.konze.de/content/view/8/26/', 'http://www.konze.de/content/view/8/26/', 'http://mamboportal.com', '#__akocomment');
        $CommentSystems[] = new JOtherCommentSystem('MosCom', 'MosCom', 'Chanh Ong', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://ongetc.com', '#__content_comments');
        $CommentSystems[] = new JOtherCommentSystem('ComboMax', 'ComboMax', 'Phil Taylor', 'Commercial (22.50 GPB)', '', 'http://www.phil-taylor.com/Joomla/Components/ComboMAX/', '#__combomax');
        $CommentSystems[] = new JOtherCommentSystem('JoomlaComment', 'JoomlaComment', 'Frantisek Hliva', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://cavo.co.nr', '#__comment');
        $CommentSystems[] = new JOtherCommentSystem('mXcomment', 'mXcomment', 'Bernard Gilly', 'Creative Commons', '', 'http://www.visualclinic.fr', '#__mxc_comments');
        $CommentSystems[] = new JOtherCommentSystem('JomComment', 'JomComment', 'Azrul Rahim', 'Commercial/Free', '', 'http://www.azrul.com', '#__jomcomment');
        $CommentSystems[] = new JOtherCommentSystem('jxtendedcomments', 'JXtended Comments', 'JXtended LLC', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://jxtended.com/products/comments.html', '#__jxcomments_comments');
        $CommentSystems[] = new JOtherCommentSystem('chronocomments', 'Chrono Comments', 'Chronoman', 'CC', '', 'http://www.chronoengine.com/', '#__chrono_comments');
        $CommentSystems[] = new JOtherCommentSystem('jacomment', 'JA Comment', 'JoomlArt', 'Copyrighted Commercial Software', '', 'www.joomlart.com', '#__jacomment_items');
        $CommentSystems[] = new JOtherCommentSystem('DatsoGallery', 'DatsoGallery comments', 'Andrey Datso', 'Free', '', 'http://www.datso.fr', '#__datsogallery_comments');
        $CommentSystems[] = new JOtherCommentSystem('JoomGallery', 'JoomGallery comments', 'M. Andreas Boettcher', 'Free', '', 'http://www.joomgallery.net', '#__joomgallery_comments');
        $CommentSystems[] = new JOtherCommentSystem('IceGallery', 'IceGallery comments', 'Markus Donhauser', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://joomlacode.org/gf/project/ice/', '#__ice_comments');
        $CommentSystems[] = new JOtherCommentSystem('Remository', 'Remository file reviews', 'Martin Brampton', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.remository.com', '#__downloads_reviews');
        $CommentSystems[] = new JOtherCommentSystem('PAXXGallery', 'PAXXGallery comments', 'Tobias Floery', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.paxxgallery.com', '#__paxxcomments');
        $CommentSystems[] = new JOtherCommentSystem('PhocaGallery', 'PhocaGallery comments', 'Jan Pavelka', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.phoca.cz', '#__phocagallery_comments');
        $CommentSystems[] = new JOtherCommentSystem('JMovies', 'JMovies comments', 'Luscarpa &amp; Vamba', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.jmovies.eu/', '#__jmovies_comments');
        $CommentSystems[] = new JOtherCommentSystem('Cinema', 'Cinema comments', 'Vamba', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.joomlaitalia.com', '#__cinema_comments');
        $CommentSystems[] = new JOtherCommentSystem('MosetsTree', 'Mosets Tree reviews', 'Mosets Consulting', 'Commercial', '', 'http://www.mosets.com', '#__mt_reviews');
        $CommentSystems[] = new JOtherCommentSystem('LinkDirectory', 'LinkDirectory link comments', 'Soner Ekici', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.sonerekici.com/', '#__ldcomment');
        $CommentSystems[] = new JOtherCommentSystem('zOOmMediaGallery', 'zOOm Media Gallery comments', 'Mike de Boer', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.zoomfactory.org/', '#__zoom_comments');
        $CommentSystems[] = new JOtherCommentSystem('rsgallery2', 'RSGallery2 comments', 'rsgallery2.net', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://rsgallery2.net/', '#__rsgallery2_comments');
        $CommentSystems[] = new JOtherCommentSystem('hotornot2', 'Hotornot2 comments', 'Aron Watson', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://joomlacode.org/gf/project/com_hotornot2/frs/', '#__hotornot_comments');
        $CommentSystems[] = new JOtherCommentSystem('easycomments', 'EasyComments (www.easy-joomla.org)', 'EasyJoomla', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.easy-joomla.org/', '#__easycomments');
        $CommentSystems[] = new JOtherCommentSystem('musicbox', 'MusicBox', 'Vamba', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.joomlaitalia.com', '#__musicboxrewiev');
        $CommentSystems[] = new JOtherCommentSystem('jreviews', 'JReviews', 'Alejandro Schmeichler', 'Commercial', '', 'http://www.reviewsforjoomla.com', '#__jreviews_comments');
        $CommentSystems[] = new JOtherCommentSystem('tutorials', 'Tutorials (comments for items)', 'NSOrg Project', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.nsorg.com', '#__tutorials_comments');
        $CommentSystems[] = new JOtherCommentSystem('idoblog', 'IDoBlog', 'Sunshine studio', 'GNU/GPL', '', 'http://idojoomla.com', '#__idoblog_comments');
        $CommentSystems[] = new JOtherCommentSystem('sobi2reviews', 'SOBI2 Reviews', 'SOBI2 Developer Team', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.sigsiu.net', '#__sobi2_plugin_reviews');
        $CommentSystems[] = new JOtherCommentSystem('jreactions', 'J! Reactions', 'SDeCNet Software', '', '', 'http://jreactions.sdecnet.com', '#__jreactions');
        $CommentSystems[] = new JOtherCommentSystem('virtuemart', 'VirtueMart product reviews', 'The VirtueMart Development Team', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.virtuemart.net', '#__vm_product_reviews');
        $CommentSystems[] = new JOtherCommentSystem('akobook', 'AkoBook', 'Arthur Konze', '', '', 'http://mamboportal.com', '#__akobook');
        $CommentSystems[] = new JOtherCommentSystem('jambook', 'JamBook', 'Olle Johansson', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.jxdevelopment.com/', '#__jx_jambook');
        $CommentSystems[] = new JOtherCommentSystem('k2', 'K2 Comments', 'JoomlaWorks', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://k2.joomlaworks.gr/', '#__k2_comments');
        $CommentSystems[] = new JOtherCommentSystem('smartblog', 'SmartBlog Comments', 'Aneesh S', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.aarthikaindia.com', '#__blog_comment');
        $CommentSystems[] = new JOtherCommentSystem('urcomment', 'UrComment', 'Comdev Software Sdn Bhd', 'GPL, Commercial Software', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://joomla.comdevweb.com', '#__urcomment');
        $CommentSystems[] = new yvCommentSystem('yvcomment', 'yvComment', 'Yuri Volkov', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://yurivolkov.com/Joomla/yvComment/index_en.html', '#__yvcomment');
        $CommentSystems[] = new JOtherCommentSystem('zimb', 'ZiMB Comment', 'ZiMB LLC', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.zimbllc.com/Software/zimbcomment', '#__zimbcomment_comment');
        $CommentSystems[] = new JOtherCommentSystem('rdbscomment', 'RDBS Commment', 'Robert Deutz', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.rdbs.de', '#__rdbs_comment_comments');
        $CommentSystems[] = new JOtherCommentSystem('lyftenbloggie', 'LyftenBloggie', 'Lyften Designs', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.lyften.com', '#__bloggies_comments');
        $CommentSystems[] = new JOtherCommentSystem('webee', 'Webee Comment', 'Onno Groen', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.onnogroen.nl/webee/', '#__webeecomment_comment');
        $CommentSystems[] = new JOtherCommentSystem('resource', 'MightyExtensions Resource comments', 'MightyExtensions', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://mightyextensions.com/', '#__js_res_comments');
        $CommentSystems[] = new JOtherCommentSystem('tpdugg', 'TPDugg', 'TemplatePlazza', '', '', 'http://templateplazza.com/', '#__tpdugg_comments');
        $CommentSystems[] = new JOtherCommentSystem('zoo', 'ZOO Comments', 'YOOtheme', 'GNU/GPLv2', 'http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only', 'http://zoo.yootheme.com', '#__zoo_comment');
        $CommentSystems[] = new JOtherCommentSystem('beeheard', 'BeeHeard Comments', 'Kaysten Mazerino', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://www.cmstactics.com', '#__beeheard_comments');
        $CommentSystems[] = new JOtherCommentSystem('jmylife', 'JMyLife Comments', 'Jeff Channell', 'GNU/GPL', 'http://www.gnu.org/copyleft/gpl.html', 'http://jeffchannell.com', '#__jmylife_comments');
        $CommentSystems[] = new JOtherCommentSystem('muscol', 'Music Colllection Comments', 'Germinal Camps', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.joomlamusicsolutions.com', '#__muscol_comments');
        $CommentSystems[] = new JOtherCommentSystem('rscomments', 'RSComments', 'RSJoomla', 'GNU/GPL', 'http://www.gnu.org/licenses/gpl-2.0.html', 'http://www.rsjoomla.com/joomla-components/joomla-comments.html', '#__rscomments_comments');
        $db =& JCommentsFactory::getDBO();
        $db->setQuery("SHOW tables");
        $tables = $db->loadResultArray();
        foreach ($tables as $tblval) {
            for ($i = 0, $n = count($CommentSystems); $i < $n; $i++) {
                $table_mask = str_replace('#_', '', $CommentSystems[$i]->table);
                if (preg_match('/' . $table_mask . '$/i', $tblval)) {
                    $CommentSystems[$i]->found = true;
                    $CommentSystems[$i]->UpdateCount();
                }
            }
        }
        $languages = array();
        $joomfish = JOOMLATUNE_JPATH_SITE . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
        if (is_file($joomfish)) {
            $db =& JCommentsFactory::getDBO();
            $db->setQuery("SELECT name, `code` as value FROM #__languages WHERE active = 1");
            $languages = $db->loadObjectList();
        }
        if (JCOMMENTS_JVERSION == '1.5') {
            $params = JComponentHelper::getParams('com_languages');
            $lang = $params->get("site", 'en-GB');
        } else {
            $lang = JCommentsMultilingual::getLanguage();
        }
        $ajaxUrl = JCommentsFactory::getLink('ajax-backend');
        ?>
<script type="text/javascript" src="<?php 
        echo $mainframe->getCfg('live_site');
        ?>
/components/com_jcomments/libraries/joomlatune/ajax.js?v=2"></script>
<script type="text/javascript" src="<?php 
        echo $mainframe->getCfg('live_site');
        ?>
/administrator/components/com_jcomments/assets/jcomments-backend-v2.1.js"></script>
<script type="text/javascript">
<!--
function JCommentsImportCommentsAJAX() {
	try{
		jtajax.setup({url:'<?php 
        echo $ajaxUrl;
        ?>
'});
		return jtajax.call('JCommentsImportCommentsAjax',null,'post','adminForm');
	}catch(e){
		return false;
	}
}

function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}

	JCommentsImportCommentsAJAX();
}
//-->
</script>
<script type="text/javascript">
<!--
var jc_comments = new Array(
<?php 
        $jsArray = array();
        foreach ($CommentSystems as $CommentSystem) {
            if ($CommentSystem->found) {
                $jsArray[] = $CommentSystem->code;
            }
        }
        echo "'" . implode("', '", $jsArray) . "'";
        ?>
			);

function importMode( mode ) {
	if(document.getElementById) {
		for(var i=0;i<jc_comments.length;i++) {
		        if (mode == jc_comments[i]) {
				document.getElementById('import' + jc_comments[i]).checked = true;
				document.getElementById('import' + jc_comments[i]+'Info').style.display = '';
			} else {
				document.getElementById('import' + jc_comments[i]).checked = false;
				document.getElementById('import' + jc_comments[i]+'Info').style.display = 'none';
			}
		}
	}
}
//-->
</script>

<style type="text/css">
#jcomments-message {padding: 0 0 0 25px;margin: 0; width: auto; float: right; font-size: 14px; font-weight: bold;}
.jcomments-message-error {background: transparent url(components/com_jcomments/assets/error.gif) no-repeat 4px 50%; color: red;}
.jcomments-message-info {background: transparent url(components/com_jcomments/assets/info.gif) no-repeat 4px 50%; color: green;}
fieldset { border: 1px #999 solid; }
span.note { color: #777; }
table.componentinfo td { color: #777; padding: 0; }
</style>

<div id="jc">
<form action="<?php 
        echo JCOMMENTS_INDEX;
        ?>
" method="post" name="adminForm" id="adminForm">
<input type="hidden" name="option" value="com_jcomments" />
<input type="hidden" name="task" value="" />
<?php 
        if (JCOMMENTS_JVERSION == '1.0') {
            ?>
<table class="adminheading">
<tr>
	<th style="background-image: none; padding: 0;"><img src="./components/com_jcomments/assets/import48x48.png" width="48" height="48" align="middle">&nbsp;<?php 
            echo JText::_('A_IMPORT');
            ?>
</th>
</tr>
</table>
<?php 
        }
        ?>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr valign="top">
		<td align="right">&nbsp;</td>
		<td width="50%" align="right"><div id="jcomments-message-holder"></div></td>
	</tr>
</table>

<table width="100%" border="0" cellpadding="4" cellspacing="2" class="adminform">
<tr>
	<td>
		<fieldset>
		<legend><?php 
        echo JText::_('A_IMPORT_SELECT_SOURCE');
        ?>
</legend>

		<table cellpadding="1" cellspacing="1" border="0">

<?php 
        $foundSources = 0;
        foreach ($CommentSystems as $CommentSystem) {
            if ($CommentSystem->found) {
                $foundSources++;
                ?>
		<tr valign="top" align="left">
			<td><input type="radio" id="import<?php 
                echo $CommentSystem->code;
                ?>
" name="vars[import]" value="<?php 
                echo $CommentSystem->code;
                ?>
" onclick="importMode('<?php 
                echo $CommentSystem->code;
                ?>
')" <?php 
                echo $CommentSystem->found ? '' : 'disabled';
                ?>
 /></td>
			<td><label for="import<?php 
                echo $CommentSystem->code;
                ?>
"><?php 
                echo $CommentSystem->name;
                ?>
 <?php 
                echo $CommentSystem->found ? '' : '<span class="note">[' . JText::_('A_IMPORT_COMPONENT_NOT_INSTALLED') . ']</span>';
                ?>
</label></td>
			<td><div id="jcomments-message-<?php 
                echo strtolower($CommentSystem->code);
                ?>
"></div></td>
		</tr>
		<tr id="import<?php 
                echo $CommentSystem->code;
                ?>
Info" style="display: none;">
			<td>&nbsp;</td>
			<td>
				<table cellpadding="0" cellspacing="0" border="0" class="componentinfo">
				<tr>
					<td width="150px"><?php 
                echo JText::_('A_IMPORT_COMPONENT_AUTHOR');
                ?>
</td>
					<td><?php 
                echo $CommentSystem->author;
                ?>
</td>
				</tr>
				<tr>
					<td><?php 
                echo JText::_('A_IMPORT_COMPONENT_HOMEPAGE');
                ?>
</td>
					<td><a href="<?php 
                echo $CommentSystem->homepage;
                ?>
" target="_blank"><?php 
                echo str_replace('http://', '', $CommentSystem->homepage);
                ?>
</a></td>
				</tr>
				<tr>
					<td><?php 
                echo JText::_('A_IMPORT_COMPONENT_LICENSE');
                ?>
</td>
					<td>
<?php 
                if ($CommentSystem->license_url != '') {
                    ?>
					
						<a href="<?php 
                    echo $CommentSystem->license_url;
                    ?>
" target="_blank"><?php 
                    echo $CommentSystem->license;
                    ?>
</a>
<?php 
                } else {
                    ?>
					
						<?php 
                    echo $CommentSystem->license;
                }
                ?>
					
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr valign="top" align="left">
					<td>
						<?php 
                echo JText::_('A_IMPORT_COMPONENT_COMMENTS_COUNT');
                ?>
					</td>
					<td>
					        <label for="import<?php 
                echo $CommentSystem->code;
                ?>
"><?php 
                echo $CommentSystem->count;
                ?>
</label>
					        <br />
<?php 
                if (count($languages)) {
                    echo JCommentsHTML::selectList($languages, strtolower($CommentSystem->code) . '_lang', 'class="inputbox" size="1"', 'value', 'name', $lang) . '&nbsp;';
                }
                ?>
					        
					        <input type="button" id="import<?php 
                echo $CommentSystem->code;
                ?>
" name="import<?php 
                echo $CommentSystem->code;
                ?>
" value="<?php 
                echo JText::_('A_IMPORT_DO_IMPORT');
                ?>
" onclick="submitbutton('doimport')" <?php 
                echo $CommentSystem->count ? '' : 'disabled';
                ?>
 />
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				</table>
			</td>
		</tr>
<?php 
            }
        }
        if ($foundSources == 0) {
            ?>
		<tr>
			<td><?php 
            echo JText::_('A_IMPORT_NO_SOURCES');
            ?>
</td>
		</tr>
<?php 
        }
        ?>
		</table>
	</fieldset>
	</td>
</tr>
</table>
</form>
</div>
<?php 
    }
Ejemplo n.º 10
0
 public static function loadSettingsByLanguage($language = '')
 {
     $lang = '';
     $joomfish = JOOMLATUNE_JPATH_SITE . '/components/com_joomfish/joomfish.php';
     if (is_file($joomfish) || JCommentsMultilingual::isEnabled()) {
         $lang = $language;
         if ($lang == '') {
             $lang = JCommentsMultilingual::getLanguage();
         }
         // reload configuration
         JCommentsFactory::getConfig($lang);
     }
     return $lang;
 }
Ejemplo n.º 11
0
 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);
     }
     $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[] = 'o.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 o.id, o.title, o.link" . ", COUNT(c.id) AS commentsCount, MAX(c.date) AS commentdate" . " FROM #__jcomments_objects AS o" . " JOIN #__jcomments AS c 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) : '') . " GROUP BY o.id, o.title, o.link" . " ORDER BY commentsCount DESC, c.date DESC";
     $db->setQuery($query, 0, $params->get('count'));
     $list = $db->loadObjectList();
     return $list;
 }
Ejemplo n.º 12
0
 function addComment($values = array())
 {
     global $my, $mainframe;
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $acl =& JCommentsFactory::getACL();
     $config =& JCommentsFactory::getConfig();
     $response =& JCommentsFactory::getAjaxResponse();
     if ($acl->canComment()) {
         $values = JCommentsAJAX::prepareValues($_POST);
         $userIP = $acl->getUserIP();
         if (!$my->id) {
             $noErrors = false;
             if (empty($values['name'])) {
                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_NAME'), 'name');
             } else {
                 if (JCommentsSecurity::checkIsRegisteredUsername($values['name']) == 1) {
                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_NAME_EXISTS'), 'name');
                 } else {
                     if (JCommentsSecurity::checkIsForbiddenUsername($values['name']) == 1) {
                         JCommentsAJAX::showErrorMessage(JText::_('ERROR_FORBIDDEN_NAME'), 'name');
                     } else {
                         if (preg_match('/[\\"\'\\[\\]\\=\\<\\>\\(\\)\\;]+/', $values['name'])) {
                             JCommentsAJAX::showErrorMessage(JText::_('ERROR_INVALID_NAME'), 'name');
                         } else {
                             if ($config->get('username_maxlength') != 0 && JCommentsText::strlen($values['name']) > $config->get('username_maxlength')) {
                                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_TOO_LONG_USERNAME'), 'name');
                             } else {
                                 if ($config->get('author_email') == 2 && empty($values['email'])) {
                                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_EMAIL'), 'email');
                                 } else {
                                     if (!empty($values['email']) && !preg_match(_JC_REGEXP_EMAIL2, $values['email'])) {
                                         JCommentsAJAX::showErrorMessage(JText::_('ERROR_INCORRECT_EMAIL'), 'email');
                                     } else {
                                         if ($config->get('author_email') != 0 && JCommentsSecurity::checkIsRegisteredEmail($values['email']) == 1) {
                                             // TODO: change this error message with more appropriate
                                             JCommentsAJAX::showErrorMessage(JText::_('ERROR_NAME_EXISTS'), 'email');
                                         } else {
                                             if (empty($values['homepage']) && $config->get('author_homepage') == 2) {
                                                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_HOMEPAGE'), 'homepage');
                                             } else {
                                                 $noErrors = true;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (!$noErrors) {
                 return $response;
             }
         }
         if ($acl->check('floodprotection') == 1 && JCommentsSecurity::checkFlood($userIP)) {
             JCommentsAJAX::showErrorMessage(JText::_('ERROR_TOO_QUICK'));
         } else {
             if (empty($values['homepage']) && $config->get('author_homepage') == 3) {
                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_HOMEPAGE'), 'homepage');
             } else {
                 if (empty($values['title']) && $config->get('comment_title') == 3) {
                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_TITLE'), 'title');
                 } else {
                     if (empty($values['comment'])) {
                         JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
                     } else {
                         if ($config->getInt('comment_maxlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) > $config->get('comment_maxlength')) {
                             JCommentsAJAX::showErrorMessage(JText::_('Your comment is too long'), 'comment');
                         } else {
                             if ($config->getInt('comment_minlength', 0) != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) < $config->get('comment_minlength')) {
                                 JCommentsAJAX::showErrorMessage(JText::_('Your comment is too short'), 'comment');
                             } else {
                                 if ($acl->check('enable_captcha') == 1) {
                                     $captchaEngine = $config->get('captcha_engine', 'kcaptcha');
                                     if ($captchaEngine == 'kcaptcha') {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.captcha.php';
                                         if (!JCommentsCaptcha::check($values['captcha-refid'])) {
                                             JCommentsAJAX::showErrorMessage(JText::_('ERROR_CAPTCHA'), 'captcha');
                                             JCommentsCaptcha::destroy();
                                             $response->addScript("jcomments.clear('captcha');");
                                             return $response;
                                         }
                                     } else {
                                         if ($config->getInt('enable_mambots') == 1) {
                                             require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                                             JCommentsPluginHelper::importPlugin('jcomments');
                                             $result = JCommentsPluginHelper::trigger('onJCommentsCaptchaVerify', array($values['captcha-refid'], &$response));
                                             // if all plugins returns false
                                             if (!in_array(true, $result, true)) {
                                                 JCommentsAJAX::showErrorMessage(JText::_('ERROR_CAPTCHA'));
                                                 return $response;
                                             }
                                         }
                                     }
                                 }
                                 $db =& JCommentsFactory::getDBO();
                                 // small fix (by default $my has empty 'name' and 'email' field)
                                 if ($my->id) {
                                     $currentUser = JCommentsFactory::getUser($my->id);
                                     $my->name = $currentUser->name;
                                     $my->username = $currentUser->username;
                                     $my->email = $currentUser->email;
                                     unset($currentUser);
                                 }
                                 $comment = new JCommentsDB($db);
                                 $comment->id = 0;
                                 $comment->name = $my->id ? $my->name : preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $values['name']);
                                 $comment->username = $my->id ? $my->username : $comment->name;
                                 $comment->email = $my->id ? $my->email : (isset($values['email']) ? $values['email'] : '');
                                 if ($config->getInt('author_homepage') != 0 && !empty($values['homepage'])) {
                                     $comment->homepage = JCommentsText::url($values['homepage']);
                                 }
                                 $comment->comment = $values['comment'];
                                 //$comment->comment = JCommentsText::nl2br(stripslashes($values['comment']));
                                 // filter forbidden bbcodes
                                 $bbcode = JCommentsFactory::getBBCode();
                                 $comment->comment = $bbcode->filter($comment->comment);
                                 if ($comment->comment != '') {
                                     if ($config->getInt('enable_custom_bbcode')) {
                                         // filter forbidden custom bbcodes
                                         $commentLength = strlen($comment->comment);
                                         $customBBCode =& JCommentsFactory::getCustomBBCode();
                                         $comment->comment = $customBBCode->filter($comment->comment);
                                         if (strlen($comment->comment) == 0 && $commentLength > 0) {
                                             JCommentsAJAX::showErrorMessage(JText::_('You have no rights to use this tag'), 'comment');
                                             return $response;
                                         }
                                     }
                                 }
                                 if ($comment->comment == '') {
                                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
                                     return $response;
                                 }
                                 $commentWithoutQuotes = $bbcode->removeQuotes($comment->comment);
                                 if ($commentWithoutQuotes == '') {
                                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_NOTHING_EXCEPT_QUOTES'), 'comment');
                                     return $response;
                                 } else {
                                     if ($config->getInt('comment_minlength', 0) != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($commentWithoutQuotes) < $config->get('comment_minlength')) {
                                         JCommentsAJAX::showErrorMessage(JText::_('Your comment is too short'), 'comment');
                                         return $response;
                                     }
                                 }
                                 unset($commentWithoutQuotes);
                                 $values['subscribe'] = isset($values['subscribe']) ? (int) $values['subscribe'] : 0;
                                 if ($values['subscribe'] == 1 && $comment->email == '') {
                                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_SUBSCRIPTION_EMAIL'), 'email');
                                     return $response;
                                 }
                                 $object_group = trim(strip_tags($values['object_group']));
                                 $object_group = preg_replace('#[^0-9A-Za-z\\-\\_\\,\\.]#is', '', $object_group);
                                 $comment->object_id = (int) $values['object_id'];
                                 $comment->object_group = $object_group;
                                 $comment->title = isset($values['title']) ? $values['title'] : '';
                                 $comment->parent = isset($values['parent']) ? intval($values['parent']) : 0;
                                 $comment->lang = JCommentsMultilingual::getLanguage();
                                 $comment->ip = $userIP;
                                 $comment->userid = $my->id ? $my->id : 0;
                                 $comment->published = $acl->check('autopublish');
                                 if (JCOMMENTS_JVERSION == '1.5') {
                                     $dateNow =& JFactory::getDate();
                                     $comment->date = $dateNow->toMySQL();
                                 } else {
                                     $comment->date = date('Y-m-d H:i:s', time() + $mainframe->getCfg('offset') * 60 * 60);
                                 }
                                 $query = "SELECT COUNT(*) " . "\nFROM #__jcomments " . "\nWHERE comment = '" . $db->getEscaped($comment->comment) . "'" . "\n  AND ip = '" . $db->getEscaped($comment->ip) . "'" . "\n  AND name = '" . $db->getEscaped($comment->name) . "'" . "\n  AND userid = '" . $comment->userid . "'" . "\n  AND object_id = " . $comment->object_id . "\n  AND parent = " . $comment->parent . "\n  AND object_group = '" . $db->getEscaped($comment->object_group) . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "");
                                 $db->setQuery($query);
                                 $found = $db->loadResult();
                                 // if duplicates is not found
                                 if ($found == 0) {
                                     // trigger onBeforeCommentAdded event
                                     $allowed = true;
                                     if ($config->getInt('enable_mambots') == 1) {
                                         require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                                         JCommentsPluginHelper::importPlugin('jcomments');
                                         JCommentsPluginHelper::trigger('onBeforeCommentAdded', array(&$comment, &$response, &$allowed));
                                     }
                                     if ($allowed === false) {
                                         return $response;
                                     }
                                     // save comments subscription
                                     if ($values['subscribe']) {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
                                         $manager =& JCommentsSubscriptionManager::getInstance();
                                         $manager->subscribe($comment->object_id, $comment->object_group, $comment->userid, $comment->email, $comment->name, $comment->lang);
                                     }
                                     $merged = false;
                                     $merge_time = $config->getInt('merge_time', 0);
                                     // merge comments from same author
                                     if ($my->id && $merge_time > 0) {
                                         // load previous comment for same object and group
                                         $prevComment = JComments::getLastComment($comment->object_id, $comment->object_group, $comment->parent);
                                         if ($prevComment != null) {
                                             // if previous comment from same author and it currently not edited
                                             // by any user - we'll update comment, else - insert new record to database
                                             if ($prevComment->userid == $comment->userid && $prevComment->parent == $comment->parent && !$acl->isLocked($prevComment)) {
                                                 $newText = $prevComment->comment . '<br /><br />' . $comment->comment;
                                                 $timeDiff = strtotime($comment->date) - strtotime($prevComment->datetime);
                                                 if ($timeDiff < $merge_time) {
                                                     $maxlength = $config->getInt('comment_maxlength');
                                                     $needcheck = $acl->check('enable_comment_length_check');
                                                     // validate new comment text length and if it longer than specified -
                                                     // disable union current comment with previous
                                                     if ($needcheck == 0 || $needcheck == 1 && $maxlength != 0 && JCommentsText::strlen($newText) <= $maxlength) {
                                                         $comment->id = $prevComment->id;
                                                         $comment->comment = $newText;
                                                         $merged = true;
                                                     }
                                                 }
                                             }
                                             unset($prevComment);
                                         }
                                     }
                                     if ($comment->parent > 0) {
                                         $parent = new JCommentsDB($db);
                                         if ($parent->load($comment->parent)) {
                                             if ($config->getInt('comment_title') == 1 && $comment->title == '') {
                                                 if (!empty($parent->title)) {
                                                     $comment->title = JText::_('Re') . ' ' . $parent->title;
                                                 }
                                             }
                                             $comment->level = $parent->level + 1;
                                             $comment->path = $parent->path . ',' . $parent->id;
                                         }
                                     } else {
                                         if ($config->getInt('comment_title') == 1 && $comment->title == '') {
                                             $object_title = JCommentsObjectHelper::getTitle($comment->object_id, $comment->object_group, $comment->lang);
                                             $comment->title = JText::_('Re') . ' ' . $object_title;
                                         }
                                         $comment->path = '0';
                                     }
                                     // save new comment to database
                                     if (!$comment->store()) {
                                         $response->addScript("jcomments.clear('comment');");
                                         if ($acl->check('enable_captcha') == 1) {
                                             JCommentsCaptcha::destroy();
                                             $response->addScript("jcomments.clear('captcha');");
                                         }
                                         $errorMessage = $db->getErrorMsg();
                                         if ($errorMessage != '') {
                                             if ($my->usertype == 'Super Administrator') {
                                                 JCommentsAJAX::showErrorMessage($db->getErrorMsg());
                                             }
                                         }
                                         return $response;
                                     }
                                     // datetime field is used in prepareComment function
                                     $comment->datetime = $comment->date;
                                     if (is_string($comment->datetime)) {
                                         $comment->datetime = strtotime($comment->datetime);
                                     }
                                     if ($config->getInt('enable_mambots') == 1) {
                                         require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
                                         JCommentsPluginHelper::importPlugin('jcomments');
                                         JCommentsPluginHelper::trigger('onAfterCommentAdded', array(&$comment, &$response, &$allowed));
                                     }
                                     // send notification to administrators
                                     if ($config->getInt('enable_notification') == 1) {
                                         if ($config->check('notification_type', 1) == true) {
                                             JComments::sendNotification($comment, true);
                                         }
                                     }
                                     // if comment published we need update comments list
                                     if ($comment->published) {
                                         // send notification to comment subscribers
                                         JComments::sendToSubscribers($comment, true);
                                         $comment->usertype = $my->id != 0 ? str_replace(' ', '-', strtolower($my->usertype)) : 'guest';
                                         if ($merged) {
                                             $commentText = $comment->comment;
                                             JComments::prepareComment($comment);
                                             $tmpl =& JCommentsFactory::getTemplate();
                                             $tmpl->load('tpl_comment');
                                             $tmpl->addVar('tpl_comment', 'get_comment_body', 1);
                                             $tmpl->addObject('tpl_comment', 'comment', $comment);
                                             $html = $tmpl->renderTemplate('tpl_comment');
                                             $html = JCommentsText::jsEscape($html);
                                             $response->addScript("jcomments.updateComment(" . $comment->id . ", '{$html}');");
                                             $comment->comment = $commentText;
                                         } else {
                                             $count = JCommentsModel::getCommentsCount($comment->object_id, $comment->object_group);
                                             if ($config->get('template_view') == 'tree') {
                                                 if ($count > 1) {
                                                     $html = JComments::getCommentListItem($comment);
                                                     $html = JCommentsText::jsEscape($html);
                                                     $response->addScript("jcomments.updateTree('{$html}','{$comment->parent}');");
                                                 } else {
                                                     $html = JComments::getCommentsTree($comment->object_id, $comment->object_group);
                                                     $html = JCommentsText::jsEscape($html);
                                                     $response->addScript("jcomments.updateTree('{$html}',null);");
                                                 }
                                             } else {
                                                 // if pagination disabled and comments count > 1...
                                                 if ($config->getInt('comments_per_page') == 0 && $count > 1) {
                                                     // update only added comment
                                                     $html = JComments::getCommentListItem($comment);
                                                     $html = JCommentsText::jsEscape($html);
                                                     if ($config->get('comments_order') == 'DESC') {
                                                         $response->addScript("jcomments.updateList('{$html}','p');");
                                                     } else {
                                                         $response->addScript("jcomments.updateList('{$html}','a');");
                                                     }
                                                 } else {
                                                     // update comments list
                                                     $html = JComments::getCommentsList($comment->object_id, $comment->object_group, JComments::getCommentPage($comment->object_id, $comment->object_group, $comment->id));
                                                     $html = JCommentsText::jsEscape($html);
                                                     $response->addScript("jcomments.updateList('{$html}','r');");
                                                 }
                                                 // scroll to first comment
                                                 if ($config->get('comments_order') == 'DESC') {
                                                     $response->addScript("jcomments.scrollToList();");
                                                 }
                                             }
                                         }
                                         JCommentsAJAX::showInfoMessage(JText::_('Thank you for your submission!'));
                                     } else {
                                         JCommentsAJAX::showInfoMessage(JText::_('Thank you, your comment will be published once reviewed'));
                                     }
                                     // clear comments textarea & update comment length counter if needed
                                     $response->addScript("jcomments.clear('comment');");
                                     unset($comment);
                                     if ($acl->check('enable_captcha') == 1) {
                                         $captchaEngine = $config->get('captcha_engine', 'kcaptcha');
                                         if ($captchaEngine == 'kcaptcha') {
                                             require_once JCOMMENTS_BASE . DS . 'jcomments.captcha.php';
                                             JCommentsCaptcha::destroy();
                                             $response->addScript("jcomments.clear('captcha');");
                                         }
                                     }
                                 } else {
                                     JCommentsAJAX::showErrorMessage(JText::_('ERROR_DUPLICATE_COMMENT'), 'comment');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $response->addAlert(JText::_('ERROR_CANT_COMMENT'));
     }
     return $response;
 }
Ejemplo n.º 13
0
 function _isSubscribed($object_id, $object_group, $userid, $email = '', $language = '')
 {
     if (empty($language)) {
         $language = JCommentsMultilingual::getLanguage();
     }
     $db = JCommentsFactory::getDBO();
     $query = "SELECT COUNT(*) " . " FROM #__jcomments_subscriptions" . " WHERE object_id = " . (int) $object_id . " AND object_group = " . $db->Quote($object_group) . " AND userid = " . (int) $userid . ($userid == 0 ? " AND email = " . $db->Quote($email) : '') . (JCommentsMultilingual::isEnabled() ? " AND lang = " . $db->Quote($language) : "");
     $db->setQuery($query);
     $cnt = $db->loadResult();
     return $cnt > 0 ? 1 : 0;
 }
Ejemplo n.º 14
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();
}
Ejemplo n.º 15
0
 /**
  * Checks if given user is subscribed to new comments notifications for an object
  *
  * @param int $object_id	The object identifier
  * @param string $object_group	The object group (component name)
  * @param int $userid	The registered user identifier
  * @param string $email	The user email (for guests only)
  * @return int
  */
 function isSubscribed($object_id, $object_group, $userid, $email = '', $lang = '')
 {
     static $cache = null;
     if (isset($cache[$object_id . $object_group . $userid . $email])) {
         return $cache[$object_id . $object_group . $userid . $email];
     }
     $dbo =& JCommentsFactory::getDBO();
     if ($lang == '') {
         $lang = JCommentsMultilingual::getLanguage();
     }
     $query = "SELECT COUNT(*) " . "\n FROM #__jcomments_subscriptions" . "\n WHERE object_id = " . (int) $object_id . "\n AND object_group = '" . $dbo->getEscaped($object_group) . "'" . "\n AND userid = " . (int) $userid . ($userid == 0 ? "\n AND email = '" . $dbo->getEscaped($email) . "'" : '') . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . $lang . "'" : "");
     $dbo->setQuery($query);
     $cnt = $dbo->loadResult();
     $cache[$object_id . $object_group . $userid . $email] = (int) $cnt > 0;
     return $cnt > 0 ? 1 : 0;
 }
Ejemplo n.º 16
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;
     }
 }
 /**
  * onJCommentsCommentBeforeAdd trigger
  * @access public
  * @param JCommentsDB $comment
  * @return bolean true
  * @since 1.5
  */
 public function onJCommentsCommentBeforeAdd(&$comment)
 {
     $config = $this->getCTConfig();
     $session = JFactory::getSession();
     $submit_time = $this->submit_time_test();
     // set new time because onJCommentsFormAfterDisplay worked only once
     // and formtime in session need to be renewed between ajax posts
     $session->set($this->form_load_label, time());
     $checkjs = $this->get_ct_checkjs(true);
     $sender_info = $this->get_sender_info();
     $sender_info = json_encode($sender_info);
     if ($sender_info === false) {
         $sender_info = '';
     }
     $post_info['comment_type'] = 'jcomments_comment';
     $post_info['post_url'] = $session->get($this->current_page);
     $post_info = json_encode($post_info);
     if ($post_info === false) {
         $post_info = '';
     }
     $plugin_groups = array();
     $param_groups = $this->params->get('groups');
     if (is_array($param_groups)) {
         foreach ($param_groups as $group) {
             array_push($plugin_groups, (int) $group);
         }
     } else {
         array_push($plugin_groups, (int) $param_groups);
     }
     $user = JFactory::getUser();
     if (method_exists($user, 'getAuthorisedGroups')) {
         // 1.6+
         $user_groups = $user->getAuthorisedGroups();
     } else {
         // 1.5
         $user_groups = array();
         if ($user->guest) {
             array_push($user_groups, 29);
         } else {
             array_push($user_groups, $user->gid);
         }
     }
     foreach ($user_groups as $group) {
         if (in_array($group, $plugin_groups)) {
             $example = null;
             if ($config['relevance_test'] !== '') {
                 switch ($comment->object_group) {
                     case 'com_content':
                         $article = JTable::getInstance('content');
                         $article->load($comment->object_id);
                         $baseText = $article->introtext . '<br>' . $article->fulltext;
                         break;
                     default:
                         $baseText = '';
                 }
                 $db = JCommentsFactory::getDBO();
                 $query = "SELECT comment " . "\nFROM #__jcomments " . "\nWHERE published = 1 " . "\n  AND object_group = '" . $db->getEscaped($comment->object_group) . "'" . "\n  AND object_id = " . $comment->object_id . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . " ORDER BY id DESC " . " LIMIT 10 ";
                 $db->setQuery($query);
                 $prevComments = $db->loadResultArray();
                 $prevComments = $prevComments == NULL ? '' : implode("\n\n", $prevComments);
                 $example = $baseText . "\n\n\n\n" . $prevComments;
             }
             self::getCleantalk();
             $ctResponse = self::ctSendRequest('check_message', array('example' => $example, 'message' => $comment->comment, 'sender_nickname' => $comment->name, 'sender_email' => $comment->email, 'sender_ip' => self::$CT->ct_session_ip($_SERVER['REMOTE_ADDR']), 'js_on' => $checkjs, 'submit_time' => $submit_time, 'sender_info' => $sender_info, 'post_info' => $post_info));
             if (!empty($ctResponse) && is_array($ctResponse)) {
                 if ($ctResponse['stop_queue'] == 1) {
                     JCommentsAJAX::showErrorMessage($ctResponse['comment'], 'comment');
                     return false;
                 } else {
                     if ($ctResponse['allow'] == 0) {
                         $comment->published = false;
                         // Send notification to administrator
                         if ($config['jcomments_unpublished_nofications'] != '') {
                             JComments::sendNotification($comment, true);
                         }
                     }
                 }
             }
             return true;
         }
         //if(in_array($group, $plugin_groups))
     }
     //foreach
 }
Ejemplo n.º 18
0
 /**
  * Stores object information (inserts new or updates existing)
  *
  * @param int $object_id
  * @param string $object_group
  * @param string $language 
  * @param boolean $cleanCache
  * @param boolean $allowEmpty
  * @return JCommentsObjectInfo
  */
 public static function storeObjectInfo($object_id, $object_group = 'com_content', $language = null, $cleanCache = false, $allowEmpty = false)
 {
     if (empty($language)) {
         $language = JCommentsMultilingual::getLanguage();
     }
     $app = JFactory::getApplication();
     // try to load object information from database
     $object = JCommentsModelObject::getObjectInfo($object_id, $object_group, $language);
     $objectId = $object === false ? 0 : $object->id;
     if ($objectId == 0 && $app->isAdmin()) {
         // return empty object because we can not create link in backend
         return new JCommentsObjectInfo();
     }
     // get object information via plugins
     $info = self::_loadObjectInfo($object_id, $object_group, $language);
     if (!JCommentsModelObject::IsEmpty($info) || $allowEmpty) {
         if ($app->isAdmin()) {
             // we do not have to update object's link from backend
             $info->link = null;
         }
         // insert/update object information
         JCommentsModelObject::setObjectInfo($objectId, $info);
         if ($cleanCache) {
             // clean cache for given object group
             $cache = JFactory::getCache('com_jcomments_objects_' . strtolower($object_group));
             $cache->clean();
         }
     }
     return $info;
 }
Ejemplo n.º 19
0
 public static function addComment($values = array())
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $user = JCommentsFactory::getUser();
     $acl = JCommentsFactory::getACL();
     $config = JCommentsFactory::getConfig();
     $response = JCommentsFactory::getAjaxResponse();
     if ($acl->canComment()) {
         $values = self::prepareValues($_POST);
         $object_group = isset($values['object_group']) ? JCommentsSecurity::clearObjectGroup($values['object_group']) : '';
         $object_id = isset($values['object_id']) ? intval($values['object_id']) : '';
         if ($object_group == '' || $object_id == '') {
             // TODO: add appropriate error message
             return $response;
         }
         $commentsPerObject = $config->getInt('max_comments_per_object');
         if ($commentsPerObject > 0) {
             $commentsCount = JComments::getCommentsCount($object_id, $object_group);
             if ($commentsCount >= $commentsPerObject) {
                 $message = $config->get('message_locked');
                 if (empty($message)) {
                     $message = $config->get('ERROR_CANT_COMMENT');
                 }
                 $message = self::escapeMessage($message);
                 $response->addAlert($message);
                 return $response;
             }
         }
         $userIP = $acl->getUserIP();
         if (!$user->id) {
             $noErrors = false;
             if (isset($values['userid']) && intval($values['userid']) > 0) {
                 // TODO: we need more correct way to detect login timeout
                 self::showErrorMessage(JText::_('ERROR_SESSION_EXPIRED'));
             } else {
                 if ($config->getInt('author_name', 2) == 2 && empty($values['name'])) {
                     self::showErrorMessage(JText::_('ERROR_EMPTY_NAME'), 'name');
                 } else {
                     if (JCommentsSecurity::checkIsRegisteredUsername($values['name']) == 1) {
                         self::showErrorMessage(JText::_('ERROR_NAME_EXISTS'), 'name');
                     } else {
                         if (JCommentsSecurity::checkIsForbiddenUsername($values['name']) == 1) {
                             self::showErrorMessage(JText::_('ERROR_FORBIDDEN_NAME'), 'name');
                         } else {
                             if (preg_match('/[\\"\'\\[\\]\\=\\<\\>\\(\\)\\;]+/', $values['name'])) {
                                 self::showErrorMessage(JText::_('ERROR_INVALID_NAME'), 'name');
                             } else {
                                 if ($config->get('username_maxlength') != 0 && JCommentsText::strlen($values['name']) > $config->get('username_maxlength')) {
                                     self::showErrorMessage(JText::_('ERROR_TOO_LONG_USERNAME'), 'name');
                                 } else {
                                     if ($config->getInt('author_email') == 2 && empty($values['email'])) {
                                         self::showErrorMessage(JText::_('ERROR_EMPTY_EMAIL'), 'email');
                                     } else {
                                         if (!empty($values['email']) && !preg_match(_JC_REGEXP_EMAIL2, $values['email'])) {
                                             self::showErrorMessage(JText::_('ERROR_INCORRECT_EMAIL'), 'email');
                                         } else {
                                             if ($config->getInt('author_email') != 0 && JCommentsSecurity::checkIsRegisteredEmail($values['email']) == 1) {
                                                 self::showErrorMessage(JText::_('ERROR_EMAIL_EXISTS'), 'email');
                                             } else {
                                                 if ($config->getInt('author_homepage') == 2 && empty($values['homepage'])) {
                                                     self::showErrorMessage(JText::_('ERROR_EMPTY_HOMEPAGE'), 'homepage');
                                                 } else {
                                                     $noErrors = true;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (!$noErrors) {
                 return $response;
             }
         }
         if ($acl->check('floodprotection') == 1 && JCommentsSecurity::checkFlood($userIP)) {
             self::showErrorMessage(JText::_('ERROR_TOO_QUICK'));
         } else {
             if (empty($values['homepage']) && $config->get('author_homepage') == 3) {
                 self::showErrorMessage(JText::_('ERROR_EMPTY_HOMEPAGE'), 'homepage');
             } else {
                 if (empty($values['title']) && $config->get('comment_title') == 3) {
                     self::showErrorMessage(JText::_('ERROR_EMPTY_TITLE'), 'title');
                 } else {
                     if (empty($values['comment'])) {
                         self::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
                     } else {
                         if ($config->getInt('comment_maxlength') != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) > $config->get('comment_maxlength')) {
                             self::showErrorMessage(JText::_('ERROR_YOUR_COMMENT_IS_TOO_LONG'), 'comment');
                         } else {
                             if ($config->getInt('comment_minlength', 0) != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($values['comment']) < $config->get('comment_minlength')) {
                                 self::showErrorMessage(JText::_('ERROR_YOUR_COMMENT_IS_TOO_SHORT'), 'comment');
                             } else {
                                 if ($acl->check('enable_captcha') == 1) {
                                     $captchaEngine = $config->get('captcha_engine', 'kcaptcha');
                                     if ($captchaEngine == 'kcaptcha') {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.captcha.php';
                                         if (!JCommentsCaptcha::check($values['captcha_refid'])) {
                                             self::showErrorMessage(JText::_('ERROR_CAPTCHA'), 'captcha');
                                             JCommentsCaptcha::destroy();
                                             $response->addScript("jcomments.clear('captcha');");
                                             return $response;
                                         }
                                     } else {
                                         $result = JCommentsEvent::trigger('onJCommentsCaptchaVerify', array($values['captcha_refid'], &$response));
                                         // if all plugins returns false
                                         if (!in_array(true, $result, true)) {
                                             self::showErrorMessage(JText::_('ERROR_CAPTCHA'));
                                             return $response;
                                         }
                                     }
                                 }
                                 $db = JCommentsFactory::getDBO();
                                 // small fix (by default $my has empty 'name' and 'email' field)
                                 if ($user->id) {
                                     $currentUser = JCommentsFactory::getUser($user->id);
                                     $user->name = $currentUser->name;
                                     $user->username = $currentUser->username;
                                     $user->email = $currentUser->email;
                                     unset($currentUser);
                                 }
                                 if (empty($values['name'])) {
                                     $values['name'] = 'Guest';
                                     // JText::_('Guest');
                                 }
                                 $comment = new JCommentsTableComment($db);
                                 $comment->id = 0;
                                 $comment->name = $user->id ? $user->name : preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $values['name']);
                                 $comment->username = $user->id ? $user->username : $comment->name;
                                 $comment->email = $user->id ? $user->email : (isset($values['email']) ? $values['email'] : '');
                                 if ($config->getInt('author_homepage') != 0 && !empty($values['homepage'])) {
                                     $comment->homepage = JCommentsText::url($values['homepage']);
                                 }
                                 $comment->comment = $values['comment'];
                                 // filter forbidden bbcodes
                                 $bbcode = JCommentsFactory::getBBCode();
                                 $comment->comment = $bbcode->filter($comment->comment);
                                 if ($comment->comment != '') {
                                     if ($config->getInt('enable_custom_bbcode')) {
                                         // filter forbidden custom bbcodes
                                         $commentLength = strlen($comment->comment);
                                         $customBBCode = JCommentsFactory::getCustomBBCode();
                                         $comment->comment = $customBBCode->filter($comment->comment);
                                         if (strlen($comment->comment) == 0 && $commentLength > 0) {
                                             self::showErrorMessage(JText::_('ERROR_YOU_HAVE_NO_RIGHTS_TO_USE_THIS_TAG'), 'comment');
                                             return $response;
                                         }
                                     }
                                 }
                                 if ($comment->comment == '') {
                                     self::showErrorMessage(JText::_('ERROR_EMPTY_COMMENT'), 'comment');
                                     return $response;
                                 }
                                 $commentWithoutQuotes = $bbcode->removeQuotes($comment->comment);
                                 if ($commentWithoutQuotes == '') {
                                     self::showErrorMessage(JText::_('ERROR_NOTHING_EXCEPT_QUOTES'), 'comment');
                                     return $response;
                                 } else {
                                     if ($config->getInt('comment_minlength', 0) != 0 && $acl->check('enable_comment_length_check') == 1 && JCommentsText::strlen($commentWithoutQuotes) < $config->get('comment_minlength')) {
                                         self::showErrorMessage(JText::_('ERROR_YOUR_COMMENT_IS_TOO_SHORT'), 'comment');
                                         return $response;
                                     }
                                 }
                                 $values['subscribe'] = isset($values['subscribe']) ? (int) $values['subscribe'] : 0;
                                 if ($values['subscribe'] == 1 && $comment->email == '') {
                                     self::showErrorMessage(JText::_('ERROR_SUBSCRIPTION_EMAIL'), 'email');
                                     return $response;
                                 }
                                 $comment->object_id = (int) $object_id;
                                 $comment->object_group = $object_group;
                                 $comment->title = isset($values['title']) ? $values['title'] : '';
                                 $comment->parent = isset($values['parent']) ? intval($values['parent']) : 0;
                                 $comment->lang = JCommentsMultilingual::getLanguage();
                                 $comment->ip = $userIP;
                                 $comment->userid = $user->id ? $user->id : 0;
                                 $comment->published = $acl->check('autopublish');
                                 $comment->date = JCommentsFactory::getDate();
                                 $query = "SELECT COUNT(*) " . "\nFROM #__jcomments " . "\nWHERE comment = '" . $db->getEscaped($comment->comment) . "'" . "\n  AND ip = '" . $db->getEscaped($comment->ip) . "'" . "\n  AND name = '" . $db->getEscaped($comment->name) . "'" . "\n  AND userid = '" . $comment->userid . "'" . "\n  AND object_id = " . $comment->object_id . "\n  AND parent = " . $comment->parent . "\n  AND object_group = '" . $db->getEscaped($comment->object_group) . "'" . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "");
                                 $db->setQuery($query);
                                 $found = $db->loadResult();
                                 // if duplicates is not found
                                 if ($found == 0) {
                                     $result = JCommentsEvent::trigger('onJCommentsCommentBeforeAdd', array(&$comment));
                                     if (in_array(false, $result, true)) {
                                         return $response;
                                     }
                                     // save comments subscription
                                     if ($values['subscribe']) {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.subscription.php';
                                         $manager = JCommentsSubscriptionManager::getInstance();
                                         $manager->subscribe($comment->object_id, $comment->object_group, $comment->userid, $comment->email, $comment->name, $comment->lang);
                                     }
                                     $merged = false;
                                     $merge_time = $config->getInt('merge_time', 0);
                                     // merge comments from same author
                                     if ($user->id && $merge_time > 0) {
                                         // load previous comment for same object and group
                                         $prevComment = JCommentsModel::getLastComment($comment->object_id, $comment->object_group, $comment->parent);
                                         if ($prevComment != null) {
                                             // if previous comment from same author and it currently not edited
                                             // by any user - we'll update comment, else - insert new record to database
                                             if ($prevComment->userid == $comment->userid && $prevComment->parent == $comment->parent && !$acl->isLocked($prevComment)) {
                                                 $newText = $prevComment->comment . '<br /><br />' . $comment->comment;
                                                 $timeDiff = strtotime($comment->date) - strtotime($prevComment->date);
                                                 if ($timeDiff < $merge_time) {
                                                     $maxlength = $config->getInt('comment_maxlength');
                                                     $needcheck = $acl->check('enable_comment_length_check');
                                                     // validate new comment text length and if it longer than specified -
                                                     // disable union current comment with previous
                                                     if ($needcheck == 0 || $needcheck == 1 && $maxlength != 0 && JCommentsText::strlen($newText) <= $maxlength) {
                                                         $comment->id = $prevComment->id;
                                                         $comment->comment = $newText;
                                                         $merged = true;
                                                     }
                                                 }
                                             }
                                             unset($prevComment);
                                         }
                                     }
                                     // save new comment to database
                                     if (!$comment->store()) {
                                         $response->addScript("jcomments.clear('comment');");
                                         if ($acl->check('enable_captcha') == 1 && $config->get('captcha_engine', 'kcaptcha') == 'kcaptcha') {
                                             JCommentsCaptcha::destroy();
                                             $response->addScript("jcomments.clear('captcha');");
                                         }
                                         return $response;
                                     }
                                     // store/update information about commented object
                                     JCommentsObjectHelper::storeObjectInfo($comment->object_id, $comment->object_group, $comment->lang);
                                     JCommentsEvent::trigger('onJCommentsCommentAfterAdd', array(&$comment));
                                     // send notification to administrators
                                     if ($config->getInt('enable_notification') == 1) {
                                         if ($config->check('notification_type', 1) == true) {
                                             JComments::sendNotification($comment, true);
                                         }
                                     }
                                     // if comment published we need update comments list
                                     if ($comment->published) {
                                         // send notification to comment subscribers
                                         JComments::sendToSubscribers($comment, true);
                                         if ($merged) {
                                             $commentText = $comment->comment;
                                             $html = JCommentsText::jsEscape(JComments::getCommentItem($comment));
                                             $response->addScript("jcomments.updateComment(" . $comment->id . ", '{$html}');");
                                             $comment->comment = $commentText;
                                         } else {
                                             $count = JComments::getCommentsCount($comment->object_id, $comment->object_group);
                                             if ($config->get('template_view') == 'tree') {
                                                 if ($count > 1) {
                                                     $html = JComments::getCommentListItem($comment);
                                                     $html = JCommentsText::jsEscape($html);
                                                     $mode = $config->getInt('tree_order') == 1 || $config->getInt('tree_order') == 2 && $comment->parent > 0 ? 'b' : 'a';
                                                     $response->addScript("jcomments.updateTree('{$html}','{$comment->parent}','{$mode}');");
                                                 } else {
                                                     $html = JComments::getCommentsTree($comment->object_id, $comment->object_group);
                                                     $html = JCommentsText::jsEscape($html);
                                                     $response->addScript("jcomments.updateTree('{$html}',null);");
                                                 }
                                             } else {
                                                 // if pagination disabled and comments count > 1...
                                                 if ($config->getInt('comments_per_page') == 0 && $count > 1) {
                                                     // update only added comment
                                                     $html = JComments::getCommentListItem($comment);
                                                     $html = JCommentsText::jsEscape($html);
                                                     if ($config->get('comments_order') == 'DESC') {
                                                         $response->addScript("jcomments.updateList('{$html}','p');");
                                                     } else {
                                                         $response->addScript("jcomments.updateList('{$html}','a');");
                                                     }
                                                 } else {
                                                     // update comments list
                                                     $html = JComments::getCommentsList($comment->object_id, $comment->object_group, JComments::getCommentPage($comment->object_id, $comment->object_group, $comment->id));
                                                     $html = JCommentsText::jsEscape($html);
                                                     $response->addScript("jcomments.updateList('{$html}','r');");
                                                 }
                                                 // scroll to first comment
                                                 if ($config->get('comments_order') == 'DESC') {
                                                     $response->addScript("jcomments.scrollToList();");
                                                 }
                                             }
                                         }
                                         self::showInfoMessage(JText::_('THANK_YOU_FOR_YOUR_SUBMISSION'));
                                     } else {
                                         self::showInfoMessage(JText::_('THANK_YOU_YOUR_COMMENT_WILL_BE_PUBLISHED_ONCE_REVIEWED'));
                                     }
                                     // clear comments textarea & update comment length counter if needed
                                     $response->addScript("jcomments.clear('comment');");
                                     if ($acl->check('enable_captcha') == 1 && $config->get('captcha_engine', 'kcaptcha') == 'kcaptcha') {
                                         require_once JCOMMENTS_BASE . DS . 'jcomments.captcha.php';
                                         JCommentsCaptcha::destroy();
                                         $response->addScript("jcomments.clear('captcha');");
                                     }
                                 } else {
                                     self::showErrorMessage(JText::_('ERROR_DUPLICATE_COMMENT'), 'comment');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $message = $config->get('ERROR_CANT_COMMENT');
         if ($acl->getUserBlocked()) {
             $bannedMessage = $config->get('message_banned');
             if (!empty($bannedMessage)) {
                 $message = self::escapeMessage($bannedMessage);
             }
         }
         $response->addAlert($message);
     }
     return $response;
 }
Ejemplo n.º 20
0
 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');
 }
Ejemplo n.º 21
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;
     }
 }
Ejemplo n.º 22
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;
 }
Ejemplo n.º 23
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;
 }
Ejemplo n.º 24
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;
 }
 function _isSubscribed($object_id, $object_group, $userid, $email = '', $language = '')
 {
     if (empty($language)) {
         $language = JCommentsMultilingual::getLanguage();
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('COUNT(*)');
     $query->from($db->quoteName('#__jcomments_subscriptions'));
     $query->where($db->quoteName('object_id') . ' = ' . (int) $object_id);
     $query->where($db->quoteName('object_group') . ' = ' . $db->Quote($object_group));
     $query->where($db->quoteName('userid') . ' = ' . (int) $userid);
     if ($userid == 0) {
         $query->where($db->quoteName('email') . ' = ' . $db->Quote($email));
     }
     if (JCommentsMultilingual::isEnabled()) {
         $query->where($db->quoteName('lang') . ' = ' . $db->Quote($language));
     }
     $db->setQuery($query);
     $count = $db->loadResult();
     return $count > 0 ? 1 : 0;
 }
Ejemplo n.º 26
0
    public static function showImport($CommentSystems = array())
    {
        $app = JCommentsFactory::getApplication('administrator');
        $db = JCommentsFactory::getDBO();
        $db->setQuery("SHOW TABLES");
        $tables = $db->loadResultArray();
        foreach ($tables as $tableName) {
            for ($i = 0, $n = count($CommentSystems); $i < $n; $i++) {
                $tableMask = str_replace('#__', $app->getCfg('dbprefix'), $CommentSystems[$i]->table);
                if (preg_match('/' . $tableMask . '$/i', $tableName)) {
                    $CommentSystems[$i]->found = true;
                    $CommentSystems[$i]->UpdateCount();
                }
            }
        }
        $languages = JCommentsMultilingual::getLanguages();
        if (JCOMMENTS_JVERSION == '1.0') {
            $lang = JCommentsMultilingual::getLanguage();
        } else {
            $params = JComponentHelper::getParams('com_languages');
            $lang = $params->get("site", 'en-GB');
        }
        $ajaxUrl = JCommentsFactory::getLink('ajax-backend');
        ?>
<link rel="stylesheet" href="<?php 
        echo $app->getCfg('live_site');
        ?>
/administrator/components/com_jcomments/assets/style.css" type="text/css" />
<script type="text/javascript" src="<?php 
        echo $app->getCfg('live_site');
        ?>
/components/com_jcomments/libraries/joomlatune/ajax.js?v=2"></script>
<script type="text/javascript" src="<?php 
        echo $app->getCfg('live_site');
        ?>
/administrator/components/com_jcomments/assets/jcomments-backend-v2.1.js"></script>
<script type="text/javascript">
<!--
function JCommentsImportCommentsAJAX(source, language, start)
{
	try {
		jtajax.setup({url:'<?php 
        echo $ajaxUrl;
        ?>
'});
		return jtajax.call('JCommentsImportCommentsAjax', arguments, 'post');
	} catch (e) {
		return false;
	}
}

function startCommentsImport(source)
{
	var language = '';
	var e=document.getElementById(source.toLowerCase() + '_lang');
	if (e){for (var i=0;i<e.length;i++) {if (e.options[i].selected){language=e.options[i].value;break;}}}
	var b = document.getElementById('btnImport' + source);
	if (b) {b.disabled = true;}
	JCommentsImportCommentsAJAX(source, language, 0);
}

function finishCommentsImport(source) {
	var b=document.getElementById('btnImport'+source);if(b){b.disabled=false;}
}

<?php 
        if (JCOMMENTS_JVERSION == '1.7') {
            ?>
Joomla.submitbutton = function (task) {
	Joomla.submitform(task, document.getElementById('adminForm'));
};
<?php 
        } else {
            ?>
function submitbutton(task)
{
	submitform(task);
}
<?php 
        }
        ?>
//-->
</script>
<script type="text/javascript">
<!--
var jc_comments = new Array(
<?php 
        $jsArray = array();
        foreach ($CommentSystems as $CommentSystem) {
            if ($CommentSystem->found) {
                $jsArray[] = $CommentSystem->code;
            }
        }
        echo "'" . implode("', '", $jsArray) . "'";
        ?>
			);

function importMode( mode ) {
	if(document.getElementById) {
		for(var i=0;i<jc_comments.length;i++) {
			if (mode == jc_comments[i]) {
				document.getElementById('import' + jc_comments[i]).checked = true;
				document.getElementById('import' + jc_comments[i]+'Info').style.display = '';
			} else {
				document.getElementById('import' + jc_comments[i]).checked = false;
				document.getElementById('import' + jc_comments[i]+'Info').style.display = 'none';
			}
		}
	}
}
//-->
</script>

<style type="text/css">
#jcomments-message {padding: 0 0 0 25px;margin: 0; width: auto; float: right; font-size: 14px; font-weight: bold;}
.jcomments-message-error {background: transparent url(components/com_jcomments/assets/error.gif) no-repeat 4px 50%; color: red;}
.jcomments-message-info {background: transparent url(components/com_jcomments/assets/info.gif) no-repeat 4px 50%; color: green;}
.jcomments-message-wait {background: transparent url(components/com_jcomments/assets/wait.gif) no-repeat 4px 50%; color: green;}
.adminform fieldset { border: 1px #999 solid; }
.adminform fieldset input, fieldset select { float: none; }
.adminform span.note { color: #777; }
table.componentinfo td { color: #777; padding: 0; }
</style>

<div>
<form action="<?php 
        echo JCOMMENTS_INDEX;
        ?>
" method="post" name="adminForm" id="adminForm">
<input type="hidden" name="option" value="com_jcomments" />
<input type="hidden" name="task" value="" />
<?php 
        if (JCOMMENTS_JVERSION == '1.0') {
            ?>
<table class="adminheading">
<tr>
	<th style="background-image: none; padding: 0;"><img src="components/com_jcomments/assets/icon-48-import.png" width="48" height="48" align="middle" alt="<?php 
            echo JText::_('A_IMPORT');
            ?>
">&nbsp;<?php 
            echo JText::_('A_IMPORT');
            ?>
</th>
</tr>
</table>
<?php 
        }
        ?>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr valign="top">
		<td align="right">&nbsp;</td>
		<td width="50%" align="right"><div id="jcomments-message-holder"></div></td>
	</tr>
</table>

<table width="100%" border="0" cellpadding="4" cellspacing="2" class="adminform">
<tr>
	<td>
		<fieldset>
		<legend><?php 
        echo JText::_('A_IMPORT_SELECT_SOURCE');
        ?>
</legend>
		<table cellpadding="1" cellspacing="1" border="0">
<?php 
        $foundSources = 0;
        foreach ($CommentSystems as $CommentSystem) {
            if ($CommentSystem->found) {
                $foundSources++;
                ?>
		<tr valign="top" align="left">
			<td><input type="radio" id="import<?php 
                echo $CommentSystem->code;
                ?>
" name="vars[import]" value="<?php 
                echo $CommentSystem->code;
                ?>
" onclick="importMode('<?php 
                echo $CommentSystem->code;
                ?>
')" <?php 
                echo $CommentSystem->found ? '' : 'disabled';
                ?>
 /></td>
			<td><label for="import<?php 
                echo $CommentSystem->code;
                ?>
"><?php 
                echo $CommentSystem->name;
                ?>
</label></td>
			<td><div id="jcomments-message-<?php 
                echo strtolower($CommentSystem->code);
                ?>
"></div></td>
		</tr>
		<tr id="import<?php 
                echo $CommentSystem->code;
                ?>
Info" style="display: none;">
			<td>&nbsp;</td>
			<td>
				<table cellpadding="0" cellspacing="0" border="0" class="componentinfo">
				<tr>
					<td width="150px"><?php 
                echo JText::_('A_IMPORT_COMPONENT_AUTHOR');
                ?>
</td>
					<td><?php 
                echo $CommentSystem->author;
                ?>
</td>
				</tr>
				<tr>
					<td><?php 
                echo JText::_('A_IMPORT_COMPONENT_HOMEPAGE');
                ?>
</td>
					<td><a href="<?php 
                echo $CommentSystem->homepage;
                ?>
" target="_blank"><?php 
                echo str_replace('http://', '', $CommentSystem->homepage);
                ?>
</a></td>
				</tr>
				<tr>
					<td><?php 
                echo JText::_('A_IMPORT_COMPONENT_LICENSE');
                ?>
</td>
					<td>
<?php 
                if ($CommentSystem->license_url != '') {
                    ?>
						<a href="<?php 
                    echo $CommentSystem->license_url;
                    ?>
" target="_blank"><?php 
                    echo $CommentSystem->license;
                    ?>
</a>
<?php 
                } else {
                    ?>
					
						<?php 
                    echo $CommentSystem->license;
                }
                ?>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr valign="top" align="left">
					<td>
						<?php 
                echo JText::_('A_IMPORT_COMPONENT_COMMENTS_COUNT');
                ?>
					</td>
					<td>
						<label for="import<?php 
                echo $CommentSystem->code;
                ?>
"><?php 
                echo $CommentSystem->count;
                ?>
</label>
					</td>
				</tr>

				<tr valign="top" align="left">
					<td>
					</td>
					<td>
<?php 
                if (count($languages)) {
                    echo JCommentsHTML::selectList($languages, strtolower($CommentSystem->code) . '_lang', 'class="inputbox" size="1"', 'value', 'name', $lang) . '&nbsp;';
                }
                ?>
						<input type="button" id="btnImport<?php 
                echo $CommentSystem->code;
                ?>
" name="btnImport<?php 
                echo $CommentSystem->code;
                ?>
" value="<?php 
                echo JText::_('A_IMPORT_BUTTON_IMPORT');
                ?>
" onclick="startCommentsImport('<?php 
                echo $CommentSystem->code;
                ?>
')" <?php 
                echo $CommentSystem->count ? '' : 'disabled';
                ?>
 />
					</td>
				</tr>

				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				</table>
			</td>
		</tr>
<?php 
            }
        }
        if ($foundSources == 0) {
            ?>
		<tr>
			<td><?php 
            echo JText::_('A_IMPORT_NO_SOURCES');
            ?>
</td>
		</tr>
<?php 
        }
        ?>
		</table>
	</fieldset>
	</td>
</tr>
</table>
<?php 
        echo JCommentsSecurity::formToken();
        ?>
</form>
</div>
<?php 
    }
Ejemplo n.º 27
0
 function loadSettingsByLanguage($language = '')
 {
     $lang = '';
     $joomfish = JOOMLATUNE_JPATH_SITE . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish)) {
         $lang = $language;
         if ($lang == '') {
             $lang = JCommentsMultilingual::getLanguage();
         }
         // reload configuration
         JCommentsFactory::getConfig($lang);
     }
     return $lang;
 }