Ejemplo n.º 1
0
 function store($updateNulls = false)
 {
     if ($this->source != '') {
         if ($this->name == '') {
             $this->name = 'Guest';
         } else {
             $this->name = JCommentsMigrationTool::processName($this->name);
         }
         if ($this->username == '') {
             $this->username = $this->name;
         } else {
             $this->username = JCommentsMigrationTool::processName($this->username);
         }
         $this->email = strip_tags($this->email);
         $this->homepage = strip_tags($this->homepage);
         $this->title = strip_tags($this->title);
         $this->comment = JCommentsMigrationTool::processComment(stripslashes($this->comment));
         if (!isset($this->source_id)) {
             $this->source_id = 0;
         }
     }
     return parent::store($updateNulls);
 }
Ejemplo n.º 2
0
 public function store($updateNulls = false)
 {
     $config = JCommentsFactory::getConfig();
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         $language = JFactory::getLanguage();
         $language->load('com_jcomments', JPATH_SITE);
         if ($this->id == 0 && !empty($this->source)) {
             $this->comment = $this->clearComment($this->comment);
             $this->homepage = strip_tags($this->homepage);
             $this->title = strip_tags($this->title);
             if (!$this->userid) {
                 $this->name = $this->clearComment($this->name);
                 $this->username = $this->clearComment($this->username);
             }
         }
     }
     if ($this->parent > 0) {
         $parent = new JCommentsTableComment($this->_db);
         if ($parent->load($this->parent)) {
             if (empty($this->title) && $config->getInt('comment_title') == 1) {
                 if (!empty($parent->title)) {
                     if (strpos($parent->title, JText::_('COMMENT_TITLE_RE')) === false) {
                         $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $parent->title;
                     } else {
                         $this->title = $parent->title;
                     }
                 }
             }
             $this->thread_id = $parent->thread_id ? $parent->thread_id : $parent->id;
             $this->level = $parent->level + 1;
             $this->path = $parent->path . ',' . $parent->id;
         }
     } else {
         if (empty($this->title) && $config->getInt('comment_title') == 1) {
             $title = JCommentsObjectHelper::getTitle($this->object_id, $this->object_group, $this->lang);
             if (!empty($title)) {
                 $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $title;
             }
         }
         $this->path = '0';
     }
     if (isset($this->datetime)) {
         unset($this->datetime);
     }
     if (isset($this->author)) {
         unset($this->author);
     }
     return parent::store($updateNulls);
 }
Ejemplo n.º 3
0
 public static function remove()
 {
     JCommentsSecurity::checkToken();
     $cid = JCommentsInput::getVar('cid', array());
     if (is_array($cid)) {
         $db = JCommentsFactory::getDBO();
         $config = JCommentsFactory::getConfig();
         if ($config->getInt('delete_mode') == 0) {
             JCommentsModel::deleteCommentsByIds($cid);
         } else {
             $comment = new JCommentsTableComment($db);
             foreach ($cid as $id) {
                 $comment->reset();
                 if ($comment->load($id)) {
                     $comment->markAsDeleted();
                 }
             }
         }
         $cache = JCommentsFactory::getCache('com_jcomments');
         $cache->clean();
     }
     JCommentsRedirect(JCOMMENTS_INDEX . '?option=com_jcomments&task=comments');
 }
Ejemplo n.º 4
0
 public function store($updateNulls = false)
 {
     $config = JCommentsFactory::getConfig();
     if ($this->parent > 0) {
         $parent = new JCommentsTableComment($this->_db);
         if ($parent->load($this->parent)) {
             if (empty($this->title) && $config->getInt('comment_title') == 1) {
                 if (!empty($parent->title)) {
                     if (strpos($parent->title, JText::_('COMMENT_TITLE_RE')) === false) {
                         $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $parent->title;
                     } else {
                         $this->title = $parent->title;
                     }
                 }
             }
             $this->thread_id = $parent->thread_id ? $parent->thread_id : $parent->id;
             $this->level = $parent->level + 1;
             $this->path = $parent->path . ',' . $parent->id;
         }
     } else {
         if (empty($this->title) && $config->getInt('comment_title') == 1) {
             $title = JCommentsObjectHelper::getTitle($this->object_id, $this->object_group, $this->lang);
             if (!empty($title)) {
                 $this->title = JText::_('COMMENT_TITLE_RE') . ' ' . $title;
             }
         }
         $this->path = '0';
     }
     if (isset($this->datetime)) {
         unset($this->datetime);
     }
     if (isset($this->author)) {
         unset($this->author);
     }
     return parent::store($updateNulls);
 }
Ejemplo n.º 5
0
 public static function executeCmd()
 {
     $app = JCommentsFactory::getApplication('site');
     $cmd = strtolower(JCommentsInput::getVar('cmd', ''));
     $hash = JCommentsInput::getVar('hash', '');
     $id = (int) JCommentsInput::getVar('id', 0);
     $message = '';
     $link = $app->getCfg('live_site') . '/index.php';
     $checkHash = JCommentsFactory::getCmdHash($cmd, $id);
     if ($hash == $checkHash) {
         $config = JCommentsFactory::getConfig();
         if ($config->getInt('enable_quick_moderation') == 1) {
             $db = JCommentsFactory::getDBO();
             $comment = new JCommentsTableComment($db);
             if ($comment->load($id)) {
                 $link = JCommentsObjectHelper::getLink($comment->object_id, $comment->object_group, $comment->lang);
                 $link = str_replace('&', '&', $link);
                 switch ($cmd) {
                     case 'publish':
                         $comment->published = 1;
                         $comment->store();
                         // send notification to comment subscribers
                         JComments::sendToSubscribers($comment, true);
                         $link .= '#comment-' . $comment->id;
                         break;
                     case 'unpublish':
                         $comment->published = 0;
                         $comment->store();
                         $acl = JCommentsFactory::getACL();
                         if ($acl->canPublish()) {
                             $link .= '#comment-' . $comment->id;
                         } else {
                             $link .= '#comments';
                         }
                         break;
                     case 'delete':
                         if ($config->getInt('delete_mode') == 0) {
                             $comment->delete();
                             $link .= '#comments';
                         } else {
                             $comment->markAsDeleted();
                             $link .= '#comment-' . $comment->id;
                         }
                         break;
                     case 'ban':
                         if ($config->getInt('enable_blacklist') == 1) {
                             $acl = JCommentsFactory::getACL();
                             // we will not ban own IP ;)
                             if ($comment->ip != $acl->getUserIP()) {
                                 $options = array();
                                 $options['ip'] = $comment->ip;
                                 // check if this IP already banned
                                 if (JCommentsSecurity::checkBlacklist($options)) {
                                     require_once JCOMMENTS_TABLES . '/blacklist.php';
                                     $blacklist = new JCommentsTableBlacklist($db);
                                     $blacklist->ip = $comment->ip;
                                     $blacklist->created = JCommentsFactory::getDate();
                                     $blacklist->created_by = $acl->getUserId();
                                     $blacklist->store();
                                     $message = JText::_('SUCCESSFULLY_BANNED');
                                 } else {
                                     $message = JText::_('ERROR_IP_ALREADY_BANNED');
                                 }
                             } else {
                                 $message = JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP');
                             }
                         }
                         break;
                 }
             } else {
                 $message = JText::_('ERROR_NOT_FOUND');
             }
         } else {
             $message = JText::_('ERROR_QUICK_MODERATION_DISABLED');
         }
     } else {
         $message = JText::_('ERROR_QUICK_MODERATION_INCORRECT_HASH');
     }
     JCommentsRedirect($link, $message);
 }
Ejemplo n.º 6
0
 public static function BanIP($id)
 {
     if (JCommentsSecurity::badRequest() == 1) {
         JCommentsSecurity::notAuth();
     }
     $acl = JCommentsFactory::getACL();
     $response = JCommentsFactory::getAjaxResponse();
     if ($acl->canBan()) {
         $config = JCommentsFactory::getConfig();
         if ($config->getInt('enable_blacklist') == 1) {
             $id = (int) $id;
             $db = JCommentsFactory::getDBO();
             $comment = new JCommentsTableComment($db);
             if ($comment->load($id)) {
                 // we will not ban own IP ;)
                 if ($comment->ip != $acl->getUserIP()) {
                     $options = array();
                     $options['ip'] = $comment->ip;
                     // check if this IP already banned
                     if (JCommentsSecurity::checkBlacklist($options)) {
                         $result = JCommentsEvent::trigger('onJCommentsUserBeforeBan', array(&$comment, &$options));
                         if (!in_array(false, $result, true)) {
                             require_once JCOMMENTS_TABLES . '/blacklist.php';
                             $blacklist = new JCommentsTableBlacklist($db);
                             $blacklist->ip = $comment->ip;
                             $blacklist->created = JCommentsFactory::getDate();
                             $blacklist->created_by = $acl->getUserId();
                             if ($blacklist->store()) {
                                 JCommentsEvent::trigger('onJCommentsUserAfterBan', array(&$comment, $options));
                                 self::showInfoMessage(JText::_('SUCCESSFULLY_BANNED'), 'comment-item-' . $id);
                             }
                         }
                     } else {
                         self::showErrorMessage(JText::_('ERROR_IP_ALREADY_BANNED'), '', 'comment-item-' . $id);
                     }
                 } else {
                     self::showErrorMessage(JText::_('ERROR_YOU_CAN_NOT_BAN_YOUR_IP'), '', 'comment-item-' . $id);
                 }
             }
         }
     }
     return $response;
 }