diff --git a/addons/spam_filter/spam_filter.addon.php b/addons/spam_filter/spam_filter.addon.php
index a7d9183e3..5f66827f1 100644
--- a/addons/spam_filter/spam_filter.addon.php
+++ b/addons/spam_filter/spam_filter.addon.php
@@ -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();
?>
diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php
index 1260db775..06d2995e5 100644
--- a/classes/module/ModuleObject.class.php
+++ b/classes/module/ModuleObject.class.php
@@ -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());
diff --git a/modules/addon/addon.controller.php b/modules/addon/addon.controller.php
index 0eeaea4a0..e650f39eb 100644
--- a/modules/addon/addon.controller.php
+++ b/modules/addon/addon.controller.php
@@ -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('', $buff);
diff --git a/modules/board/skins/default/view_document.html b/modules/board/skins/default/view_document.html
index 74783663b..1eefef13b 100644
--- a/modules/board/skins/default/view_document.html
+++ b/modules/board/skins/default/view_document.html
@@ -44,10 +44,10 @@
- {$lang->document_url} : {getUrl()}?document_srl={$document->document_srl}
+ {$lang->document_url} : {getUrl()}{$document->document_srl}
- {$lang->trackback_url} : {getUrl()}trackback.php?document_srl={$document->document_srl}
+ {$lang->trackback_url} : {getUrl()}trackback/{$document->document_srl}
diff --git a/modules/spamfilter/lang/ko.lang.php b/modules/spamfilter/lang/ko.lang.php
index 53cffd1a2..6b7c503ff 100644
--- a/modules/spamfilter/lang/ko.lang.php
+++ b/modules/spamfilter/lang/ko.lang.php
@@ -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에 등록되셔서 정상적인 활동에 제한을 받게 되셨습니다. 문의는 사이트 관리자에게 해주시기 바랍니다';
?>
diff --git a/modules/spamfilter/queries/isDeniedIP.xml b/modules/spamfilter/queries/isDeniedIP.xml
new file mode 100644
index 000000000..3255d6ce7
--- /dev/null
+++ b/modules/spamfilter/queries/isDeniedIP.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/spamfilter/schemas/spamfilter_log.xml b/modules/spamfilter/schemas/spamfilter_log.xml
index 40b971ee4..f40d469ca 100644
--- a/modules/spamfilter/schemas/spamfilter_log.xml
+++ b/modules/spamfilter/schemas/spamfilter_log.xml
@@ -1,5 +1,5 @@
diff --git a/modules/spamfilter/spamfilter.controller.php b/modules/spamfilter/spamfilter.controller.php
index c3ba414ae..999a2f577 100644
--- a/modules/spamfilter/spamfilter.controller.php
+++ b/modules/spamfilter/spamfilter.controller.php
@@ -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;
}
}
diff --git a/modules/spamfilter/spamfilter.model.php b/modules/spamfilter/spamfilter.model.php
index ade87585e..545c653ff 100644
--- a/modules/spamfilter/spamfilter.model.php
+++ b/modules/spamfilter/spamfilter.model.php
@@ -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;
}
diff --git a/modules/spamfilter/tpl.admin/index.html b/modules/spamfilter/tpl.admin/index.html
index 36abb6276..87655c552 100644
--- a/modules/spamfilter/tpl.admin/index.html
+++ b/modules/spamfilter/tpl.admin/index.html
@@ -10,6 +10,13 @@
{$lang->about_interval}
+
+ {$lang->limit_count}
+
+
+
+ {$lang->about_limit_count}
+