mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Allow selecting which actions to block if the user's IP is listed in spamfilter #2423
This commit is contained in:
parent
a04dc1270f
commit
fe6625bfbb
5 changed files with 91 additions and 13 deletions
|
|
@ -28,7 +28,9 @@ $lang->cmd_spamfilter_except_member = 'Except Members';
|
|||
$lang->cmd_spamfilter_filter_html = 'HTML';
|
||||
$lang->cmd_spamfilter_is_regexp = 'REGEXP';
|
||||
$lang->cmd_interval = 'Block Post/Comment Spam';
|
||||
$lang->cmd_interval_help = 'Block IP addresses that post or comment too much in a short time. Blocked IP addresses will not be able to post, comment, or send messages.';
|
||||
$lang->cmd_interval_help = 'Block IP addresses that post or comment too much in a short time.';
|
||||
$lang->cmd_blocked_actions = 'Blocked actions';
|
||||
$lang->cmd_blocked_actions_help = 'The actions above will be disabled from blocked IP addresses.';
|
||||
$lang->cmd_check_trackback = 'Block Trackback Spam';
|
||||
$lang->cmd_check_trackback_help = 'Block IP addresses that send multiple trackbacks to the same document.<br>This only works if the trackback module is installed.';
|
||||
$lang->cmd_limits_interval = 'Block Interval';
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ $lang->msg_alert_trackback_denied = '한 글에는 하나의 트랙백만 허용
|
|||
$lang->cmd_spamfilter_except_member = '회원 제외';
|
||||
$lang->cmd_spamfilter_filter_html = 'HTML';
|
||||
$lang->cmd_spamfilter_is_regexp = '정규식';
|
||||
$lang->cmd_interval = '글, 댓글 스팸 차단';
|
||||
$lang->cmd_interval_help = '지정한 시간 내에 다수의 글이나 댓글을 작성하면 스패머로 간주하고 글, 댓글 작성과 엮인글 발송, 쪽지 발송을 차단합니다.';
|
||||
$lang->cmd_interval = '단시간 다수 작성 차단';
|
||||
$lang->cmd_interval_help = '지정한 시간 내에 다수의 글이나 댓글을 작성하면 스패머로 간주하고 IP를 차단합니다.';
|
||||
$lang->cmd_blocked_actions = '차단할 행동';
|
||||
$lang->cmd_blocked_actions_help = '차단된 IP에서는 위의 행동들을 할 수 없게 됩니다.';
|
||||
$lang->cmd_check_trackback = '트랙백 스팸 차단';
|
||||
$lang->cmd_check_trackback_help = '하나의 글에 2회 이상 엮인글을 등록하면 스패머로 간주하고 엮인글을 차단합니다.<br>트랙백 모듈이 설치되어 있는 경우에만 적용됩니다.';
|
||||
$lang->cmd_limits_interval = '글, 댓글 제한 시간';
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class SpamfilterAdminController extends Spamfilter
|
|||
$config = ModuleModel::getModuleConfig('spamfilter') ?: new stdClass;
|
||||
|
||||
// Get the default information
|
||||
$args = Context::gets('limits', 'limits_interval', 'limits_count', 'ipv4_block_range', 'ipv6_block_range', 'except_ip', 'custom_message');
|
||||
$args = Context::gets('limits', 'limits_interval', 'limits_count', 'blocked_actions', 'ipv4_block_range', 'ipv6_block_range', 'except_ip', 'custom_message');
|
||||
|
||||
// Set default values
|
||||
if($args->limits != 'Y')
|
||||
|
|
@ -38,6 +38,7 @@ class SpamfilterAdminController extends Spamfilter
|
|||
$args->except_ip = array_map('trim', preg_split('/[\n,]/', trim($args->except_ip ?? ''), -1, \PREG_SPLIT_NO_EMPTY));
|
||||
$args->limits_interval = intval($args->limits_interval);
|
||||
$args->limits_count = intval($args->limits_count);
|
||||
$args->blocked_actions = array_values($args->blocked_actions ?? []);
|
||||
$args->custom_message = escape(utf8_trim($args->custom_message));
|
||||
foreach ($args as $key => $val)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,7 +52,15 @@ class SpamfilterController extends Spamfilter
|
|||
|
||||
// Check if the IP is prohibited
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$config = SpamfilterModel::getConfig();
|
||||
if (!isset($config->blocked_actions) || in_array('document', $config->blocked_actions))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is a ban on the word
|
||||
$filter_targets = [$obj->title, $obj->content, $obj->tags ?? ''];
|
||||
if(!$is_logged)
|
||||
|
|
@ -104,7 +112,15 @@ class SpamfilterController extends Spamfilter
|
|||
|
||||
// Check if the IP is prohibited
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$config = SpamfilterModel::getConfig();
|
||||
if (!isset($config->blocked_actions) || in_array('comment', $config->blocked_actions))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is a ban on the word
|
||||
if($is_logged)
|
||||
{
|
||||
|
|
@ -185,7 +201,7 @@ class SpamfilterController extends Spamfilter
|
|||
*/
|
||||
function triggerVote(&$obj)
|
||||
{
|
||||
if ($_SESSION['avoid_log'])
|
||||
if (!empty($_SESSION['avoid_log']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -195,6 +211,16 @@ class SpamfilterController extends Spamfilter
|
|||
return;
|
||||
}
|
||||
|
||||
$config = SpamfilterModel::getConfig();
|
||||
if ($obj->point > 0 && isset($config->blocked_actions) && !in_array('vote_up', $config->blocked_actions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ($obj->point < 0 && isset($config->blocked_actions) && !in_array('vote_down', $config->blocked_actions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if (!$output->toBool())
|
||||
{
|
||||
|
|
@ -207,7 +233,7 @@ class SpamfilterController extends Spamfilter
|
|||
*/
|
||||
function triggerDeclare(&$obj)
|
||||
{
|
||||
if ($_SESSION['avoid_log'])
|
||||
if (!empty($_SESSION['avoid_log']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -217,6 +243,12 @@ class SpamfilterController extends Spamfilter
|
|||
return;
|
||||
}
|
||||
|
||||
$config = SpamfilterModel::getConfig();
|
||||
if (isset($config->blocked_actions) && !in_array('declare', $config->blocked_actions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if (!$output->toBool())
|
||||
{
|
||||
|
|
@ -229,25 +261,36 @@ class SpamfilterController extends Spamfilter
|
|||
*/
|
||||
function triggerSendMessage(&$obj)
|
||||
{
|
||||
if($_SESSION['avoid_log']) return;
|
||||
if($this->user->isAdmin() || !empty($_SESSION['avoid_log']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($obj->use_spamfilter) && $obj->use_spamfilter === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->is_admin == 'Y') return;
|
||||
|
||||
// Check if the IP is prohibited
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$config = SpamfilterModel::getConfig();
|
||||
if (!isset($config->blocked_actions) || in_array('message', $config->blocked_actions))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is a ban on the word
|
||||
$text = $obj->title . ' ' . $obj->content;
|
||||
$output = SpamfilterModel::isDeniedWord($text);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// Check the specified time
|
||||
$output = SpamfilterModel::checkLimited(TRUE);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// Save a log
|
||||
$this->insertLog();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,36 @@
|
|||
<p class="x_help-block">{$lang->cmd_interval_help}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->cmd_blocked_actions}</label>
|
||||
<div class="x_controls">
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="document" checked="checked"|cond="!$config->blocked_actions || in_array('document', $config->blocked_actions)" />
|
||||
{$lang->document}
|
||||
</label>
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="comment" checked="checked"|cond="!$config->blocked_actions || in_array('comment', $config->blocked_actions)" />
|
||||
{$lang->comment}
|
||||
</label>
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="vote_up" checked="checked"|cond="!$config->blocked_actions || in_array('vote_up', $config->blocked_actions)" />
|
||||
{$lang->cmd_vote}
|
||||
</label>
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="vote_down" checked="checked"|cond="!$config->blocked_actions || in_array('vote_down', $config->blocked_actions)" />
|
||||
{$lang->cmd_vote_down}
|
||||
</label>
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="declare" checked="checked"|cond="!$config->blocked_actions || in_array('declare', $config->blocked_actions)" />
|
||||
{$lang->cmd_declare}
|
||||
</label>
|
||||
<label class="x_inline">
|
||||
<input type="checkbox" name="blocked_actions[]" value="message" checked="checked"|cond="!$config->blocked_actions || in_array('message', $config->blocked_actions)" />
|
||||
{$lang->member_message}
|
||||
</label>
|
||||
<p class="x_help-block">{$lang->cmd_blocked_actions_help}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="custom_message">{$lang->custom_message}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue