Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_spamblock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22418/plugins/serendipity_event_spamblock
Added Files:
serendipity_event_spamblock.php
Log Message:
alpha-spamblock plugin. I'd like to have the stub for this in 0.7 to be able
to release an enhanced anti-spam plugin for future service releases, because
I guess it will take a time until a 0.8 will be released.
If any of you have a problem with this, please raise your voice.
--- NEW FILE: serendipity_event_spamblock.php ---
<?php # $Id: serendipity_event_spamblock.php,v 1.1 2004/09/01 14:15:10 garvinhicking Exp $
switch ($serendipity['lang']) {
default:
@define('PLUGIN_EVENT_SPAMBLOCK_TITLE', 'Spam-Protection');
@define('PLUGIN_EVENT_SPAMBLOCK_DESC', 'Protection of comment spam, ... (ALPHA)');
break;
}
class serendipity_event_spamblock extends serendipity_event
{
var $services;
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_TITLE);
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_DESC);
$propbag->add('event_hooks', array(
'frontend_saveComment' => true
));
}
function generate_content(&$title) {
$title = PLUGIN_EVENT_SPAMBLOCK_TITLE;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_saveComment':
if (!is_array($eventData) || serendipity_db_bool($eventData['allow_comments'])) {
// Check for identical comments.
$query = "SELECT count(id) AS counter FROM {$serendipity['dbPrefix']}comments WHERE body = '" . serendipity_db_escape_string($addData['comment']) . "'";
$row = serendipity_db_query($query, true);
if (is_array($row) && $row['counter'] > 0) {
$eventData = array('allow_comments' => false);
}
}
return true;
break;
default:
return false;
break;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|