function quoteComment($id, $loadForm = 0) { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $db =& JCommentsFactory::getDBO(); $acl =& JCommentsFactory::getACL(); $config =& JCommentsFactory::getConfig(); $response =& JCommentsFactory::getAjaxResponse(); $comment = new JCommentsDB($db); $id = (int) $id; if ($comment->load($id)) { $comment_name = JComments::getCommentAuthorName($comment); $comment_text = JCommentsText::br2nl($comment->comment); if ($config->getInt('enable_nested_quotes') == 0) { $bbcode =& JCommentsFactory::getBBCode(); $comment_text = $bbcode->removeQuotes($comment_text); } if ($config->getInt('enable_custom_bbcode')) { $customBBCode =& JCommentsFactory::getCustomBBCode(); $comment_text = $customBBCode->filter($comment_text, true); } if ($acl->getUserId() == 0) { $bbcode =& JCommentsFactory::getBBCode(); $comment_text = $bbcode->removeHidden($comment_text); } if ($comment_text != '') { if ($acl->check('enable_autocensor')) { $comment_text = JCommentsText::censor($comment_text); } if (intval($loadForm) == 1) { $form = JComments::getCommentsForm($comment->object_id, $comment->object_group, true); $response->addAssign('comments-form-link', 'innerHTML', $form); } $comment_text = JCommentsText::jsEscape($comment_text); $text = "[quote name=\"" . $comment_name . "\"]" . $comment_text . "[/quote]\\n"; $response->addScript("jcomments.insertText('" . $text . "');"); } else { $response->addAlert(JText::_('ERROR_NOTHING_TO_QUOTE')); } } unset($comment); return $response; }
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)); }
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)); } }
/** * Cleans text of all formatting and scripting code * * @param $text string The input string. * @return string Returns the altered string. */ public static function cleanText($text) { $bbcode = JCommentsFactory::getBBCode(); $config = JCommentsFactory::getConfig(); $text = $bbcode->filter($text, true); if ($config->getInt('enable_custom_bbcode')) { $customBBCode = JCommentsFactory::getCustomBBCode(); $text = $customBBCode->filter($text, true); } $text = str_replace('<br />', ' ', $text); $text = preg_replace('#(\\s){2,}#ism' . JCOMMENTS_PCRE_UTF8, '\\1', $text); $text = preg_replace('#<script[^>]*>.*?</script>#ism' . JCOMMENTS_PCRE_UTF8, '', $text); $text = preg_replace('#<a\\s+.*?href="([^"]+)"[^>]*>([^<]+)<\\/a>#ism' . JCOMMENTS_PCRE_UTF8, '\\2 (\\1)', $text); $text = preg_replace('#<!--.+?-->#ism' . JCOMMENTS_PCRE_UTF8, '', $text); $text = preg_replace('# #ism' . JCOMMENTS_PCRE_UTF8, ' ', $text); $text = preg_replace('#&#ism' . JCOMMENTS_PCRE_UTF8, ' ', $text); $text = preg_replace('#"#ism' . JCOMMENTS_PCRE_UTF8, ' ', $text); $text = strip_tags($text); $text = htmlspecialchars($text); $text = html_entity_decode($text); //$text = html_entity_decode($text, ENT_COMPAT, JCOMMENTS_ENCODING); return $text; }
/** * 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; }