update spamblock wordfilter to function & updated NEWS
This commit is contained in:
@ -4,11 +4,17 @@
|
|||||||
Version 1.7 ()
|
Version 1.7 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Updated spamblock plugin (ophian)
|
||||||
|
changed wordfilter to function and Commenters moderation check verify_once
|
||||||
|
to get checked via wordfilter to reject known spam comments before
|
||||||
|
|
||||||
* Changed backend comment (error) messages (ophian)
|
* Changed backend comment (error) messages (ophian)
|
||||||
as now captured and styleable messages
|
as now captured and styleable messages
|
||||||
(newly added .serendipity_backend_msg_notice css class)
|
(newly added .serendipity_backend_msg_notice css class)
|
||||||
|
|
||||||
* Updated nl2br plugin (ophian)
|
* Updated nl2br plugin (ophian)
|
||||||
|
added isolation tag using nl to br
|
||||||
|
this also adds some NoBR buttons to backend entry forms
|
||||||
|
|
||||||
* EXPERIMENTAL: Smarty3 support (ophian)
|
* EXPERIMENTAL: Smarty3 support (ophian)
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ var $filter_defaults;
|
|||||||
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TITLE);
|
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TITLE);
|
||||||
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
|
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Garvin Hicking, Sebastian Nohn, Grischa Brockhaus');
|
$propbag->add('author', 'Garvin Hicking, Sebastian Nohn, Grischa Brockhaus, Ian');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '0.8',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
$propbag->add('version', '1.77');
|
$propbag->add('version', '1.78');
|
||||||
$propbag->add('event_hooks', array(
|
$propbag->add('event_hooks', array(
|
||||||
'frontend_saveComment' => true,
|
'frontend_saveComment' => true,
|
||||||
'external_plugin' => true,
|
'external_plugin' => true,
|
||||||
@ -920,12 +920,21 @@ var $filter_defaults;
|
|||||||
AND name = '" . serendipity_db_escape_string($addData['email']) . "'
|
AND name = '" . serendipity_db_escape_string($addData['email']) . "'
|
||||||
AND value = '" . serendipity_db_escape_string($addData['name']) . "'", true);
|
AND value = '" . serendipity_db_escape_string($addData['name']) . "'", true);
|
||||||
if (!is_array($auth)) {
|
if (!is_array($auth)) {
|
||||||
|
// Filter authors names, Filter URL, Filter Content, Filter Emails, Check for maximum number of links before rejecting
|
||||||
|
// moderate false
|
||||||
|
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData, true)) {
|
||||||
|
// already there #$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS, $addData);
|
||||||
|
// already there #$eventData = array('allow_comments' => false);
|
||||||
|
// already there #$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_MAIL, $addData);
|
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_MAIL, $addData);
|
||||||
$eventData['moderate_comments'] = true;
|
$eventData['moderate_comments'] = true;
|
||||||
$eventData['status'] = 'confirm1';
|
$eventData['status'] = 'confirm1';
|
||||||
$serendipity['csuccess'] = 'moderate';
|
$serendipity['csuccess'] = 'moderate';
|
||||||
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_MAIL;
|
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_MAIL;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// User is allowed to post message, bypassing other checks as if he were logged in.
|
// User is allowed to post message, bypassing other checks as if he were logged in.
|
||||||
return true;
|
return true;
|
||||||
@ -1063,106 +1072,9 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for word filtering
|
if(false === $this->wordfilter($logfile, $eventData, $wordmatch, $addData)) {
|
||||||
if ($filter_type = $this->get_config('contentfilter_activate', 'moderate')) {
|
|
||||||
|
|
||||||
// Filter authors names
|
|
||||||
$filter_authors = explode(';', $this->get_config('contentfilter_authors', $this->filter_defaults['authors']));
|
|
||||||
if (is_array($filter_authors)) {
|
|
||||||
foreach($filter_authors AS $filter_author) {
|
|
||||||
$filter_author = trim($filter_author);
|
|
||||||
if (empty($filter_author)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (preg_match('@(' . $filter_author . ')@i', $addData['name'], $wordmatch)) {
|
|
||||||
if ($filter_type == 'moderate') {
|
|
||||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData['moderate_comments'] = true;
|
|
||||||
$serendipity['csuccess'] = 'moderate';
|
|
||||||
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1] . ')';
|
|
||||||
} else {
|
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData = array('allow_comments' => false);
|
|
||||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter URL
|
|
||||||
$filter_urls = explode(';', $this->get_config('contentfilter_urls', $this->filter_defaults['urls']));
|
|
||||||
if (is_array($filter_urls)) {
|
|
||||||
foreach($filter_urls AS $filter_url) {
|
|
||||||
$filter_url = trim($filter_url);
|
|
||||||
if (empty($filter_url)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (preg_match('@(' . $filter_url . ')@i', $addData['url'], $wordmatch)) {
|
|
||||||
if ($filter_type == 'moderate') {
|
|
||||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData['moderate_comments'] = true;
|
|
||||||
$serendipity['csuccess'] = 'moderate';
|
|
||||||
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1] . ')';
|
|
||||||
} else {
|
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData = array('allow_comments' => false);
|
|
||||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter Content
|
|
||||||
$filter_bodys = explode(';', $this->get_config('contentfilter_words', $this->filter_defaults['words']));
|
|
||||||
if (is_array($filter_bodys)) {
|
|
||||||
foreach($filter_bodys AS $filter_body) {
|
|
||||||
$filter_body = trim($filter_body);
|
|
||||||
if (empty($filter_body)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (preg_match('@(' . $filter_body . ')@i', $addData['comment'], $wordmatch)) {
|
|
||||||
if ($filter_type == 'moderate') {
|
|
||||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData['moderate_comments'] = true;
|
|
||||||
$serendipity['csuccess'] = 'moderate';
|
|
||||||
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1] . ')';
|
|
||||||
} else {
|
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData = array('allow_comments' => false);
|
|
||||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter Emails
|
|
||||||
$filter_emails = explode(';', $this->get_config('contentfilter_emails', $this->filter_defaults['emails']));
|
|
||||||
if (is_array($filter_emails)) {
|
|
||||||
foreach($filter_emails AS $filter_email) {
|
|
||||||
$filter_email = trim($filter_email);
|
|
||||||
if (empty($filter_email)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (preg_match('@(' . $filter_email . ')@i', $addData['email'], $wordmatch)) {
|
|
||||||
$this->IsHardcoreSpammer();
|
|
||||||
if ($filter_type == 'moderate') {
|
|
||||||
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData['moderate_comments'] = true;
|
|
||||||
$serendipity['csuccess'] = 'moderate';
|
|
||||||
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1] . ')';
|
|
||||||
} else {
|
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1], $addData);
|
|
||||||
$eventData = array('allow_comments' => false);
|
|
||||||
$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // Content filtering end
|
|
||||||
|
|
||||||
// Filter Blogg.de Blacklist?
|
// Filter Blogg.de Blacklist?
|
||||||
$bloggdeblacklist = $this->get_config('bloggdeblacklist');
|
$bloggdeblacklist = $this->get_config('bloggdeblacklist');
|
||||||
@ -1513,6 +1425,129 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wordfilter, email and additional link check moved to this function, to allow comment user to opt-in (verify_once), but reject all truly spam comments before.
|
||||||
|
**/
|
||||||
|
function wordfilter($logfile, &$eventData, $wordmatch, $addData, $ftc = false) {
|
||||||
|
global $serendipity;
|
||||||
|
|
||||||
|
// Check for word filtering
|
||||||
|
if ($filter_type = $this->get_config('contentfilter_activate', 'moderate')) {
|
||||||
|
|
||||||
|
if($ftc) $filter_type = 'reject';
|
||||||
|
|
||||||
|
// Filter authors names
|
||||||
|
$filter_authors = explode(';', $this->get_config('contentfilter_authors', $this->filter_defaults['authors']));
|
||||||
|
if (is_array($filter_authors)) {
|
||||||
|
foreach($filter_authors AS $filter_author) {
|
||||||
|
$filter_author = trim($filter_author);
|
||||||
|
if (empty($filter_author)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (preg_match('@(' . $filter_author . ')@i', $addData['name'], $wordmatch)) {
|
||||||
|
if ($filter_type == 'moderate') {
|
||||||
|
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData['moderate_comments'] = true;
|
||||||
|
$serendipity['csuccess'] = 'moderate';
|
||||||
|
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1] . ')';
|
||||||
|
} else {
|
||||||
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_AUTHORS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData = array('allow_comments' => false);
|
||||||
|
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter URL
|
||||||
|
$filter_urls = explode(';', $this->get_config('contentfilter_urls', $this->filter_defaults['urls']));
|
||||||
|
if (is_array($filter_urls)) {
|
||||||
|
foreach($filter_urls AS $filter_url) {
|
||||||
|
$filter_url = trim($filter_url);
|
||||||
|
if (empty($filter_url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (preg_match('@(' . $filter_url . ')@i', $addData['url'], $wordmatch)) {
|
||||||
|
if ($filter_type == 'moderate') {
|
||||||
|
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData['moderate_comments'] = true;
|
||||||
|
$serendipity['csuccess'] = 'moderate';
|
||||||
|
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1] . ')';
|
||||||
|
} else {
|
||||||
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_URLS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData = array('allow_comments' => false);
|
||||||
|
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter Content
|
||||||
|
$filter_bodys = explode(';', $this->get_config('contentfilter_words', $this->filter_defaults['words']));
|
||||||
|
if (is_array($filter_bodys)) {
|
||||||
|
foreach($filter_bodys AS $filter_body) {
|
||||||
|
$filter_body = trim($filter_body);
|
||||||
|
if (empty($filter_body)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (preg_match('@(' . $filter_body . ')@i', $addData['comment'], $wordmatch)) {
|
||||||
|
if ($filter_type == 'moderate') {
|
||||||
|
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData['moderate_comments'] = true;
|
||||||
|
$serendipity['csuccess'] = 'moderate';
|
||||||
|
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1] . ')';
|
||||||
|
} else {
|
||||||
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_WORDS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData = array('allow_comments' => false);
|
||||||
|
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter Emails
|
||||||
|
$filter_emails = explode(';', $this->get_config('contentfilter_emails', $this->filter_defaults['emails']));
|
||||||
|
if (is_array($filter_emails)) {
|
||||||
|
foreach($filter_emails AS $filter_email) {
|
||||||
|
$filter_email = trim($filter_email);
|
||||||
|
if (empty($filter_email)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (preg_match('@(' . $filter_email . ')@i', $addData['email'], $wordmatch)) {
|
||||||
|
$this->IsHardcoreSpammer();
|
||||||
|
if ($filter_type == 'moderate') {
|
||||||
|
$this->log($logfile, $eventData['id'], 'MODERATE', PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData['moderate_comments'] = true;
|
||||||
|
$serendipity['csuccess'] = 'moderate';
|
||||||
|
$serendipity['moderate_reason'] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY . ' (' . PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1] . ')';
|
||||||
|
} else {
|
||||||
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_FILTER_EMAILS . ': ' . $wordmatch[1], $addData);
|
||||||
|
$eventData = array('allow_comments' => false);
|
||||||
|
$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // Content filtering end
|
||||||
|
|
||||||
|
if($ftc) {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // function wordfilter end
|
||||||
|
|
||||||
|
|
||||||
function &checkFilter($what, $match, $getItems = false) {
|
function &checkFilter($what, $match, $getItems = false) {
|
||||||
$items = explode(';', $this->get_config('contentfilter_' . $what, $this->filter_defaults[$what]));
|
$items = explode(';', $this->get_config('contentfilter_' . $what, $this->filter_defaults[$what]));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user