From 88fab6e0f3f5a650904908589a9cf9c867d766ec Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 11 Jan 2006 15:48:34 +0000 Subject: [PATCH] Implement suggestion by http://deep-resonance.org/2006/01/07/nochmal-trackbackspam-gegenmassnahmen This is an experiment. I don't yet know if to trust this. It may get removed. --- .../lang_en.inc.php | 4 ++ .../serendipity_event_spamblock.php | 38 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/plugins/serendipity_event_spamblock/lang_en.inc.php b/plugins/serendipity_event_spamblock/lang_en.inc.php index 45c4241..aea6dc2 100644 --- a/plugins/serendipity_event_spamblock/lang_en.inc.php +++ b/plugins/serendipity_event_spamblock/lang_en.inc.php @@ -92,4 +92,8 @@ @define('PLUGIN_EVENT_SPAMBLOCK_REASON_TITLE', 'Entry title equals comment'); @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Reject comments which only contain the entry title'); +@define('PLUGIN_EVENT_SPAMBLOCK_TRACKBACKURL', 'Check Trackback URLs'); +@define('PLUGIN_EVENT_SPAMBLOCK_TRACKBACKURL_DESC', 'Only allow trackbacks, when its URL contains a link to your blog'); +@define('PLUGIN_EVENT_SPAMBLOCK_REASON_TRACKBACKURL', 'Trackback URL invalid.'); + ?> diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index 9881020..641f56d 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -34,7 +34,7 @@ var $filter_defaults; 'smarty' => '2.6.7', 'php' => '4.1.0' )); - $propbag->add('version', '1.30'); + $propbag->add('version', '1.31'); $propbag->add('event_hooks', array( 'frontend_saveComment' => true, 'external_plugin' => true, @@ -43,7 +43,7 @@ var $filter_defaults; 'backend_comments_top' => true, 'backend_view_comment' => true )); - $propbag->add('configuration', array('killswitch', 'bodyclone', 'entrytitle', '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('configuration', array('killswitch', 'bodyclone', 'entrytitle', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'trackback_check_url', '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( @@ -71,6 +71,13 @@ var $filter_defaults; break; + case 'trackback_check_url': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TRACKBACKURL); + $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_TRACKBACKURL_DESC); + $propbag->add('default', false); + break; + case 'hide_email': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL); @@ -406,6 +413,33 @@ var $filter_defaults; } return false; } + + // Check Trackback URLs? + if ($addData['type'] == 'TRACKBACK' && serendipity_db_bool($this->get_config('trackback_check_url')) { + require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; + + $req = &new HTTP_Request($addData['url'], array('allowRedirects' => true, 'maxRedirects' => 5)); + $is_valid = false; + if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { + $is_valid = false; + } else { + $fdata = $req->getResponseBody(); + + // Check if the target page contains a link to our blog + if (preg_match('@' . preg_quote($serendipity['baseURL'], '@') . '@i', $fdata)) { + $is_valid = true; + } else { + $is_valid = false; + } + } + + if ($is_valid === false) { + $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_TRACKBACKURL, $addData); + $eventData = array('allow_comments' => false); + $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_REASON_TRACKBACKURL; + return false; + } + } // Check for word filtering if ($filter_type = $this->get_config('contentfilter_activate', 'moderate')) { -- 2.39.5