@define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR', 'Unblock this author via Spamblock plugin');
@define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Unblock this URL via Spamblock plugin');
+@define('PLUGIN_EVENT_SPAMBLOCK_BLOGG_SPAMLIST', 'Activate URL filtering by blogg.de Blacklist');
+@define('PLUGIN_EVENT_SPAMBLOCK_REASON_BLOGG_SPAMLIST', 'Filtered by blogg.de Blacklist');
+
class serendipity_event_spamblock extends serendipity_event
{
var $filter_defaults;
'smarty' => '2.6.7',
'php' => '4.1.0'
));
- $propbag->add('version', '1.25');
+ $propbag->add('version', '1.26');
$propbag->add('event_hooks', array(
'frontend_saveComment' => true,
'external_plugin' => true,
'backend_comments_top' => true,
'backend_view_comment' => true
));
- $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile'));
+ $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'bloggdeblacklist', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile'));
$propbag->add('groups', array('ANTISPAM'));
$this->filter_defaults = array(
break;
+ case 'bloggdeblacklist':
+ $propbag->add('type', 'radio');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_BLOGG_SPAMLIST);
+ $propbag->add('description', '');
+ $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 'contentfilter_urls':
$propbag->add('type', 'text');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS);
return true;
}
+ function getBlacklist($where) {
+ global $serendipity;
+
+ switch($where) {
+ case 'blogg.de':
+ $target = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/blogg.de.blacklist.txt';
+ $timeout = 3600; // One hour
+
+ if (file_exists($target) && filemtime($target) > time()-$timeout) {
+ $data = file_get_contents($target);
+ } else {
+ $data = '';
+ require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
+ $req = &new HTTP_Request('http://spam.blogg.de/blacklist.txt');
+
+ if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
+ if (file_exists($target) && filesize($target) > 0) {
+ $data = file_get_contents($target);
+ }
+ } else {
+ // Fetch file
+ $data = $req->getResponseBody();
+ $fp = @fopen($target, 'w');
+
+ if ($fp) {
+ fwrite($fp, $data);
+ fclose($fp);
+ }
+ }
+ }
+
+ $blacklist = explode("\n", $data);
+ return $blacklist;
+
+ default:
+ return false;
+ }
+ }
+
function checkScheme($maxVersion) {
global $serendipity;
}
}
}
+
+ // Filter Blogg.de Blacklist?
+ $bloggdeblacklist = $this->get_config('bloggdeblacklist');
+ if ($bloggdeblacklist == 'moderate' || $bloggdeblacklist == 'reject') {
+ $domains = $this->getBlacklist('blogg.de');
+ if (is_array($domains)) {
+ foreach($domains AS $domain) {
+ $domain = trim($domain);
+ if (empty($domain)) {
+ continue;
+ }
+
+ if (preg_match('@' . preg_quote($domain) . '@i', $addData['url'])) {
+ if ($bloggdeblacklist == 'moderate') {
+ $this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_REASON_BLOGG_SPAMLIST . ': ' . $domain, $addData);
+ $eventData['moderate_comments'] = true;
+ $serendipity['csuccess'] = 'moderate';
+ $serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ return false;
+ } else {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_BLOGG_SPAMLIST . ': ' . $domain, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
+ return false;
+ }
+ }
+ }
+ }
+ }
}
// Check for maximum number of links before rejecting