XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
spamfilter.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class spamfilter extends ModuleObject
9 {
13  function moduleInstall()
14  {
15  // Register action forward (to use in administrator mode)
17  // 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
18  $oModuleController->insertTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
19  $oModuleController->insertTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
20  $oModuleController->insertTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before');
21  // 2008-12-17 Add a spamfilter for post modification actions
22  $oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
23  $oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
24  // 2013-11-14 The trigger which try to perform spam filtering when new message are registered
25  $oModuleController->insertTrigger('communication.sendMessage', 'spamfilter', 'controller', 'triggerSendMessage', 'before');
26 
27  return new BaseObject();
28  }
29 
33  function checkUpdate()
34  {
35  $oDB = &DB::getInstance();
36  $oModuleModel = getModel('module');
38  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
39  if($oModuleModel->needUpdate($version_update_id))
40  {
41  // 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
42  if(!$oModuleModel->getTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')) return true;
43  if(!$oModuleModel->getTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before')) return true;
44  if(!$oModuleModel->getTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before')) return true;
45  // 2008-12-17 Add a spamfilter for post modification actions
46  if(!$oModuleModel->getTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before')) return true;
47  if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before')) return true;
48  // 2013-11-14 The trigger which try to perform spam filtering when new message are registered
49  if(!$oModuleModel->getTrigger('communication.sendMessage', 'spamfilter', 'controller', 'triggerSendMessage', 'before')) return true;
50 
54  if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit')) return true;
55  if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit')) return true;
56 
57  if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description')) return true;
58 
59  $oModuleController->insertUpdatedLog($version_update_id);
60  }
61 
62  return false;
63  }
64 
68  function moduleUpdate()
69  {
70  $oDB = &DB::getInstance();
71  $oModuleModel = getModel('module');
73  $version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
74  if($oModuleModel->needUpdate($version_update_id))
75  {
76  // 2007.12.7 The triggers which try to perform spam filtering when new posts/comments/trackbacks are registered
77  if(!$oModuleModel->getTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before'))
78  $oModuleController->insertTrigger('document.insertDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
79  if(!$oModuleModel->getTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before'))
80  $oModuleController->insertTrigger('comment.insertComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
81  if(!$oModuleModel->getTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before'))
82  $oModuleController->insertTrigger('trackback.insertTrackback', 'spamfilter', 'controller', 'triggerInsertTrackback', 'before');
83  // 2008-12-17 Add a spamfilter for post modification actions
84  if(!$oModuleModel->getTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before'))
85  {
86  $oModuleController->insertTrigger('comment.updateComment', 'spamfilter', 'controller', 'triggerInsertComment', 'before');
87  }
88  // 2008-12-17 Add a spamfilter for post modification actions
89  if(!$oModuleModel->getTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before'))
90  {
91  $oModuleController->insertTrigger('document.updateDocument', 'spamfilter', 'controller', 'triggerInsertDocument', 'before');
92  }
93  // 2013-11-14 The trigger which try to perform spam filtering when new message are registered
94  if(!$oModuleModel->getTrigger('communication.sendMessage', 'spamfilter', 'controller', 'triggerSendMessage', 'before'))
95  {
96  $oModuleController->insertTrigger('communication.sendMessage', 'spamfilter', 'controller', 'triggerSendMessage', 'before');
97  }
98 
102  if(!$oDB->isColumnExists('spamfilter_denied_word', 'hit'))
103  {
104  $oDB->addColumn('spamfilter_denied_word','hit','number',12,0,true);
105  $oDB->addIndex('spamfilter_denied_word','idx_hit', 'hit');
106  }
107  if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit'))
108  {
109  $oDB->addColumn('spamfilter_denied_word','latest_hit','date');
110  $oDB->addIndex('spamfilter_denied_word','idx_latest_hit', 'latest_hit');
111  }
112 
113  if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description'))
114  {
115  $oDB->addColumn('spamfilter_denied_ip','description','varchar', 250);
116  }
117 
118  $oModuleController->insertUpdatedLog($version_update_id);
119  }
120 
121  return new BaseObject(0,'success_updated');
122  }
123 
127  function recompileCache()
128  {
129  }
130 }
131 /* End of file spamfilter.class.php */
132 /* Location: ./modules/spamfilter/spamfilter.class.controller.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
recompileCache()
Re-generate the cache file.
const __XE_VERSION__
Definition: config.inc.php:32
The parent class of the spamfilter module.
getInstance($db_type=NULL)
Definition: DB.class.php:142
getModel($module_name)
Definition: func.inc.php:145
moduleInstall()
Additional tasks required to accomplish during the installation.
$oModuleController
Definition: ko.install.php:287
moduleUpdate()
Execute update.
checkUpdate()
A method to check if the installation has been successful.