mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Fix #2252 add option to whitelist an IP/range in spamfilter module
This commit is contained in:
parent
ca4e2d60e3
commit
e0cdd463f4
5 changed files with 24 additions and 4 deletions
|
|
@ -39,6 +39,8 @@ $lang->cmd_ipv6_block_range = 'IPv6 Block Range';
|
|||
$lang->cmd_block_range_self = 'single IP address only';
|
||||
$lang->cmd_block_range_help = 'This option allows you to block an entire range of IP addresses when a spammer is found.<br>Caution: if you block an excessively wide range, you may also end up blocking innocent users.';
|
||||
$lang->cmd_block_range = 'IP addresses with the same %d last blocks';
|
||||
$lang->cmd_spamfilter_except_ip = 'Whitelist IP';
|
||||
$lang->cmd_spamfilter_except_ip_help = 'IPs or IP ranges entered here will not be blocked.<br>e.g. 123.45.67.89, 123.45.67.0/24, 123.45.67.*';
|
||||
$lang->unit_write_count = 'times';
|
||||
$lang->add = 'Add';
|
||||
$lang->msg_duplicate = 'Duplicate';
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ $lang->cmd_ipv6_block_range = 'IPv6 차단 범위';
|
|||
$lang->cmd_block_range_self = '해당 IP만 차단';
|
||||
$lang->cmd_block_range_help = '스패머 발견시 비슷한 대역의 IP를 한꺼번에 차단할 수 있습니다. 숫자가 작을수록 광범위하게 차단됩니다.<br>지나치게 광범위하게 차단하면 정상적인 사용자에게 피해가 발생할 수 있으니 주의하시기 바랍니다.';
|
||||
$lang->cmd_block_range = '마지막 %d자리가 같은 IP를 모두 차단';
|
||||
$lang->cmd_spamfilter_except_ip = '예외 IP';
|
||||
$lang->cmd_spamfilter_except_ip_help = '차단하지 않을 IP 또는 IP 대역을 한 줄에 하나씩 입력하십시오.<br>예: 123.45.67.89, 123.45.67.0/24, 123.45.67.*';
|
||||
$lang->unit_write_count = '회';
|
||||
$lang->add = '추가';
|
||||
$lang->msg_duplicate = '이미 존재합니다.';
|
||||
|
|
|
|||
|
|
@ -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', 'custom_message');
|
||||
$args = Context::gets('limits', 'limits_interval', 'limits_count', 'ipv4_block_range', 'ipv6_block_range', 'except_ip', 'custom_message');
|
||||
|
||||
// Set default values
|
||||
if($args->limits != 'Y')
|
||||
|
|
@ -35,6 +35,7 @@ class SpamfilterAdminController extends Spamfilter
|
|||
{
|
||||
$args->ipv6_block_range = '';
|
||||
}
|
||||
$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->custom_message = escape(utf8_trim($args->custom_message));
|
||||
|
|
|
|||
|
|
@ -169,6 +169,14 @@ class SpamfilterModel extends Spamfilter
|
|||
$limit_count = $config->limits_count ?: 3;
|
||||
$interval = $config->limits_interval ?: 10;
|
||||
|
||||
if (!empty($config->except_ip))
|
||||
{
|
||||
if (Rhymix\Framework\Filters\IpFilter::inRanges(\RX_CLIENT_IP, $config->except_ip))
|
||||
{
|
||||
return new BaseObject();
|
||||
}
|
||||
}
|
||||
|
||||
$count = $this->getLogCount($interval);
|
||||
|
||||
// Ban the IP address if the interval is exceeded
|
||||
|
|
@ -183,7 +191,7 @@ class SpamfilterModel extends Spamfilter
|
|||
$suffix = $config->ipv6_block_range ?: '';
|
||||
}
|
||||
|
||||
$oSpamFilterController = getController('spamfilter');
|
||||
$oSpamFilterController = SpamfilterController::getInstance();
|
||||
$oSpamFilterController->insertIP(\RX_CLIENT_IP . $suffix, 'AUTO-DENIED : Over limit');
|
||||
return new BaseObject(-1, 'msg_alert_registered_denied_ip');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<include target="./header.html" />
|
||||
<section class="section">
|
||||
<form action="./" method="post" id="spamfilterConfig" class="x_form-horizontal">
|
||||
<form action="./" method="post" id="spamfilterConfig" class="x_form-horizontal">
|
||||
<input type="hidden" name="act" value="procSpamfilterAdminInsertConfig" />
|
||||
<input type="hidden" name="module" value="spamfilter" />
|
||||
<input type="hidden" name="xe_validator_id" value="modules/spamfilter/tpl/1" />
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
{$lang->cmd_yes}
|
||||
</label>
|
||||
<label for="spamCond1_no" class="x_inline">
|
||||
<input type="radio" name="limits" id="spamCond1_no" value="N" checked="checked"|cond="$config->limits!='Y' && $config->limits !=''" />
|
||||
<input type="radio" name="limits" id="spamCond1_no" value="N" checked="checked"|cond="$config->limits!='Y' && $config->limits !=''" />
|
||||
{$lang->cmd_no}
|
||||
</label>
|
||||
</p>
|
||||
|
|
@ -60,6 +60,13 @@
|
|||
<p class="x_help-block">{$lang->cmd_block_range_help}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label for="except_ip" class="x_control-label">{$lang->cmd_spamfilter_except_ip}</label>
|
||||
<div class="x_controls">
|
||||
<textarea name="except_ip" id="except_ip">{implode("\n", $config->except_ip ?? [])}</textarea>
|
||||
<p class="x_help-block">{$lang->cmd_spamfilter_except_ip_help}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_save}</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue