mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Add regexp support to spamfilter
This commit is contained in:
parent
75f55c9b5e
commit
7c07727e91
9 changed files with 38 additions and 16 deletions
|
|
@ -12,9 +12,12 @@ $lang->check_trackback = 'Check Trackbacks';
|
||||||
$lang->word = 'Keyword';
|
$lang->word = 'Keyword';
|
||||||
$lang->hit = 'Hit';
|
$lang->hit = 'Hit';
|
||||||
$lang->latest_hit = 'Latest Hits';
|
$lang->latest_hit = 'Latest Hits';
|
||||||
|
$lang->custom_message = 'Error Message';
|
||||||
|
$lang->about_custom_message = 'You can customize the error message that will be displayed if a spam keyword is found.<br>%s can be used as a placeholder for the keyword. If not used, the keyword will be hidden.';
|
||||||
$lang->about_interval = 'All articles attempted for posting within the assigned time will be blocked.';
|
$lang->about_interval = 'All articles attempted for posting within the assigned time will be blocked.';
|
||||||
$lang->about_denied_ip = 'Please enter one IP address (e.g. 127.0.0.1) or range (e.g. 127.0.0.0/24) per line. Comments may start with //.';
|
$lang->about_denied_ip = 'Please enter one IP address (e.g. 127.0.0.1) or range (e.g. 127.0.0.0/24) per line. Comments may start with //.';
|
||||||
$lang->about_denied_word = 'Please enter one keyword per line. Keywords may contain 2 to 40 characters.';
|
$lang->about_denied_word = 'Please enter one keyword per line. Keywords may contain 2 to 180 characters.<br>Formats such as /spam(key|word)?/ will be treated as a regular expression, and must use the proper syntax.<br>Spam keywords are not case sensitive.';
|
||||||
|
$lang->msg_denied_word_is_regexp = 'REGEXP';
|
||||||
$lang->msg_alert_limited_by_config = 'Please do not post repeatedly within %d seconds. If you keep trying, your IP address will be blocked.';
|
$lang->msg_alert_limited_by_config = 'Please do not post repeatedly within %d seconds. If you keep trying, your IP address will be blocked.';
|
||||||
$lang->msg_alert_limited_message_by_config = 'Please do not send messages repeatedly within %d seconds. If you keep trying, your IP address will be blocked.';
|
$lang->msg_alert_limited_message_by_config = 'Please do not send messages repeatedly within %d seconds. If you keep trying, your IP address will be blocked.';
|
||||||
$lang->msg_alert_denied_word = 'The word "%s" is not allowed on this site.';
|
$lang->msg_alert_denied_word = 'The word "%s" is not allowed on this site.';
|
||||||
|
|
@ -37,5 +40,5 @@ $lang->unit_write_count = 'times';
|
||||||
$lang->add = 'Add';
|
$lang->add = 'Add';
|
||||||
$lang->msg_duplicate = 'Duplicate';
|
$lang->msg_duplicate = 'Duplicate';
|
||||||
$lang->msg_invalid_ip = 'Invalid IP address format.';
|
$lang->msg_invalid_ip = 'Invalid IP address format.';
|
||||||
$lang->msg_invalid_word = 'Spam keywords must be between 2 and 40 characters.';
|
$lang->msg_invalid_word = 'Spam keywords must be between 2 and 180 characters.';
|
||||||
$lang->msg_faillist = '<br />Error (already blocked)<br /> %s ';
|
$lang->msg_faillist = '<br />Error (already blocked)<br /> %s ';
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,5 @@ $lang->yes = 'はい';
|
||||||
$lang->no = 'いいえ';
|
$lang->no = 'いいえ';
|
||||||
$lang->msg_duplicate = '既に存在します。';
|
$lang->msg_duplicate = '既に存在します。';
|
||||||
$lang->msg_invalid_ip = 'IPアドレスの形式が正しくありません。';
|
$lang->msg_invalid_ip = 'IPアドレスの形式が正しくありません。';
|
||||||
$lang->msg_invalid_word = 'スパムキーワードは2〜40文字の範囲で指定します。';
|
$lang->msg_invalid_word = 'スパムキーワードは2〜180文字の範囲で指定します。';
|
||||||
$lang->msg_faillist = '<br />失敗(既に存在します。) <br /> %s ';
|
$lang->msg_faillist = '<br />失敗(既に存在します。) <br /> %s ';
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,12 @@ $lang->check_trackback = '트랙백 검사';
|
||||||
$lang->word = '키워드';
|
$lang->word = '키워드';
|
||||||
$lang->hit = '히트';
|
$lang->hit = '히트';
|
||||||
$lang->latest_hit = '최근 히트';
|
$lang->latest_hit = '최근 히트';
|
||||||
$lang->custom_message = '에러메세지 설정';
|
$lang->custom_message = '차단 메시지 설정';
|
||||||
$lang->about_custom_message = '키워드를 출력하지 않을시 에러메세지를 설정합니다.';
|
$lang->about_custom_message = '스팸 키워드 발견시 표시할 에러 메시지를 지정할 수 있습니다.<br>%s를 넣으면 그 자리에 해당 키워드를 표시하고, 그렇지 않으면 키워드를 숨깁니다.';
|
||||||
$lang->about_interval = '지정된 시간 내에 글을 등록하지 못하게 합니다.';
|
$lang->about_interval = '지정된 시간 내에 글을 등록하지 못하게 합니다.';
|
||||||
$lang->about_denied_ip = '한 줄에 하나씩 IP 주소 또는 대역을 입력하세요. "//" 또는 "#" 뒷부분은 설명으로 저장됩니다. 예: 127.0.0.1 //설명, 127.0.0.1 #설명<br>IP 대역 표기법은 <a href="https://github.com/rhymix/rhymix-docs/blob/master/ko/misc/ipfilter.md" target="_blank">매뉴얼</a>을 참고하십시오.';
|
$lang->about_denied_ip = '한 줄에 하나씩 IP 주소 또는 대역을 입력하세요. "//" 또는 "#" 뒷부분은 설명으로 저장됩니다. 예: 127.0.0.1 //설명, 127.0.0.1 #설명<br>IP 대역 표기법은 <a href="https://github.com/rhymix/rhymix-docs/blob/master/ko/misc/ipfilter.md" target="_blank">매뉴얼</a>을 참고하십시오.';
|
||||||
$lang->about_denied_word = '한 줄에 하나씩 스팸 키워드를 입력하세요. (2~40자)';
|
$lang->about_denied_word = '한 줄에 하나씩 스팸 키워드를 입력하세요. (2~180자)<br>/스팸(키+|워드)?/ 와 같은 형태로 입력하면 정규식으로 간주하며, 올바른 정규식 문법을 사용해야 합니다.<br>대소문자는 구분하지 않습니다.';
|
||||||
|
$lang->msg_denied_word_is_regexp = '정규식';
|
||||||
$lang->msg_alert_limited_by_config = '%d초 이내에 연속 글 작성은 금지됩니다. 계속 시도하면 IP가 차단될 수 있습니다.';
|
$lang->msg_alert_limited_by_config = '%d초 이내에 연속 글 작성은 금지됩니다. 계속 시도하면 IP가 차단될 수 있습니다.';
|
||||||
$lang->msg_alert_limited_message_by_config = '%d초 이내에 연속 쪽지 발송은 금지됩니다. 계속 시도하면 IP가 차단될 수 있습니다.';
|
$lang->msg_alert_limited_message_by_config = '%d초 이내에 연속 쪽지 발송은 금지됩니다. 계속 시도하면 IP가 차단될 수 있습니다.';
|
||||||
$lang->msg_alert_denied_word = '"%s"은(는) 사용이 금지된 단어입니다.';
|
$lang->msg_alert_denied_word = '"%s"은(는) 사용이 금지된 단어입니다.';
|
||||||
|
|
@ -39,5 +40,5 @@ $lang->unit_write_count = '회';
|
||||||
$lang->add = '추가';
|
$lang->add = '추가';
|
||||||
$lang->msg_duplicate = '이미 존재합니다.';
|
$lang->msg_duplicate = '이미 존재합니다.';
|
||||||
$lang->msg_invalid_ip = 'IP 주소 형식이 올바르지 않습니다.';
|
$lang->msg_invalid_ip = 'IP 주소 형식이 올바르지 않습니다.';
|
||||||
$lang->msg_invalid_word = '스팸 키워드는 2~40자 사이여야 합니다.';
|
$lang->msg_invalid_word = '스팸 키워드는 2~180자 사이여야 합니다.';
|
||||||
$lang->msg_faillist = '<br />실패 (이미 차단되어 있습니다)<br /> %s ';
|
$lang->msg_faillist = '<br />실패 (이미 차단되어 있습니다)<br /> %s ';
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<table name="spamfilter_denied_word">
|
<table name="spamfilter_denied_word">
|
||||||
<column name="word" type="varchar" size="250" utf8mb4="false" notnull="notnull" primary_key="primary_key" />
|
<column name="word" type="varchar" size="180" utf8mb4="false" notnull="notnull" primary_key="primary_key" />
|
||||||
<column name="hit" type="number" notnull="notnull" default="0" index="idx_hit" />
|
<column name="hit" type="number" notnull="notnull" default="0" index="idx_hit" />
|
||||||
<column name="latest_hit" type="date" index="idx_latest_hit" />
|
<column name="latest_hit" type="date" index="idx_latest_hit" />
|
||||||
<column name="regdate" type="date" index="idx_regdate" />
|
<column name="regdate" type="date" index="idx_regdate" />
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ class spamfilterAdminController extends spamfilter
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb_strlen($word, 'UTF-8') < 2 || mb_strlen($word, 'UTF-8') > 40)
|
if (mb_strlen($word, 'UTF-8') < 2 || mb_strlen($word, 'UTF-8') > 180)
|
||||||
{
|
{
|
||||||
return $this->setError('msg_invalid_word');
|
return $this->setError('msg_invalid_word');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,8 @@ class spamfilterModel extends spamfilter
|
||||||
{
|
{
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->sort_index = "hit";
|
$args->sort_index = "hit";
|
||||||
$output = executeQuery('spamfilter.getDeniedWordList', $args);
|
$output = executeQueryArray('spamfilter.getDeniedWordList', $args);
|
||||||
if(!$output->data) return;
|
return $output->data ?: array();
|
||||||
if(!is_array($output->data)) return array($output->data);
|
|
||||||
return $output->data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -84,7 +82,16 @@ class spamfilterModel extends spamfilter
|
||||||
foreach ($word_list as $word_item)
|
foreach ($word_list as $word_item)
|
||||||
{
|
{
|
||||||
$word = $word_item->word;
|
$word = $word_item->word;
|
||||||
if (strpos($text, strtolower($word)) !== false)
|
$hit = false;
|
||||||
|
if (preg_match('#^/.+/$#', $word))
|
||||||
|
{
|
||||||
|
$hit = preg_match($word . 'iu', $text, $matches) ? $matches[0] : false;
|
||||||
|
}
|
||||||
|
if ($hit === false)
|
||||||
|
{
|
||||||
|
$hit = (strpos($text, strtolower($word)) !== false) ? $word : false;
|
||||||
|
}
|
||||||
|
if ($hit !== false)
|
||||||
{
|
{
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->word = $word;
|
$args->word = $word;
|
||||||
|
|
@ -106,7 +113,12 @@ class spamfilterModel extends spamfilter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$custom_message = sprintf(lang('msg_alert_denied_word'), $word);
|
$custom_message = lang('msg_alert_denied_word');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($custom_message, '%s') !== false)
|
||||||
|
{
|
||||||
|
$custom_message = sprintf($custom_message, escape($hit, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BaseObject(-1, $custom_message);
|
return new BaseObject(-1, $custom_message);
|
||||||
|
|
|
||||||
5
modules/spamfilter/tpl/css/spamfilter_admin.css
Normal file
5
modules/spamfilter/tpl/css/spamfilter_admin.css
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
span.is_regexp {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 4px;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr loop="$word_list => $word_info">
|
<tr loop="$word_list => $word_info">
|
||||||
<td>{$word_info->word}</td>
|
<td>{$word_info->word} <!--@if(preg_match('#^/.+/$#', $word_info->word))--><span class="is_regexp">[{$lang->msg_denied_word_is_regexp}]</span><!--@end--></td>
|
||||||
<td><!--@if($word_info->latest_hit)-->{zdate($word_info->latest_hit,'Y-m-d H:i')}<!--@else-->-<!--@end--></td>
|
<td><!--@if($word_info->latest_hit)-->{zdate($word_info->latest_hit,'Y-m-d H:i')}<!--@else-->-<!--@end--></td>
|
||||||
<td>{$word_info->hit}</td>
|
<td>{$word_info->hit}</td>
|
||||||
<td>{zdate($word_info->regdate,'Y-m-d')}</td>
|
<td>{zdate($word_info->regdate,'Y-m-d')}</td>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<load target="css/spamfilter_admin.css" />
|
||||||
<load target="js/spamfilter_admin.js" />
|
<load target="js/spamfilter_admin.js" />
|
||||||
<div class="x_page-header">
|
<div class="x_page-header">
|
||||||
<h1>{$lang->spamfilter} <a class="x_icon-question-sign" href="./common/manual/admin/index.html#UMAN_content_spamfilter" target="_blank">{$lang->help}</a></h1>
|
<h1>{$lang->spamfilter} <a class="x_icon-question-sign" href="./common/manual/admin/index.html#UMAN_content_spamfilter" target="_blank">{$lang->help}</a></h1>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue