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 saveSettingsAjax() { $response = JCommentsFactory::getAjaxResponse(); $jtx64 = JCommentsInput::getVar('jtx64', ''); if ($jtx64 != '') { $jtx64 = base64_decode(urldecode($jtx64)); $data = array(); parse_str($jtx64, $data); if (JCOMMENTS_JVERSION == '1.0') { require_once JCOMMENTS_BASE . '/jcomments.ajax.php'; $data = JCommentsAJAX::convertEncoding($data); } $_POST = array_merge($_POST, $data); $_REQUEST = array_merge($_REQUEST, $data); } $lang = JCommentsAdmin::loadSettingsByLanguage(JCommentsInput::getVar('lang', '')); $message = JCommentsAdmin::saveSettings($lang); $response->addScript("jcbackend.showMessage('{$message}', 'info', 'jcomments-message-holder', 1);"); return $response; }
case 'unsubscribe': JComments::unsubscribe(); break; case 'cmd': JComments::executeCmd(); break; case 'notifications-cron': $limit = $app->input->getInt('limit', 10); $secret = trim($app->input->get('secret', '')); if ($secret == $app->getCfg('secret')) { JCommentsNotificationHelper::send($limit); } break; case 'refreshObjectsAjax': require_once JCOMMENTS_SITE . '/jcomments.ajax.php'; JCommentsAJAX::refreshObjectsAjax(); exit; break; default: $jc_option = $app->input->get('option', ''); $jc_ajax = $app->input->get('jtxf', ''); if ($jc_option == 'com_jcomments' && $jc_ajax == '' && !$app->isAdmin()) { $_Itemid = $app->input->getInt('Itemid'); $_tmpl = $app->input->get('tmpl'); if ($_Itemid !== 0 && $_tmpl !== 'component') { // $params = JComponentHelper::getParams('com_jcomments'); $params = $app->getParams(); $object_group = $params->get('object_group'); $object_id = (int) $params->get('object_id', 0); if ($object_id != 0 && $object_group != '') { if ($params->get('language_suffix') != '') {
/** * 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 }