]> git.mjollnir.org Git - s9y.git/commitdiff
block comments based on entry title
authorgarvinhicking <garvinhicking>
Wed, 9 Nov 2005 09:08:40 +0000 (09:08 +0000)
committergarvinhicking <garvinhicking>
Wed, 9 Nov 2005 09:08:40 +0000 (09:08 +0000)
docs/NEWS
include/functions_comments.inc.php
plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php
plugins/serendipity_event_spamblock/lang_de.inc.php
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php

index 13bbb3b2dbe5ce2a49c14a621fdd0306bcecbabb..5cfbc320b9994a8a618e29a3d96b7f039cac6d8b 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Spamblock plugin can block comments when they only contain the
+     entry title (garvinhicking)
+
    * Make RSS feeds templatable with Smarty .tpl files (feed_*.tpl), so
      that you can easily customize your feeds layouts, inject nagging
      ads and so on (garvinhicking)
index f7c35eac8704368e9deadebbb73f93b2c324b8ff..0946fa59f44b00285c0944f66d7d01c57c02a6b6 100644 (file)
@@ -312,7 +312,7 @@ function serendipity_approveComment($cid, $entry_id, $force = false) {
 function serendipity_saveComment($id, $commentInfo, $type = 'NORMAL', $source = 'internal') {
     global $serendipity;
 
-    $query = "SELECT id, allow_comments, moderate_comments, last_modified, timestamp FROM {$serendipity['dbPrefix']}entries WHERE id = '". (int)$id ."'";
+    $query = "SELECT id, allow_comments, moderate_comments, last_modified, timestamp, title FROM {$serendipity['dbPrefix']}entries WHERE id = '". (int)$id ."'";
     $ca    = serendipity_db_query($query, true);
 
     $commentInfo['type'] = $type;
index ab338a97dc7f125c4cab2a27a99493956e1cdbcb..e1a6f2f16860ddb81c37382b544ae353e16de14c 100644 (file)
@@ -79,3 +79,5 @@
         @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Blockade dieser URL via Spamschutz aufheben');
 
         @define('PLUGIN_EVENT_SPAMBLOCK_BLOGG_SPAMLIST', 'URL-Filterung anhand der blogg.de Blacklist aktivieren');
+        @define('PLUGIN_EVENT_SPAMBLOCK_REASON_TITLE', 'Artikeltitel ist derselbe wie Kommentar');
+        @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Kommentare abweisen, die als Text nur den Artikeltitel enthalten');
index cea8e2c962bcf70b0f9dc92fc0e5f90c7d715b87..ed9f52f84945e81b23bd7d64b396f94ca89836ab 100644 (file)
@@ -79,3 +79,5 @@
         @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Blockade dieser URL via Spamschutz aufheben');
 
         @define('PLUGIN_EVENT_SPAMBLOCK_BLOGG_SPAMLIST', 'URL-Filterung anhand der blogg.de Blacklist aktivieren');
+        @define('PLUGIN_EVENT_SPAMBLOCK_REASON_TITLE', 'Artikeltitel ist derselbe wie Kommentar');
+        @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Kommentare abweisen, die als Text nur den Artikeltitel enthalten');
index 91c9f1bf714e69039a240bc772ae08eb3f11bf13..457cc478a35be4472e0716129ae30b0635aa3322 100644 (file)
@@ -95,6 +95,9 @@ if (!function_exists('serendipity_serverOffsetHour')) {
 @define('PLUGIN_EVENT_SPAMBLOCK_BLOGG_SPAMLIST', 'Activate URL filtering by blogg.de Blacklist');
 @define('PLUGIN_EVENT_SPAMBLOCK_REASON_BLOGG_SPAMLIST', 'Filtered by blogg.de Blacklist');
 
+@define('PLUGIN_EVENT_SPAMBLOCK_REASON_TITLE', 'Entry title equals comment');
+@define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Reject comments which only contain the entry title');
+
 class serendipity_event_spamblock extends serendipity_event
 {
 var $filter_defaults;
@@ -114,7 +117,7 @@ var $filter_defaults;
             'smarty'      => '2.6.7',
             'php'         => '4.1.0'
         ));
-        $propbag->add('version',       '1.26');
+        $propbag->add('version',       '1.27');
         $propbag->add('event_hooks',    array(
             'frontend_saveComment' => true,
             'external_plugin'      => true,
@@ -123,7 +126,7 @@ var $filter_defaults;
             'backend_comments_top' => true,
             'backend_view_comment' => true
         ));
-        $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'bloggdeblacklist', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile'));
+        $propbag->add('configuration', array('killswitch', 'bodyclone', 'entrytitle', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'bloggdeblacklist', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile'));
         $propbag->add('groups', array('ANTISPAM'));
 
         $this->filter_defaults = array(
@@ -157,6 +160,13 @@ var $filter_defaults;
                 $propbag->add('default', false);
                 break;
 
+            case 'entrytitle':
+                $propbag->add('type', 'boolean');
+                $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE);
+                $propbag->add('description', '');
+                $propbag->add('default', false);
+                break;
+
             case 'checkmail':
                 $propbag->add('type', 'boolean');
                 $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL);
@@ -425,7 +435,7 @@ var $filter_defaults;
                         $serendipity['csuccess'] = 'true';
                         $logfile = $this->get_config('logfile', $serendipity['serendipityPath'] . 'spamblock.log');
                         $required_fields = $this->get_config('required_fields', '');
-
+                        
                         // Check required fields
                         if ($addData['type'] == 'NORMAL' && !empty($required_fields)) {
                             $required_field_list = explode(',', $required_fields);
@@ -439,6 +449,14 @@ var $filter_defaults;
                                 }
                             }
                         }
+                        
+                        // Check if entry title is the same as comment body
+                        if (serendipity_db_bool($this->get_config('entrytitle')) && trim($eventData['title']) == trim($addData['comment'])) {
+                            $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_TITLE, $addData);
+                            $eventData = array('allow_comments' => false);
+                            $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+                            return false;
+                        }
 
                         // Check for global emergency moderation
                         if ( $this->get_config('killswitch', false) === true ) {