english comments added

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0_english@8278 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
mosmartin 2011-04-06 16:48:06 +00:00
parent 693e215bc1
commit 4d272994dd
219 changed files with 6407 additions and 8705 deletions

View file

@ -2,33 +2,32 @@
/**
* @class spamfilterAdminController
* @author NHN (developers@xpressengine.com)
* @brief spamfilter 모듈의 admin controller class
* @brief The admin controller class of the spamfilter module
**/
class spamfilterAdminController extends spamfilter {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 스팸필터 설정
* @brief Spam filter configurations
**/
function procSpamfilterAdminInsertConfig() {
// 기본 정보를 받음
// Get the default information
$args = Context::gets('interval','limit_count','check_trackback');
if($args->check_trackback!='Y') $args->check_trackback = 'N';
// module Controller 객체 생성하여 입력
// Create and insert the module Controller object
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('spamfilter',$args);
return $output;
}
/**
* @brief 금지 IP등록
* @brief Register the banned IP address
**/
function procSpamfilterAdminInsertDeniedIP() {
$ipaddress = Context::get('ipaddress');
@ -39,7 +38,7 @@
}
/**
* @brief 금지 IP삭제
* @brief Delete the banned IP
**/
function procSpamfilterAdminDeleteDeniedIP() {
$ipaddress = Context::get('ipaddress');
@ -47,7 +46,7 @@
}
/**
* @brief 금지 Word등록
* @brief Register the prohibited word
**/
function procSpamfilterAdminInsertDeniedWord() {
$word = Context::get('word');
@ -55,7 +54,7 @@
}
/**
* @brief 금지 Word삭제
* @brief Delete the prohibited Word
**/
function procSpamfilterAdminDeleteDeniedWord() {
$word = base64_decode(Context::get('word'));
@ -63,8 +62,8 @@
}
/**
* @brief IP 제거
* 스패머로 등록된 IP를 제거
* @brief Delete IP
* Remove the IP address which was previously registered as a spammers
**/
function deleteIP($ipaddress) {
if(!$ipaddress) return;
@ -74,8 +73,8 @@
}
/**
* @brief 스팸단어 등록
* 등록된 단어가 포함된 글은 스팸글로 간주
* @brief Register the spam word
* The post, which contains the newly registered spam word, should be considered as a spam
**/
function insertWord($word) {
if(!$word) return;
@ -85,8 +84,8 @@
}
/**
* @brief 스팸단어 제거
* 스팸 단어로 등록된 단어 제거
* @brief Remove the spam word
* Remove the word which was previously registered as a spam word
**/
function deleteWord($word) {
if(!$word) return;

View file

@ -2,57 +2,54 @@
/**
* @class spamfilterAdminView
* @author NHN (developers@xpressengine.com)
* @brief spamfilter 모듈의 admin view class
* @brief The admin view class of the spamfilter module
**/
class spamfilterAdminView extends spamfilter {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
// 템플릿 경로 지정
// Set template path
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 스팸필터의 설정 화면
* @brief Spam Filter configurations
**/
function dispSpamfilterAdminConfig() {
// 설정 정보를 받아옴 (module model 객체를 이용)
// Get configurations (using module model object)
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('spamfilter');
Context::set('config',$config);
// 템플릿 파일 지정
// Set a template file
$this->setTemplateFile('index');
}
/**
* @brief 금지 목록 출력
* @brief Output the list of banned IPs
**/
function dispSpamfilterAdminDeniedIPList() {
// 등록된 금지 IP 목록을 가져옴
// Get the list of banned IP addresses
$oSpamFilterModel = &getModel('spamfilter');
$ip_list = $oSpamFilterModel->getDeniedIPList();
Context::set('ip_list', $ip_list);
// 템플릿 파일 지정
// Set a template file
$this->setTemplateFile('denied_ip_list');
}
/**
* @brief 금지 목록 출력
* @brief Output the list of prohibited words
**/
function dispSpamfilterAdminDeniedWordList() {
// 등록된 금지 Word 목록을 가져옴
// Get the list of prohibited words
$oSpamFilterModel = &getModel('spamfilter');
$word_list = $oSpamFilterModel->getDeniedWordList();
Context::set('word_list', $word_list);
// 템플릿 파일 지정
// Set a template file
$this->setTemplateFile('denied_word_list');
}
}

View file

@ -2,25 +2,22 @@
/**
* @class spamfilter
* @author NHN (developers@xpressengine.com)
* @brief spamfilter 모듈의 high class
* @brief The parent class of the spamfilter module
**/
class spamfilter extends ModuleObject {
/**
* @brief 설치시 추가 작업이 필요할시 구현
* @brief Additional tasks required to accomplish during the installation
**/
function moduleInstall() {
// action forward에 등록 (관리자 모드에서 사용하기 위함)
// Register action forward (to use in administrator mode)
$oModuleController = &getController('module');
// 2007. 12. 7 글/ 댓글/ 엮인글이 등록될때 스팸필터링을 시도하는 트리거
// 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
$oModuleController->insertTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
$oModuleController->insertTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
$oModuleController->insertTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before');
//2008-12-17 글 수정시 스펨필터 추가
// 2008-12-17 Add a spamfilter for post modification actions
$oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
@ -29,23 +26,21 @@
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
* @brief A method to check if the installation has been successful
**/
function checkUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
// 2007. 12. 7 글/ 댓글/ 엮인글이 등록될때 스팸필터링을 시도하는 트리거
// 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
if(!$oModuleModel->getTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')) return true;
if(!$oModuleModel->getTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before')) return true;
if(!$oModuleModel->getTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before')) return true;
//2008-12-17 글 수정시 스펨필터 추가
// 2008-12-17 Add a spamfilter for post modification actions
if(!$oModuleModel->getTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before')) return true;
if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')) return true;
/**
* 히트 카운트 필드(hit) 추가
* Add the hit count field (hit)
**/
if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit')) return true;
if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit')) return true;
@ -56,32 +51,30 @@
}
/**
* @brief 업데이트 실행
* @brief Execute update
**/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 2007. 12. 7 글/ 댓글/ 엮인글이 등록될때 스팸필터링을 시도하는 트리거
// 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
if(!$oModuleModel->getTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before'))
$oModuleController->insertTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
if(!$oModuleModel->getTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before'))
$oModuleController->insertTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
if(!$oModuleModel->getTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before'))
$oModuleController->insertTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before');
//2008-12-17 글 수정시 스펨필터 추가
// 2008-12-17 Add a spamfilter for post modification actions
if(!$oModuleModel->getTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before')){
$oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
}
//2008-12-17 글 수정시 스펨필터 추가
// 2008-12-17 Add a spamfilter for post modification actions
if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')){
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
}
/**
* 히트 카운트 필드(hit) 추가
* Add the hit count field (hit)
**/
if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit')) {
$oDB->addColumn('spamfilter_denied_word','hit','number',12,0,true);
@ -100,7 +93,7 @@
}
/**
* @brief 캐시 파일 재생성
* @brief Re-generate the cache file
**/
function recompileCache() {
}

View file

@ -2,141 +2,124 @@
/**
* @class spamfilterController
* @author NHN (developers@xpressengine.com)
* @brief spamfilter 모듈의 controller class
* @brief The controller class for the spamfilter module
**/
class spamfilterController extends spamfilter {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 배치작업등을 할때 스팸필터의 사용을 중지 시킬 필요가 있을 경우 호출
* @brief Call this function in case you need to stop the spam filter's usage during the batch work
**/
function setAvoidLog() {
$_SESSION['avoid_log'] = true;
}
/**
* @brief 작성시 작성 시간 체크 금지 ip/단어 처리 루틴
* @brief The routine process to check the time it takes to store a document, when writing it, and to ban IP/word
**/
function triggerInsertDocument(&$obj) {
if($_SESSION['avoid_log']) return new Object();
// 로그인 여부, 로그인 정보, 권한 유무 체크
// Check the login status, login information, and permission
$is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info');
$grant = Context::get('grant');
// 로그인 되어 있을 경우 관리자 여부를 체크
// In case logged in, check if it is an administrator
if($is_logged) {
if($logged_info->is_admin == 'Y') return new Object();
if($grant->manager) return new Object();
}
$oFilterModel = &getModel('spamfilter');
// ip가 금지되어 있는 경우를 체크
// Check if the IP is prohibited
$output = $oFilterModel->isDeniedIP();
if(!$output->toBool()) return $output;
// 금지 단어에 있을 경우 체크
// Check if there is a ban on the word
$text = $obj->title.$obj->content;
$output = $oFilterModel->isDeniedWord($text);
if(!$output->toBool()) return $output;
// 지정된 시간 체크, 수정시 제외
// Check the specified time beside the modificaiton time
if($obj->document_srl == 0){
$output = $oFilterModel->checkLimited();
if(!$output->toBool()) return $output;
}
// 로그 남김
// Save a log
$this->insertLog();
return new Object();
}
/**
* @brief 댓글 작성 시간 금지 ip/ 단어 처리 루틴
* @brief The routine process to check the time it takes to store a comment, and to ban IP/word
**/
function triggerInsertComment(&$obj) {
if($_SESSION['avoid_log']) return new Object();
// 로그인 여부, 로그인 정보, 권한 유무 체크
// Check the login status, login information, and permission
$is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info');
$grant = Context::get('grant');
// 로그인 되어 있을 경우 관리자 여부를 체크
// In case logged in, check if it is an administrator
if($is_logged) {
if($logged_info->is_admin == 'Y') return new Object();
if($grant->manager) return new Object();
}
$oFilterModel = &getModel('spamfilter');
// ip가 금지되어 있는 경우를 체크
// Check if the IP is prohibited
$output = $oFilterModel->isDeniedIP();
if(!$output->toBool()) return $output;
// 금지 단어에 있을 경우 체크
// Check if there is a ban on the word
$text = $obj->content;
$output = $oFilterModel->isDeniedWord($text);
if(!$output->toBool()) return $output;
// 지정된 시간 체크 수정이 아닌경우만
// If the specified time check is not modified
if(!$obj->__isupdate){
$output = $oFilterModel->checkLimited();
if(!$output->toBool()) return $output;
}
unset($obj->__isupdate);
// 로그 남김
// Save a log
$this->insertLog();
return new Object();
}
/**
* @brief 엮인글 작성시 시간 ip 검사
* @brief Inspect the trackback creation time and IP
**/
function triggerInsertTrackback(&$obj) {
if($_SESSION['avoid_log']) return new Object();
$oFilterModel = &getModel('spamfilter');
// 해당 글에 엮인글을 한번 이상 추가하였는지를 확인
// Confirm if the trackbacks have been added more than once to your document
$output = $oFilterModel->isInsertedTrackback($obj->document_srl);
if(!$output->toBool()) return $output;
// ip가 금지되어 있는 경우를 체크
// Check if the IP is prohibited
$output = $oFilterModel->isDeniedIP();
if(!$output->toBool()) return $output;
// 금지 단어에 있을 경우 체크
// Check if there is a ban on the word
$text = $obj->blog_name.$obj->title.$obj->excerpt.$obj->url;
$output = $oFilterModel->isDeniedWord($text);
if(!$output->toBool()) return $output;
// 필터링 시작
// Start Filtering
$oTrackbackModel = &getModel('trackback');
$oTrackbackController = &getController('trackback');
list($ipA,$ipB,$ipC,$ipD) = explode('.',$_SERVER['REMOTE_ADDR']);
$ipaddress = $ipA.'.'.$ipB.'.'.$ipC;
// 제목과 블로그이름이 동일할 경우 최근 6시간내의 ip를 조사하여 삭제하고 금지ip로 등록
// In case the title and the blog name are indentical, investigate the IP address of the last 6 hours, delete and ban it.
if($obj->title == $obj->excerpt) {
$oTrackbackController->deleteTrackbackSender(60*60*6, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
$this->insertIP($ipaddress.'.*', 'AUTO-DENIED : trackback.insertTrackback');
return new Object(-1,'msg_alert_trackback_denied');
}
// 30분 이내에 1개 이상의 한 C클래스의 ip에서 엮인글 등록 시도시 금지 아이피로 지정하고 해당 ip의 글을 모두 삭제
// If trackbacks have been registered by one C-class IP address more than once for the last 30 minutes, ban the IP address and delete all the posts
/* 호스팅 환경을 감안하여 일단 부분은 동작하지 않도록 주석 처리
$count = $oTrackbackModel->getRegistedTrackback(30*60, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
if($count > 1) {
@ -150,8 +133,8 @@
}
/**
* @brief IP 등록
* 등록된 IP는 스패머로 간주
* @brief IP registration
* The registered IP address is considered as a spammer
**/
function insertIP($ipaddress, $description = null) {
$args->ipaddress = $ipaddress;
@ -161,9 +144,9 @@
}
/**
* @brief 로그 등록
* 접속 IP를 로그에 등록, 로그의 간격이 특정 시간 이내일 경우 도배로 간주하여
* 스패머로 등록할 있음
* @brief Log registration
* Register the newly accessed IP address in the log. In case the log interval is withing a certain time,
* register it as a spammer
**/
function insertLog() {
$output = executeQuery('spamfilter.insertLog');

View file

@ -2,28 +2,28 @@
/**
* @class spamfilterModel
* @author NHN (developers@xpressengine.com)
* @brief spamfilter 모듈의 Model class
* @brief The Model class of the spamfilter module
**/
class spamfilterModel extends spamfilter {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 스팸필터 모듈의 사용자 설정 return
* @brief Return the user setting values of the Spam filter module
**/
function getConfig() {
// 설정 정보를 받아옴 (module model 객체를 이용)
// Get configurations (using the module model object)
$oModuleModel = &getModel('module');
return $oModuleModel->getModuleConfig('spamfilter');
}
/**
* @brief 등록된 금지 IP의 목록을 return
* @brief Return the list of registered IP addresses which were banned
**/
function getDeniedIPList() {
$args->sort_index = "regdate";
@ -35,7 +35,7 @@
}
/**
* @brief 인자로 넘겨진 ipaddress가 금지 ip인지 체크하여 return
* @brief Check if the ipaddress is in the list of banned IP addresses
**/
function isDeniedIP() {
$ipaddress = $_SERVER['REMOTE_ADDR'];
@ -58,7 +58,7 @@
}
/**
* @brief 등록된 금지 Word 목록을 return
* @brief Return the list of registered Words which were banned
**/
function getDeniedWordList() {
$args->sort_index = "hit";
@ -69,7 +69,7 @@
}
/**
* @brief 넘어온 text에 금지 단어가 있는지 확인
* @brief Check if the text, received as a parameter, is banned or not
**/
function isDeniedWord($text) {
$word_list = $this->getDeniedWordList();
@ -89,7 +89,7 @@
}
/**
* @brief 지정된 시간을 체크
* @brief Check the specified time
**/
function checkLimited() {
$config = $this->getConfig();
@ -100,15 +100,13 @@
$count = $this->getLogCount($interval);
$ipaddress = $_SERVER['REMOTE_ADDR'];
// 정해진 시간보다 클 경우 금지 ip로 등록
// Ban the IP address if the interval is exceeded
if($count>=$limit_count) {
$oSpamFilterController = &getController('spamfilter');
$oSpamFilterController->insertIP($ipaddress, 'AUTO-DENIED : Over limit');
return new Object(-1, 'msg_alert_registered_denied_ip');
}
// 제한 글수까지는 아니지만 정해진 시간내에 글 작성을 계속 할때
// If the number of limited posts is not reached, keep creating.
if($count) {
$message = sprintf(Context::getLang('msg_alert_limited_by_config'), $interval);
@ -122,7 +120,7 @@
}
/**
* @brief 특정 글에 이미 엮인글이 등록되어 있는지 확인
* @brief Check if the trackbacks have already been registered to a particular article
**/
function isInsertedTrackback($document_srl) {
$oTrackbackModel = &getModel('trackback');
@ -133,7 +131,7 @@
}
/**
* @brief 지정된 IPaddress의 특정 시간대 내의 로그 수를 return
* @brief Return the number of logs recorded within the interval for the specified IPaddress
**/
function getLogCount($time = 60, $ipaddress='') {
if(!$ipaddress) $ipaddress = $_SERVER['REMOTE_ADDR'];