Procházet zdrojové kódy

Merge branch 'master' of https://github.com/unaio/una

AntonLV před 7 roky
rodič
revize
c0739577d5

+ 1 - 2
modules/boonex/antispam/classes/BxAntispamAlertsResponse.php

@@ -32,11 +32,10 @@ class BxAntispamAlertsResponse extends BxDolAlertsResponse
             switch ($oAlert->sAction) {    
                 case 'check_spam':
                     $oAlert->aExtras['content'] = BxDolService::call('bx_antispam', 'filter_spam', array($oAlert->aExtras['content']));
-                    if (!isset($oAlert->aExtras['type']) || 'textarea' == $oAlert->aExtras['type'])
+                    if ((!isset($oAlert->aExtras['type']) || 'textarea' == $oAlert->aExtras['type']) && is_string($oAlert->aExtras['content']))
                         $oAlert->aExtras['is_spam'] = BxDolService::call('bx_antispam', 'is_spam', array(&$oAlert->aExtras['content']));
                     break;
             }
-            
         }
     }
 }

+ 3 - 3
modules/boonex/antispam/classes/BxAntispamModule.php

@@ -58,13 +58,13 @@ class BxAntispamModule extends BxDolModule
      * @param $sIp IP address of content poster
      * @return modified or the same content.
      */
-    public function serviceFilterSpam ($sContent, $sIp = '')
+    public function serviceFilterSpam ($mContent, $sIp = '')
     {      
         if (defined('BX_DOL_CRON_EXECUTE') || isAdmin() || 'on' != $this->_oConfig->getAntispamOption('profanity_enable'))
-            return $sContent;
+            return $mContent;
         
         $oProfanityFilter = bx_instance('BxAntispamProfanityFilter', array(), $this->_aModule);
-        return $oProfanityFilter->censorString($sContent); 
+        return $oProfanityFilter->censor($mContent); 
     }
     
     /**

+ 16 - 5
modules/boonex/antispam/classes/BxAntispamProfanityFilter.php

@@ -16,7 +16,6 @@ class BxAntispamProfanityFilter extends BxDol
 {
     protected $oProfanityFilter = null;
     protected $sPluginPath = BX_DIRECTORY_PATH_PLUGINS . 'banbuilder/src/';
-    protected $bIsFullWord = false;
     
     public function __construct()
     {
@@ -25,7 +24,7 @@ class BxAntispamProfanityFilter extends BxDol
         require_once ($this->sPluginPath .'CensorWords.php');
         $sClassName = 'Snipe\BanBuilder\CensorWords';
         $this->oProfanityFilter = new $sClassName;
-       
+        
         $aTmp = explode(',', getParam('bx_antispam_profanity_filter_dicts'));
         foreach ($aTmp as $sLng) {
             if ($sLng != '')
@@ -45,10 +44,22 @@ class BxAntispamProfanityFilter extends BxDol
             $this->oProfanityFilter->addWhiteList(explode(',', $sWhiteWords));
     }
 
-    public function censorString ($s)
+    public function censor ($mValue)
     {
-        $aTmp = $this->oProfanityFilter->censorString($s, $this->bIsFullWord);
-        return $aTmp['clean'];
+        $bFullWord = getParam('bx_antispam_profanity_filter_full_words_only') =='on' ? true : false;
+        if (is_array($mValue)){
+            for ($i = 0; $i < count($mValue); $i++) {
+                if (is_string($mValue[$i])){
+                    $aTmp = $this->oProfanityFilter->censorString($mValue[$i], $bFullWord);
+                    $mValue[$i] = $aTmp['clean'];
+                }
+            }
+        }
+        else{
+            $aTmp = $this->oProfanityFilter->censorString($mValue, $bFullWord);
+            $mValue = $aTmp['clean'];
+        }
+        return $mValue;
     } 
     
     public function getDicts ()

+ 1 - 0
modules/boonex/antispam/install/langs/en.xml

@@ -143,6 +143,7 @@ This antispam method scan submitted content for the URLs and check them if any o
   <string name="_bx_antispam_option_profanity_filter_bad_words_list"><![CDATA[Bad words list (comma separated)]]></string>
   <string name="_bx_antispam_option_profanity_filter_char_replace"><![CDATA[Char to replace]]></string>
   <string name="_bx_antispam_option_profanity_filter_white_words_list"><![CDATA[White words list (comma separated)]]></string>
+  <string name="_bx_antispam_option_profanity_filter_full_words_only"><![CDATA[Full words only]]></string>
 
   <string name="_bx_antispam_spam_report_name"><![CDATA[Spam report message]]></string>
     <string name="_bx_antispam_spam_report_subject"><![CDATA[Automatic spam report]]></string>

+ 2 - 1
modules/boonex/antispam/install/sql/enable.sql

@@ -75,7 +75,8 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'bx_antispam_profanity_filter_dicts', '_bx_antispam_option_profanity_filter_dicts', '', 'list', 'a:2:{s:6:"module";s:11:"bx_antispam";s:6:"method";s:26:"get_profanity_filter_dicts";}', '', '', 15),
 (@iCategoryId, 'bx_antispam_profanity_filter_bad_words_list', '_bx_antispam_option_profanity_filter_bad_words_list', '', 'text', '', '', '', 20),
 (@iCategoryId, 'bx_antispam_profanity_filter_char_replace', '_bx_antispam_option_profanity_filter_char_replace', '*', 'digit', '', '', '', 30),
-(@iCategoryId, 'bx_antispam_profanity_filter_white_words_list', '_bx_antispam_option_profanity_filter_white_words_list', '', 'text', '', '', '', 40);
+(@iCategoryId, 'bx_antispam_profanity_filter_white_words_list', '_bx_antispam_option_profanity_filter_white_words_list', '', 'text', '', '', '', 40),
+(@iCategoryId, 'bx_antispam_profanity_filter_full_words_only', '_bx_antispam_option_profanity_filter_full_words_only', 'on', 'checkbox', '', '', '', 50);
 
 
 -- page: DNSBL list

+ 1 - 0
modules/boonex/polls/classes/BxPollsFormEntry.php

@@ -24,6 +24,7 @@ class BxPollsFormEntry extends BxBaseModTextFormEntry
     public function __construct($aInfo, $oTemplate = false)
     {
         $this->MODULE = 'bx_polls';
+        $this->_aFieldsCheckForSpam = array('subentries');
         parent::__construct($aInfo, $oTemplate);
     }
 

+ 1 - 1
modules/boonex/posts/classes/BxPostsFormPoll.php

@@ -14,7 +14,7 @@ class BxPostsFormPoll extends BxBaseModTextFormPoll
     public function __construct($aInfo, $oTemplate = false)
     {
         $this->_sModule = 'bx_posts';
-
+        $this->_aFieldsCheckForSpam = array('answers');
         parent::__construct($aInfo, $oTemplate);
     }
 }

+ 3 - 2
modules/boonex/russian/data/langs/bx_antispam/ru.xml

@@ -143,8 +143,9 @@ URI DNSBL - это DNSBL, которые перечисляют доменные
   <string name="_bx_antispam_option_profanity_filter_char_replace"><![CDATA[Символ замены]]></string>
   <string name="_bx_antispam_option_profanity_filter_white_words_list"><![CDATA[Список слов исключений (разделенных запятой)]]></string>
   <string name="_bx_antispam_option_profanity_filter_dicts"><![CDATA[Словари]]></string>
-  
-    <string name="_bx_antispam_spam_report_name"><![CDATA[Сообщение отчёта о спаме]]></string>
+  <string name="_bx_antispam_option_profanity_filter_full_words_only"><![CDATA[Только слова целиком]]></string>
+
+  <string name="_bx_antispam_spam_report_name"><![CDATA[Сообщение отчёта о спаме]]></string>
     <string name="_bx_antispam_spam_report_subject"><![CDATA[Автоматический отчёт о спаме]]></string>
     <string name="_bx_antispam_spam_report_body"><![CDATA[{email_header}
 <b>Профиль:</b> <a href="{SpammerUrl}">{SpammerNickName}</a><br />