From 06a89067b4dd9ef5236ad2f4e62bccfb2c7448df Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 9 Nov 2005 09:08:40 +0000 Subject: [PATCH] block comments based on entry title --- docs/NEWS | 3 +++ include/functions_comments.inc.php | 2 +- .../UTF-8/lang_de.inc.php | 2 ++ .../lang_de.inc.php | 2 ++ .../serendipity_event_spamblock.php | 24 ++++++++++++++++--- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 13bbb3b..5cfbc32 100644 --- 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) diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php index f7c35ea..0946fa5 100644 --- a/include/functions_comments.inc.php +++ b/include/functions_comments.inc.php @@ -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; diff --git a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php index ab338a9..e1a6f2f 100644 --- a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php @@ -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'); diff --git a/plugins/serendipity_event_spamblock/lang_de.inc.php b/plugins/serendipity_event_spamblock/lang_de.inc.php index cea8e2c..ed9f52f 100644 --- a/plugins/serendipity_event_spamblock/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/lang_de.inc.php @@ -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'); diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index 91c9f1b..457cc47 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -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 ) { -- 2.39.5