From: garvinhicking Date: Thu, 13 Oct 2005 10:55:02 +0000 (+0000) Subject: * Improve Spamblock plugin to allow configuring author/url filters straight... X-Git-Tag: 0.9~70 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=abefd6b362735a9ab0be076deea46e0476e130c3;p=s9y.git * Improve Spamblock plugin to allow configuring author/url filters straight from the "Comments" interface. (garvinhicking) M trunk/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php M trunk/plugins/serendipity_event_spamblock/lang_de.inc.php M trunk/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php M trunk/include/admin/comments.inc.php M trunk/docs/NEWS AM trunk/templates/default/admin/img/unconfigure.png --- diff --git a/docs/NEWS b/docs/NEWS index 5bdf7c9..0f90b1c 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 0.9-beta2 () ------------------------------------------------------------------------ + * Improve Spamblock plugin to allow configuring author/url filters + straight from the "Comments" interface. (garvinhicking) + * Fix a bug in the fetchEntry() function which can lead to wrong author/authorid settings when editing an existing entry. Thanks to Martin Eichenberg! (garvinhicking) diff --git a/include/admin/comments.inc.php b/include/admin/comments.inc.php index ee0a063..5807f5a 100644 --- a/include/admin/comments.inc.php +++ b/include/admin/comments.inc.php @@ -248,10 +248,11 @@ function highlightComment(id, checkvalue) { - + +

- '. NO_COMMENTS .' -'; @@ -328,7 +329,7 @@ foreach ($sql as $rs) { - + + + + + ?> + + + + + @@ -365,7 +372,9 @@ foreach ($sql as $rs) { } else { ?> - + + + - + diff --git a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php index 8a52ad9..e85c800 100644 --- a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php @@ -68,3 +68,12 @@ @define('PLUGIN_EVENT_SPAMBLOCK_REASON_CHECKMAIL', 'Ungültige E-Mail Adresse'); @define('PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL', 'Auf ungültige E-Mail Adressen prüfen?'); + @define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS', 'Pflichtfelder'); + @define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS_DESC', 'Geben Sie die Liste von Pflichtfeldern bei der Abgabe eines Kommentares ein. Mehrere Felder können mit "," getrennt werden. Verfügbare Felder sind: name, email, url, replyTo, comment'); + @define('PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD', 'Sie haben das Feld %s nicht ausgefüllt!'); + + @define('PLUGIN_EVENT_SPAMBLOCK_CONFIG', 'Anti-Spam-Maßnahmen konfigurieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR', 'Diesen Autoren via Spamschutz blockieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_ADD_URL', 'Diese URL via Spamschutz blockieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR', 'Blockade dieses Autoren via Spamschutz aufheben'); + @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Blockade dieser URL via Spamschutz aufheben'); diff --git a/plugins/serendipity_event_spamblock/lang_de.inc.php b/plugins/serendipity_event_spamblock/lang_de.inc.php index 4663804..78062e6 100644 --- a/plugins/serendipity_event_spamblock/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/lang_de.inc.php @@ -68,3 +68,12 @@ @define('PLUGIN_EVENT_SPAMBLOCK_REASON_CHECKMAIL', 'Ungültige E-Mail Adresse'); @define('PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL', 'Auf ungültige E-Mail Adressen prüfen?'); + @define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS', 'Pflichtfelder'); + @define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS_DESC', 'Geben Sie die Liste von Pflichtfeldern bei der Abgabe eines Kommentares ein. Mehrere Felder können mit "," getrennt werden. Verfügbare Felder sind: name, email, url, replyTo, comment'); + @define('PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD', 'Sie haben das Feld %s nicht ausgefüllt!'); + + @define('PLUGIN_EVENT_SPAMBLOCK_CONFIG', 'Anti-Spam-Maßnahmen konfigurieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR', 'Diesen Autoren via Spamschutz blockieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_ADD_URL', 'Diese URL via Spamschutz blockieren'); + @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR', 'Blockade dieses Autoren via Spamschutz aufheben'); + @define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Blockade dieser URL via Spamschutz aufheben'); diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index 3b8ba0e..a5bca5a 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -86,6 +86,12 @@ if (!function_exists('serendipity_serverOffsetHour')) { @define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS_DESC', 'Enter a list of required fields that need to be filled when a user comments. Seperate multiple fields with a ",". Available keys are: name, email, url, replyTo, comment'); @define('PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD', 'You did not specify the %s field!'); +@define('PLUGIN_EVENT_SPAMBLOCK_CONFIG', 'Configure Anti-Spam methods'); +@define('PLUGIN_EVENT_SPAMBLOCK_ADD_AUTHOR', 'Block this author via Spamblock plugin'); +@define('PLUGIN_EVENT_SPAMBLOCK_ADD_URL', 'Block this URL via Spamblock plugin'); +@define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_AUTHOR', 'Unblock this author via Spamblock plugin'); +@define('PLUGIN_EVENT_SPAMBLOCK_REMOVE_URL', 'Unblock this URL via Spamblock plugin'); + class serendipity_event_spamblock extends serendipity_event { var $filter_defaults; @@ -110,7 +116,9 @@ var $filter_defaults; 'frontend_saveComment' => true, 'external_plugin' => true, 'frontend_comment' => true, - 'fetchcomments' => true + 'fetchcomments' => 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('groups', array('ANTISPAM')); @@ -653,6 +661,38 @@ var $filter_defaults; return true; break; + case 'backend_comments_top': + + // Add Author to blacklist. If already filtered, it will be removed from the filter. (AKA "Toggle") + if (isset($serendipity['GET']['spamBlockAuthor'])) { + $item = $this->getComment('author', $serendipity['GET']['spamBlockAuthor']); + $items = &$this->checkFilter('authors', $item, true); + $this->set_config('contentfilter_authors', implode(';', $items)); + } + + // Add URL to blacklist. If already filtered, it will be removed from the filter. (AKA "Toggle") + if (isset($serendipity['GET']['spamBlockURL'])) { + $item = $this->getComment('url', $serendipity['GET']['spamBlockURL']); + $items = &$this->checkFilter('urls', $item, true); + $this->set_config('contentfilter_urls', implode(';', $items)); + } + + echo ' - ' . WORD_OR . ' - ' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . ''; + return true; + break; + + case 'backend_view_comment': + $author_is_filtered = $this->checkFilter('authors', $eventData['author']); + $eventData['action_author'] .= ' '; + + if (!empty($eventData['url'])) { + $url_is_filtered = $this->checkFilter('urls', $eventData['url']); + $eventData['action_url'] .= ' '; + } + + return true; + break; + default: return false; break; @@ -662,6 +702,50 @@ var $filter_defaults; } } + function &checkFilter($what, $match, $getItems = false) { + $items = explode(';', $this->get_config('contentfilter_' . $what, $this->filter_defaults[$what])); + + $filtered = false; + if (is_array($items)) { + foreach($items AS $key => $item) { + if (empty($match)) { + continue; + } + + if (empty($item)) { + unset($items[$key]); + continue; + } + + if (preg_match('@' . $item . '@', $match)) { + $filtered = true; + unset($items[$key]); + } + } + } + + if ($getItems) { + if (!$filtered && !empty($match)) { + $items[] = preg_quote($match, '@'); + } + + return $items; + } + + return $filtered; + } + + function getComment($key, $id) { + global $serendipity; + $c = serendipity_db_query("SELECT $key FROM {$serendipity['dbPrefix']}comments WHERE id = '" . (int)$id . "'", true, 'assoc'); + + if (!is_array($c) || !isset($c[$key])) { + return false; + } + + return $c[$key]; + } + function random_string($max_char, $min_char) { $this->chars = array(2, 3, 4, 7, 9); // 1, 5, 6 and 8 may look like characters. $this->chars = array_merge($this->chars, array('A','B','C','D','E','F','H','J','K','L','M','N','P','Q','R','T','U','V','W','X','Y','Z')); // I, O, S may look like numbers diff --git a/templates/default/admin/img/unconfigure.png b/templates/default/admin/img/unconfigure.png new file mode 100644 index 0000000..80b718c Binary files /dev/null and b/templates/default/admin/img/unconfigure.png differ
: : : -
IP: @@ -346,7 +349,9 @@ foreach ($sql as $rs) { } else { echo htmlspecialchars($comment['ip']); } - ?> : -
 
@@ -381,10 +390,11 @@ foreach ($sql as $rs) { <?php echo EDIT; ?> ")' title="" class="serendipityIconLink"><?php echo DELETE; ?> +