public static function getList($params) { $db = JFactory::getDBO(); $db->setQuery("SELECT * FROM #__jcomments ORDER BY date DESC", 0, $params->get('count')); $items = $db->loadObjectList(); if (!is_array($items)) { $items = array(); } if (count($items)) { $config = JCommentsFactory::getConfig(); $bbcode = JCommentsFactory::getBBCode(); $limit_comment_text = (int) $params->get('limit_comment_text', 0); foreach ($items as &$item) { $item->link = 'index.php?option=com_jcomments&&view=comment&layout=edit&id=' . $item->id; $item->author = JComments::getCommentAuthorName($item); $text = JCommentsText::censor($item->comment); $text = $bbcode->filter($text, true); $text = JCommentsText::cleanText($text); if ($limit_comment_text && JString::strlen($text) > $limit_comment_text) { $text = self::truncateText($text, $limit_comment_text - 1); } $item->comment = $text; } } return $items; }
public function strip($str) { if (count($this->_replacements) > 0) { $str = JCommentsText::br2nl($str); $str = preg_replace($this->_replacements['code'], '\\1\\3', $str); $str = JCommentsText::nl2br($str); } return $str; }
function render() { $comment = $this->getVar('comment'); $object_title = $this->getVar('comment-object_title'); $object_link = $this->getVar('comment-object_link'); $hash = $this->getVar('hash'); $link = '<a href="' . $object_link . '" target="_blank">' . $object_title . '</a>'; $unsubscribeMessage = JText::sprintf('NOTIFICATION_COMMENT_UNSUBSCRIBE', $link); $unsubscribeLink = JCommentsFactory::getUnsubscribeLink($hash); // add inline styles for quotes to default comment html layout $comment->comment = str_replace('<blockquote>', '<blockquote style="border-left: 2px solid #ccc; padding-left: 5px; margin-left: 10px;">', $comment->comment); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=<? echo $this->getVar('charset'); ?>" http-equiv="content-type" /> <meta name="Generator" content="JComments" /> </head> <body> <a style="color: #777;" href="<? echo $object_link ?>#comment-<? echo $comment->id; ?>" target="_blank">#</a> <? if ($comment->title != '') { ?> <span style="color: #b01625;font: bold 1em Verdana, Arial, Sans-Serif;"><? echo $comment->title; ?></span> — <? } if ($comment->homepage != '') { ?> <a style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;" href="<? echo $comment->homepage; ?>" target="_blank"><? echo $comment->name; ?></a> <? } else { ?> <span style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;"><? echo $comment->name; ?></span> <? } ?> — <span style="font-size: 11px; color: #999;"><? echo JCommentsText::formatDate($comment->datetime, JText::_('DATETIME_FORMAT')); ?></span> <div style="border: 1px solid #ccc; padding: 10px 5px; margin: 5px 0; font: normal 1em Verdana, Arial, Sans-Serif;"><? echo $comment->comment; ?></div> <p style="border-top: 1px solid #ccc; margin: 10px 0 0 0; color: #555;"><? echo $unsubscribeMessage; ?>:<br /><a href="<? echo $unsubscribeLink; ?>" target="_blank"><? echo JText::_('Unsubscribe');?></a></p> </body> </html> <? }
function getCommentsFormFull() { $object_id = $this->getVar('comment-object_id'); $object_group = $this->getVar('comment-object_group'); $htmlBeforeForm = $this->getVar('comments-form-html-before'); $htmlAfterForm = $this->getVar('comments-form-html-after'); ?> <!-- <h4><?php echo JText::_('FORM_HEADER'); ?> </h4> --> <div class="contenedor-blog-1-sep2"></div> <div class="blogcomentarios-header">Deja un comentario</div> <?php if ($this->getVar('comments-form-policy', 0) == 1) { ?> <div class="comments-policy"><?php echo $this->getVar('comments-policy'); ?> </div> <?php } echo $htmlBeforeForm; ?> <a id="addcomments" href="#addcomments"></a> <form id="comments-form" name="comments-form" action="javascript:void(null);"> <?php if ($this->getVar('comments-form-user-name', 1) == 1) { $text = $this->getVar('comments-form-user-name-required', 1) == 0 ? JText::_('FORM_NAME') : JText::_('FORM_NAME_REQUIRED'); ?> <p> <span> <input id="comments-form-name" type="text" name="name" value="" maxlength="<?php echo $this->getVar('comment-name-maxlength'); ?> " size="22" tabindex="1" class="blog-comment-text" /> <label for="comments-form-name" class="blogcomentarios-campo-form"><b>Nombre</b> requerido</label> </span> </p> <?php } if ($this->getVar('comments-form-user-email', 1) == 1) { $text = $this->getVar('comments-form-email-required', 1) == 0 ? JText::_('FORM_EMAIL') : JText::_('FORM_EMAIL_REQUIRED'); ?> <p> <span> <input id="comments-form-email" type="text" name="email" value="" size="22" tabindex="2" class="blog-comment-text" /> <label for="comments-form-email" class="blogcomentarios-campo-form"><b>E-MAIL</b> requerido (no se publicará)</label> </span> </p> <?php } if ($this->getVar('comments-form-user-homepage', 0) == 1) { $text = $this->getVar('comments-form-homepage-required', 1) == 0 ? JText::_('FORM_HOMEPAGE') : JText::_('FORM_HOMEPAGE_REQUIRED'); ?> <p> <span> <input id="comments-form-homepage" type="text" name="homepage" value="" size="22" tabindex="3" /> <label for="comments-form-homepage"><?php echo $text; ?> </label> </span> </p> <?php } if ($this->getVar('comments-form-title', 0) == 1) { $text = $this->getVar('comments-form-title-required', 1) == 0 ? JText::_('FORM_TITLE') : JText::_('FORM_TITLE_REQUIRED'); ?> <p> <span> <input id="comments-form-title" type="text" name="title" value="" size="22" tabindex="4" /> <label for="comments-form-title"><?php echo $text; ?> </label> </span> </p> <?php } ?> <p> <span> <textarea id="comments-form-comment" name="comment" cols="205" rows="5" tabindex="5" class="blog-comment-text"></textarea> </span> </p> <?php if ($this->getVar('comments-form-subscribe', 0) == 1) { ?> <p> <span> <input class="checkbox" id="comments-form-subscribe" type="checkbox" name="subscribe" value="1" tabindex="5" /> <label for="comments-form-subscribe"><?php echo JText::_('FORM_SUBSCRIBE'); ?> </label><br /> </span> </p> <?php } if ($this->getVar('comments-form-captcha', 0) == 1) { $html = $this->getVar('comments-form-captcha-html'); if ($html != '') { echo $html; } else { $link = JCommentsFactory::getLink('captcha'); ?> <p> <span> <img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" src="<?php echo $link; ?> " width="121" height="60" alt="<?php echo JText::_('FORM_CAPTCHA'); ?> " /><br /> <span class="captcha" onclick="jcomments.clear('captcha');">Pulsa para mostrar otra imagen</span><br /> <input class="captcha" id="comments-form-captcha" type="text" name="captcha_refid" value="" size="5" tabindex="6" /><br /> </span> </p> <?php } } ?> <div id="comments-form-buttons"> <div id="comments-form-send" class="contenidonivel2-lateralderecho-boton-interno" style="background-image:url(http://www.cesae.es/images/btnpeq.png);cursor:hand;" onmouseover="JavaScript:this.style.backgroundImage='url(http://www.cesae.es/images/btnpeqon.png)'" onmouseout="JavaScript:this.style.backgroundImage='url(http://www.cesae.es/images/btnpeq.png)'" ontouchstart="JavaScript:this.style.backgroundImage='url(http://www.cesae.es/images/btnpeqon.png)'" ontouchend="JavaScript:this.style.backgroundImage='url(http://www.cesae.es/images/btnpeq.png)'"> <a href="#" onclick="jcomments.saveComment();return false;" title="CESAE ENVIAR COMENTARIO" id="contenidonivel2-lateralderecho-boton-interno-btn" >ENVIAR COMENTARIO</a> </div> <div class="btn" id="comments-form-cancel" style="display:none;"><div><a href="#" tabindex="8" onclick="return false;" title="<?php echo JText::_('FORM_CANCEL'); ?> "><?php echo JText::_('FORM_CANCEL'); ?> </a></div></div> <div style="clear:both;"></div> </div> <div> <input type="hidden" name="object_id" value="<?php echo $object_id; ?> " /> <input type="hidden" name="object_group" value="<?php echo $object_group; ?> " /> </div> </form> <script type="text/javascript"> <!-- function JCommentsInitializeForm() { var jcEditor = new JCommentsEditor('comments-form-comment', true); <?php if ($this->getVar('comments-form-bbcode', 0) == 1) { $bbcodes = array('b' => array(0 => JText::_('FORM_BBCODE_B'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'i' => array(0 => JText::_('FORM_BBCODE_I'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'u' => array(0 => JText::_('FORM_BBCODE_U'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 's' => array(0 => JText::_('FORM_BBCODE_S'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'img' => array(0 => JText::_('FORM_BBCODE_IMG'), 1 => JText::_('BBCODE_HINT_ENTER_FULL_URL_TO_THE_IMAGE')), 'url' => array(0 => JText::_('FORM_BBCODE_URL'), 1 => JText::_('BBCODE_HINT_ENTER_FULL_URL')), 'hide' => array(0 => JText::_('FORM_BBCODE_HIDE'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT_TO_HIDE_IT_FROM_UNREGISTERED')), 'quote' => array(0 => JText::_('FORM_BBCODE_QUOTE'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT_TO_QUOTE')), 'list' => array(0 => JText::_('FORM_BBCODE_LIST'), 1 => JText::_('BBCODE_HINT_ENTER_LIST_ITEM_TEXT'))); foreach ($bbcodes as $k => $v) { if ($this->getVar('comments-form-bbcode-' . $k, 0) == 1) { $title = trim(JCommentsText::jsEscape($v[0])); $text = trim(JCommentsText::jsEscape($v[1])); ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> '); <?php } } } $customBBCodes = $this->getVar('comments-form-custombbcodes'); if (count($customBBCodes)) { foreach ($customBBCodes as $code) { if ($code->button_enabled) { $k = 'custombbcode' . $code->id; $title = trim(JCommentsText::jsEscape($code->button_title)); $text = empty($code->button_prompt) ? JText::_('BBCODE_HINT_ENTER_TEXT') : JText::_($code->button_prompt); $open_tag = $code->button_open_tag; $close_tag = $code->button_close_tag; $icon = $code->button_image; $css = $code->button_css; ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> ','<?php echo $open_tag; ?> ','<?php echo $close_tag; ?> ','<?php echo $css; ?> ','<?php echo $icon; ?> '); <?php } } } $smiles = $this->getVar('comment-form-smiles'); if (isset($smiles)) { if (is_array($smiles) && count($smiles) > 0) { ?> jcEditor.initSmiles('<?php echo $this->getVar("smilesurl"); ?> '); <?php foreach ($smiles as $code => $icon) { $code = trim(JCommentsText::jsEscape($code)); $icon = trim(JCommentsText::jsEscape($icon)); ?> jcEditor.addSmile('<?php echo $code; ?> ','<?php echo $icon; ?> '); <?php } } } if ($this->getVar('comments-form-showlength-counter', 0) == 1) { ?> jcEditor.addCounter(<?php echo $this->getVar('comment-maxlength'); ?> , 'Quedan', 'caracteres', 'counter'); <?php } ?> jcomments.setForm(new JCommentsForm('comments-form', jcEditor)); } <?php if ($this->getVar('comments-form-ajax', 0) == 1) { ?> setTimeout(JCommentsInitializeForm, 100); <?php } else { ?> if (window.addEventListener) {window.addEventListener('load',JCommentsInitializeForm,false);} else if (document.addEventListener){document.addEventListener('load',JCommentsInitializeForm,false);} else if (window.attachEvent){window.attachEvent('onload',JCommentsInitializeForm);} else {if (typeof window.onload=='function'){var oldload=window.onload;window.onload=function(){oldload();JCommentsInitializeForm();}} else window.onload=JCommentsInitializeForm;} <?php } ?> //--> </script> <?php echo $htmlAfterForm; }
public function save($data) { $table = $this->getTable(); $pkName = $table->getKeyName(); $pk = !empty($data[$pkName]) ? $data[$pkName] : (int) $this->getState($this->getName() . '.id'); try { if ($pk > 0) { $table->load($pk); } $prevPublished = $table->published; if (!$table->bind($data)) { $this->setError($table->getError()); return false; } if ($table->userid == 0) { $table->name = preg_replace('/[\'"\\>\\<\\(\\)\\[\\]]?+/i', '', $table->name); $table->username = $table->name; } else { $user = JFactory::getUser($table->userid); $table->name = $user->name; $table->username = $user->username; $table->email = $user->email; } if (get_magic_quotes_gpc() == 1) { $table->title = stripslashes($table->title); $table->comment = stripslashes($table->comment); } $table->comment = JCommentsText::nl2br($table->comment); $table->comment = JCommentsFactory::getBBCode()->filter($table->comment); if (!$table->check()) { $this->setError($table->getError()); return false; } if (!$table->store()) { $this->setError($table->getError()); return false; } if ($table->published && $prevPublished != $table->published) { JCommentsNotificationHelper::push(array('comment' => $table), 'comment-new'); } $this->cleanCache('com_jcomments'); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } if (isset($table->{$pkName})) { $this->setState($this->getName() . '.id', $table->{$pkName}); } return true; }
public static function prepareComment(&$comment) { if (isset($comment->_skip_prepare) && $comment->_skip_prepare == 1) { return; } JCommentsEventHelper::trigger('onJCommentsCommentBeforePrepare', array(&$comment)); $config = JCommentsFactory::getConfig(); $acl = JCommentsFactory::getACL(); // run autocensor if ($acl->check('enable_autocensor')) { $comment->comment = JCommentsText::censor($comment->comment); if ($comment->title != '') { $comment->title = JCommentsText::censor($comment->title); } } // replace deleted comment text with predefined message if ($comment->deleted == 1) { $comment->comment = JText::_('COMMENT_TEXT_COMMENT_HAS_BEEN_DELETED'); $comment->username = ''; $comment->name = ''; $comment->email = ''; $comment->homepage = ''; $comment->userid = 0; $comment->isgood = 0; $comment->ispoor = 0; } // replace BBCode tags $comment->comment = JCommentsFactory::getBBCode()->replace($comment->comment); if ($config->getInt('enable_custom_bbcode')) { $comment->comment = JCommentsFactory::getCustomBBCode()->replace($comment->comment); } // fix long words problem $word_maxlength = $config->getInt('word_maxlength'); if ($word_maxlength > 0) { $comment->comment = JCommentsText::fixLongWords($comment->comment, $word_maxlength); if ($comment->title != '') { $comment->title = JCommentsText::fixLongWords($comment->title, $word_maxlength); } } if ($acl->check('emailprotection')) { $comment->comment = JComments::maskEmail($comment->id, $comment->comment); } // autolink urls if ($acl->check('autolinkurls')) { $comment->comment = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $comment->comment); if ($acl->check('emailprotection') != 1) { $comment->comment = preg_replace(_JC_REGEXP_EMAIL, '<a href="mailto:\\1@\\2">\\1@\\2</a>', $comment->comment); } } // replace smilies' codes with images if ($config->get('enable_smilies') == '1') { $comment->comment = JCommentsFactory::getSmilies()->replace($comment->comment); } $comment->author = JComments::getCommentAuthorName($comment); // Gravatar support $comment->gravatar = md5(strtolower($comment->email)); if (empty($comment->avatar)) { $comment->avatar = '<img src="http://www.gravatar.com/avatar/' . $comment->gravatar . '?d=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars($comment->author) . '" />'; } JCommentsEventHelper::trigger('onJCommentsCommentAfterPrepare', array(&$comment)); }
?> </td> </tr> </tfoot> <tbody> <?php foreach ($this->items as $i => $item) { $canEdit = $user->authorise('core.edit', 'com_jcomments'); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0; $canChange = $user->authorise('core.edit.state', 'com_jcomments') && $canCheckin; $title = $item->title; if (empty($title)) { if ($this->state->get('config.comment_title', 0) == 1 && !empty($item->object_title)) { $title = JText::_('A_COMMENT_TITLE_RE') . ' ' . $item->object_title; } else { $title = JCommentsText::cleanText(strip_tags($item->comment)); $title = JString::substr($title, 0, 200); } } ?> <tr class="row<?php echo $i % 2; ?> "> <td class="center hidden-phone"> <?php echo JHTML::_('grid.id', $i, $item->id); ?> </td> <td class="left hidden-phone"> <?php
protected function clearComment($value) { // change \n to <br /> $matches = array(); preg_match_all('#(\\[code\\=?([a-z0-9]*?)\\].*\\[\\/code\\])#isUu', trim($value), $matches); $map = array(); $key = ''; foreach ($matches[1] as $code) { $key = '{' . md5($code . $key) . '}'; $map[$key] = $code; $value = preg_replace('#' . preg_quote($code, '#') . '#isUu', $key, $value); } $value = JCommentsText::nl2br($value); foreach ($map as $key => $code) { $value = preg_replace('#' . preg_quote($key, '#') . '#isUu', $code, $value); } // strip bbcodes $patterns = array('/\\[font=(.*?)\\](.*?)\\[\\/font\\]/i', '/\\[size=(.*?)\\](.*?)\\[\\/size\\]/i', '/\\[color=(.*?)\\](.*?)\\[\\/color\\]/i', '/\\[b\\](null|)\\[\\/b\\]/i', '/\\[i\\](null|)\\[\\/i\\]/i', '/\\[u\\](null|)\\[\\/u\\]/i', '/\\[s\\](null|)\\[\\/s\\]/i', '/\\[url=null\\]null\\[\\/url\\]/i', '/\\[img\\](null|)\\[\\/img\\]/i', '/\\[url=(.*?)\\](.*?)\\[\\/url\\]/i', '/\\[email](.*?)\\[\\/email\\]/i', '/\\[quote=\\"?([^\\:\\]]+)(\\:[0-9]+)?\\"?\\]/ism', '/\\[link=\\"?([^\\]]+)\\"?\\]/ism', '/\\[\\/link\\]/ism', '/\\[youtube ([^\\s]+) youtube\\]/ism'); $replacements = array('\\2', '\\2', '\\2', '', '', '', '', '', '', '\\2 ([url]\\1[/url])', '\\1', '[quote name="\\1"]', '[url=\\1]', '[/url]', '[youtube]\\1[/youtube]'); $value = preg_replace($patterns, $replacements, $value); return $value; }
/** * 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(); }
/** * Prepares data for notification * * @param array $data An associative array of notification data * @param string $type Type of notification * * @return mixed */ private static function prepareData($data, $type) { require_once JPATH_ROOT . '/components/com_jcomments/jcomments.php'; $object = JCommentsObjectHelper::getObjectInfo($data['comment']->object_id, $data['comment']->object_group, $data['comment']->lang); $data['notification-type'] = $type; $data['object_title'] = $object->title; $data['object_link'] = JCommentsFactory::getAbsLink($object->link); $data['comment']->author = JComments::getCommentAuthorName($data['comment']); $data['comment']->title = JCommentsText::censor($data['comment']->title); $data['comment']->comment = JCommentsText::censor($data['comment']->comment); $data['comment']->comment = JCommentsFactory::getBBCode()->replace($data['comment']->comment); if (JCommentsFactory::getConfig()->getInt('enable_custom_bbcode')) { $data['comment']->comment = JCommentsFactory::getCustomBBCode()->replace($data['comment']->comment, true); } $data['comment']->comment = trim(preg_replace('/(\\s){2,}/i', '\\1', $data['comment']->comment)); return $data; }
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 . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="' . htmlspecialchars(JComments::getCommentAuthorName($item)) . '" />'; } $item->readmoreText = JText::_('MOD_JCOMMENTS_LATEST_READMORE'); } } return $list; }
function getCommentsFormFull() { $object_id = $this->getVar('comment-object_id'); $object_group = $this->getVar('comment-object_group'); $htmlBeforeForm = $this->getVar('comments-form-html-before'); $htmlAfterForm = $this->getVar('comments-form-html-after'); ?> <div class="comment-formular"> <h3>Leave a comment</h3> <?php if ($this->getVar('comments-form-policy', 0) == 1) { ?> <div class="comments-policy"><?php echo $this->getVar('comments-policy'); ?> </div> <?php } echo $htmlBeforeForm; ?> <a id="addcomments" href="#addcomments"></a> <form id="comments-form" class="validate" name="comments-form" action="javascript:void(null);"> <?php if ($this->getVar('comments-form-user-name', 1) == 1) { $text = $this->getVar('comments-form-user-name-required', 1) == 0 ? JText::_('FORM_NAME') : JText::_('FORM_NAME_REQUIRED'); ?> <div class="row"> <div class="col-md-6 col-sm-6 col-md-6 col-xs-12"> <div class="form-group"> <label for="name">Name</label> <input id="comments-form-name" type="text" class="form-control input-lg required" name="name" value="" maxlength="<?php echo $this->getVar('comment-name-maxlength'); ?> " size="22" tabindex="1" placeholder="Enter name" /> </div> <?php } if ($this->getVar('comments-form-user-email', 1) == 1) { $text = $this->getVar('comments-form-email-required', 1) == 0 ? JText::_('FORM_EMAIL') : JText::_('FORM_EMAIL_REQUIRED'); ?> <div class="form-group"> <label for="email">Email</label> <input id="comments-form-email" type="text" class="form-control input-lg required email" placeholder="Enter email" name="email" value="" size="22" tabindex="2" /> </div> </div> <?php } if ($this->getVar('comments-form-user-homepage', 0) == 1) { $text = $this->getVar('comments-form-homepage-required', 1) == 0 ? JText::_('FORM_HOMEPAGE') : JText::_('FORM_HOMEPAGE_REQUIRED'); ?> <p> <span> <input id="comments-form-homepage" type="text" name="homepage" value="" size="22" tabindex="3" /> <label for="comments-form-homepage"><?php echo $text; ?> </label> </span> </p> <?php } if ($this->getVar('comments-form-title', 0) == 1) { $text = $this->getVar('comments-form-title-required', 1) == 0 ? JText::_('FORM_TITLE') : JText::_('FORM_TITLE_REQUIRED'); ?> <p> <span> <input id="comments-form-title" type="text" name="title" value="" size="22" tabindex="4" /> <label for="comments-form-title"><?php echo $text; ?> </label> </span> </p> <?php } ?> <div class="col-md-6 col-sm-6 col-md-6 col-xs-12"> <div class="form-group"> <label for="message">Message</label> <textarea id="comments-form-comment" placeholder="Enter Message" class="form-control input-lg required" name="comment" cols="65" rows="9" tabindex="5"></textarea> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="action form-button medium"> <div class="mybutton medium"> <div id="comments-form-send"><div><a href="#" tabindex="7" onclick="jcomments.saveComment();return false;" title="<?php echo JText::_('FORM_SEND_HINT'); ?> "><span data-hover="Post comment">Post comment</span></a></div></div> <div id="comments-form-cancel" style="display:none;"><div><a href="#" tabindex="8" onclick="return false;" title="<?php echo JText::_('FORM_CANCEL'); ?> "><span data-hover="<?php echo JText::_('FORM_CANCEL'); ?> "><?php echo JText::_('FORM_CANCEL'); ?> </span></a></div></div> </div> </div> </div> <div> <input type="hidden" name="object_id" value="<?php echo $object_id; ?> " /> <input type="hidden" name="object_group" value="<?php echo $object_group; ?> " /> </div> </form> </div> </div> <script type="text/javascript"> <!-- function JCommentsInitializeForm() { var jcEditor = new JCommentsEditor('comments-form-comment', true); <?php if ($this->getVar('comments-form-bbcode', 0) == 1) { $bbcodes = array('b' => array(0 => JText::_('FORM_BBCODE_B'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'i' => array(0 => JText::_('FORM_BBCODE_I'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'u' => array(0 => JText::_('FORM_BBCODE_U'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 's' => array(0 => JText::_('FORM_BBCODE_S'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT')), 'img' => array(0 => JText::_('FORM_BBCODE_IMG'), 1 => JText::_('BBCODE_HINT_ENTER_FULL_URL_TO_THE_IMAGE')), 'url' => array(0 => JText::_('FORM_BBCODE_URL'), 1 => JText::_('BBCODE_HINT_ENTER_FULL_URL')), 'hide' => array(0 => JText::_('FORM_BBCODE_HIDE'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT_TO_HIDE_IT_FROM_UNREGISTERED')), 'quote' => array(0 => JText::_('FORM_BBCODE_QUOTE'), 1 => JText::_('BBCODE_HINT_ENTER_TEXT_TO_QUOTE')), 'list' => array(0 => JText::_('FORM_BBCODE_LIST'), 1 => JText::_('BBCODE_HINT_ENTER_LIST_ITEM_TEXT'))); foreach ($bbcodes as $k => $v) { if ($this->getVar('comments-form-bbcode-' . $k, 0) == 1) { $title = trim(JCommentsText::jsEscape($v[0])); $text = trim(JCommentsText::jsEscape($v[1])); ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> '); <?php } } } $customBBCodes = $this->getVar('comments-form-custombbcodes'); if (count($customBBCodes)) { foreach ($customBBCodes as $code) { if ($code->button_enabled) { $k = 'custombbcode' . $code->id; $title = trim(JCommentsText::jsEscape($code->button_title)); $text = empty($code->button_prompt) ? JText::_('BBCODE_HINT_ENTER_TEXT') : JText::_($code->button_prompt); $open_tag = $code->button_open_tag; $close_tag = $code->button_close_tag; $icon = $code->button_image; $css = $code->button_css; ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> ','<?php echo $open_tag; ?> ','<?php echo $close_tag; ?> ','<?php echo $css; ?> ','<?php echo $icon; ?> '); <?php } } } $smiles = $this->getVar('comment-form-smiles'); if (isset($smiles)) { if (is_array($smiles) && count($smiles) > 0) { ?> jcEditor.initSmiles('<?php echo $this->getVar("smilesurl"); ?> '); <?php foreach ($smiles as $code => $icon) { $code = trim(JCommentsText::jsEscape($code)); $icon = trim(JCommentsText::jsEscape($icon)); ?> jcEditor.addSmile('<?php echo $code; ?> ','<?php echo $icon; ?> '); <?php } } } if ($this->getVar('comments-form-showlength-counter', 0) == 1) { ?> jcEditor.addCounter(<?php echo $this->getVar('comment-maxlength'); ?> , '<?php echo JText::_('FORM_CHARSLEFT_PREFIX'); ?> ', '<?php echo JText::_('FORM_CHARSLEFT_SUFFIX'); ?> ', 'counter'); <?php } ?> jcomments.setForm(new JCommentsForm('comments-form', jcEditor)); } <?php if ($this->getVar('comments-form-ajax', 0) == 1) { ?> setTimeout(JCommentsInitializeForm, 100); <?php } else { ?> if (window.addEventListener) {window.addEventListener('load',JCommentsInitializeForm,false);} else if (document.addEventListener){document.addEventListener('load',JCommentsInitializeForm,false);} else if (window.attachEvent){window.attachEvent('onload',JCommentsInitializeForm);} else {if (typeof window.onload=='function'){var oldload=window.onload;window.onload=function(){oldload();JCommentsInitializeForm();}} else window.onload=JCommentsInitializeForm;} <?php } ?> //--> </script> <?php echo $htmlAfterForm; }
function render() { $comment = $this->getVar('comment'); if (isset($comment)) { if ($this->getVar('get_comment_vote', 0) == 1) { // return comment vote $this->getCommentVoteValue($comment); } else if ($this->getVar('get_comment_body', 0) == 1) { // return only comment body (for example after quick edit) echo $comment->comment; } else { // return all comment item ?> <div class="metadata"> <p class="author"> <? $comment_number = $this->getVar('comment-number', 1); $thisurl = $this->getVar('thisurl', ''); $commentBoxIndentStyle = ($this->getVar('avatar') == 1) ? ' avatar-indent' : ''; if (isset($comment->usertype)) { $commentBoxIndentStyle .= ' usertype-' . $comment->usertype; } if ($this->getVar('avatar') == 1) { ?> <span class="comment-avatar"><? echo $comment->avatar; ?></span> <? } ?> <? if ($this->getVar('comment-show-vote', 0) == 1) { $this->getCommentVote($comment); } ?> <a class="comment-anchor" href="<? echo $thisurl; ?>#comment-<? echo $comment->id; ?>" id="comment-<? echo $comment->id; ?>">#<? echo $comment_number; ?></a> <? if (($this->getVar('comment-show-title') > 0) && ($comment->title != '')) { ?> <span class="comment-title"><? echo $comment->title; ?></span> — <? } if ($this->getVar('comment-show-homepage') == 1) { ?> <a class="author-homepage" href="<? echo $comment->homepage; ?>" rel="nofollow" title="<? echo $comment->author; ?>"><? echo $comment->author; ?></a> <? } else { ?> <span class="comment-author"><? echo $comment->author ?></span> <? } ?> <span class="comment-date"><? echo JCommentsText::formatDate($comment->datetime, JText::_('DATETIME_FORMAT')); ?></span> </p> </div> <div class="comment-body" id="comment-body-<? echo $comment->id; ?>"><? echo $comment->comment; ?></div> <div class="rbox"> <div class="comment-box<? echo $commentBoxIndentStyle; ?>"> <? if (($this->getVar('button-reply') == 1) || ($this->getVar('button-quote') == 1) || ($this->getVar('button-report') == 1)) { ?> <span class="comments-buttons"> <? if ($this->getVar('button-reply') == 1) { ?> <a href="#" onclick="jcomments.showReply(<? echo $comment->id; ?>); return false;"><? echo JText::_('Reply'); ?></a> <? if ($this->getVar('button-quote') == 1) { ?> | <a href="#" onclick="jcomments.showReply(<? echo $comment->id; ?>,1); return false;"><? echo JText::_('Reply with quote'); ?></a> | <? } } if ($this->getVar('button-quote') == 1) { ?> <a href="#" onclick="jcomments.quoteComment(<? echo $comment->id; ?>); return false;"><? echo JText::_('Quote'); ?></a> <? } if ($this->getVar('button-report') == 1) { if ($this->getVar('button-quote') == 1 || $this->getVar('button-reply') == 1) { ?> | <? } ?> <a href="#" onclick="jcomments.reportComment(<? echo $comment->id; ?>); return false;"><? echo JText::_('Report to administrator'); ?></a> <? } ?> </span> <? } ?> </div><div class="clear"></div> <? // show frontend moderation panel $this->getCommentAdministratorPanel($comment); ?> </div> <? } } }
function save() { $task = JCommentsInput::getVar('task'); $id = (int) JCommentsInput::getVar('id', 0); $bbcode =& JCommentsFactory::getBBCode(); $db =& JCommentsFactory::getDBO(); $row = new JCommentsDB($db); if ($row->load($id)) { $row->homepage = trim(strip_tags(JCommentsInput::getVar('homepage'))); $row->email = trim(strip_tags(JCommentsInput::getVar('email'))); $row->title = trim(strip_tags(JCommentsInput::getVar('title'))); $row->comment = JCommentsInput::getVar('comment'); $row->published = (int) JCommentsInput::getVar('published'); if ($row->userid == 0) { $row->name = strip_tags(JCommentsInput::getVar('name')); $row->name = preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $row->name); if ($row->username != $row->name) { $row->username = $row->name; } $row->username = preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $row->username); } else { if ($row->name == '' || $row->username == '' || $row->email == '') { $user = JCommentsFactory::getUser($row->userid); $row->name = $row->name == '' ? $user->name : $row->name; $row->username = $row->username == '' ? $user->username : $row->username; $row->email = $row->email == '' ? $user->email : $row->email; } } // handle magic quotes compatibility if (get_magic_quotes_gpc() == 1) { $row->title = stripslashes($row->title); $row->comment = stripslashes($row->comment); } $row->comment = JCommentsText::nl2br($row->comment); $row->comment = $bbcode->filter($row->comment); $row->store(); $row->checkin(); JCommentsCache::cleanCache('com_jcomments'); JCommentsCache::cleanCache($row->object_group); } switch ($task) { case 'apply': JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=edit&hidemainmenu=1&cid[]=' . $row->id); break; case 'save': default: JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=comments'); break; } }
public static function save() { JCommentsSecurity::checkToken(); $task = JCommentsInput::getVar('task'); $id = (int) JCommentsInput::getVar('id', 0); $bbcode = JCommentsFactory::getBBCode(); $db = JCommentsFactory::getDBO(); $row = new JCommentsTableComment($db); if ($row->load($id)) { $prevPublished = $row->published; $row->homepage = trim(strip_tags(JCommentsInput::getVar('homepage'))); $row->email = trim(strip_tags(JCommentsInput::getVar('email'))); $row->title = trim(strip_tags(JCommentsInput::getVar('title'))); $row->comment = trim(strip_tags(JCommentsInput::getVar('comment'))); $row->published = (int) JCommentsInput::getVar('published'); if ($row->userid == 0) { $row->name = strip_tags(JCommentsInput::getVar('name')); $row->name = preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $row->name); if ($row->username != $row->name) { $row->username = $row->name; } $row->username = preg_replace("/[\\'\"\\>\\<\\(\\)\\[\\]]?+/i", '', $row->username); } else { if ($row->name == '' || $row->username == '' || $row->email == '') { $user = JCommentsFactory::getUser($row->userid); $row->name = $row->name == '' ? $user->name : $row->name; $row->username = $row->username == '' ? $user->username : $row->username; $row->email = $row->email == '' ? $user->email : $row->email; } } // handle magic quotes compatibility if (get_magic_quotes_gpc() == 1) { $row->title = stripslashes($row->title); $row->comment = stripslashes($row->comment); } $row->comment = JCommentsText::nl2br($row->comment); $row->comment = $bbcode->filter($row->comment); $row->store(); $row->checkin(); // send notification to comment subscribers if ($row->published && $prevPublished != $row->published) { // TODO: add separate message for just published comments include_once JCOMMENTS_BASE . '/jcomments.php'; $language = JCommentsFactory::getLanguage(); $language->load('com_jcomments', JOOMLATUNE_JPATH_SITE, $row->lang); JComments::sendToSubscribers($row, true); } $cache = JCommentsFactory::getCache('com_jcomments'); $cache->clean(); $cache = JCommentsFactory::getCache($row->object_group); $cache->clean(); } switch ($task) { case 'comments.apply': JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=comments.edit&hidemainmenu=1&cid[]=' . $row->id); break; case 'comments.save': default: JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=comments'); break; } }
function prepareComment(&$comment) { if (isset($comment->_skip_prepare) && $comment->_skip_prepare == 1) { return; } $config =& JCommentsFactory::getConfig(); $bbcode =& JCommentsFactory::getBBCode(); $acl =& JCommentsFactory::getACL(); // convert to datetime if variable contains string value if (is_string($comment->datetime)) { $comment->datetime = strtotime($comment->datetime); } // run autocensor if ($acl->check('enable_autocensor')) { $comment->comment = JCommentsText::censor($comment->comment); } // replace BBCode tags $comment->comment = $bbcode->replace($comment->comment); if ($config->getInt('enable_custom_bbcode')) { $customBBCode =& JCommentsFactory::getCustomBBCode(); $comment->comment = $customBBCode->replace($comment->comment); } // fix long words problem $word_maxlength = $config->getInt('word_maxlength'); if ($word_maxlength > 0) { $comment->comment = JCommentsText::fixLongWords($comment->comment, $word_maxlength); if ($comment->title != '') { $comment->title = JCommentsText::fixLongWords($comment->title, $word_maxlength); } } if ($acl->check('emailprotection')) { $comment->comment = JComments::maskEmail($comment->id, $comment->comment); } // autolink urls if ($acl->check('autolinkurls')) { $comment->comment = preg_replace_callback(_JC_REGEXP_LINK, array('JComments', 'urlProcessor'), $comment->comment); if ($acl->check('emailprotection') != 1) { $comment->comment = preg_replace(_JC_REGEXP_EMAIL, '<a href="mailto:\\1@\\2">\\1@\\2</a>', $comment->comment); } } // replace smile codes with images if ($config->get('enable_smiles') == '1') { $smiles =& JCommentsFactory::getSmiles(); $comment->comment = $smiles->replace($comment->comment); } // Gravatar support $comment->gravatar = md5(strtolower($comment->email)); if (empty($comment->avatar)) { $comment->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id=' . $comment->gravatar . '&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="" />'; } $comment->author = JComments::getCommentAuthorName($comment); if ($config->getInt('enable_mambots') == 1) { JCommentsPluginHelper::trigger('onAfterPrepareComment', array(&$comment)); } }
function getCommentsFormFull() { $object_id = $this->getVar('comment-object_id'); $object_group = $this->getVar('comment-object_group'); $htmlBeforeForm = $this->getVar('comments-form-html-before'); $htmlAfterForm = $this->getVar('comments-form-html-after'); ?> <h4><?php echo JText::_('FORM_HEADER'); ?> </h4> <?php if ($this->getVar('comments-form-policy', 0) == 1) { ?> <div class="comments-policy"><?php echo $this->getVar('comments-policy'); ?> </div> <?php } echo $htmlBeforeForm; ?> <a id="addcomments" href="#addcomments"></a> <form id="comments-form" name="comments-form" action="javascript:void(null);"> <?php if ($this->getVar('comments-form-user-name', 1) == 1) { ?> <p> <input id="comments-form-name" type="text" name="name" value="" maxlength="<?php echo $this->getVar('comment-name-maxlength'); ?> " size="22" tabindex="1" /> <label for="comments-form-name"><?php echo JText::_('FORM_NAME'); ?> </label> </p> <?php } if ($this->getVar('comments-form-user-email', 1) == 1) { $text = $this->getVar('comments-form-email-required', 1) == 0 ? JText::_('FORM_EMAIL') : JText::_('FORM_EMAIL_REQUIRED'); ?> <p> <input id="comments-form-email" type="text" name="email" value="" size="22" tabindex="2" /> <label for="comments-form-email"><?php echo $text; ?> </label> </p> <?php } if ($this->getVar('comments-form-user-homepage', 0) == 1) { $text = $this->getVar('comments-form-homepage-required', 1) == 0 ? JText::_('FORM_HOMEPAGE') : JText::_('FORM_HOMEPAGE_REQUIRED'); ?> <p> <input id="comments-form-homepage" type="text" name="homepage" value="" size="22" tabindex="3" /> <label for="comments-form-homepage"><?php echo $text; ?> </label> </p> <?php } if ($this->getVar('comments-form-title', 0) == 1) { $text = $this->getVar('comments-form-title-required', 1) == 0 ? JText::_('FORM_TITLE') : JText::_('FORM_TITLE_REQUIRED'); ?> <p> <input id="comments-form-title" type="text" name="title" value="" size="22" tabindex="4" /> <label for="comments-form-title"><?php echo $text; ?> </label> </p> <?php } ?> <p> <textarea id="comments-form-comment" name="comment" cols="65" rows="8" tabindex="5"></textarea> </p> <?php if ($this->getVar('comments-form-subscribe', 0) == 1) { ?> <p> <input class="checkbox" id="comments-form-subscribe" type="checkbox" name="subscribe" value="1" tabindex="5" /> <label for="comments-form-subscribe"><?php echo JText::_('FORM_SUBSCRIBE'); ?> </label><br /> </p> <?php } if ($this->getVar('comments-form-captcha', 0) == 1) { $html = $this->getVar('comments-form-captcha-html'); if ($html != '') { echo $html; } else { $link = JCommentsFactory::getLink('captcha'); ?> <p> <img class="captcha" onclick="jcomments.clear('captcha');" id="comments-form-captcha-image" name="captcha-image" src="<?php echo $link; ?> " width="121" height="60" alt="<?php echo JText::_('FORM_CAPTCHA'); ?> " /><br /> <span class="captcha" onclick="jcomments.clear('captcha');"><?php echo JText::_('FORM_CAPTCHA_REFRESH'); ?> </span><br /> <input class="captcha" id="comments-form-captcha" type="text" name="captcha-refid" value="" size="5" tabindex="6" /><br /> </p> <?php } } ?> <div id="comments-form-buttons"> <div class="btn" id="comments-form-send"><div><a href="#" tabindex="7" onclick="jcomments.saveComment();return false;" title="<?php echo JText::_('FORM_SEND_HINT'); ?> "><?php echo JText::_('FORM_SEND'); ?> </a></div></div> <div class="btn" id="comments-form-cancel" style="display:none;"><div><a href="#" tabindex="8" onclick="return false;" title="<?php echo JText::_('FORM_CANCEL'); ?> "><?php echo JText::_('FORM_CANCEL'); ?> </a></div></div> <div style="clear:both;"></div> </div> <input type="hidden" name="object_id" value="<?php echo $object_id; ?> " /> <input type="hidden" name="object_group" value="<?php echo $object_group; ?> " /> </form> <script type="text/javascript"> <!-- function JCommentsInitializeForm() { var jcEditor = new JCommentsEditor('comments-form-comment', true); <?php if ($this->getVar('comments-form-bbcode', 0) == 1) { $bbcodes = array('b' => array(0 => JText::_('FORM_BBCODE_B'), 1 => JText::_('Enter text')), 'i' => array(0 => JText::_('FORM_BBCODE_I'), 1 => JText::_('Enter text')), 'u' => array(0 => JText::_('FORM_BBCODE_U'), 1 => JText::_('Enter text')), 's' => array(0 => JText::_('FORM_BBCODE_S'), 1 => JText::_('Enter text')), 'img' => array(0 => JText::_('FORM_BBCODE_IMG'), 1 => JText::_('Enter full URL to the image')), 'url' => array(0 => JText::_('FORM_BBCODE_URL'), 1 => JText::_('Enter full URL')), 'hide' => array(0 => JText::_('FORM_BBCODE_HIDE'), 1 => JText::_('Enter text to hide it from unregistered')), 'quote' => array(0 => JText::_('FORM_BBCODE_QUOTE'), 1 => JText::_('Enter text to quote')), 'list' => array(0 => JText::_('FORM_BBCODE_LIST'), 1 => JText::_('Enter list item text'))); foreach ($bbcodes as $k => $v) { if ($this->getVar('comments-form-bbcode-' . $k, 0) == 1) { $title = trim(JCommentsText::jsEscape($v[0])); $text = trim(JCommentsText::jsEscape($v[1])); ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> '); <?php } } } $customBBCodes = $this->getVar('comments-form-custombbcodes'); if (count($customBBCodes)) { foreach ($customBBCodes as $code) { if ($code->button_enabled) { $k = 'custombbcode' . $code->id; $title = trim(JCommentsText::jsEscape($code->button_title)); $text = empty($code->button_prompt) ? JText::_('Enter text') : JText::_($code->button_prompt); $open_tag = $code->button_open_tag; $close_tag = $code->button_close_tag; $icon = $code->button_image; $css = $code->button_css; ?> jcEditor.addButton('<?php echo $k; ?> ','<?php echo $title; ?> ','<?php echo $text; ?> ','<?php echo $open_tag; ?> ','<?php echo $close_tag; ?> ','<?php echo $css; ?> ','<?php echo $icon; ?> '); <?php } } } $smiles = $this->getVar('comment-form-smiles'); if (isset($smiles)) { if (is_array($smiles) && count($smiles) > 0) { ?> jcEditor.initSmiles('<?php echo $this->getVar("smilesurl"); ?> '); <?php foreach ($smiles as $code => $icon) { $code = trim(JCommentsText::jsEscape($code)); $icon = trim(JCommentsText::jsEscape($icon)); ?> jcEditor.addSmile('<?php echo $code; ?> ','<?php echo $icon; ?> '); <?php } } } if ($this->getVar('comments-form-showlength-counter', 0) == 1) { ?> jcEditor.addCounter(<?php echo $this->getVar('comment-maxlength'); ?> , '<?php echo JText::_('FORM_CHARSLEFT_PREFIX'); ?> ', '<?php echo JText::_('FORM_CHARSLEFT_SUFFIX'); ?> ', 'counter'); <?php } ?> jcomments.setForm(new JCommentsForm('comments-form', jcEditor)); } <?php if ($this->getVar('comments-form-ajax', 0) == 1) { ?> setTimeout(JCommentsInitializeForm, 100); <?php } else { ?> if (window.addEventListener) {window.addEventListener('load',JCommentsInitializeForm,false);} else if (document.addEventListener){document.addEventListener('load',JCommentsInitializeForm,false);} else if (window.attachEvent){window.attachEvent('onload',JCommentsInitializeForm);} else {if (typeof window.onload=='function'){var oldload=window.onload;window.onload=function(){oldload();JCommentsInitializeForm();}} else window.onload=JCommentsInitializeForm;} <?php } ?> //--> </script> <?php echo $htmlAfterForm; }
function render() { $comment = $this->getVar('comment'); $object_title = $this->getVar('comment-object_title'); $object_link = $this->getVar('comment-object_link'); // add inline styles for quotes to default comment html layout $comment->comment = str_replace('<blockquote>', '<blockquote style="border-left: 2px solid #ccc; padding-left: 5px; margin-left: 10px;">', $comment->comment); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=<? echo $this->getVar('charset'); ?>" http-equiv="content-type" /> <meta name="Generator" content="JComments" /> </head> <body> <? echo JText::_('COMMENTS_FOR'); ?>: <a href="<? echo $object_link ?>#comment-<? echo $comment->id; ?>" target="_blank"><? echo $object_title ?></a><br /><br /> <a style="color: #777;" href="<? echo $object_link ?>#comment-<? echo $comment->id; ?>" target="_bllank">#</a> <? if ($comment->title != '') { ?> <span style="color: #b01625;font: bold 1em Verdana, Arial, Sans-Serif;"><? echo $comment->title; ?></span> — <? } if ($comment->homepage != '') { ?> <a style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;" href="<? echo $comment->homepage; ?>" target="_blank"><? echo $comment->name; ?></a> <? } else { ?> <span style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;"><? echo $comment->name; ?></span> <? } ?> ( <? if ($comment->email != '') { ?> <a href="mailto: <? echo $comment->email; ?>" target="_blank"><? echo $comment->email; ?></a>, <? } ?> <span style="font-size: 11px;">IP: <? echo $comment->ip; ?></span> ) — <span style="font-size: 11px; color: #999;"><? echo JCommentsText::formatDate($comment->datetime, JText::_('DATETIME_FORMAT')); ?></span> <div style="border: 1px solid #ccc; padding: 10px 5px; margin: 5px 0; font: normal 1em Verdana, Arial, Sans-Serif;"><? echo $comment->comment; ?></div> <? if ($this->getVar('quick-moderation') == 1) { $commands = array(); if ($comment->published == 0) { $commands[] = $this->getCmdLink('publish', JText::_('Publish'), $comment); } else { $commands[] = $this->getCmdLink('unpublish', JText::_('Unpublish'), $comment); } $commands[] = $this->getCmdLink('delete', JText::_('Delete'), $comment); if (count($commands)) { echo JText::_('Quick moderation') . ' ' . implode(' | ', $commands); } } ?> </body> </html> <? }
function render() { $comment = $this->getVar('comment'); $object_title = $this->getVar('comment-object_title'); $object_link = $this->getVar('comment-object_link'); // add inline styles $comment->comment = str_replace('class="quotebody"', 'style="margin: 5px 0 0 0;padding: 8px; border: 1px dashed #aaa;"', $comment->comment); $comment->comment = str_replace('<blockquote>', '<blockquote style="border-left: 2px solid #ccc; padding-left: 5px; margin-left: 10px;">', $comment->comment); $comment->comment = str_replace('<code>', '<code style="display: block; padding: 8px; border: 1px dashed #aaa;">', $comment->comment); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <meta name="Generator" content="JComments" /> </head> <body> <?php echo JText::_('NOTIFICATION_DISCUSSION'); ?> <a href="<?php echo $object_link; ?> #comment-<?php echo $comment->id; ?> " target="_blank"><?php echo $object_title; ?> </a><br /><br /> <a style="color: #777;" href="<?php echo $object_link; ?> #comment-<?php echo $comment->id; ?> " target="_bllank">#</a> <?php if ($comment->title != '') { ?> <span style="color: #b01625;font: bold 1em Verdana, Arial, Sans-Serif;"><?php echo $comment->title; ?> </span> — <?php } if ($comment->homepage != '') { ?> <a style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;" href="<?php echo $comment->homepage; ?> " target="_blank"><?php echo $comment->author; ?> </a> <?php } else { ?> <span style="color: #3c452d;font: bold 1em Verdana, Arial, Sans-Serif;"><?php echo $comment->author; ?> </span> <?php } ?> ( <?php if ($comment->email != '') { ?> <a href="mailto: <?php echo $comment->email; ?> " target="_blank"><?php echo $comment->email; ?> </a>, <?php } ?> <span style="font-size: 11px;">IP: <?php echo $comment->ip; ?> </span> ) — <span style="font-size: 11px; color: #999;"><?php echo JCommentsText::formatDate($comment->date, JText::_('DATETIME_FORMAT')); ?> </span> <div> <div style="border: 1px solid #ccc; padding: 10px 5px; margin: 5px 0; font: normal 1em Verdana, Arial, Sans-Serif;"><?php echo $comment->comment; ?> </div> <?php if ($this->getVar('quick-moderation') == 1) { $commands = array(); if ($comment->published == 0) { $commands[] = $this->getCmdLink('publish', JText::_('BUTTON_PUBLISH'), $comment); } else { $commands[] = $this->getCmdLink('unpublish', JText::_('BUTTON_UNPUBLISH'), $comment); } $commands[] = $this->getCmdLink('delete', JText::_('BUTTON_DELETE'), $comment); if ($this->getVar('enable-blacklist') == 1) { $commands[] = $this->getCmdLink('ban', JText::_('BUTTON_BANIP'), $comment); } if (count($commands)) { echo JText::_('QUICK_MODERATION') . ' ' . implode(' | ', $commands); } } ?> </div> </body> </html> <?php }
public static function showUserComments() { $config = JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $app = JCommentsFactory::getApplication('site'); $acl = JCommentsFactory::getACL(); $userid = (int) JCommentsInput::getVar('userid', 0); $limit = (int) JCommentsInput::getVar('limit', $config->getInt('feed_limit', 100)); $user = JCommentsFactory::getUser($userid); if (!isset($user->id)) { self::showNotFound(); return; } if (JCOMMENTS_JVERSION == '1.0') { $offset = $app->getCfg('offset') + date('O') / 100; } else { $offset = $app->getCfg('offset'); } $lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&lang=' . $language; } else { $language = null; $lp = ''; } if (JCOMMENTS_JVERSION == '1.0') { $syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&no_html=1'; } else { $liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site')); $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&tmpl=raw'); } $user->userid = $user->id; $username = JComments::getCommentAuthorName($user); $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = JCOMMENTS_ENCODING; $rss->title = JText::sprintf('USER_FEED_TITLE', $username); $rss->link = $app->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username); $options = array(); $options['lang'] = $language; $options['userid'] = $userid; $options['published'] = 1; $options['filter'] = 'c.deleted = 0'; $options['orderBy'] = 'c.date DESC'; $options['votes'] = false; $options['limit'] = $limit; $options['limitStart'] = 0; $options['objectinfo'] = true; $options['access'] = $acl->getUserAccess(); $rows = JCommentsModel::getCommentsList($options); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); if ($comment != '') { // getting object's information (title and link) $object_title = empty($row->object_title) ? JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang) : $row->object_title; $object_link = empty($row->object_link) ? JCommentsObjectHelper::getLink($row->object_id, $row->object_group, $lang) : $row->object_link; $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $object_link)); // apply censor filter $object_title = JCommentsText::censor($object_title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($object_title != '') { $object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' '); } } $author = JComments::getCommentAuthorName($row); $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment); $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.0') { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } else { $item->pubDate = $row->date; } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
/** * Inserts a separator in a very long continuous sequences of characters * @param string $text The input string. * @param int $maxLength The maximum length of sequence. * @param string $customBreaker The custom string to be used as breaker. * @return string Returns the altered string. */ public static function fixLongWords($text, $maxLength, $customBreaker = '') { $maxLength = (int) min(65535, $maxLength); if ($maxLength > 5) { ob_start(); if ($customBreaker == '') { if (!empty($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { $breaker = '<span style="margin: 0 -0.65ex 0 -1px;padding:0;"> </span>'; } else { $breaker = '<span style="font-size:0;padding:0;margin:0;"> </span>'; } } else { $breaker = $customBreaker; } $plainText = $text; $plainText = preg_replace(_JC_REGEXP_EMAIL, '', $plainText); $plainText = preg_replace('#<br\\s?/?>#is' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<img[^\\>]+/>#is' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<a.*?>(.*?)</a>#is' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<span class="quote">(.*?)</span>#is', '', $plainText); $plainText = preg_replace('#<span[^\\>]*?>(.*?)</span>#is', '\\1', $plainText); $plainText = preg_replace('#<pre.*?>(.*?)</pre>#isU' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<blockquote.*?>(.*?)</blockquote>#isU' . JCOMMENTS_PCRE_UTF8, '\\1 ', $plainText); $plainText = preg_replace('#<code.*?>(.*?)</code>#isU' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<embed.*?>(.*?)</embed>#is' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<object.*?>(.*?)</object>#is' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#(^|\\s|\\>|\\()((http://|https://|news://|ftp://|www.)\\w+[^\\s\\[\\]\\<\\>\\"\'\\)]+)#i' . JCOMMENTS_PCRE_UTF8, '', $plainText); $plainText = preg_replace('#<(b|strong|i|em|u|s|del|sup|sub|li)>(.*?)</(b|strong|i|em|u|s|del|sup|sub|li)>#is' . JCOMMENTS_PCRE_UTF8, '\\2 ', $plainText); $words = explode(' ', $plainText); foreach ($words as $word) { if (JCommentsText::strlen($word) > $maxLength) { $text = str_replace($word, JCommentsText::wordwrap($word, $maxLength, $breaker, true), $text); } } ob_end_clean(); } return $text; }
function feedLastCommentsGlobal() { global $mainframe; $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', ''))); $object_group = preg_replace('#[^0-9A-Za-z\\-\\_\\,\\.]#is', '', $object_group); $limit = (int) JCommentsInput::getVar('limit', 100); $config =& JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $iso = explode('=', _ISO); $charset = strtolower((string) $iso[1]); if (JCOMMENTS_JVERSION == '1.5') { $offset = $mainframe->getCfg('offset'); } else { $offset = $mainframe->getCfg('offset') + date('O') / 100; } $object_group = preg_replace('#[\'\\"]#ism', '', $object_group); $og = $object_group ? '&object_group=' . $object_group : ''; $lm = $limit != 100 ? '&limit=' . $limit : ''; if (JCOMMENTS_JVERSION == '1.5') { $syndicationURL = JoomlaTuneRoute::_('index.php?option=com_jcomments&task=rss_full' . $og . $lm . '&tmpl=component'); } else { $syndicationURL = $mainframe->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_full' . $og . $lm . '&no_html=1'; } $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = $charset; $rss->title = JText::_('Comments'); $rss->link = $mainframe->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::_('COMMENTS_FOR') . ' ' . $mainframe->getCfg('sitename'); if ($object_group != '') { $groups = explode(',', $object_group); } else { $groups = array(); } $db =& JCommentsFactory::getDBO(); $query = "SELECT id, title, object_id, object_group, userid, name, username, date, UNIX_TIMESTAMP(date) as date_ts, comment" . "\nFROM #__jcomments " . "\nWHERE published = '1'" . (count($groups) > 0 ? "\n AND (object_group = '" . implode("' OR object_group='", $groups) . "')" : '') . (JCommentsMultilingual::isEnabled() ? "\nAND lang = '" . JCommentsMultilingual::getLanguage() . "'" : "") . "\nORDER BY date DESC"; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); $author = JComments::getCommentAuthorName($row); if ($comment != '') { $object_title = JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang); $object_link = JCommentsObjectHelper::getLink($row->object_id, $row->object_group); $object_link = str_replace('amp;', '', $object_link); $object_link = JCommentsFactory::getAbsLink($object_link); // apply censor filter $object_title = JCommentsText::censor($object_title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($comment != '') { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); } } $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = $author . ' ' . JText::_('Wrote') . ' "' . $comment . '"'; $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.5') { $item->pubDate = $row->date; } else { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
/** * 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; }
public static function reportComment() { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $acl = JCommentsFactory::getACL(); $db = JCommentsFactory::getDBO(); $config = JCommentsFactory::getConfig(); $response = JCommentsFactory::getAjaxResponse(); $values = self::prepareValues($_POST); $id = (int) $values['commentid']; $reason = trim(strip_tags($values['reason'])); $name = trim(strip_tags($values['name'])); $ip = $acl->getUserIP(); if (empty($reason)) { if ($config->getInt('report_reason_required') == 1) { self::showErrorMessage(JText::_('ERROR_NO_REASON_FOR_REPORT'), '', 'comments-report-form'); return $response; } else { $reason = JText::_('REPORT_REASON_UNKNOWN_REASON'); } } $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id; if ($acl->getUserId()) { $query .= ' AND userid = ' . $acl->getUserId(); } else { $query .= ' AND userid = 0 AND ip = "' . $ip . '"'; } $db->setQuery($query); $reported = $db->loadResult(); if (!$reported) { $maxReportsPerComment = $config->getInt('reports_per_comment', 1); $maxReportsBeforeUnpublish = $config->getInt('reports_before_unpublish', 0); $db->setQuery('SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id); $reported = $db->loadResult(); if ($reported < $maxReportsPerComment || $maxReportsPerComment == 0) { $comment = new JCommentsTableComment($db); if ($comment->load($id)) { if ($acl->canReport($comment)) { if ($acl->getUserId()) { $user = JCommentsFactory::getUser(); $name = $user->name; } else { if (empty($name)) { $name = 'Guest'; // JText::_('Guest'); } } require_once JCOMMENTS_TABLES . '/report.php'; $report = new JCommentsTableReport($db); $report->commentid = $comment->id; $report->date = JCommentsFactory::getDate(); $report->userid = $acl->getUserId(); $report->ip = $ip; $report->name = $name; $report->reason = $reason; $html = ''; $result = JCommentsEvent::trigger('onJCommentsCommentBeforeReport', array(&$comment, &$report)); if (!in_array(false, $result, true)) { if ($report->store()) { JCommentsEvent::trigger('onJCommentsCommentAfterReport', array(&$comment, $report)); if ($config->getInt('enable_notification') == 1) { if ($config->check('notification_type', 2)) { JComments::sendReport($comment, $name, $reason); } } // unpublish comment if reports count is enough if ($maxReportsBeforeUnpublish > 0 && $reported >= $maxReportsBeforeUnpublish) { $comment->published = 0; $comment->store(); } $html = JText::_('REPORT_SUCCESSFULLY_SENT'); $html = str_replace("\n", '\\n', $html); $html = str_replace('\\n', '<br />', $html); $html = JCommentsText::jsEscape($html); } } $response->addScript("jcomments.closeReport('{$html}');"); } else { self::showErrorMessage(JText::_('ERROR_YOU_HAVE_NO_RIGHTS_TO_REPORT'), '', 'comments-report-form'); } } else { $response->addAlert(JText::_('ERROR_NOT_FOUND')); } } else { self::showErrorMessage(JText::_('ERROR_COMMENT_ALREADY_REPORTED'), '', 'comments-report-form'); } } else { self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_REPORT_THE_SAME_COMMENT_MORE_THAN_ONCE'), '', 'comments-report-form'); } return $response; }
function reportComment() { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $acl =& JCommentsFactory::getACL(); $db =& JCommentsFactory::getDBO(); $config =& JCommentsFactory::getConfig(); $response =& JCommentsFactory::getAjaxResponse(); $values = JCommentsAJAX::prepareValues($_POST); $id = (int) $values['commentid']; $reason = trim(strip_tags($values['reason'])); $name = trim(strip_tags($values['name'])); $ip = $acl->getUserIP(); if ($reason == '') { JCommentsAJAX::showErrorMessage(JText::_('Please enter the reason for your report!'), '', 'comments-report-form'); return $response; } $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id; if ($acl->getUserId()) { $query .= ' AND userid = ' . $acl->getUserId(); } else { $query .= ' AND ip = "' . $ip . '"'; } $db->setQuery($query); $reported = $db->loadResult(); if (!$reported) { $query = 'SELECT COUNT(*) FROM `#__jcomments_reports` WHERE commentid = ' . $id; $db->setQuery($query); $reported = $db->loadResult(); if (!$reported) { $comment = new JCommentsDB($db); if ($comment->load($id)) { if ($acl->canReport($comment)) { $allowed = true; if ($config->getInt('enable_mambots') == 1) { require_once JCOMMENTS_HELPERS . DS . 'plugin.php'; JCommentsPluginHelper::importPlugin('jcomments'); JCommentsPluginHelper::trigger('onReportComment', array(&$comment, &$response, &$allowed, &$value)); } if ($allowed !== false) { if ($acl->getUserId()) { $user = JCommentsFactory::getUser(); $name = $user->name; } else { if ($name == '') { $name = JText::_('Guest'); } } $query = "INSERT INTO `#__jcomments_reports`(`commentid`,`userid`, `name`,`ip`,`date`,`reason`)" . "VALUES('" . $comment->id . "', '" . $acl->getUserId() . "', '" . $db->getEscaped($name) . "', '" . $db->getEscaped($ip) . "', now(), '" . $db->getEscaped($reason) . "')"; $db->setQuery($query); $db->query(); if ($config->getInt('enable_notification') == 1) { if ($config->check('notification_type', 2)) { $comment->datetime = $comment->date; if (is_string($comment->datetime)) { $comment->datetime = strtotime($comment->datetime); } JComments::sendReport($comment, $name, $reason); } } $html = JText::_('Report successfully sent!'); $html = str_replace("\n", '\\n', $html); $html = str_replace('\\n', '<br />', $html); $html = JCommentsText::jsEscape($html); $response->addScript("jcomments.closeReport('{$html}');"); } } else { JCommentsAJAX::showErrorMessage(JText::_('You have no rights to report comment!'), '', 'comments-report-form'); } } else { $response->addAlert(JText::_('ERROR_NOT_FOUND')); } unset($comment); } else { JCommentsAJAX::showErrorMessage(JText::_('Comment already reported to the site administrator'), '', 'comments-report-form'); } } else { JCommentsAJAX::showErrorMessage(JText::_('You can\'t report the same comment more than once!'), '', 'comments-report-form'); } return $response; }
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') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&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&task=rss_user&userid=' . $userid . $lm . $lp . '&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; } }
function render() { $comment = $this->getVar('comment'); if (isset($comment)) { if ($this->getVar('get_comment_vote', 0) == 1) { // return comment vote $this->getCommentVoteValue($comment); } else { if ($this->getVar('get_comment_body', 0) == 1) { // return only comment body (for example after quick edit) echo $comment->comment; } else { // return all comment item ?> <div class="rbox"> <?php $comment_number = $this->getVar('comment-number', 1); $thisurl = $this->getVar('thisurl', ''); $commentBoxIndentStyle = $this->getVar('avatar') == 1 ? ' avatar-indent' : ''; if ($this->getVar('avatar') == 1) { ?> <div class="comment-avatar"><?php echo $comment->avatar; ?> </div> <?php } ?> <div class="comment-box<?php echo $commentBoxIndentStyle; ?> "> <?php if ($this->getVar('comment-show-vote', 0) == 1) { $this->getCommentVote($comment); } ?> <a class="comment-anchor" href="<?php echo $thisurl; ?> #comment-<?php echo $comment->id; ?> " id="comment-<?php echo $comment->id; ?> ">#<?php echo $comment_number; ?> </a> <?php if ($this->getVar('comment-show-title') > 0 && $comment->title != '') { ?> <span class="comment-title"><?php echo $comment->title; ?> </span> — <?php } if ($this->getVar('comment-show-homepage') == 1) { ?> <a class="author-homepage" href="<?php echo $comment->homepage; ?> " rel="nofollow" title="<?php echo $comment->author; ?> "><?php echo $comment->author; ?> </a> <?php } else { ?> <span class="comment-author"><?php echo $comment->author; ?> </span> <?php } if ($this->getVar('comment-show-email') > 0 && $comment->email != '') { ?> <a class="comment-email" href="mailto:<?php echo $comment->email; ?> "><?php echo $comment->email; ?> </a> <?php } ?> <span class="comment-date"><?php echo JCommentsText::formatDate($comment->date, JText::_('DATETIME_FORMAT')); ?> </span> <div class="comment-body" id="comment-body-<?php echo $comment->id; ?> "><?php echo $comment->comment; ?> </div> <?php if ($this->getVar('button-reply') == 1 || $this->getVar('button-quote') == 1 || $this->getVar('button-report') == 1) { ?> <span class="comments-buttons"> <?php if ($this->getVar('button-reply') == 1) { ?> <a href="#" onclick="jcomments.showReply(<?php echo $comment->id; ?> ); return false;"><?php echo JText::_('BUTTON_REPLY'); ?> </a> <?php if ($this->getVar('button-quote') == 1) { ?> | <a href="#" onclick="jcomments.showReply(<?php echo $comment->id; ?> ,1); return false;"><?php echo JText::_('BUTTON_REPLY_WITH_QUOTE'); ?> </a> | <?php } } if ($this->getVar('button-quote') == 1) { ?> <a href="#" onclick="jcomments.quoteComment(<?php echo $comment->id; ?> ); return false;"><?php echo JText::_('BUTTON_QUOTE'); ?> </a> <?php } if ($this->getVar('button-report') == 1) { if ($this->getVar('button-quote') == 1 || $this->getVar('button-reply') == 1) { ?> | <?php } ?> <a href="#" onclick="jcomments.reportComment(<?php echo $comment->id; ?> ); return false;"><?php echo JText::_('BUTTON_REPORT'); ?> </a> <?php } ?> </span> <?php } ?> </div><div class="clear"></div> <?php // show frontend moderation panel $this->getCommentAdministratorPanel($comment); ?> </div> <?php } } } }
function strip($str) { if (count($this->_smiles) == 0) { return $str; } $str = JCommentsText::br2nl($str); $str = preg_replace($this->_smiles['code'], '\\1\\3', $str); $str = JCommentsText::nl2br($str); return $str; }