Added TypePad Antispam akismet server

This commit is contained in:
Judebert 2009-01-19 02:04:04 +00:00
parent de96fbb588
commit 43ffb5e5c7
2 changed files with 36 additions and 5 deletions
plugins/serendipity_event_spamblock

@ -105,8 +105,12 @@
@define('PLUGIN_EVENT_SPAMBLOCK_HIDE', 'Disable spamblock for Authors');
@define('PLUGIN_EVENT_SPAMBLOCK_HIDE_DESC', 'You can allow authors in the following usergroups to post comments without them being checked by the spamblock plugin.');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER', 'Akismet server');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER_DESC', 'Which server is the above key registered for?');
@define('PLUGIN_EVENT_SPAMBLOCK_SERVER_TPAS', 'TypePad Antispam');
@define('PLUGIN_EVENT_SPAMBLOCK_SERVER_AKISMET', 'Original Akismet');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET', 'Akismet API Key');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET_DESC', 'Akismet.com is a central anti-spam and blacklisting server. It can analyze your incoming comments and check if that comment has been listed as Spam. Akismet was developed for WordPress specifically, but can be used by other systems. You just need an API Key from http://www.akismet.com by registering an account at http://www.wordpress.com/. If you leave this API key empty, Akismet will not be used.');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET_DESC', 'Akismet is an anti-spam and blacklisting protocol. It can analyze your incoming comments and check if that comment has been listed as Spam. Two servers are supported: the original Akismet server, and the TypePad Antispam (TPAS) Open Source server. To use the Akismet server, you must register for an account at http://www.wordpress.com/. To use the TPAS server, you must optain a free key from http://antispam.typepad.com/. If you leave the key blank, Akismet will not be used to check spam.');
@define('PLUGIN_EVENT_SPAMBLOCK_AKISMET_FILTER', 'How to treat Akismet-reported spam');
@define('PLUGIN_EVENT_SPAMBLOCK_REASON_AKISMET_SPAMLIST', 'Filtered by Akismet.com Blacklist');

@ -74,6 +74,7 @@ var $filter_defaults;
'contentfilter_emails',
'bloggdeblacklist',
'akismet',
'akismet_server',
'akismet_filter',
'hide_email',
'checkmail',
@ -250,9 +251,17 @@ var $filter_defaults;
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_AKISMET);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_AKISMET_DESC);
$propbag->add('default', '');
break;
case 'akismet_server':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_AKISMET_SERVER_DESC);
$propbag->add('default', 'tpas');
$propbag->add('radio', array(
'value' => array('moderate', 'reject', 'none'),
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
'value' => array('tpas', 'akismet'),
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_SERVER_TPAS, PLUGIN_EVENT_SPAMBLOCK_SERVER_AKISMET)
));
$propbag->add('radio_per_row', '1');
@ -466,8 +475,26 @@ var $filter_defaults;
'readTimeout' => array(5,0),
);
$server_type = $this->get_config('akismet_server');
$server = '';
switch ($server_type) {
case 'tpas':
$server = 'api.antispam.typepad.com';
break;
case 'akismet':
$server = 'rest.akismet.com';
break;
}
if (empty($server)) {
$this->log($this->logfile, $eventData['id'], 'AKISMET_SERVER', 'No Akismet server found', $addData);
$ret['is_spam'] = false;
$ret['message'] = 'No server for Akismet request';
break;
} else {
$this->log($this->logfile, $eventData['id'], 'AKISMET_SERVER', 'Using Akismet server at ' . $server, $addData);
}
$req = &new HTTP_Request(
'http://rest.akismet.com/1.1/verify-key',
'http://' . $server . '/1.1/verify-key',
$opt
);
@ -492,7 +519,7 @@ var $filter_defaults;
}
$req = &new HTTP_Request(
'http://' . $api_key . '.rest.akismet.com/1.1/comment-check',
'http://' . $api_key . '.' . $server . '/1.1/comment-check',
$opt
);