mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
issue 2662 trash, widget, session, trackback, spamfilter, tag
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12260 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
e1a22ca6f0
commit
5219a360c6
31 changed files with 3465 additions and 3173 deletions
|
|
@ -1,127 +1,137 @@
|
|||
<?php
|
||||
/**
|
||||
* @class spamfilterAdminController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The admin controller class of the spamfilter module
|
||||
**/
|
||||
/**
|
||||
* @class spamfilterAdminController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The admin controller class of the spamfilter module
|
||||
*/
|
||||
class spamfilterAdminController extends spamfilter
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
class spamfilterAdminController extends spamfilter {
|
||||
function procSpamfilterAdminInsertConfig()
|
||||
{
|
||||
// Get the default information
|
||||
$argsConfig = Context::gets('limits','check_trackback');
|
||||
$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;
|
||||
|
||||
/**
|
||||
* @brief Initialization
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
|
||||
function procSpamfilterAdminInsertConfig() {
|
||||
|
||||
// Get the default information
|
||||
$argsConfig = Context::gets('limits','check_trackback');
|
||||
$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;
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
function procSpamfilterAdminInsertDeniedIP()
|
||||
{
|
||||
//스팸IP 추가
|
||||
$ipaddress_list = Context::get('ipaddress_list');
|
||||
$oSpamfilterController = &getController('spamfilter');
|
||||
if($ipaddress_list)
|
||||
{
|
||||
$output = $oSpamfilterController->insertIP($ipaddress_list);
|
||||
if(!$output->toBool() && !$output->get('fail_list')) return $output;
|
||||
}
|
||||
|
||||
function procSpamfilterAdminInsertDeniedIP(){
|
||||
//스팸IP 추가
|
||||
$ipaddress_list = Context::get('ipaddress_list');
|
||||
$oSpamfilterController = &getController('spamfilter');
|
||||
if($ipaddress_list){
|
||||
$output = $oSpamfilterController->insertIP($ipaddress_list);
|
||||
if(!$output->toBool() && !$output->get('fail_list')) return $output;
|
||||
}
|
||||
if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
|
||||
$this->setMessage(Context::getLang('success_registed').$message_fail);
|
||||
|
||||
if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
|
||||
$this->setMessage(Context::getLang('success_registed').$message_fail);
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedIPList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedIPList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
function procSpamfilterAdminInsertDeniedWord()
|
||||
{
|
||||
//스팸 키워드 추가
|
||||
$word_list = Context::get('word_list');
|
||||
if($word_list)
|
||||
{
|
||||
$output = $this->insertWord($word_list);
|
||||
if(!$output->toBool() && !$output->get('fail_list')) return $output;
|
||||
}
|
||||
function procSpamfilterAdminInsertDeniedWord(){
|
||||
//스팸 키워드 추가
|
||||
$word_list = Context::get('word_list');
|
||||
if($word_list){
|
||||
$output = $this->insertWord($word_list);
|
||||
if(!$output->toBool() && !$output->get('fail_list')) return $output;
|
||||
}
|
||||
if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
|
||||
$this->setMessage(Context::getLang('success_registed').$message_fail);
|
||||
if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>';
|
||||
$this->setMessage(Context::getLang('success_registed').$message_fail);
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete the banned IP
|
||||
*/
|
||||
function procSpamfilterAdminDeleteDeniedIP()
|
||||
{
|
||||
$ipaddress = Context::get('ipaddress');
|
||||
$output = $this->deleteIP($ipaddress);
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedIPList');
|
||||
return $this->setRedirectUrl($returnUrl, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete the prohibited Word
|
||||
*/
|
||||
function procSpamfilterAdminDeleteDeniedWord()
|
||||
{
|
||||
$word = Context::get('word');
|
||||
//$word = base64_decode(Context::get('word'));
|
||||
$output = $this->deleteWord($word);
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList','active','word');
|
||||
return $this->setRedirectUrl($returnUrl, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete IP
|
||||
* Remove the IP address which was previously registered as a spammers
|
||||
*/
|
||||
function deleteIP($ipaddress)
|
||||
{
|
||||
if(!$ipaddress) return;
|
||||
|
||||
$args->ipaddress = $ipaddress;
|
||||
return executeQuery('spamfilter.deleteDeniedIP', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register the spam word
|
||||
* The post, which contains the newly registered spam word, should be considered as a spam
|
||||
*/
|
||||
function insertWord($word_list)
|
||||
{
|
||||
if(!preg_match("/^(.{2,40}\s*)*$/",$word_list)) return new Object(-1, 'msg_invalid');
|
||||
|
||||
$word_list = str_replace("\r","",$word_list);
|
||||
$word_list = explode("\n",$word_list);
|
||||
$fail_word = '';
|
||||
foreach($word_list as $word)
|
||||
{
|
||||
if(trim($word)) $args->word = $word;
|
||||
$output = executeQuery('spamfilter.insertDeniedWord', $args);
|
||||
if(!$output->toBool()) $fail_word .= $word.'<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete the banned IP
|
||||
**/
|
||||
function procSpamfilterAdminDeleteDeniedIP() {
|
||||
$ipaddress = Context::get('ipaddress');
|
||||
$output = $this->deleteIP($ipaddress);
|
||||
$output->add('fail_list',$fail_word);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedIPList');
|
||||
return $this->setRedirectUrl($returnUrl, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete the prohibited Word
|
||||
**/
|
||||
function procSpamfilterAdminDeleteDeniedWord() {
|
||||
$word = Context::get('word');
|
||||
//$word = base64_decode(Context::get('word'));
|
||||
$output = $this->deleteWord($word);
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList','active','word');
|
||||
return $this->setRedirectUrl($returnUrl, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete IP
|
||||
* Remove the IP address which was previously registered as a spammers
|
||||
**/
|
||||
function deleteIP($ipaddress) {
|
||||
if(!$ipaddress) return;
|
||||
|
||||
$args->ipaddress = $ipaddress;
|
||||
return executeQuery('spamfilter.deleteDeniedIP', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register the spam word
|
||||
* The post, which contains the newly registered spam word, should be considered as a spam
|
||||
**/
|
||||
function insertWord($word_list) {
|
||||
if(!preg_match("/^(.{2,40}\s*)*$/",$word_list)) return new Object(-1, 'msg_invalid');
|
||||
|
||||
$word_list = str_replace("\r","",$word_list);
|
||||
$word_list = explode("\n",$word_list);
|
||||
$fail_word = '';
|
||||
foreach($word_list as $word) {
|
||||
if(trim($word)) $args->word = $word;
|
||||
$output = executeQuery('spamfilter.insertDeniedWord', $args);
|
||||
if(!$output->toBool()) $fail_word .= $word.'<br />';
|
||||
}
|
||||
$output->add('fail_list',$fail_word);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove the spam word
|
||||
* Remove the word which was previously registered as a spam word
|
||||
**/
|
||||
function deleteWord($word) {
|
||||
if(!$word) return;
|
||||
$args->word = $word;
|
||||
return executeQuery('spamfilter.deleteDeniedWord', $args);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* @brief Remove the spam word
|
||||
* Remove the word which was previously registered as a spam word
|
||||
*/
|
||||
function deleteWord($word)
|
||||
{
|
||||
if(!$word) return;
|
||||
$args->word = $word;
|
||||
return executeQuery('spamfilter.deleteDeniedWord', $args);
|
||||
}
|
||||
}
|
||||
/* End of file spamfilter.admin.controller.php */
|
||||
/* Location: ./modules/spamfilter/spamfilter.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@
|
|||
* @class spamfilterAdminView
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The admin view class of the spamfilter module
|
||||
**/
|
||||
|
||||
*/
|
||||
class spamfilterAdminView extends spamfilter
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
**/
|
||||
function init()
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
// Set template path
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
|
|
@ -18,7 +17,7 @@ class spamfilterAdminView extends spamfilter
|
|||
|
||||
/**
|
||||
* @brief Output the list of banned IPs
|
||||
**/
|
||||
*/
|
||||
function dispSpamfilterAdminDeniedIPList()
|
||||
{
|
||||
// Get the list of denied IP addresses and words
|
||||
|
|
@ -36,7 +35,7 @@ class spamfilterAdminView extends spamfilter
|
|||
|
||||
/**
|
||||
* @brief Output the list of banned words
|
||||
**/
|
||||
*/
|
||||
function dispSpamfilterAdminDeniedWordList()
|
||||
{
|
||||
// Get the list of denied IP addresses and words
|
||||
|
|
@ -53,7 +52,7 @@ class spamfilterAdminView extends spamfilter
|
|||
|
||||
/**
|
||||
* @brief Configure auto block
|
||||
**/
|
||||
*/
|
||||
function dispSpamfilterAdminConfigBlock()
|
||||
{
|
||||
// Get configurations (using module model object)
|
||||
|
|
@ -63,5 +62,6 @@ class spamfilterAdminView extends spamfilter
|
|||
|
||||
$this->setTemplateFile('config_block');
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
/* End of file spamfilter.admin.view.php */
|
||||
/* Location: ./modules/spamfilter/spamfilter.admin.view.php */
|
||||
|
|
|
|||
|
|
@ -1,101 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* @class spamfilter
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The parent class of the spamfilter module
|
||||
**/
|
||||
/**
|
||||
* @class spamfilter
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The parent class of the spamfilter module
|
||||
*/
|
||||
class spamfilter extends ModuleObject
|
||||
{
|
||||
/**
|
||||
* @brief Additional tasks required to accomplish during the installation
|
||||
*/
|
||||
function moduleInstall()
|
||||
{
|
||||
// Register action forward (to use in administrator mode)
|
||||
$oModuleController = &getController('module');
|
||||
// 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 Add a spamfilter for post modification actions
|
||||
$oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
|
||||
|
||||
class spamfilter extends ModuleObject {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Additional tasks required to accomplish during the installation
|
||||
**/
|
||||
function moduleInstall() {
|
||||
// Register action forward (to use in administrator mode)
|
||||
$oModuleController = &getController('module');
|
||||
// 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 Add a spamfilter for post modification actions
|
||||
$oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
|
||||
/**
|
||||
* @brief A method to check if the installation has been successful
|
||||
*/
|
||||
function checkUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
// 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 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
return new Object();
|
||||
}
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description')) return true;
|
||||
|
||||
/**
|
||||
* @brief A method to check if the installation has been successful
|
||||
**/
|
||||
function checkUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
// 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 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;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* @brief Execute update
|
||||
*/
|
||||
function moduleUpdate()
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
// 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 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 Add a spamfilter for post modification actions
|
||||
if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
|
||||
}
|
||||
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description')) return true;
|
||||
/**
|
||||
* Add the hit count field (hit)
|
||||
*/
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit'))
|
||||
{
|
||||
$oDB->addColumn('spamfilter_denied_word','hit','number',12,0,true);
|
||||
$oDB->addIndex('spamfilter_denied_word','idx_hit', 'hit');
|
||||
}
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit'))
|
||||
{
|
||||
$oDB->addColumn('spamfilter_denied_word','latest_hit','date');
|
||||
$oDB->addIndex('spamfilter_denied_word','idx_latest_hit', 'latest_hit');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description'))
|
||||
{
|
||||
$oDB->addColumn('spamfilter_denied_ip','description','varchar', 250);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execute update
|
||||
**/
|
||||
function moduleUpdate() {
|
||||
$oDB = &DB::getInstance();
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
// 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 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 Add a spamfilter for post modification actions
|
||||
if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')){
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
|
||||
}
|
||||
return new Object(0,'success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the hit count field (hit)
|
||||
**/
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit')) {
|
||||
$oDB->addColumn('spamfilter_denied_word','hit','number',12,0,true);
|
||||
$oDB->addIndex('spamfilter_denied_word','idx_hit', 'hit');
|
||||
}
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit')) {
|
||||
$oDB->addColumn('spamfilter_denied_word','latest_hit','date');
|
||||
$oDB->addIndex('spamfilter_denied_word','idx_latest_hit', 'latest_hit');
|
||||
}
|
||||
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description')) {
|
||||
$oDB->addColumn('spamfilter_denied_ip','description','varchar', 250);
|
||||
}
|
||||
|
||||
return new Object(0,'success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Re-generate the cache file
|
||||
**/
|
||||
function recompileCache() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* @brief Re-generate the cache file
|
||||
*/
|
||||
function recompileCache()
|
||||
{
|
||||
}
|
||||
}
|
||||
/* End of file spamfilter.class.php */
|
||||
/* Location: ./modules/spamfilter/spamfilter.class.controller.php */
|
||||
|
|
|
|||
|
|
@ -1,171 +1,184 @@
|
|||
<?php
|
||||
/**
|
||||
* @class spamfilterController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The controller class for the spamfilter module
|
||||
**/
|
||||
/**
|
||||
* @class spamfilterController
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The controller class for the spamfilter module
|
||||
*/
|
||||
class spamfilterController extends spamfilter
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
class spamfilterController extends spamfilter {
|
||||
/**
|
||||
* @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 Initialization
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
$oFilterModel = &getModel('spamfilter');
|
||||
// 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();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
$oFilterModel = &getModel('spamfilter');
|
||||
// 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();
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
$oFilterModel = &getModel('spamfilter');
|
||||
// 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();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
$oFilterModel = &getModel('spamfilter');
|
||||
// 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();
|
||||
/**
|
||||
* @brief Inspect the trackback creation time and IP
|
||||
*/
|
||||
function triggerInsertTrackback(&$obj)
|
||||
{
|
||||
if($_SESSION['avoid_log']) return new Object();
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Inspect the trackback creation time and IP
|
||||
**/
|
||||
function triggerInsertTrackback(&$obj) {
|
||||
if($_SESSION['avoid_log']) return new Object();
|
||||
// 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');
|
||||
|
||||
$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;
|
||||
|
||||
// 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;
|
||||
// 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');
|
||||
}
|
||||
// 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) {
|
||||
$oTrackbackController->deleteTrackbackSender(3*60, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
|
||||
$this->insertIP($ipaddress.'.*');
|
||||
return new Object(-1,'msg_alert_trackback_denied');
|
||||
}
|
||||
*/
|
||||
|
||||
list($ipA,$ipB,$ipC,$ipD) = explode('.',$_SERVER['REMOTE_ADDR']);
|
||||
$ipaddress = $ipA.'.'.$ipB.'.'.$ipC;
|
||||
// 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');
|
||||
}
|
||||
// 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) {
|
||||
$oTrackbackController->deleteTrackbackSender(3*60, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt);
|
||||
$this->insertIP($ipaddress.'.*');
|
||||
return new Object(-1,'msg_alert_trackback_denied');
|
||||
}
|
||||
*/
|
||||
return new Object();
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IP registration
|
||||
* The registered IP address is considered as a spammer
|
||||
**/
|
||||
function insertIP($ipaddress_list, $description = null) {
|
||||
print_r($ipaddress_list);
|
||||
$regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/";
|
||||
if(!preg_match($regExr,$ipaddress_list)) return new Object(-1, 'msg_invalid');
|
||||
$ipaddress_list = str_replace("\r","",$ipaddress_list);
|
||||
$ipaddress_list = explode("\n",$ipaddress_list);
|
||||
foreach($ipaddress_list as $ipaddressValue) {
|
||||
preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/",$ipaddressValue,$matches);
|
||||
if($ipaddress=trim($matches[1])) {
|
||||
$args->ipaddress = $ipaddress;
|
||||
if(!$description && $matches[4]) $args->description = $matches[4];
|
||||
else $args->description = $description;
|
||||
}
|
||||
$output = executeQuery('spamfilter.insertDeniedIP', $args);
|
||||
if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>';
|
||||
/**
|
||||
* @brief IP registration
|
||||
* The registered IP address is considered as a spammer
|
||||
*/
|
||||
function insertIP($ipaddress_list, $description = null)
|
||||
{
|
||||
print_r($ipaddress_list);
|
||||
$regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/";
|
||||
if(!preg_match($regExr,$ipaddress_list)) return new Object(-1, 'msg_invalid');
|
||||
$ipaddress_list = str_replace("\r","",$ipaddress_list);
|
||||
$ipaddress_list = explode("\n",$ipaddress_list);
|
||||
foreach($ipaddress_list as $ipaddressValue)
|
||||
{
|
||||
preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/",$ipaddressValue,$matches);
|
||||
if($ipaddress=trim($matches[1]))
|
||||
{
|
||||
$args->ipaddress = $ipaddress;
|
||||
if(!$description && $matches[4]) $args->description = $matches[4];
|
||||
else $args->description = $description;
|
||||
}
|
||||
$output = executeQuery('spamfilter.insertDeniedIP', $args);
|
||||
if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>';
|
||||
}
|
||||
|
||||
$output->add('fail_list',$fail_list);
|
||||
return $output;
|
||||
$output->add('fail_list',$fail_list);
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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');
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* @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');
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
/* End of file spamfilter.controller.php */
|
||||
/* Location: ./modules/spamfilter/spamfilter.controller.php */
|
||||
|
|
|
|||
|
|
@ -1,144 +1,155 @@
|
|||
<?php
|
||||
/**
|
||||
* @class spamfilterModel
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The Model class of the spamfilter module
|
||||
**/
|
||||
/**
|
||||
* @class spamfilterModel
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief The Model class of the spamfilter module
|
||||
*/
|
||||
class spamfilterModel extends spamfilter
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
class spamfilterModel extends spamfilter {
|
||||
/**
|
||||
* @brief Return the user setting values of the Spam filter module
|
||||
*/
|
||||
function getConfig()
|
||||
{
|
||||
// Get configurations (using the module model object)
|
||||
$oModuleModel = &getModel('module');
|
||||
return $oModuleModel->getModuleConfig('spamfilter');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialization
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
/**
|
||||
* @brief Return the list of registered IP addresses which were banned
|
||||
*/
|
||||
function getDeniedIPList()
|
||||
{
|
||||
$args->sort_index = "regdate";
|
||||
$args->page = Context::get('page')?Context::get('page'):1;
|
||||
$output = executeQuery('spamfilter.getDeniedIPList', $args);
|
||||
if(!$output->data) return;
|
||||
if(!is_array($output->data)) return array($output->data);
|
||||
return $output->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the user setting values of the Spam filter module
|
||||
**/
|
||||
function getConfig() {
|
||||
// Get configurations (using the module model object)
|
||||
$oModuleModel = &getModel('module');
|
||||
return $oModuleModel->getModuleConfig('spamfilter');
|
||||
}
|
||||
/**
|
||||
* @brief Check if the ipaddress is in the list of banned IP addresses
|
||||
*/
|
||||
function isDeniedIP()
|
||||
{
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
/**
|
||||
* @brief Return the list of registered IP addresses which were banned
|
||||
**/
|
||||
function getDeniedIPList() {
|
||||
$args->sort_index = "regdate";
|
||||
$args->page = Context::get('page')?Context::get('page'):1;
|
||||
$output = executeQuery('spamfilter.getDeniedIPList', $args);
|
||||
if(!$output->data) return;
|
||||
if(!is_array($output->data)) return array($output->data);
|
||||
return $output->data;
|
||||
}
|
||||
$ip_list = $this->getDeniedIPList();
|
||||
if(!count($ip_list)) return new Object();
|
||||
|
||||
/**
|
||||
* @brief Check if the ipaddress is in the list of banned IP addresses
|
||||
**/
|
||||
function isDeniedIP() {
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
$count = count($ip_list);
|
||||
for($i=0;$i<$count;$i++)
|
||||
{
|
||||
$ip = str_replace('.', '\.', str_replace('*','(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',$ip_list[$i]->ipaddress));
|
||||
if(preg_match('/^'.$ip.'$/', $ipaddress, $matches)) return new Object(-1,'msg_alert_registered_denied_ip');
|
||||
}
|
||||
|
||||
$ip_list = $this->getDeniedIPList();
|
||||
if(!count($ip_list)) return new Object();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
$count = count($ip_list);
|
||||
for($i=0;$i<$count;$i++) {
|
||||
$ip = str_replace('.', '\.', str_replace('*','(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',$ip_list[$i]->ipaddress));
|
||||
if(preg_match('/^'.$ip.'$/', $ipaddress, $matches)) return new Object(-1,'msg_alert_registered_denied_ip');
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
/**
|
||||
* @brief Return the list of registered Words which were banned
|
||||
*/
|
||||
function getDeniedWordList()
|
||||
{
|
||||
$args->sort_index = "hit";
|
||||
$output = executeQuery('spamfilter.getDeniedWordList', $args);
|
||||
if(!$output->data) return;
|
||||
if(!is_array($output->data)) return array($output->data);
|
||||
return $output->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the list of registered Words which were banned
|
||||
**/
|
||||
function getDeniedWordList() {
|
||||
$args->sort_index = "hit";
|
||||
$output = executeQuery('spamfilter.getDeniedWordList', $args);
|
||||
if(!$output->data) return;
|
||||
if(!is_array($output->data)) return array($output->data);
|
||||
return $output->data;
|
||||
}
|
||||
/**
|
||||
* @brief Check if the text, received as a parameter, is banned or not
|
||||
*/
|
||||
function isDeniedWord($text)
|
||||
{
|
||||
$word_list = $this->getDeniedWordList();
|
||||
if(!count($word_list)) return new Object();
|
||||
|
||||
/**
|
||||
* @brief Check if the text, received as a parameter, is banned or not
|
||||
**/
|
||||
function isDeniedWord($text) {
|
||||
$word_list = $this->getDeniedWordList();
|
||||
if(!count($word_list)) return new Object();
|
||||
$count = count($word_list);
|
||||
for($i=0;$i<$count;$i++)
|
||||
{
|
||||
$word = $word_list[$i]->word;
|
||||
if(preg_match('/'.preg_quote($word,'/').'/is', $text))
|
||||
{
|
||||
$args->word = $word;
|
||||
$output = executeQuery('spamfilter.updateDeniedWordHit', $args);
|
||||
return new Object(-1,sprintf(Context::getLang('msg_alert_denied_word'), $word));
|
||||
}
|
||||
}
|
||||
|
||||
$count = count($word_list);
|
||||
for($i=0;$i<$count;$i++) {
|
||||
$word = $word_list[$i]->word;
|
||||
if(preg_match('/'.preg_quote($word,'/').'/is', $text)) {
|
||||
$args->word = $word;
|
||||
$output = executeQuery('spamfilter.updateDeniedWordHit', $args);
|
||||
return new Object(-1,sprintf(Context::getLang('msg_alert_denied_word'), $word));
|
||||
}
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
/**
|
||||
* @brief Check the specified time
|
||||
*/
|
||||
function checkLimited()
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
|
||||
/**
|
||||
* @brief Check the specified time
|
||||
**/
|
||||
function checkLimited() {
|
||||
$config = $this->getConfig();
|
||||
|
||||
if($config->limits != 'Y') return new Object();
|
||||
$limit_count = '3';
|
||||
$interval = '10';
|
||||
if($config->limits != 'Y') return new Object();
|
||||
$limit_count = '3';
|
||||
$interval = '10';
|
||||
|
||||
$count = $this->getLogCount($interval);
|
||||
$count = $this->getLogCount($interval);
|
||||
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
// 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);
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
// 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);
|
||||
|
||||
$oSpamFilterController = &getController('spamfilter');
|
||||
$oSpamFilterController->insertLog();
|
||||
$oSpamFilterController = &getController('spamfilter');
|
||||
$oSpamFilterController->insertLog();
|
||||
|
||||
return new Object(-1, $message);
|
||||
}
|
||||
return new Object(-1, $message);
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
/**
|
||||
* @brief Check if the trackbacks have already been registered to a particular article
|
||||
*/
|
||||
function isInsertedTrackback($document_srl)
|
||||
{
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
$count = $oTrackbackModel->getTrackbackCountByIPAddress($document_srl, $_SERVER['REMOTE_ADDR']);
|
||||
if($count>0) return new Object(-1, 'msg_alert_trackback_denied');
|
||||
|
||||
/**
|
||||
* @brief Check if the trackbacks have already been registered to a particular article
|
||||
**/
|
||||
function isInsertedTrackback($document_srl) {
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
$count = $oTrackbackModel->getTrackbackCountByIPAddress($document_srl, $_SERVER['REMOTE_ADDR']);
|
||||
if($count>0) return new Object(-1, 'msg_alert_trackback_denied');
|
||||
return new Object();
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
/**
|
||||
* @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'];
|
||||
|
||||
/**
|
||||
* @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'];
|
||||
|
||||
$args->ipaddress = $ipaddress;
|
||||
$args->regdate = date("YmdHis", time()-$time);
|
||||
$output = executeQuery('spamfilter.getLogCount', $args);
|
||||
$count = $output->data->count;
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
$args->ipaddress = $ipaddress;
|
||||
$args->regdate = date("YmdHis", time()-$time);
|
||||
$output = executeQuery('spamfilter.getLogCount', $args);
|
||||
$count = $output->data->count;
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
/* End of file spamfilter.model.php */
|
||||
/* Location: ./modules/spamfilter/spamfilter.model.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue