Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21324
Modified Files:
serendipity_event_spamblock.php
Log Message:
word filtering. may need some improvements.
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- serendipity_event_spamblock.php 27 Jan 2005 12:46:33 -0000 1.43
+++ serendipity_event_spamblock.php 1 Feb 2005 10:23:04 -0000 1.44
@@ -75,6 +75,13 @@
@define('PLUGIN_EVENT_SPAMBLOCK_API_REJECT', 'abweisen');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_API', 'Keine API-erstellten Kommentare (u.a. Trackbacks) erlaubt');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE', 'Wortfilter aktivieren');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE_DESC', 'Durchsucht Kommentare nach speziellen Zeichenketten und markiert diese als Spam.');
+
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS', 'Wortfilter für URLs');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS_DESC', 'Reguläre Ausdrücke erlaubt, Zeichenkennten durch Semikolon (;) trennen.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS', 'Wortfilter für Autorennamen');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS_DESC', 'Reguläre Ausdrücke erlaubt, Zeichenkennten durch Semikolon (;) trennen.');
break;
default:
@@ -140,19 +147,27 @@
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_FILE', 'File (see "logfile" option below)');
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_DB', 'Database');
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_NONE', 'No Logging');
-
+
@define('PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS', 'How to treat comments made via APIs');
@define('PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS_DESC', 'This affects the moderation of comments made via API calls (Trackbacks, WFW:commentAPI comments). If set to "moderate", all those comments always need to be approved first. If set to "reject", the are completely disallowed. If set to "none", the comments will be treated as usual comments.');
@define('PLUGIN_EVENT_SPAMBLOCK_API_MODERATE', 'moderate');
@define('PLUGIN_EVENT_SPAMBLOCK_API_REJECT', 'reject');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_API', 'No API-created comments (like trackbacks) allowed');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE', 'Activate wordfilter');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE_DESC', 'Searches comments for certain strings and marks them as spam.');
+
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS', 'Wordfilter for URLs');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS_DESC', 'Regular Expressions allowed, separate strings by semicolons (;).');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS', 'Wordfilter for author names');
+ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS_DESC', 'Regular Expressions allowed, separate strings by semicolons (;).');
+
break;
}
class serendipity_event_spamblock extends serendipity_event
{
-var $services;
+var $filter_defaults;
function introspect(&$propbag)
{
@@ -164,14 +179,19 @@
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Sebastian Nohn');
- $propbag->add('version', '1.2');
+ $propbag->add('version', '1.21');
$propbag->add('event_hooks', array(
'frontend_saveComment' => true,
'external_plugin' => true,
'frontend_comment' => true,
'fetchcomments' => true
));
- $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'surbl_enabled', 'rbl_enabled', 'rbllist', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'hide_email', 'logtype', 'logfile'));
+ $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'surbl_enabled', 'rbl_enabled', 'rbllist', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'filter_activate', 'filter_urls', 'filter_authors', 'hide_email', 'logtype', 'logfile'));
+
+ $this->filter_defaults = array(
+ 'authors' => 'casino;phentermine;credit;loans;poker',
+ 'urls' => '8gold\.com;911easymoney\.com;canadianlabels\.net;condodream\.com;crepesuzette\.com;debt-help-bill-consolidation-elimination\.com;fidelityfunding\.net;flafeber\.com;gb\.com;houseofsevengables\.com;instant-quick-money-cash-advance-personal-loans-until-pay-day\.com;mediavisor\.com;newtruths\.com;oiline\.com;onlinegamingassociation\.com;online\-+poker\.com;popwow\.com;royalmailhotel\.com;spoodles\.com;sportsparent\.com;stmaryonline\.org;thatwhichis\.com;tmsathai\.org;uaeecommerce\.com;learnhowtoplay\.com'
+ );
}
function introspect_config_item($name, &$propbag)
@@ -220,6 +240,33 @@
$propbag->add('default', false);
break;
+ case 'filter_activate':
+ $propbag->add('type', 'radio');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_FILTER_ACTIVATE_DESC);
+ $propbag->add('default', 'moderate');
+ $propbag->add('radio', array(
+ 'value' => array('moderate', 'reject', 'none'),
+ 'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
+ ));
+ $propbag->add('radio_per_row', '1');
+
+ break;
+
+ case 'filter_urls':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS_DESC);
+ $propbag->add('default', $this->filter_defaults['urls']);
+ break;
+
+ case 'filter_authors':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS_DESC);
+ $propbag->add('default', $this->filter_defaults['authors']);
+ break;
+
case 'logfile':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_LOGFILE);
@@ -418,6 +465,48 @@
return false;
}
+ // Check for word filtering
+ if ($filter_type = $this->get_config('filter_activate', 'moderate')) {
+
+ // Filter authors names
+ $filter_authors = explode(';', $this->get_config('filter_authors', $this->filter_defaults['authors']));
+ if (is_array($filter_authors)) {
+ foreach($filter_authors AS $filter_author) {
+ if (preg_match('@' . $filter_author . '@', $eventData['name'])) {
+ if ($filter_type == 'moderate') {
+ $this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS, $addData);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ } else {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ }
+ }
+ }
+ }
+
+ // Filter URL
+ $filter_urls = explode(';', $this->get_config('filter_urls', $this->filter_defaults['urls']));
+ if (is_array($filter_urls)) {
+ foreach($filter_urlss AS $filter_url) {
+ if (preg_match('@' . $filter_url . '@', $eventData['url'])) {
+ if ($filter_type == 'moderate') {
+ $this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS, $addData);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ } else {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ }
+ }
+ }
+ }
+ }
+
// Check for forced moderation
if ($forcemoderation > 0 && $eventData['timestamp'] < (time() - ($forcemoderation * 60 * 60 * 24))) {
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_REASON_FORCEMODERATION, $addData);
|