issue 160, change spamfilter

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9353 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
chschy 2011-09-27 03:00:50 +00:00
parent be8f7fe300
commit 94217bdd73
4 changed files with 64 additions and 53 deletions

View file

@ -19,10 +19,13 @@
</menus>
<actions>
<action name="dispSpamfilterAdminSetting" type="view" admin_index="true" standalone="true" menu_name="spamFilter" menu_index="true" />
<action name="procSpamfilterAdminInsertDeniedIP" type="controller" standalone="true" ruleset="insertDeniedIp" />
<action name="procSpamfilterAdminInsertDeniedWord" type="controller" standalone="true" ruleset="insertDeniedWord" />
<action name="procSpamfilterAdminDeleteDeniedIP" type="controller" standalone="true" ruleset="deleteDeniedIp" />
<action name="procSpamfilterAdminDeleteDeniedWord" type="controller" standalone="true" ruleset="deleteDeniedWord" />
<action name="procSpamfilterAdminInsertSetting" type="controller" standalone="true" ruleset="insertSetting" />
<action name="procSpamfilterAdminInsertConfig" type="controller" standalone="true" ruleset="insertSetting" />
</actions>
</module>

View file

@ -14,38 +14,50 @@
}
function procSpamfilterAdminInsertSetting() {
function procSpamfilterAdminInsertConfig() {
// Get the default information
$argsConfig = Context::gets('limits','check_trackback');
$ipaddressList = Context::get('ipaddressList');
$wordList = Context::get('wordList');
$flag = Context::get('flag');
//interval, limit_count
if($argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N';
if($argsConfig->limits!='Y') $argsConfig->limits = 'N';
// Create and insert the module Controller object
$oModuleController = &getController('module');
$moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig);
if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput;
if(!$flag){
if($argsConfig->check_trackback && $argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N';
//컬럼 변경하거나. 변경이 불가능하다면 룰셋에서 값을 고정 할 수 잇는지 알아볼 것 (config에서 값을 10,2f로 세팅할 것)
if($argsConfig->limits && $argsConfig->limits!='Y') $argsConfig->limits = 'N';
// Create and insert the module Controller object
$oModuleController = &getController('module');
$moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig);
if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput;
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminSetting');
header('location:'.$returnUrl);
return;
}
return false;
}
function procSpamfilterAdminInsertDeniedIP(){
//스팸IP 추가
$ipaddressList = Context::get('ipaddressList');
$oSpamfilterController = &getController('spamfilter');
if($ipaddressList){
$insertIPOutput = $oSpamfilterController->insertIP($ipaddressList);
if(!$insertIPOutput->toBool()) return $insertIPOutput;
}
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminSetting');
header('location:'.$returnUrl);
return;
}
return false;
}
function procSpamfilterAdminInsertDeniedWord(){
//스팸 키워드 추가
$wordList = Context::get('wordList');
if($wordList){
$insertWordOutput = $this->insertWord($wordList);
if(!$insertWordOutput->toBool()) return $insertWordOutput;
}
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminSetting');
header('location:'.$returnUrl);

View file

@ -1,26 +1,20 @@
<script type="text/javascript">
function doInsertDeniedSome(some){
if(!checkSomeValid(some)) {
alert('{$lang->invalid}');
return false;
} else {
jQuery("#spamfilterInsert").submit();
}
}
</script>
<load target="js/spamfilter_admin.js" usecdn="true" />
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<form id="spamfilterDelete" action="" method="post">
<input type="hidden" name="act" value="" />
<input type="hidden" name="ipaddress" value="" />
<input type="hidden" name="word" value="" />
<input type="hidden" name="ruleset" value="">
</form>
<form action="" id="spamfilterInsert" class="form" ruleset="@insertSetting">
<input type="hidden" name="act" value="procSpamfilterAdminInsertSetting">
<form action="" id="spamfilterConfig" class="form" ruleset="@insertConfig">
<input type="hidden" name="act" value="procSpamfilterAdminInsertConfig">
<input type="hidden" name="module" value="spamfilter">
<input type="hidden" name="ruleset" value="insertSetting">
<input type="hidden" name="flag" value="">
<h1 class="h1">Spam Filter</h1>
<input type="hidden" name="ruleset" value="insertConfig">
<h1 class="h1">{$lang->spamfilter}</h1>
<ul>
<li>
<p class="q">{$lang->cmd_interval}</p>
@ -38,6 +32,16 @@ function doInsertDeniedSome(some){
<input type="radio" name="check_trackback" id="spamCond2_yes" value="N" <!--@if($config->check_trackback!='Y' && $config->check_trackback!='')--> checked="checked"<!--@end--> / > <label for="spamCond2_yes">{$lang->cmd_no}</label>
</p>
</li>
</ul>
<div class="btnArea">
<span class="btn medium"><input type="submit" value="Save" /></span>
</div>
</form>
<form action="" id="spamfilterInsert" class="form">
<input type="hidden" name="act" value="">
<input type="hidden" name="module" value="spamfilter">
<input type="hidden" name="ruleset" value="">
<ul>
<li>
<p class="q">{$lang->cmd_denied_ip}</p>
<div class="a">
@ -51,7 +55,7 @@ function doInsertDeniedSome(some){
</div>
<p class="a">
<textarea rows="4" cols="42" name="ipaddressList" title="스팸 IP 추가"></textarea>
<span class="btn small"><button type="button" onclick="doInsertDeniedSome('ip')">{$lang->cmd_insert}</button></span>
<span class="btn small"><button type="button" onclick="doInsertDeniedIP('{$lang->msg_invalid_format}')">{$lang->cmd_insert}</button></span>
<span class="desc">{$lang->about_denied_ip}</span>
</p>
</li>
@ -66,12 +70,9 @@ function doInsertDeniedSome(some){
</div>
<p class="a">
<textarea rows="4" cols="42" name="wordList" title="스팸 키워드 추가"></textarea>
<span class="btn small"><button type="button" onclick="doInsertDeniedSome('word')">{$lang->add}</button></span>
<span class="btn small"><button type="button" onclick="doInsertDeniedWord('{$lang->msg_invalid_format}')">{$lang->add}</button></span>
<span class="desc">{$lang->about_denied_word}</span>
</p>
</li>
</ul>
<div class="btnArea">
<span class="btn medium"><input type="submit" value="Save" /></span>
</div>
</form>

View file

@ -19,31 +19,26 @@ function doDeleteDeniedWord(word) {
fo_obj.ruleset.value = 'deleteDeniedWord';
fo_obj.submit();
}
function checkSomeValid(some){
function doInsertDeniedIP(msg_invalid_format){
var fo_obj = get_by_id('spamfilterInsert');
var reg_ipaddress = /^(\d{1,3}(?:.(\d{1,3}|\*)){3}\s*(\/\/[^\r\n]*)?[\r\n]*)*$/;
var matchStr_ipaddress = fo_obj.ipaddressList.value;
if(!matchStr_ipaddress.match(reg_ipaddress)) {
alert(msg_invalid_format); return false;
}
fo_obj.act.value = "procSpamfilterAdminInsertDeniedIP";
fo_obj.ruleset.value = "insertDeniedIp";
fo_obj.submit();
}
function doInsertDeniedWord(msg_invalid_format){
var fo_obj = get_by_id('spamfilterInsert');
var reg_word = /^(.{2,40}[\r\n]+)*.{0,40}$/;
var matchStr_word = fo_obj.wordList.value;
var valid_word = true;
var valid_ip = true;
if(!matchStr_ipaddress.match(reg_ipaddress)) valid_ip = false;
if(!matchStr_word.match(reg_word)) valid_word = false;
if(some == 'ip'){
fo_obj.wordList.value = '';
valid_word = true;
} else if(some == 'word'){
fo_obj.ipaddressList.value = '';
valid_ip = true;
if(!matchStr_word.match(reg_word)) {
alert(msg_invalid_format); return false;
}
if(valid_ip && valid_word) return true;
else return false;
fo_obj.act.value = "procSpamfilterAdminInsertDeniedWord";
fo_obj.ruleset.value = "insertDeniedWord";
fo_obj.submit();
}