Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28426/plugins/serendipity_event_spamblock
Modified Files:
serendipity_event_spamblock.php
Log Message:
Upgrade spamblock plugin to reject/moderate incoming trackbacks/wfwcomments seperately from other comments
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- serendipity_event_spamblock.php 16 Jan 2005 10:09:20 -0000 1.42
+++ serendipity_event_spamblock.php 27 Jan 2005 12:46:33 -0000 1.43
@@ -68,6 +68,13 @@
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_FILE', 'Einfache Datei (siehe Option "Logfile")');
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_DB', 'Datenbank');
@define('PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_NONE', 'Keine Protokollierung');
+
+ @define('PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS', 'Behandlung von per API übermittelten Kommentaren');
+ @define('PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS_DESC', 'Diese Einstellung bestimmt, wie per API abgegebene Kommentare (Trackbacks, wfw:commentApi) behandelt werden. Falls diese Einstellung auf "moderieren" gestellt ist, müssen alle solche Kommentare immer bestätigt werden. Falls auf "abweisen" gestellt, werden solche Kommentare global nicht erlaubt. Bei der Einstellung "keine" werden solche Kommentare wie andere behandelt.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_API_MODERATE', 'moderieren');
+ @define('PLUGIN_EVENT_SPAMBLOCK_API_REJECT', 'abweisen');
+ @define('PLUGIN_EVENT_SPAMBLOCK_REASON_API', 'Keine API-erstellten Kommentare (u.a. Trackbacks) erlaubt');
+
break;
default:
@@ -133,6 +140,13 @@
@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');
+
break;
}
@@ -157,7 +171,7 @@
'frontend_comment' => true,
'fetchcomments' => true
));
- $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'surbl_enabled', 'rbl_enabled', 'rbllist', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', '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', 'hide_email', 'logtype', 'logfile'));
}
function introspect_config_item($name, &$propbag)
@@ -165,6 +179,19 @@
global $serendipity;
switch($name) {
+ case 'disable_api_comments':
+ $propbag->add('type', 'radio');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS_DESC);
+ $propbag->add('default', 'none');
+ $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 'hide_email':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL);
@@ -367,6 +394,7 @@
$serendipity['csuccess'] = 'true';
$logfile = $this->get_config('logfile', $serendipity['serendipityPath'] . 'spamblock.log');
+ // Check for global emergency moderation
if ( $this->get_config('killswitch', false) === true ) {
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_KILLSWITCH, $addData);
$eventData = array('allow_comments' => false);
@@ -374,6 +402,22 @@
return false;
}
+ // Check for not allowing trackbacks/wfwcomments
+ if ( ($addData['type'] != 'NORMAL' || $addData['source'] == 'API') &&
+ $this->get_config('disable_api_comments', 'none') != 'none') {
+ if ($this->get_config('disable_api_comments') == 'reject') {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_API, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_REASON_API;
+ } elseif ($this->get_config('disable_api_comments') == 'moderate') {
+ $this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_REASON_API, $addData);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_REASON_API;
+ }
+ return false;
+ }
+
// 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);
|