Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32630/plugins/serendipity_event_spamblock
Modified Files:
serendipity_event_spamblock.php
Log Message:
Make the order of spamblock events cost-based:
1. Checks that don't require any database or network access
2. Checks that require databases access, but no network access
3. Checks that require network access
Index: serendipity_event_spamblock.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- serendipity_event_spamblock.php 4 Jan 2005 10:06:37 -0000 1.41
+++ serendipity_event_spamblock.php 16 Jan 2005 10:09:20 -0000 1.42
@@ -374,6 +374,43 @@
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);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_REASON_FORCEMODERATION;
+ return false;
+ }
+
+ // Check for maximum number of links before rejecting
+ $link_count = substr_count(strtolower($addData['comment']), 'http://');
+ if ($links_reject > 0 && $link_count > $links_reject) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_REJECT, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ return false;
+ }
+
+ // Check for maximum number of links before forcing moderation
+ if ($links_moderate > 0 && $link_count > $links_moderate) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_MODERATE, $addData);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_MODERATE;
+ 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'])) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_CAPTCHAS, $serendipity['POST']['captcha'], $_SESSION['spamblock']['captcha']), $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_CAPTCHAS;
+ 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']) {
$query = "SELECT count(id) AS counter FROM {$serendipity['dbPrefix']}comments WHERE body = '" . serendipity_db_escape_string($addData['comment']) . "'";
@@ -453,41 +490,6 @@
}
}
}
-
- // 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'])) {
- $this->log($logfile, $eventData['id'], 'REJECTED', sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_CAPTCHAS, $serendipity['POST']['captcha'], $_SESSION['spamblock']['captcha']), $addData);
- $eventData = array('allow_comments' => false);
- $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_CAPTCHAS;
- 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);
- $eventData['moderate_comments'] = true;
- $serendipity['csuccess'] = 'moderate';
- $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_REASON_FORCEMODERATION;
- return false;
- }
-
- $link_count = substr_count(strtolower($addData['comment']), 'http://');
- if ($links_reject > 0 && $link_count > $links_reject) {
- $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_REJECT, $addData);
- $eventData = array('allow_comments' => false);
- $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
- return false;
- }
-
- if ($links_moderate > 0 && $link_count > $links_moderate) {
- $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_MODERATE, $addData);
- $eventData['moderate_comments'] = true;
- $serendipity['csuccess'] = 'moderate';
- $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_REASON_LINKS_MODERATE;
- return false;
- }
}
return true;
break;
|