Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2042/plugins/serendipity_event_spamblock
Modified Files:
Tag: branch-smarty
serendipity_event_spamblock.php
Log Message:
MFH
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.1
retrieving revision 1.4.2.2
diff -u -d -r1.4.2.1 -r1.4.2.2
--- serendipity_event_spamblock.php 17 Sep 2004 12:06:58 -0000 1.4.2.1
+++ serendipity_event_spamblock.php 18 Sep 2004 19:47:06 -0000 1.4.2.2
@@ -4,18 +4,18 @@
default:
@define('PLUGIN_EVENT_SPAMBLOCK_TITLE', 'Spam Protector');
@define('PLUGIN_EVENT_SPAMBLOCK_DESC', 'A varity of methods to prevent comment spam');
- @define('PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY', 'SPAM Prevention detected invalid message. Comment not added.');
- @define('PLUGIN_EVENT_SPAMBLOCK_ERROR_IP', 'SPAM Prevention asks you to not mass-post comments to this blog. Comment not added.');
+ @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_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');
@define('PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH', 'Emergency comment shutdown');
@define('PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH_DESC', 'Temporarily disable comments for all entries. Useful if your blog is under spam attack.');
- @define('PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH_NOTICE', 'This blog is in "Emergency Comment Blockage Mode", please come back another time');
@define('PLUGIN_EVENT_SPAMBLOCK_IPFLOOD', 'IP block interval');
@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', 'Block comments from RBL-listed hosts');
- @define('PLUGIN_EVENT_SPAMBLOCK_RBL_DESC', 'Be careful with this feature. Avoid to choose an RBL that includes dialup-hosts.');
- @define('PLUGIN_EVENT_SPAMBLOCK_RBL_NOTICE', 'SPAM Prevention detected that your host is listed as open relay. Comment not added.');
+ @define('PLUGIN_EVENT_SPAMBLOCK_RBL_DESC', 'Blocks comments based on provided RPL lists. Avoid lists with dynamic hosts.');
break;
}
@@ -63,7 +63,7 @@
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_RBL);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_RBL_DESC);
- $propbag->add('default', 'bl.spamcop.net, sbl-xbl.spamhaus.org');
+ $propbag->add('default', 'sbl-xbl.spamhaus.org, bl.spamcop.net');
break;
default:
@@ -89,7 +89,7 @@
if ( $this->get_config('killswitch', false) === true ) {
$eventData = array('allow_comments' => false);
- $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH_NOTICE;
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
return false;
}
@@ -116,26 +116,28 @@
}
// Check for IP listed in RBL
- // Partly based on work done bei James Seward (ja...@ja...)
+ // Partly based on work done by James Seward (ja...@ja...)
if ( $this->get_config('rbl') != '' ) {
- $rbls = explode(',', $this->get_config('rbl'));
- // $remote = '81.70.69.193';
- $remote = $_SERVER['REMOTE_ADDR'];
- if (preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/", $remote, $matches)) {
- foreach ($rbls as $rbl) {
- $rblhost = $matches[4] . "." . $matches[3] . "." . $matches[2] . "." . $matches[1] . "." . trim($rbl);
- $resolved = gethostbyname($rblhost);
- if ($resolved != $rblhost) {
- $eventData = array('allow_comments' => false);
- $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_RBL_NOTICE;
- return false;
- }
- }
- }
- }
- }
- return true;
- break;
+ $remoteIP = $_SERVER['REMOTE_ADDR'];
+ # $remoteIP = '81.70.69.193';
+
+ $rbls = explode(',', $this->get_config('rbl'));
+ if (preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/", $remoteIP, $res)) {
+ array_shift($res);
+ $reverseIP = implode('.', array_reverse($res));
+ foreach ($rbls as $rbl) {
+ $rblhost = $reverseIP .'.'. trim($rbl);
+ if (gethostbyname($rblhost) != $rblhost) {
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_RBL;
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ break;
default:
return false;
|