mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Make all spamfilter model methods static
This commit is contained in:
parent
a90f444182
commit
a04dc1270f
2 changed files with 24 additions and 34 deletions
|
|
@ -50,9 +50,8 @@ class SpamfilterController extends Spamfilter
|
|||
if($grant->manager) return;
|
||||
}
|
||||
|
||||
$oFilterModel = getModel('spamfilter');
|
||||
// Check if the IP is prohibited
|
||||
$output = $oFilterModel->isDeniedIP();
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
// Check if there is a ban on the word
|
||||
$filter_targets = [$obj->title, $obj->content, $obj->tags ?? ''];
|
||||
|
|
@ -71,7 +70,7 @@ class SpamfilterController extends Spamfilter
|
|||
}
|
||||
}
|
||||
}
|
||||
$output = $oFilterModel->isDeniedWord(implode("\n", $filter_targets));
|
||||
$output = SpamfilterModel::isDeniedWord(implode("\n", $filter_targets));
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
|
|
@ -79,7 +78,7 @@ class SpamfilterController extends Spamfilter
|
|||
// Check the specified time beside the modificaiton time
|
||||
if($obj->document_srl == 0)
|
||||
{
|
||||
$output = $oFilterModel->checkLimited();
|
||||
$output = SpamfilterModel::checkLimited();
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
// Save a log
|
||||
|
|
@ -103,9 +102,8 @@ class SpamfilterController extends Spamfilter
|
|||
if($grant->manager) return;
|
||||
}
|
||||
|
||||
$oFilterModel = getModel('spamfilter');
|
||||
// Check if the IP is prohibited
|
||||
$output = $oFilterModel->isDeniedIP();
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
// Check if there is a ban on the word
|
||||
if($is_logged)
|
||||
|
|
@ -116,12 +114,12 @@ class SpamfilterController extends Spamfilter
|
|||
{
|
||||
$text = $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage;
|
||||
}
|
||||
$output = $oFilterModel->isDeniedWord($text);
|
||||
$output = SpamfilterModel::isDeniedWord($text);
|
||||
if(!$output->toBool()) return $output;
|
||||
// If the specified time check is not modified
|
||||
if(!$obj->__isupdate)
|
||||
{
|
||||
$output = $oFilterModel->checkLimited();
|
||||
$output = SpamfilterModel::checkLimited();
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
unset($obj->__isupdate);
|
||||
|
|
@ -197,7 +195,7 @@ class SpamfilterController extends Spamfilter
|
|||
return;
|
||||
}
|
||||
|
||||
$output = SpamfilterModel::getInstance()->isDeniedIP();
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if (!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
|
|
@ -219,7 +217,7 @@ class SpamfilterController extends Spamfilter
|
|||
return;
|
||||
}
|
||||
|
||||
$output = SpamfilterModel::getInstance()->isDeniedIP();
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if (!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
|
|
@ -240,16 +238,15 @@ class SpamfilterController extends Spamfilter
|
|||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->is_admin == 'Y') return;
|
||||
|
||||
$oFilterModel = getModel('spamfilter');
|
||||
// Check if the IP is prohibited
|
||||
$output = $oFilterModel->isDeniedIP();
|
||||
$output = SpamfilterModel::isDeniedIP();
|
||||
if(!$output->toBool()) return $output;
|
||||
// Check if there is a ban on the word
|
||||
$text = $obj->title . ' ' . $obj->content;
|
||||
$output = $oFilterModel->isDeniedWord($text);
|
||||
$output = SpamfilterModel::isDeniedWord($text);
|
||||
if(!$output->toBool()) return $output;
|
||||
// Check the specified time
|
||||
$output = $oFilterModel->checkLimited(TRUE);
|
||||
$output = SpamfilterModel::checkLimited(TRUE);
|
||||
if(!$output->toBool()) return $output;
|
||||
// Save a log
|
||||
$this->insertLog();
|
||||
|
|
|
|||
|
|
@ -7,17 +7,10 @@
|
|||
*/
|
||||
class SpamfilterModel extends Spamfilter
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the user setting values of the Spam filter module
|
||||
*/
|
||||
function getConfig()
|
||||
public static function getConfig()
|
||||
{
|
||||
return ModuleModel::getModuleConfig('spamfilter') ?: new stdClass;
|
||||
}
|
||||
|
|
@ -25,7 +18,7 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Return the list of registered IP addresses which were banned
|
||||
*/
|
||||
function getDeniedIPList($sort_index = 'regdate')
|
||||
public static function getDeniedIPList($sort_index = 'regdate')
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->sort_index = $sort_index;
|
||||
|
|
@ -38,12 +31,12 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Check if the ipaddress is in the list of banned IP addresses
|
||||
*/
|
||||
function isDeniedIP()
|
||||
public static function isDeniedIP()
|
||||
{
|
||||
$ip_list = Rhymix\Framework\Cache::get('spamfilter:denied_ip_list');
|
||||
if ($ip_list === null)
|
||||
{
|
||||
$ip_list = $this->getDeniedIPList();
|
||||
$ip_list = self::getDeniedIPList();
|
||||
Rhymix\Framework\Cache::set('spamfilter:denied_ip_list', $ip_list);
|
||||
}
|
||||
if (!count($ip_list))
|
||||
|
|
@ -75,7 +68,7 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Return the list of registered Words which were banned
|
||||
*/
|
||||
function getDeniedWordList($sort_index = 'hit')
|
||||
public static function getDeniedWordList($sort_index = 'hit')
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->sort_index = $sort_index;
|
||||
|
|
@ -86,12 +79,12 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Check if the text, received as a parameter, is banned or not
|
||||
*/
|
||||
function isDeniedWord($text)
|
||||
public static function isDeniedWord($text)
|
||||
{
|
||||
$word_list = Rhymix\Framework\Cache::get('spamfilter:denied_word_list');
|
||||
if ($word_list === null)
|
||||
{
|
||||
$word_list = $this->getDeniedWordList();
|
||||
$word_list = self::getDeniedWordList();
|
||||
Rhymix\Framework\Cache::set('spamfilter:denied_word_list', $word_list);
|
||||
}
|
||||
if (!count($word_list))
|
||||
|
|
@ -128,7 +121,7 @@ class SpamfilterModel extends Spamfilter
|
|||
$args->word = $word;
|
||||
executeQuery('spamfilter.updateDeniedWordHit', $args);
|
||||
|
||||
$config = $this->getConfig();
|
||||
$config = self::getConfig();
|
||||
|
||||
if($config->custom_message)
|
||||
{
|
||||
|
|
@ -161,9 +154,9 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Check the specified time
|
||||
*/
|
||||
function checkLimited($isMessage = FALSE)
|
||||
public static function checkLimited($isMessage = FALSE)
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
$config = self::getConfig();
|
||||
|
||||
if($config->limits != 'Y') return new BaseObject();
|
||||
$limit_count = $config->limits_count ?: 3;
|
||||
|
|
@ -177,7 +170,7 @@ class SpamfilterModel extends Spamfilter
|
|||
}
|
||||
}
|
||||
|
||||
$count = $this->getLogCount($interval);
|
||||
$count = self::getLogCount($interval);
|
||||
|
||||
// Ban the IP address if the interval is exceeded
|
||||
if($count>=$limit_count)
|
||||
|
|
@ -272,7 +265,7 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Check if the trackbacks have already been registered to a particular article
|
||||
*/
|
||||
function isInsertedTrackback($document_srl)
|
||||
public static function isInsertedTrackback($document_srl)
|
||||
{
|
||||
$oTrackbackModel = getModel('trackback');
|
||||
if (is_object($oTrackbackModel) && method_exists($oTrackbackModel, 'getTrackbackCountByIPAddress'))
|
||||
|
|
@ -289,7 +282,7 @@ class SpamfilterModel extends Spamfilter
|
|||
/**
|
||||
* @brief Return the number of logs recorded within the interval for the specified IPaddress
|
||||
*/
|
||||
function getLogCount($time = 60, $ipaddress='')
|
||||
public static function getLogCount($time = 60, $ipaddress='')
|
||||
{
|
||||
if(!$ipaddress) $ipaddress = \RX_CLIENT_IP;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue