Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5805/plugins/serendipity_event_spamblock
Modified Files:
Tag: branch-smarty
serendipity_event_spamblock.php
Log Message:
Added SURBL support to serendipity_event_spamblock
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.4.2.23
retrieving revision 1.4.2.24
diff -u -d -r1.4.2.23 -r1.4.2.24
--- serendipity_event_spamblock.php 29 Oct 2004 12:43:29 -0000 1.4.2.23
+++ serendipity_event_spamblock.php 11 Nov 2004 13:31:39 -0000 1.4.2.24
@@ -7,6 +7,7 @@
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY', 'Spamschutz: Ungültiger Kommentar');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_IP', 'Spamschutz: Ein weiterer Kommentar kann nicht so schnell übermittelt werden.');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_RBL', 'Spamschutz: Ihre IP ist als Open Relay geführt, daher wird Ihr Kommentar abgewiesen.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL', 'Spamschutz: Ihre Nachricht enthält eine URL, die als SPAM geführt wird, daher wird Ihr Kommentar abgewiesen.');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH', 'Dieses Blog ist im "Notfall Kommentar"-Modus. Bitte kommen Sie später wieder.');
@define('PLUGIN_EVENT_SPAMBLOCK_BODYCLONE', 'Keine doppelten Kommentare erlauben');
@define('PLUGIN_EVENT_SPAMBLOCK_BODYCLONE_DESC', 'Verbietet Benutzern ein Kommentar zu übermitteln, was gleichlautend bereits besteht.');
@@ -16,6 +17,8 @@
@define('PLUGIN_EVENT_SPAMBLOCK_IPFLOOD_DESC', 'Schränkt die Anzahl an Kommentare pro IP ein, indem nur alle X Minuten ein Kommentar erlaubt wird. Hilfreich um Spamfluten derselben IP abzuwehren.');
@define('PLUGIN_EVENT_SPAMBLOCK_RBL', 'Kommentare abweisen, die von geblacklisteten IPs stammen');
@define('PLUGIN_EVENT_SPAMBLOCK_RBL_DESC', 'Wird diese Option aktiviert, werden Kommentare abgewiesen die von IPs stammen, die in einer RBL/Blacklist geführt werden. Die Aktivierung hiervon kann Dial-Up oder Proxy-User betreffen!');
+ @define('PLUGIN_EVENT_SPAMBLOCK_SURBL', 'Kommentare abweisen, die als SPAM gelistete URLs enthalten');
+ @define('PLUGIN_EVENT_SPAMBLOCK_SURBL_DESC', 'Wird diese Option aktiviert, werden Kommentare abgewiesen die als SPAM geblacklistet sind.');
@define('PLUGIN_EVENT_SPAMBLOCK_RBLLIST', 'Welche RBLs sollen verwendet werden');
@define('PLUGIN_EVENT_SPAMBLOCK_RBLLIST_DESC', 'Eine Liste von zu verwendenden RBLs. Listen mit dynamischen Hosts sollten vermieden werden.');
@define('PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS', 'Captchas aktivieren');
@@ -55,10 +58,12 @@
default:
@define('PLUGIN_EVENT_SPAMBLOCK_TITLE', 'Spam Protector');
- @define('PLUGIN_EVENT_SPAMBLOCK_DESC', 'A varity of effective methods to prevent comment spam');
+ @define('PLUGIN_EVENT_SPAMBLOCK_DESC', 'A varity of methods to prevent comment spam');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY', 'Spam Prevention: Invalid message.');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_IP', 'Spam Prevention: You cannot post a comment so soon after submitting another one.');
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_RBL', 'Spam Prevention: The IP of the computer you are posting from, is listed as an open relay.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL', 'Spam Prevention: Your comment contains an URL listed in SURBL.');
+
@define('PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH', 'This blog is in "Emergency Comment Blockage Mode", please come back another time');
@define('PLUGIN_EVENT_SPAMBLOCK_BODYCLONE', 'Do not allow duplicate comments');
@define('PLUGIN_EVENT_SPAMBLOCK_BODYCLONE_DESC', 'Do not allow users to submit a comment which contains the same body as an already submitted comment');
@@ -68,6 +73,8 @@
@define('PLUGIN_EVENT_SPAMBLOCK_IPFLOOD_DESC', 'Only allow an IP to submit a comment every n minutes. Useful to prevent comment floods.');
@define('PLUGIN_EVENT_SPAMBLOCK_RBL', 'Reject comments from RBL-listed hosts');
@define('PLUGIN_EVENT_SPAMBLOCK_RBL_DESC', 'Enabling this setting will reject comments made from hosts which are listed in RBLs. Pay attention that this may affect proxy-users or dial-up users.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_SURBL', 'Reject comments that containt SURBL-listed hosts');
+ @define('PLUGIN_EVENT_SPAMBLOCK_SURBL_DESC', 'Reject comments that containt SURBL-listed hosts');
@define('PLUGIN_EVENT_SPAMBLOCK_RBLLIST', 'Which RBLs should be contacted');
@define('PLUGIN_EVENT_SPAMBLOCK_RBLLIST_DESC', 'Blocks comments based on provided RBL lists. Avoid lists with dynamic hosts.');
@define('PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS', 'Enable Captchas');
@@ -98,6 +105,7 @@
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_BODYCLONE', 'Duplicate comment');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_IPFLOOD', 'IP-block');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_RBL', 'RBL-block');
+ @define('PLUGIN_EVENT_SPAMBLOCK_REASON_SURBL', 'SURBL-block');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_CAPTCHAS', 'Invalid captcha');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_FORCEMODERATION', 'Auto-moderation after X days');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_REJECT', 'Too many hyperlinks');
@@ -116,15 +124,12 @@
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TITLE);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
- $propbag->add('stackable', false);
- $propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '1.0');
$propbag->add('event_hooks', array(
'frontend_saveComment' => true,
'external_plugin' => true,
'frontend_comment' => true
));
- $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'rbl_enabled', 'rbllist', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'links_moderate', 'links_reject', 'logfile'));
+ $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'surbl_enabled', 'rbl_enabled', 'rbllist', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'links_moderate', 'links_reject', 'logfile'));
}
function introspect_config_item($name, &$propbag)
@@ -167,6 +172,13 @@
$propbag->add('default', 0);
break;
+ case 'surbl_enabled':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_SURBL);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_SURBL_DESC);
+ $propbag->add('default', false);
+ break;
+
case 'rbl_enabled':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_RBL);
@@ -266,8 +278,8 @@
return false;
}
- // Check for identical comments. We allow to bypass trackbacks from our server to our own blog.
- if ( $this->get_config('bodyclone', true) === true && $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
+ // Check for identical comments.
+ if ( $this->get_config('bodyclone', true) === true ) {
$query = "SELECT count(id) AS counter FROM {$serendipity['dbPrefix']}comments WHERE body = '" . serendipity_db_escape_string($addData['comment']) . "'";
$row = serendipity_db_query($query, true);
if (is_array($row) && $row['counter'] > 0) {
@@ -312,6 +324,46 @@
}
}
+ // Check for IP listed in SURBL
+ if (serendipity_db_bool($this->get_config('surbl_enabled', false))) {
+ require_once 'bundled-libs/Services/SURBL.php';
+ $surbl = new Services_SURBL();
+ if ($surbl->isSpam($addData['url'])) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_SURBL, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL;
+ return false;
+ }
+ // BEGIN Code copied from http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
+ $urls = '(http|file|ftp)';
+ $ltrs = '\w';
+ $gunk = '/#~:.?+=&%@!\-';
+ $punc = '.:?\-';
+ $any = "$ltrs$gunk$punc";
+ preg_match_all("{
+ \b
+ $urls :
+ [$any] +?
+
+
+ (?=
+ [$punc] *
+ [^$any]
+ |
+ $
+ )
+ }x", $addData['comment'], $matches);
+ // END Code copied from http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
+ foreach ($matches[0] as $surbl_check_url) {
+ if ($surbl->isSpam($surbl_check_url)) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_SURBL, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL;
+ return false;
+ }
+ }
+ }
+
// Captcha checking
if ($show_captcha && $addData['type'] == 'NORMAL') {
if (!isset($_SESSION['spamblock']['captcha']) || !isset($serendipity['POST']['captcha']) || strtolower($serendipity['POST']['captcha']) != strtolower($_SESSION['spamblock']['captcha'])) {
@@ -373,8 +425,8 @@
}
echo '</div>';
}
- echo '<br /><label for="captcha">';
- echo PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC3 . '</label><br /><input type="text" size="5" name="serendipity[captcha]" value="" id="captcha" />';
+ echo '<br />';
+ echo '<label for="captcha">'. PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC3 . '</label><br /><input type="text" size="5" name="serendipity[captcha]" value="" id="captcha" />';
} elseif (isset($serendipity['POST']['captcha'])) {
echo '<input type="hidden" name="serendipity[captcha]" value="' . htmlspecialchars($serendipity['POST']['captcha']) . '" />';
}
|