consistent plugin usage - spamblock
this and followup commits touches: use load_languiage API class method parenthesis "\n{\n <code>\n}\n", case break switches, consistent boolean usage, append css to eventData and other cleanups
This commit is contained in:
@ -1,10 +1,14 @@
|
|||||||
<?php #
|
<?php
|
||||||
|
|
||||||
|
if (IN_serendipity !== true) {
|
||||||
|
die ("Don't hack!");
|
||||||
|
}
|
||||||
|
|
||||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||||
|
|
||||||
class serendipity_event_spamblock extends serendipity_event
|
class serendipity_event_spamblock extends serendipity_event
|
||||||
{
|
{
|
||||||
var $filter_defaults;
|
var $filter_defaults;
|
||||||
|
|
||||||
function introspect(&$propbag)
|
function introspect(&$propbag)
|
||||||
{
|
{
|
||||||
@ -17,11 +21,11 @@ var $filter_defaults;
|
|||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Garvin Hicking, Sebastian Nohn, Grischa Brockhaus, Ian');
|
$propbag->add('author', 'Garvin Hicking, Sebastian Nohn, Grischa Brockhaus, Ian');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '1.6',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
$propbag->add('version', '1.84');
|
$propbag->add('version', '1.85');
|
||||||
$propbag->add('event_hooks', array(
|
$propbag->add('event_hooks', array(
|
||||||
'frontend_saveComment' => true,
|
'frontend_saveComment' => true,
|
||||||
'external_plugin' => true,
|
'external_plugin' => true,
|
||||||
@ -100,6 +104,7 @@ var $filter_defaults;
|
|||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
switch($name) {
|
switch($name) {
|
||||||
|
|
||||||
case 'disable_api_comments':
|
case 'disable_api_comments':
|
||||||
$propbag->add('type', 'radio');
|
$propbag->add('type', 'radio');
|
||||||
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS);
|
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_API_COMMENTS);
|
||||||
@ -110,7 +115,6 @@ var $filter_defaults;
|
|||||||
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'trackback_ipvalidation':
|
case 'trackback_ipvalidation':
|
||||||
@ -241,7 +245,6 @@ var $filter_defaults;
|
|||||||
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'akismet':
|
case 'akismet':
|
||||||
@ -249,7 +252,6 @@ var $filter_defaults;
|
|||||||
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_AKISMET);
|
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_AKISMET);
|
||||||
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_AKISMET_DESC);
|
$propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_AKISMET_DESC);
|
||||||
$propbag->add('default', '');
|
$propbag->add('default', '');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'akismet_server':
|
case 'akismet_server':
|
||||||
@ -269,7 +271,6 @@ var $filter_defaults;
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'akismet_filter':
|
case 'akismet_filter':
|
||||||
@ -282,7 +283,6 @@ var $filter_defaults;
|
|||||||
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_API_MODERATE, PLUGIN_EVENT_SPAMBLOCK_API_REJECT, NONE)
|
||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'contentfilter_urls':
|
case 'contentfilter_urls':
|
||||||
@ -334,7 +334,6 @@ var $filter_defaults;
|
|||||||
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_FILE, PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_DB, PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_NONE)
|
'desc' => array(PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_FILE, PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_DB, PLUGIN_EVENT_SPAMBLOCK_LOGTYPE_NONE)
|
||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ipflood':
|
case 'ipflood':
|
||||||
@ -412,17 +411,18 @@ var $filter_defaults;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_default_exclude_urls() {
|
function get_default_exclude_urls()
|
||||||
|
{
|
||||||
return '^http://identi\.ca/notice/\d+$';
|
return '^http://identi\.ca/notice/\d+$';
|
||||||
}
|
}
|
||||||
|
|
||||||
function htaccess_update($new_ip) {
|
function htaccess_update($new_ip)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}spamblock_htaccess (ip, timestamp) VALUES ('" . serendipity_db_escape_string($new_ip) . "', '" . time() . "')");
|
serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}spamblock_htaccess (ip, timestamp) VALUES ('" . serendipity_db_escape_string($new_ip) . "', '" . time() . "')");
|
||||||
@ -473,7 +473,8 @@ var $filter_defaults;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function akismetRequest($api_key, $data, &$ret, $action = 'comment-check', $eventData = null, $addData = null) {
|
function akismetRequest($api_key, $data, &$ret, $action = 'comment-check', $eventData = null, $addData = null)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$opt = array(
|
$opt = array(
|
||||||
@ -585,8 +586,8 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tellAboutComment($where, $api_key, $comment_id, $is_spam)
|
||||||
function tellAboutComment($where, $api_key, $comment_id, $is_spam) {
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
$comment = serendipity_db_query(" SELECT C.*, L.useragent as log_useragent, E.title as entry_title "
|
$comment = serendipity_db_query(" SELECT C.*, L.useragent as log_useragent, E.title as entry_title "
|
||||||
. " FROM {$serendipity['dbPrefix']}comments C, {$serendipity['dbPrefix']}spamblocklog L , {$serendipity['dbPrefix']}entries E "
|
. " FROM {$serendipity['dbPrefix']}comments C, {$serendipity['dbPrefix']}spamblocklog L , {$serendipity['dbPrefix']}entries E "
|
||||||
@ -624,7 +625,8 @@ var $filter_defaults;
|
|||||||
if (function_exists('serendipity_request_end')) serendipity_request_end();
|
if (function_exists('serendipity_request_end')) serendipity_request_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getBlacklist($where, $api_key, &$eventData, &$addData) {
|
function &getBlacklist($where, $api_key, &$eventData, &$addData)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
@ -661,7 +663,8 @@ var $filter_defaults;
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkScheme() {
|
function checkScheme()
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$dbversion = $this->get_config('dbversion', '1');
|
$dbversion = $this->get_config('dbversion', '1');
|
||||||
@ -722,13 +725,15 @@ var $filter_defaults;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_content(&$title) {
|
function generate_content(&$title)
|
||||||
|
{
|
||||||
$title = $this->title;
|
$title = $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called on "fatal" spam errors that are unlikely to occur accidentally by users.
|
// This method will be called on "fatal" spam errors that are unlikely to occur accidentally by users.
|
||||||
// Their IPs will be constantly blocked.
|
// Their IPs will be constantly blocked.
|
||||||
function IsHardcoreSpammer() {
|
function IsHardcoreSpammer()
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
if (serendipity_db_bool($this->get_config('automagic_htaccess'))) {
|
if (serendipity_db_bool($this->get_config('automagic_htaccess'))) {
|
||||||
@ -737,7 +742,8 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks whether the current author is contained in one of the gorups that need no spam checking
|
// Checks whether the current author is contained in one of the gorups that need no spam checking
|
||||||
function inGroup() {
|
function inGroup()
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$checkgroups = explode('^', $this->get_config('hide_for_authors'));
|
$checkgroups = explode('^', $this->get_config('hide_for_authors'));
|
||||||
@ -762,11 +768,13 @@ var $filter_defaults;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function example() {
|
function example()
|
||||||
|
{
|
||||||
return '<p id="captchabox" class="msg_hint">' . PLUGIN_EVENT_SPAMBLOCK_LOOK . $this->show_captcha() . '</p>';
|
return '<p id="captchabox" class="msg_hint">' . PLUGIN_EVENT_SPAMBLOCK_LOOK . $this->show_captcha() . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_captcha($use_gd = false) {
|
function show_captcha($use_gd = false)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
if ($use_gd || (function_exists('imagettftext') && function_exists('imagejpeg'))) {
|
if ($use_gd || (function_exists('imagettftext') && function_exists('imagejpeg'))) {
|
||||||
@ -798,19 +806,21 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
$debug = true;
|
$debug = true;
|
||||||
|
|
||||||
$hooks = &$bag->get('event_hooks');
|
$hooks = &$bag->get('event_hooks');
|
||||||
|
|
||||||
if (isset($hooks[$event])) {
|
if (isset($hooks[$event])) {
|
||||||
|
|
||||||
$captchas_ttl = $this->get_config('captchas_ttl', 7);
|
$captchas_ttl = $this->get_config('captchas_ttl', 7);
|
||||||
$_captchas = $this->get_config('captchas', 'yes');
|
$_captchas = $this->get_config('captchas', 'yes');
|
||||||
$captchas = ($_captchas !== 'no' && ($_captchas === 'yes' || $_captchas === 'scramble' || serendipity_db_bool($_captchas)));
|
$captchas = ($_captchas !== 'no' && ($_captchas === 'yes' || $_captchas === 'scramble' || serendipity_db_bool($_captchas)));
|
||||||
|
|
||||||
// Check if the entry is older than the allowed amount of time. Enforce kaptchas if that is true
|
// Check if the entry is older than the allowed amount of time. Enforce Captchas if that is true
|
||||||
// of if kaptchas are activated for every entry
|
// of if Captchas are activated for every entry
|
||||||
$show_captcha = ($captchas && isset($eventData['timestamp']) && ($captchas_ttl < 1 || ($eventData['timestamp'] < (time() - ($captchas_ttl*60*60*24)))) ? true : false);
|
$show_captcha = ($captchas && isset($eventData['timestamp']) && ($captchas_ttl < 1 || ($eventData['timestamp'] < (time() - ($captchas_ttl*60*60*24)))) ? true : false);
|
||||||
|
|
||||||
// Plugins can override with custom captchas
|
// Plugins can override with custom captchas
|
||||||
@ -836,8 +846,9 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch($event) {
|
switch($event) {
|
||||||
|
|
||||||
case 'fetchcomments':
|
case 'fetchcomments':
|
||||||
if (is_array($eventData) && !$_SESSION['serendipityAuthedUser'] && serendipity_db_bool($this->get_config('hide_email', false))) {
|
if (is_array($eventData) && !$_SESSION['serendipityAuthedUser'] && serendipity_db_bool($this->get_config('hide_email', 'false'))) {
|
||||||
// Will force emails to be not displayed in comments and RSS feed for comments. Will not apply to logged in admins (so not in the backend as well)
|
// Will force emails to be not displayed in comments and RSS feed for comments. Will not apply to logged in admins (so not in the backend as well)
|
||||||
@reset($eventData);
|
@reset($eventData);
|
||||||
while(list($idx, $comment) = each($eventData)) {
|
while(list($idx, $comment) = each($eventData)) {
|
||||||
@ -862,7 +873,7 @@ var $filter_defaults;
|
|||||||
$checkmail = $this->get_config('checkmail');
|
$checkmail = $this->get_config('checkmail');
|
||||||
|
|
||||||
// Check CSRF [comments only, cannot be applied to trackbacks]
|
// Check CSRF [comments only, cannot be applied to trackbacks]
|
||||||
if ($addData['type'] == 'NORMAL' && serendipity_db_bool($this->get_config('csrf', true))) {
|
if ($addData['type'] == 'NORMAL' && serendipity_db_bool($this->get_config('csrf', 'true'))) {
|
||||||
if (!serendipity_checkFormToken(false)) {
|
if (!serendipity_checkFormToken(false)) {
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_CSRF_REASON, $addData);
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_CSRF_REASON, $addData);
|
||||||
$eventData = array('allow_comments' => false);
|
$eventData = array('allow_comments' => false);
|
||||||
@ -912,7 +923,7 @@ var $filter_defaults;
|
|||||||
// already there #$eventData = array('allow_comments' => false);
|
// already there #$eventData = array('allow_comments' => false);
|
||||||
// already there #$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
// already there #$serendipity['messagestack']['emails'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_BODY;
|
||||||
return false;
|
return false;
|
||||||
} elseif (serendipity_db_bool($this->get_config('killswitch', false)) === true) {
|
} elseif (serendipity_db_bool($this->get_config('killswitch', 'false')) === true) {
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_KILLSWITCH, $addData);
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_KILLSWITCH, $addData);
|
||||||
$eventData = array('allow_comments' => false);
|
$eventData = array('allow_comments' => false);
|
||||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
|
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
|
||||||
@ -940,7 +951,7 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for global emergency moderation
|
// Check for global emergency moderation
|
||||||
if (serendipity_db_bool($this->get_config('killswitch', false)) === true) {
|
if (serendipity_db_bool($this->get_config('killswitch', 'false')) === true) {
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_KILLSWITCH, $addData);
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_KILLSWITCH, $addData);
|
||||||
$eventData = array('allow_comments' => false);
|
$eventData = array('allow_comments' => false);
|
||||||
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
|
$serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_KILLSWITCH;
|
||||||
@ -1162,7 +1173,7 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check invalid email
|
// Check invalid email
|
||||||
if ($addData['type'] == 'NORMAL' && serendipity_db_bool($this->get_config('checkmail', false))) {
|
if ($addData['type'] == 'NORMAL' && serendipity_db_bool($this->get_config('checkmail', 'false'))) {
|
||||||
if (!empty($addData['email']) && strstr($addData['email'], '@') === false) {
|
if (!empty($addData['email']) && strstr($addData['email'], '@') === false) {
|
||||||
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_CHECKMAIL, $addData);
|
$this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_CHECKMAIL, $addData);
|
||||||
$eventData = array('allow_comments' => false);
|
$eventData = array('allow_comments' => false);
|
||||||
@ -1175,12 +1186,10 @@ var $filter_defaults;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'frontend_comment':
|
case 'frontend_comment':
|
||||||
if (serendipity_db_bool($this->get_config('hide_email', false))) {
|
if (serendipity_db_bool($this->get_config('hide_email', 'false'))) {
|
||||||
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL_NOTICE . '</div>';
|
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL_NOTICE . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1197,7 @@ var $filter_defaults;
|
|||||||
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_INFO . '</div>';
|
echo '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL_VERIFICATION_INFO . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serendipity_db_bool($this->get_config('csrf', true))) {
|
if (serendipity_db_bool($this->get_config('csrf', 'true'))) {
|
||||||
echo serendipity_setFormToken('form');
|
echo serendipity_setFormToken('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,11 +1218,8 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 'external_plugin':
|
case 'external_plugin':
|
||||||
$parts = explode('_', (string)$eventData);
|
$parts = explode('_', (string)$eventData);
|
||||||
if (!empty($parts[1])) {
|
if (!empty($parts[1])) {
|
||||||
@ -1303,7 +1309,6 @@ var $filter_defaults;
|
|||||||
echo file_get_contents($cap);
|
echo file_get_contents($cap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'backend_comments_top':
|
case 'backend_comments_top':
|
||||||
@ -1347,7 +1352,6 @@ var $filter_defaults;
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '<a class="button_link" title="' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '" href="serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance . '"><span class="icon-medkit"></span><span class="visuallyhidden"> ' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '</span></a>';
|
echo '<a class="button_link" title="' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '" href="serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance . '"><span class="icon-medkit"></span><span class="visuallyhidden"> ' . PLUGIN_EVENT_SPAMBLOCK_CONFIG . '</span></a>';
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'backend_view_comment':
|
case 'backend_view_comment':
|
||||||
@ -1374,20 +1378,16 @@ var $filter_defaults;
|
|||||||
$email_is_filtered = $this->checkFilter('emails', $eventData['email']);
|
$email_is_filtered = $this->checkFilter('emails', $eventData['email']);
|
||||||
$eventData['action_email'] .= ' <a class="button_link" title="' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&serendipity[spamBlockEmail]=' . $eventData['id'] . $addData . $randomString . '#' . $clink . '"><span class="icon-' . ($email_is_filtered ? 'ok-circled' : 'block') .'"></span><span class="visuallyhidden"> ' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '</span></a>';
|
$eventData['action_email'] .= ' <a class="button_link" title="' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '" href="serendipity_admin.php?serendipity[adminModule]=comments&serendipity[spamBlockEmail]=' . $eventData['id'] . $addData . $randomString . '#' . $clink . '"><span class="icon-' . ($email_is_filtered ? 'ok-circled' : 'block') .'"></span><span class="visuallyhidden"> ' . ($email_is_filtered ? PLUGIN_EVENT_SPAMBLOCK_REMOVE_EMAIL : PLUGIN_EVENT_SPAMBLOCK_ADD_EMAIL) . '</span></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'backend_sidebar_admin_appearance':
|
case 'backend_sidebar_admin_appearance':
|
||||||
echo '<li><a href="serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance . '">' . PLUGIN_EVENT_SPAMBLOCK_TITLE . '</a></li>';
|
echo '<li><a href="serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance . '">' . PLUGIN_EVENT_SPAMBLOCK_TITLE . '</a></li>';
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1396,7 +1396,8 @@ 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.
|
* 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) {
|
function wordfilter($logfile, &$eventData, $wordmatch, $addData, $ftc = false)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
// Check for word filtering
|
// Check for word filtering
|
||||||
@ -1517,7 +1518,8 @@ var $filter_defaults;
|
|||||||
} // function wordfilter end
|
} // 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]));
|
||||||
|
|
||||||
$filtered = false;
|
$filtered = false;
|
||||||
@ -1550,7 +1552,8 @@ var $filter_defaults;
|
|||||||
return $filtered;
|
return $filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getComment($key, $id) {
|
function getComment($key, $id)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
$c = serendipity_db_query("SELECT $key FROM {$serendipity['dbPrefix']}comments WHERE id = '" . (int)$id . "'", true, 'assoc');
|
$c = serendipity_db_query("SELECT $key FROM {$serendipity['dbPrefix']}comments WHERE id = '" . (int)$id . "'", true, 'assoc');
|
||||||
|
|
||||||
@ -1561,7 +1564,8 @@ var $filter_defaults;
|
|||||||
return $c[$key];
|
return $c[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
function random_string($max_char, $min_char) {
|
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(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
|
$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
|
||||||
|
|
||||||
@ -1575,7 +1579,8 @@ var $filter_defaults;
|
|||||||
return $strings;
|
return $strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
function log($logfile, $id, $switch, $reason, $comment) {
|
function log($logfile, $id, $switch, $reason, $comment)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$method = $this->get_config('logtype');
|
$method = $this->get_config('logtype');
|
||||||
@ -1638,6 +1643,8 @@ var $filter_defaults;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set sts=4 ts=4 expandtab : */
|
/* vim: set sts=4 ts=4 expandtab : */
|
||||||
|
?>
|
Reference in New Issue
Block a user