Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24806/plugins/serendipity_event_spamblock
Modified Files:
serendipity_event_spamblock.php
Log Message:
Merge from 'branch-smarty' to HEAD.
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- serendipity_event_spamblock.php 26 Oct 2004 13:24:16 -0000 1.25
+++ serendipity_event_spamblock.php 19 Nov 2004 11:05:42 -0000 1.26
@@ -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');
@@ -59,6 +62,8 @@
@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,12 +124,15 @@
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TITLE);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
+ $propbag->add('stackable', false);
+ $propbag->add('author', 'Garvin Hicking, Sebastian Nohn');
+ $propbag->add('version', '1.1');
$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)
@@ -164,6 +175,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);
@@ -263,8 +281,8 @@
return false;
}
- // Check for identical comments.
- if ( $this->get_config('bodyclone', true) === true ) {
+ // 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']) {
$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) {
@@ -309,6 +327,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'])) {
@@ -496,7 +554,7 @@
fwrite($fp, sprintf(
'[%s] - [%s: %s] - [#%s, Name "%s", E-Mail "%s", URL "%s", User-Agent "%s", IP %s] - [%s]' . "\n",
- date('Y-m-d H:i:s'),
+ date('Y-m-d H:i:s', serendipity_serverOffsetHour()),
$switch,
$reason,
$id,
|