mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@248 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d0aeb583ec
commit
eaadbea932
10 changed files with 134 additions and 14 deletions
|
|
@ -11,4 +11,75 @@
|
|||
* 즉 별도의 interface가 필요한 것이 아니고 모듈의 일부라고 판단하여 코드를 작성하면 된다.
|
||||
**/
|
||||
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$effecived_target = array(
|
||||
'board' => array('procInsertDocument', 'procInsertComment', 'procReceiveTrackback'),
|
||||
);
|
||||
|
||||
// point가 before일때만 실행
|
||||
if($this->point != 'before') return;
|
||||
|
||||
// 현재 모듈의 관리자이거나 그에 준하는 manager권한이면 그냥 패스~
|
||||
if($this->grant->is_admin || $this->grant->manager) return;
|
||||
|
||||
// spam filter모듈이 적용될 module+act를 체크
|
||||
if(!in_array($this->act, $effecived_target[$this->module])) return;
|
||||
|
||||
// spamfilter 모듈 객체 생성
|
||||
$oSpamFilterController = &getController('spamfilter');
|
||||
$oSpamFilterModel = &getModel('spamfilter');
|
||||
|
||||
// 스팸필터 기본 설정 출력
|
||||
$config = $oSpamFilterModel->getConfig();
|
||||
|
||||
// 스팸 간격을 체크하는 변수
|
||||
$interval = $config->interval?$config->interval:60;
|
||||
$limit_count = $config->limit_count?$config->limit_count:5;
|
||||
|
||||
// 스팸 IP에 등록되어 있는지 체크하여 등록되어 있으면 return
|
||||
$is_denied = $oSpamFilterModel->isDeniedIP($ipaddress);
|
||||
if($is_denied) {
|
||||
$output = new Object(-1, 'msg_alert_registered_denied_ip');
|
||||
$this->stop_proc = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// 정해진 시간내에 글 작성 시도를 하였는지 체크
|
||||
$count = $oSpamFilterModel->getLogCount($interval, $ipaddress);
|
||||
|
||||
// 정해진 시간내에 정해진 글의 수를 초과시 스팸 IP로 등록시킴
|
||||
if($count>=$limit_count) {
|
||||
$oSpamFilterController->insertIP($ipaddress);
|
||||
$output = new Object(-1, 'msg_alert_registered_denied_ip');
|
||||
$this->stop_proc = true;
|
||||
return;
|
||||
|
||||
// 제한 글수까지는 아니지만 정해진 시간내에 글 작성을 계속 할때
|
||||
} elseif($count) {
|
||||
$message = sprintf(Context::getLang('msg_alert_limited_by_config'), $interval);
|
||||
$output = new Object(-1, $message);
|
||||
$this->stop_proc = true;
|
||||
}
|
||||
|
||||
// 금지 단어 체크를 위해서 몇가지 지정된 변수들을 한데 묶음
|
||||
$check_vars = implode("\n",get_object_vars(Context::getRequestVars()));
|
||||
|
||||
// 금지 단어를 이용하여 본문 내용을 체크
|
||||
$denied_word_list = $oSpamFilterModel->getDeniedWordList();
|
||||
$denied_word_count = count($denied_word_list);
|
||||
if($denied_word_count>0) {
|
||||
for($i=0;$i<$denied_word_count;$i++) {
|
||||
$word = preg_quote($denied_word_list[$i]->word,'/');
|
||||
if(preg_match('/'.$word.'/i', $check_vars)) {
|
||||
$message = sprintf(Context::getLang('msg_alert_denied_word'), $word);
|
||||
$output = new Object(-1, $message);
|
||||
$this->stop_proc = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 로그를 남김
|
||||
$oSpamFilterController->insertLog();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
var $stop_proc = false; ///< action 수행중 stop()를 호출하면 ModuleObject::proc()를 수행하지 않음
|
||||
|
||||
var $point = 'before'; ///< 애드온 호출시 모듈의 실행을 before/after로 나누고 이 시점을 기록하는 변수
|
||||
|
||||
/**
|
||||
* @brief 현재 모듈의 이름을 지정
|
||||
**/
|
||||
|
|
@ -224,8 +226,16 @@
|
|||
// 기본 act조차 없으면 return
|
||||
if(!method_exists($this, $this->act)) return false;
|
||||
|
||||
// addon 실행(point를 before로 하여 호출)
|
||||
$this->point = 'before';
|
||||
@include("./files/cache/activated_addons.cache.php");
|
||||
|
||||
// this->act값으로 method 실행
|
||||
$output = call_user_method($this->act, $this);
|
||||
if(!$this->stop_proc) $output = call_user_method($this->act, $this);
|
||||
|
||||
// addon 실행(point를 after로 하여 호출)
|
||||
$this->point = 'after';
|
||||
@include("./files/cache/activated_addons.cache.php");
|
||||
|
||||
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
|
||||
$this->setError($output->getError());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
$addon = trim($addon_list[$i]);
|
||||
if(!$addon) continue;
|
||||
|
||||
$buff .= sprintf(' include("./files/addons/%s/%s.addon.php"); ', $addon, $addon);
|
||||
$buff .= sprintf(' include("./addons/%s/%s.addon.php"); ', $addon, $addon);
|
||||
}
|
||||
|
||||
$buff = sprintf('<?if(!__ZB5__)exit(); %s ?>', $buff);
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{$lang->document_url} : {getUrl()}?document_srl={$document->document_srl}
|
||||
{$lang->document_url} : {getUrl()}{$document->document_srl}
|
||||
<!--@if($document->allow_trackback=='Y')-->
|
||||
<br />
|
||||
{$lang->trackback_url} : {getUrl()}trackback.php?document_srl={$document->document_srl}
|
||||
{$lang->trackback_url} : {getUrl()}trackback/{$document->document_srl}
|
||||
<!--@end-->
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -12,13 +12,17 @@
|
|||
// 일반 단어
|
||||
$lang->denied_ip = "금지 IP";
|
||||
$lang->interval = "스팸 처리 간격";
|
||||
$lang->limit_count = "제한수";
|
||||
$lang->word = "단어";
|
||||
|
||||
// 설명문
|
||||
$lang->about_interval = "지정된 시간내에 다시 글이 등록이 되면 스팸으로 간주가 됩니다";
|
||||
$lang->about_limit_count = "지정된 시간내에 제한수를 넘겨서 글 작성을 시도하면 스팸으로 인식, IP를 금지 시킵니다";
|
||||
$lang->about_denied_ip = "127.0.0.* 와 같이 * 로 정해진 패턴의 IP 대역을 모두 금지 시킬 수 있습니다";
|
||||
$lang->about_denied_word = "금지 단어로 등록되면 해당 단어가 있는 글은 등록을 금지 시킬 수 있습니다";
|
||||
|
||||
// 메세지 출력용
|
||||
$lang->msg_alert_registered_spamer = '스패머로 등록되셨습니다';
|
||||
$lang->msg_alert_limited_by_config = '%s 초 이내에 글 작성은 금지 됩니다. 계속 시도하시면 금지 IP에 등록되실 수 있습니다';
|
||||
$lang->msg_alert_denied_word = '"%s"는 사용 금지된 단어입니다';
|
||||
$lang->msg_alert_registered_denied_ip = '금지 IP에 등록되셔서 정상적인 활동에 제한을 받게 되셨습니다. 문의는 사이트 관리자에게 해주시기 바랍니다';
|
||||
?>
|
||||
|
|
|
|||
11
modules/spamfilter/queries/isDeniedIP.xml
Normal file
11
modules/spamfilter/queries/isDeniedIP.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="isDeniedIP" action="select">
|
||||
<tables>
|
||||
<table name="spamfilter_denied_ip" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<table name="spamfilter_log">
|
||||
<column name="spamfilter_log_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="ipaddress" type="number" size="11" notnull="notnull" primary_key="primary_key" />
|
||||
<column name="ipaddress" type="varchar" size="250" notnull="notnull" index="idx_ipaddress" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
**/
|
||||
function procInsertConfig() {
|
||||
// 기본 정보를 받음
|
||||
$args = Context::gets('interval');
|
||||
$args = Context::gets('interval','limit_count');
|
||||
|
||||
// module Controller 객체 생성하여 입력
|
||||
$oModuleController = &getController('module');
|
||||
|
|
@ -110,11 +110,9 @@
|
|||
* 스패머로 등록할 수 있음
|
||||
**/
|
||||
function insertLog() {
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$args->word = $word;
|
||||
return $oDB->executeQuery('spamfilter.insertLog', $args);
|
||||
$output = $oDB->executeQuery('spamfilter.insertLog');
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,15 @@
|
|||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 스팸필터 모듈의 사용자 설정 값 return
|
||||
**/
|
||||
function getConfig() {
|
||||
// 설정 정보를 받아옴 (module model 객체를 이용)
|
||||
$oModuleModel = &getModel('module');
|
||||
return $oModuleModel->getModuleConfig('spamfilter');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 등록된 금지 IP의 목록을 return
|
||||
**/
|
||||
|
|
@ -26,13 +35,23 @@
|
|||
return $output->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 인자로 넘겨진 ipaddress가 금지 ip인지 체크하여 return
|
||||
**/
|
||||
function isDeniedIP($ipaddress) {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->ipaddress = $ipaddress;
|
||||
$output = $oDB->executeQuery('spamfilter.isDeniedIP', $args);
|
||||
if($output->data->count>0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 등록된 금지 Word 의 목록을 return
|
||||
**/
|
||||
function getDeniedWordList() {
|
||||
$oDB = &DB::getInstance();
|
||||
$args->sort_index = "regdate";
|
||||
$args->page = Context::get('page')?Context::get('page'):1;
|
||||
$output = $oDB->executeQuery('spamfilter.getDeniedWordList', $args);
|
||||
if(!$output->data) return;
|
||||
if(!is_array($output->data)) return array($output->data);
|
||||
|
|
@ -42,13 +61,13 @@
|
|||
/**
|
||||
* @brief 지정된 IPaddress의 특정 시간대 내의 로그 수를 return
|
||||
**/
|
||||
function getLogCount($time = 3600, $ipaddress='') {
|
||||
function getLogCount($time = 60, $ipaddress='') {
|
||||
if(!$ipaddress) $ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$args->ipaddress = $ipaddress;
|
||||
$args->regdate = date("YmdHis", time()-$time);
|
||||
$output = $oDB->executeQuery('spamfilter.getLogCount');
|
||||
$output = $oDB->executeQuery('spamfilter.getLogCount', $args);
|
||||
$count = $output->data->count;
|
||||
return $count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,13 @@
|
|||
<tr>
|
||||
<td>{$lang->about_interval}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th rowspan="2">{$lang->limit_count}</th>
|
||||
<td><input type="text" name="limit_count" value="{$config->limit_count?$config->limit_count:5}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{$lang->about_limit_count}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="button" value="{$lang->cmd_cancel}" onclick="location.href='{@getUrl('act','')}'" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue