Alex Trofimov %!s(int64=12) %!d(string=hai) anos
pai
achega
df8ecf65d5

+ 3 - 4
modules/boonex/antispam/classes/BxAntispamDNSBlacklists.php

@@ -145,19 +145,18 @@ class BxAntispamDNSBlacklists extends BxDol
 
 
     private function initChains() 
     private function initChains() 
     {
     {
-
         $oDb = BxDolDb::getInstance();
         $oDb = BxDolDb::getInstance();
 
 
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS])) {
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS])) {
             $sQuery = $oDb->prepare("SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = ? AND `active` = 1", BX_DOL_DNSBL_CHAIN_SPAMMERS);
             $sQuery = $oDb->prepare("SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = ? AND `active` = 1", BX_DOL_DNSBL_CHAIN_SPAMMERS);
-            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS] = $GLOBALS['MySQL']->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS, 'getAll', $sQuery);
+            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS] = $oDb->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS, 'getAll', $sQuery);
         }
         }
 
 
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST]))
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST]))
-            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST] = $GLOBALS['MySQL']->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST, 'getAll', "SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = '".BX_DOL_DNSBL_CHAIN_WHITELIST."' AND `active` = 1");
+            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST] = $oDb->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST, 'getAll', "SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = '".BX_DOL_DNSBL_CHAIN_WHITELIST."' AND `active` = 1");
 
 
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS]))
         if (!isset($GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS]))
-            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS] = $GLOBALS['MySQL']->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS, 'getAll', "SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = '".BX_DOL_DNSBL_CHAIN_URIDNS."' AND `active` = 1");
+            $GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS] = $oDb->fromCache('sys_dnsbl_'.BX_DOL_DNSBL_CHAIN_URIDNS, 'getAll', "SELECT `zonedomain`, `postvresp` FROM `bx_antispam_dnsbl_rules` WHERE `chain` = '".BX_DOL_DNSBL_CHAIN_URIDNS."' AND `active` = 1");
 
 
         $this->aChains[BX_DOL_DNSBL_CHAIN_SPAMMERS] = &$GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS];
         $this->aChains[BX_DOL_DNSBL_CHAIN_SPAMMERS] = &$GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_SPAMMERS];
         $this->aChains[BX_DOL_DNSBL_CHAIN_WHITELIST] = &$GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST];
         $this->aChains[BX_DOL_DNSBL_CHAIN_WHITELIST] = &$GLOBALS['bx_dol_dnsbl_'.BX_DOL_DNSBL_CHAIN_WHITELIST];

+ 9 - 4
modules/boonex/antispam/classes/BxAntispamDNSURIBlacklists.php

@@ -32,7 +32,7 @@ class BxAntispamDNSURIBlacklists extends BxDol
             3 => BX_DIRECTORY_PATH_MODULES . "boonex/antispam/data/three-level-tlds",
             3 => BX_DIRECTORY_PATH_MODULES . "boonex/antispam/data/three-level-tlds",
         );
         );
 
 
-        $this->oDb = &$GLOBALS['MySQL'];
+        $this->oDb = BxDolDb::getInstance();;
         $this->initZones();
         $this->initZones();
     }
     }
 
 
@@ -46,7 +46,9 @@ class BxAntispamDNSURIBlacklists extends BxDol
         if (!$aURIs)
         if (!$aURIs)
             return false;
             return false;
 
 
-        $o = bx_instance('BxDolDNSBlacklists');
+        bx_import('BxDolModule');
+        $oModule = BxDolModule::getInstance('bx_antispam');
+        $o = bx_instance('BxAntispamDNSBlacklists', array(), $oModule->_aModule);
         foreach ($aURIs as $sURI) {
         foreach ($aURIs as $sURI) {
             if (BX_DOL_DNSBL_POSITIVE == $o->dnsbl_lookup_uri ($sURI))
             if (BX_DOL_DNSBL_POSITIVE == $o->dnsbl_lookup_uri ($sURI))
                 return true;
                 return true;
@@ -58,7 +60,7 @@ class BxAntispamDNSURIBlacklists extends BxDol
     public function parseUrls (&$s)
     public function parseUrls (&$s)
     {
     {
         $aMatches = array ();
         $aMatches = array ();
-        if (!preg_match_all("!(https?|ftp|gopher|telnet|file|notes|ms-help):[/\\\\]+([\w\d\.]*)!", $s, $aMatches))
+        if (!preg_match_all("!(https?|ftp|gopher|telnet|file|notes|ms-help):[/\\\\]+([\w\d\.-]*)!", $s, $aMatches))
             return false;
             return false;
 
 
         if (!$aMatches || !isset($aMatches[2]) || !$aMatches[2])
         if (!$aMatches || !isset($aMatches[2]) || !$aMatches[2])
@@ -128,7 +130,10 @@ class BxAntispamDNSURIBlacklists extends BxDol
 
 
     public function onPositiveDetection ($sExtraData = '')
     public function onPositiveDetection ($sExtraData = '')
     {
     {
-        $o = bx_instance('BxDolDNSBlacklists');
+        bx_import('BxDolModule');
+        $oModule = BxDolModule::getInstance('bx_antispam');
+        $o = bx_instance('BxAntispamDNSBlacklists', array(), $oModule->_aModule);
+
         $o->onPositiveDetection (getVisitorIP(false), $sExtraData, 'dnsbluri');
         $o->onPositiveDetection (getVisitorIP(false), $sExtraData, 'dnsbluri');
     }
     }
 
 

+ 151 - 0
modules/boonex/antispam/classes/BxAntispamGridDNSBL.php

@@ -0,0 +1,151 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    Antispam Antispam
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplGrid');
+
+class BxAntispamGridDNSBL extends BxTemplGrid 
+{
+    public function __construct ($aOptions, $oTemplate = false) 
+    {
+        parent::__construct ($aOptions, $oTemplate);
+    }
+
+    /**
+     * add js file for AJAX form submission
+     */
+    protected function _addJsCss() 
+    {
+        parent::_addJsCss();
+    }
+
+    /**
+     * 'help' action handler
+     */
+    public function performActionHelp()
+    {
+        bx_import('BxTemplFunctions');
+
+        $s = BxTemplFunctions::getInstance()->popupBox(
+            'bx_antispam_poppup_help', 
+            _t('_bx_antispam_popup_help'), 
+            _t('_bx_antispam_help_dnsbl')
+        );
+
+        $this->_echoResultJson(array('popup' => array('html' => $s)), true);
+    }
+
+    /**
+     * 'log' action handler
+     */
+    public function performActionLog()
+    {
+    }
+
+    /**
+     * 'recheck' action handler
+     */
+    public function performActionRecheck() 
+    {
+        bx_import('BxDolForm');
+        $oForm = BxDolForm::getObjectInstance('bx_antispam_ip_table_form', $sDisplay); // get form instance for specified form object and display
+        if (!$oForm) {
+            $this->_echoResultJson(array('msg' => _t('_sys_txt_error_occured')), true);
+            exit;
+        }
+
+        $oForm->addMarkers(array(
+            'grid_object' => $this->_sObject,
+            'grid_action' => $sAction,
+        ));
+
+        $aIpTableDirective = array();
+        if ($iId) {
+            bx_import('BxDolModule');
+            $oModule = BxDolModule::getInstance('bx_antispam');
+            $oAntispamIp = bx_instance('BxAntispamIP', array(), $oModule->_aModule);
+            $aIpTableDirective = $oAntispamIp->getIpTableDirective($iId);
+            $aIpTableDirective['From'] = long2ip($aIpTableDirective['From']);
+            $aIpTableDirective['To'] = long2ip($aIpTableDirective['To']);
+        }
+        $oForm->initChecker($aIpTableDirective);
+
+        if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid            
+
+            $aCustomValues = array(
+                'From' => sprintf("%u", ip2long($oForm->getCleanValue('From'))),
+                'To' => sprintf("%u", ip2long($oForm->getCleanValue('To'))),
+            );
+
+            if ($iId) {
+                if ($oForm->update ($iId, $aCustomValues)) // update record
+                    $iRecentId = $iId;
+            } else {
+                $iRecentId = $oForm->insert ($aCustomValues, true); // insert new record
+            }
+
+            if ($iRecentId)
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $iRecentId); // if record is successfully added, reload grid and highlight added row
+            else
+                $aRes = array('msg' => _t('_sys_txt_error_occured')); // if record adding failed, display error message
+
+            $this->_echoResultJson($aRes, true);
+
+        } else { // if form is not submitted or some fields are invalid, display popup with form
+
+            bx_import('BxTemplFunctions');
+            $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_form_ip_table_add'), $oForm->getCode() . '
+                <script>
+                    $(document).ready(function () {
+                        $("#' . $oForm->getId() . '").ajaxForm({ 
+                            dataType: "json",
+                            beforeSubmit: function (formData, jqForm, options) {
+                                bx_loading($("#' . $oForm->getId() . '"), true);
+                            },
+                            success: function (data) {
+                                $(".bx-popup-applied:visible").dolPopupHide();
+                                glGrids.' . $this->_sObject . '.processJson(data, "' . $sAction . '");
+                            }
+                        });
+                    });
+                </script>');
+
+            $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true);
+
+        }
+    }
+
+
+    protected function _getCellChain ($mixedValue, $sKey, $aField, $aRow) 
+    {
+        $s = _t('_undefined');
+        switch ($mixedValue) {
+            case 'whitelist':
+            case 'spammers':
+            case 'uridns':
+                $s = _t('_bx_antispam_chain_' . $mixedValue);
+        }
+        return parent::_getCellDefault ($s, $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellComment ($mixedValue, $sKey, $aField, $aRow) 
+    {
+        $sCountry = '';
+        $aMatches = array();
+        if (preg_match('/^(\w{2})\.countries\.nerd\.dk\.$/', $aRow['zonedomain'], $aMatches) && isset($aMatches[1])) {
+            $sCountry = $aMatches[1];
+        }
+
+        return parent::_getCellDefault (_t($mixedValue, $sCountry), $sKey, $aField, $aRow);
+    }
+
+}
+
+/** @} */

+ 0 - 1
modules/boonex/antispam/classes/BxAntispamGridIpTable.php

@@ -110,7 +110,6 @@ class BxAntispamGridIpTable extends BxTemplGrid
         } else { // if form is not submitted or some fields are invalid, display popup with form
         } else { // if form is not submitted or some fields are invalid, display popup with form
 
 
             bx_import('BxTemplFunctions');
             bx_import('BxTemplFunctions');
-            // we need to use 'transBox' function to properly display 'popup'
             $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_form_ip_table_add'), $oForm->getCode() . '
             $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_form_ip_table_add'), $oForm->getCode() . '
                 <script>
                 <script>
                     $(document).ready(function () {
                     $(document).ready(function () {

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

@@ -22,9 +22,12 @@ class BxAntispamModule extends BxDolModule
 
 
     function serviceIpTable () 
     function serviceIpTable () 
     {
     {
-        bx_import('BxDolGrid');
-        $oGrid = BxDolGrid::getObjectInstance('bx_antispam_grid_ip_table'); // it automatically creates instance of default or custom class by object name
-        return $oGrid ? $oGrid->getCode() : '';
+        return $this->_grid('bx_antispam_grid_ip_table');
+    }
+
+    function serviceDnsblList () 
+    {
+        return $this->_grid('bx_antispam_grid_dnsbl');
     }
     }
 
 
     /**
     /**
@@ -236,6 +239,13 @@ class BxAntispamModule extends BxDolModule
             return _t('_bx_antispam_submit_false_positive_report', $sUrl);
             return _t('_bx_antispam_submit_false_positive_report', $sUrl);
         return '';
         return '';
     }
     }
+
+    protected function _grid ($sObjectGrid) 
+    {
+        bx_import('BxDolGrid');
+        $oGrid = BxDolGrid::getObjectInstance($sObjectGrid);
+        return $oGrid ? $oGrid->getCode() : '';
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 24 - 4
modules/boonex/antispam/install/langs/en.xml

@@ -6,22 +6,41 @@
     <string name="_bx_antispam_adm_stg_cpt_category_general"><![CDATA[General]]></string>
     <string name="_bx_antispam_adm_stg_cpt_category_general"><![CDATA[General]]></string>
     <string name="_bx_antispam_help"><![CDATA[Help]]></string>
     <string name="_bx_antispam_help"><![CDATA[Help]]></string>
     <string name="_bx_antispam_help_text"><![CDATA[TODO: help text here]]></string>
     <string name="_bx_antispam_help_text"><![CDATA[TODO: help text here]]></string>
+    <string name="_bx_antispam_help_dnsbl"><![CDATA[
+DNSBL - <a href="http://en.wikipedia.org/wiki/DNSBL">Domain Name Service Block Lists</a>.
+This functionality allows to block by IP address if it exists in one of available blocklists.
+<br /><br />
+A URI DNSBL is a DNSBL that lists the domain names and IP addresses which are found in the "clickable" links contained in the body of spams, but generally not found inside legitimate messages.
+This antispam method scan submitted content for the URLs and check them if any of them is a link to spam site. If such URL detected in the text then content is not submitted.
+]]></string>
     <string name="_bx_antispam_ip_blocked"><![CDATA[IP address is blocked. {0}]]></string>
     <string name="_bx_antispam_ip_blocked"><![CDATA[IP address is blocked. {0}]]></string>
     <string name="_bx_antispam_spam_detected"><![CDATA[Spam detected. {0}]]></string>
     <string name="_bx_antispam_spam_detected"><![CDATA[Spam detected. {0}]]></string>
     <string name="_bx_antispam_submit_false_positive_report"><![CDATA[If you believe that this is a mistake, please submit a false positive report here: {0}]]></string>
     <string name="_bx_antispam_submit_false_positive_report"><![CDATA[If you believe that this is a mistake, please submit a false positive report here: {0}]]></string>
 	<string name="_bx_antispam_ip_allow"><![CDATA[Allow]]></string>
 	<string name="_bx_antispam_ip_allow"><![CDATA[Allow]]></string>
 	<string name="_bx_antispam_ip_deny"><![CDATA[Deny]]></string>
 	<string name="_bx_antispam_ip_deny"><![CDATA[Deny]]></string>
+	<string name="_bx_antispam_chain_whitelist"><![CDATA[IP whitelist]]></string>
+	<string name="_bx_antispam_chain_spammers"><![CDATA[IP blacklist]]></string>
+	<string name="_bx_antispam_chain_uridns"><![CDATA[Spam text]]></string>
+	<string name="_bx_antispam_rule_note_country"><![CDATA[Country: {0}]]></string>
+	<string name="_bx_antispam_rule_note_spamhaus_org"><![CDATA[Detect spammer IPs from sbl.spamhaus.org]]></string>
+	<string name="_bx_antispam_rule_note_zomgbl_spameatingmonkey_net"><![CDATA[Everything is blacklisted, use only if something is whitelisted]]></string>
+	<string name="_bx_antispam_rule_note_surbl_org"><![CDATA[Detect spammer URLs from SURBLs (lists of web sites that have appeared in unsolicited messages)]]></string>
+
+	<string name="_bx_antispam_popup_help"><![CDATA[DNSBL help]]></string>
 
 
 	<string name="_bx_antispam_page_title_sys_ip_table"><![CDATA[IP table]]></string>
 	<string name="_bx_antispam_page_title_sys_ip_table"><![CDATA[IP table]]></string>
 	<string name="_bx_antispam_page_title_ip_table"><![CDATA[IP table]]></string>
 	<string name="_bx_antispam_page_title_ip_table"><![CDATA[IP table]]></string>
+	<string name="_bx_antispam_page_title_sys_dnsbl_list"><![CDATA[DNSBL list]]></string>
+	<string name="_bx_antispam_page_title_dnsbl_list"><![CDATA[DNSBL list]]></string>
 
 
 	<string name="_bx_antispam_page_block_title_ip_table"><![CDATA[IP table]]></string>
 	<string name="_bx_antispam_page_block_title_ip_table"><![CDATA[IP table]]></string>
+	<string name="_bx_antispam_page_block_title_dnsbl_list"><![CDATA[DNSBL list]]></string>
 
 
 	<string name="_bx_antispam_grid_action_delete"><![CDATA[Delete]]></string>
 	<string name="_bx_antispam_grid_action_delete"><![CDATA[Delete]]></string>
 	<string name="_bx_antispam_grid_action_add"><![CDATA[Add]]></string>
 	<string name="_bx_antispam_grid_action_add"><![CDATA[Add]]></string>
-
-	<string name="_bx_antispam_grid_title_select"><![CDATA[Select]]></string>
-	<string name="_bx_antispam_grid_title_actions"><![CDATA[Actions]]></string>
+	<string name="_bx_antispam_grid_action_log"><![CDATA[Log]]></string>
+	<string name="_bx_antispam_grid_action_recheck"><![CDATA[Re-check]]></string>
+	<string name="_bx_antispam_grid_action_help"><![CDATA[Help]]></string>
 
 
 	<string name="_bx_antispam_field_id"><![CDATA[ID]]></string>
 	<string name="_bx_antispam_field_id"><![CDATA[ID]]></string>
 	<string name="_bx_antispam_field_ip_from"><![CDATA[IP from]]></string>
 	<string name="_bx_antispam_field_ip_from"><![CDATA[IP from]]></string>
@@ -29,6 +48,7 @@
 	<string name="_bx_antispam_field_action"><![CDATA[Action]]></string>
 	<string name="_bx_antispam_field_action"><![CDATA[Action]]></string>
 	<string name="_bx_antispam_field_expiration"><![CDATA[Expiration]]></string>
 	<string name="_bx_antispam_field_expiration"><![CDATA[Expiration]]></string>
 	<string name="_bx_antispam_field_note"><![CDATA[Note]]></string>
 	<string name="_bx_antispam_field_note"><![CDATA[Note]]></string>
+	<string name="_bx_antispam_field_chain"><![CDATA[Rule]]></string>
 
 
     <string name="_bx_antispam_form_ip_table"><![CDATA[IP table directive]]></string>
     <string name="_bx_antispam_form_ip_table"><![CDATA[IP table directive]]></string>
     <string name="_bx_antispam_form_ip_table_add"><![CDATA[Add IP table directive]]></string>
     <string name="_bx_antispam_form_ip_table_add"><![CDATA[Add IP table directive]]></string>
@@ -42,7 +62,7 @@
 
 
 	<string name="_bx_antispam_option_block"><![CDATA[Total block all spam content]]></string>
 	<string name="_bx_antispam_option_block"><![CDATA[Total block all spam content]]></string>
 	<string name="_bx_antispam_option_report"><![CDATA[Send report to admin if spam content discovered]]></string>
 	<string name="_bx_antispam_option_report"><![CDATA[Send report to admin if spam content discovered]]></string>
-	<string name="_bx_antispam_option_ip_list_type"><![CDATA[IP List Type (1 - all allowed except listed, 2 - all blocked except listed, 0 - disabled)]]></string>
+	<string name="_bx_antispam_option_ip_list_type"><![CDATA[IP table type (1 - all allowed except listed, 2 - all blocked except listed, 0 - disabled)]]></string>
 	<string name="_bx_antispam_option_dnsbl_enable"><![CDATA[Enable DNS Block Lists]]></string>
 	<string name="_bx_antispam_option_dnsbl_enable"><![CDATA[Enable DNS Block Lists]]></string>
 	<string name="_bx_antispam_option_dnsbl_behaviour"><![CDATA[User join behaviour if listed in DNS Block Lists]]></string>
 	<string name="_bx_antispam_option_dnsbl_behaviour"><![CDATA[User join behaviour if listed in DNS Block Lists]]></string>
 	<string name="_bx_antispam_option_uridnsbl_enable"><![CDATA[Enable URI DNS Block Lists]]></string>
 	<string name="_bx_antispam_option_uridnsbl_enable"><![CDATA[Enable URI DNS Block Lists]]></string>

+ 7 - 7
modules/boonex/antispam/install/sql/disable.sql

@@ -3,16 +3,16 @@
 
 
 DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name`='bx_antispam';
 DELETE FROM `top`, `toc`, `to` USING `sys_options_types` AS `top` LEFT JOIN `sys_options_categories` AS `toc` ON `top`.`id`=`toc`.`type_id` LEFT JOIN `sys_options` AS `to` ON `toc`.`id`=`to`.`category_id` WHERE `top`.`name`='bx_antispam';
 
 
--- page: ip table
+-- pages
 
 
-DELETE FROM `sys_objects_page` WHERE `object`='bx_antispam_ip_table';
-DELETE FROM `sys_pages_blocks` WHERE `object`='bx_antispam_ip_table';
+DELETE FROM `sys_objects_page` WHERE `module` = 'bx_antispam';
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_antispam';
 
 
--- grid: ip table
+-- grids
 
 
-DELETE FROM `sys_objects_grid` WHERE `object` = 'bx_antispam_grid_ip_table';
-DELETE FROM `sys_grid_fields` WHERE `object` = 'bx_antispam_grid_ip_table';
-DELETE FROM `sys_grid_actions` WHERE `object` = 'bx_antispam_grid_ip_table';
+DELETE FROM `sys_objects_grid` WHERE `object` LIKE 'bx_antispam%';
+DELETE FROM `sys_grid_fields` WHERE `object` LIKE 'bx_antispam%';
+DELETE FROM `sys_grid_actions` WHERE `object` LIKE 'bx_antispam%';
 
 
 -- data list: ip table actions
 -- data list: ip table actions
 
 

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

@@ -25,6 +25,14 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'bx_antispam_stopforumspam_enable', '_bx_antispam_option_stopforumspam_enable', 'on', 'checkbox', '', '', '', 60),
 (@iCategoryId, 'bx_antispam_stopforumspam_enable', '_bx_antispam_option_stopforumspam_enable', 'on', 'checkbox', '', '', '', 60),
 (@iCategoryId, 'bx_antispam_stopforumspam_api_key', '_bx_antispam_option_stopforumspam_api_key', '', 'digit', '', '', '', 61);
 (@iCategoryId, 'bx_antispam_stopforumspam_api_key', '_bx_antispam_option_stopforumspam_api_key', '', 'digit', '', '', '', 61);
 
 
+-- page: DNSBL list
+
+INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_antispam_dnsbl', 'antispam-dnsbl-list', '_bx_antispam_page_title_sys_dnsbl_list', '_bx_antispam_page_title_dnsbl_list', 'bx_antispam', 5, 64, 1, 'page.php?i=antispam-dnsbl-list', '', '', '', 0, 1, 0, 'BxAntispamPage', 'modules/boonex/antispam/classes/BxAntispamPage.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
+('bx_antispam_dnsbl', 1, 'bx_antispam', '_bx_antispam_page_block_title_dnsbl_list', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:11:\"bx_antispam\";s:6:\"method\";s:10:\"dnsbl_list\";}', 0, 1, 1, 1);
+
 -- page: ip table
 -- page: ip table
 
 
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
@@ -33,19 +41,34 @@ INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('bx_antispam_ip_table', 1, 'bx_antispam', '_bx_antispam_page_block_title_ip_table', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:11:\"bx_antispam\";s:6:\"method\";s:8:\"ip_table\";}', 0, 1, 1, 1);
 ('bx_antispam_ip_table', 1, 'bx_antispam', '_bx_antispam_page_block_title_ip_table', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:11:\"bx_antispam\";s:6:\"method\";s:8:\"ip_table\";}', 0, 1, 1, 1);
 
 
+-- grid: DNSBL
+
+INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
+('bx_antispam_grid_dnsbl', 'Sql', 'SELECT `id`, `chain`, `zonedomain`, `postvresp`, `url`, `recheck`, `comment`, `added`, `active` FROM `bx_antispam_dnsbl_rules`', 'bx_antispam_dnsbl_rules', 'id', 'added', 'active', '', 16, NULL, 'start', '', 'chain,zonedomain,url,recheck', 'comment', 'auto', 'chain', 'comment', 64, 'BxAntispamGridDNSBL', 'modules/boonex/antispam/classes/BxAntispamGridDNSBL.php');
+
+INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
+('bx_antispam_grid_dnsbl', 'switcher', '_sys_active', '10%', 0, 0, '', 1),
+('bx_antispam_grid_dnsbl', 'chain', '_bx_antispam_field_chain', '15%', 0, 0, '', 2),
+('bx_antispam_grid_dnsbl', 'comment', '_bx_antispam_field_note', '75%', 0, 0, '', 3);
+
+INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`) VALUES
+('bx_antispam_grid_dnsbl', 'independent', 'log', '_bx_antispam_grid_action_log', '', 0, 1),
+('bx_antispam_grid_dnsbl', 'independent', 'recheck', '_bx_antispam_grid_action_recheck', '', 0, 2),
+('bx_antispam_grid_dnsbl', 'independent', 'help', '_bx_antispam_grid_action_help', '', 0, 3);
+
 -- grid: ip table
 -- grid: ip table
 
 
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 ('bx_antispam_grid_ip_table', 'Sql', 'SELECT `ID`, `From`, `To`, `Type`, `LastDT`, `Desc` FROM `bx_antispam_ip_table`', 'bx_antispam_ip_table', 'ID', '', '', 10, NULL, 'start', '', 'From,To,Desc', 'auto', 'From,To,Type,LastDT,Desc', 64, 'BxAntispamGridIpTable', 'modules/boonex/antispam/classes/BxAntispamGridIpTable.php');
 ('bx_antispam_grid_ip_table', 'Sql', 'SELECT `ID`, `From`, `To`, `Type`, `LastDT`, `Desc` FROM `bx_antispam_ip_table`', 'bx_antispam_ip_table', 'ID', '', '', 10, NULL, 'start', '', 'From,To,Desc', 'auto', 'From,To,Type,LastDT,Desc', 64, 'BxAntispamGridIpTable', 'modules/boonex/antispam/classes/BxAntispamGridIpTable.php');
 
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
-('bx_antispam_grid_ip_table', 'checkbox', '_bx_antispam_grid_title_select', '2%', '', 1),
+('bx_antispam_grid_ip_table', 'checkbox', '_sys_select', '2%', '', 1),
 ('bx_antispam_grid_ip_table', 'From', '_bx_antispam_field_ip_from', '15%', '', 2),
 ('bx_antispam_grid_ip_table', 'From', '_bx_antispam_field_ip_from', '15%', '', 2),
 ('bx_antispam_grid_ip_table', 'To', '_bx_antispam_field_ip_to', '15%', '', 3),
 ('bx_antispam_grid_ip_table', 'To', '_bx_antispam_field_ip_to', '15%', '', 3),
 ('bx_antispam_grid_ip_table', 'Type', '_bx_antispam_field_action', '15%', '', 4),
 ('bx_antispam_grid_ip_table', 'Type', '_bx_antispam_field_action', '15%', '', 4),
 ('bx_antispam_grid_ip_table', 'LastDT', '_bx_antispam_field_expiration', '15%', '', 5),
 ('bx_antispam_grid_ip_table', 'LastDT', '_bx_antispam_field_expiration', '15%', '', 5),
 ('bx_antispam_grid_ip_table', 'Desc', '_bx_antispam_field_note', '26%', '', 6),
 ('bx_antispam_grid_ip_table', 'Desc', '_bx_antispam_field_note', '26%', '', 6),
-('bx_antispam_grid_ip_table', 'actions', '_bx_antispam_grid_title_actions', '12%', '', 7);
+('bx_antispam_grid_ip_table', 'actions', '_sys_actions', '12%', '', 7);
 
 
 INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`) VALUES
 INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`) VALUES
 ('bx_antispam_grid_ip_table', 'bulk', 'delete', '_bx_antispam_grid_action_delete', '', 1, 1),
 ('bx_antispam_grid_ip_table', 'bulk', 'delete', '_bx_antispam_grid_action_delete', '', 1, 1),

+ 6 - 6
modules/boonex/antispam/install/sql/install.sql

@@ -25,12 +25,12 @@ CREATE TABLE `bx_antispam_dnsbl_rules` (
   PRIMARY KEY (`id`)
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
 
-INSERT INTO `bx_antispam_dnsbl_rules` (`id`, `chain`, `zonedomain`, `postvresp`, `url`, `recheck`, `comment`, `added`, `active`) VALUES
-(1, 'whitelist', 'au.countries.nerd.dk.', '127.0.0.2', 'http://countries.nerd.dk/', '', 'Country based zone, any ip from Australia is whitelisted', 1287642420, 0),
-(2, 'spammers', 'sbl.spamhaus.org.', 'any', 'http://www.spamhaus.org/sbl/', 'http://www.spamhaus.org/query/bl?ip=%s', 'Any non-failure result from sbl.spamhaus.org is a positive match', 1287642420, 1),
-(3, 'spammers', 'zomgbl.spameatingmonkey.net.', 'any', 'http://spameatingmonkey.com/index.html', '', 'This zone is guaranteed to block 100% of all IPs because it lists everything (0.0.0.0/0). This list should never be used in production but exists to verify overall functionality of the blacklist servers.', 1287642420, 0),
-(4, 'spammers', 'cn.countries.nerd.dk.', '127.0.0.2', 'http://countries.nerd.dk/', '', 'Country based zone, any ip from China is blocked', 1287642420, 0),
-(5, 'uridns', 'multi.surbl.org.', 'any', 'http://www.surbl.org/', 'http://george.surbl.org/lookup.html', 'SURBLs are lists of web sites that have appeared in unsolicited messages. Unlike most lists, SURBLs are not lists of message senders.', 1287642420, 1);
+INSERT INTO `bx_antispam_dnsbl_rules` (`chain`, `zonedomain`, `postvresp`, `url`, `recheck`, `comment`, `added`, `active`) VALUES
+('whitelist', 'au.countries.nerd.dk.', '127.0.0.2', 'http://countries.nerd.dk/', '', '_bx_antispam_rule_note_country', 1287642420, 0),
+('spammers', 'cn.countries.nerd.dk.', '127.0.0.2', 'http://countries.nerd.dk/', '', '_bx_antispam_rule_note_country', 1287642420, 0),
+('spammers', 'sbl.spamhaus.org.', 'any', 'http://www.spamhaus.org/sbl/', 'http://www.spamhaus.org/query/bl?ip=%s', '_bx_antispam_rule_note_spamhaus_org', 1287642420, 1),
+('spammers', 'zomgbl.spameatingmonkey.net.', 'any', 'http://spameatingmonkey.com/index.html', '', '_bx_antispam_rule_note_zomgbl_spameatingmonkey_net', 1287642420, 0),
+('uridns', 'multi.surbl.org.', 'any', 'http://www.surbl.org/', 'http://george.surbl.org/lookup.html', '_bx_antispam_rule_note_surbl_org', 1287642420, 1);
 
 
 CREATE TABLE `bx_antispam_dnsbluri_zones` (
 CREATE TABLE `bx_antispam_dnsbluri_zones` (
   `level` tinyint(4) NOT NULL,
   `level` tinyint(4) NOT NULL,

+ 3 - 0
modules/boonex/english/data/langs/system.xml

@@ -1334,6 +1334,8 @@
 	<string name="_see_more"><![CDATA[see more]]></string>
 	<string name="_see_more"><![CDATA[see more]]></string>
 	<string name="_show_replacement"><![CDATA[Show]]></string>
 	<string name="_show_replacement"><![CDATA[Show]]></string>
 	<string name="_sys_access_denied_to_private_content"><![CDATA[Access denied. This is private content.]]></string>
 	<string name="_sys_access_denied_to_private_content"><![CDATA[Access denied. This is private content.]]></string>
+	<string name="_sys_actions"><![CDATA[Actions]]></string>
+	<string name="_sys_active"><![CDATA[Active]]></string>
 	<string name="_sys_acl_action_comments_edit_all"><![CDATA[Comments Edit All]]></string>
 	<string name="_sys_acl_action_comments_edit_all"><![CDATA[Comments Edit All]]></string>
 	<string name="_sys_acl_action_comments_edit_own"><![CDATA[Comments Edit Own]]></string>
 	<string name="_sys_acl_action_comments_edit_own"><![CDATA[Comments Edit Own]]></string>
 	<string name="_sys_acl_action_comments_post"><![CDATA[Comments Post]]></string>
 	<string name="_sys_acl_action_comments_post"><![CDATA[Comments Post]]></string>
@@ -1800,6 +1802,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_request_method_not_found_cpt"><![CDATA[Method was not found]]></string>
 	<string name="_sys_request_method_not_found_cpt"><![CDATA[Method was not found]]></string>
 	<string name="_sys_request_method_not_found_cnt"><![CDATA[Method({0}) was not found in module({1})]]></string>
 	<string name="_sys_request_method_not_found_cnt"><![CDATA[Method({0}) was not found in module({1})]]></string>
 	<string name="_sys_search_main_title"><![CDATA[Search Home]]></string>
 	<string name="_sys_search_main_title"><![CDATA[Search Home]]></string>
+	<string name="_sys_select"><![CDATA[Select]]></string>
 	<string name="_sys_spam_detected"><![CDATA[Sorry, it looks like you are trying to submit spam, if you believe that it is not spam please submit false positive report here: {0}]]></string>
 	<string name="_sys_spam_detected"><![CDATA[Sorry, it looks like you are trying to submit spam, if you believe that it is not spam please submit false positive report here: {0}]]></string>
 	<string name="_sys_splash_btn_start"><![CDATA[Start]]></string>
 	<string name="_sys_splash_btn_start"><![CDATA[Start]]></string>
 	<string name="_sys_splash_err_domain_incorrect"><![CDATA[Domain is essential. Please, fill in this field, for example, my-first-site.]]></string>
 	<string name="_sys_splash_err_domain_incorrect"><![CDATA[Domain is essential. Please, fill in this field, for example, my-first-site.]]></string>

+ 6 - 3
scripts/check_unused_lang.php

@@ -49,17 +49,20 @@ class BxDolCheckUnusedLangsCmd
             '/^_adm_[A-Za-z0-9_-]+_cnf_/',
             '/^_adm_[A-Za-z0-9_-]+_cnf_/',
             '/^_sys_request_[A-Za-z0-9_-]+_not_found_(cpt|cnt)/',
             '/^_sys_request_[A-Za-z0-9_-]+_not_found_(cpt|cnt)/',
 
 
-            /* wall */
+            // timeline
             '/^_bx_timeline_alert_module_/',
             '/^_bx_timeline_alert_module_/',
             '/^_bx_timeline_alert_action_/',
             '/^_bx_timeline_alert_action_/',
 
 
-            /* sites */
+            // sites 
             '/^_bx_sites_txt_status_/',
             '/^_bx_sites_txt_status_/',
             '/^_bx_sites_txt_payment_type_/',
             '/^_bx_sites_txt_payment_type_/',
             '/^_bx_sites_paypal_duration_/',
             '/^_bx_sites_paypal_duration_/',
 
 
-            /* developer */
+            // developer 
             '/^_bx_dev_pgt_txt_manage_/',
             '/^_bx_dev_pgt_txt_manage_/',
+
+            // antispam
+            '/^_bx_antispam_chain_/',
         );
         );
 
 
         $this->_aOptionsSystem = array (
         $this->_aOptionsSystem = array (

+ 48 - 0
tests/units/modules/boonex/antispam/classes/BxAntispamDNSURIBlacklistsTest.php

@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * Test DNSURI black lists in Antispam module
+ */
+class BxAntispamDNSURIBlacklistsTest extends BxDolTestCase
+{
+    protected $_oDNSURIBlacklists;
+    
+
+    protected function setUp()
+    {
+        bx_import('BxDolModule');
+        $oModule = BxDolModule::getInstance('bx_antispam');
+
+        $this->_oDNSURIBlacklists = bx_instance('BxAntispamDNSURIBlacklists', array(), $oModule->_aModule);
+    }
+
+    protected function tearDown()
+    {
+        unset($this->_oDNSURIBlacklists);
+    }
+
+    public function providerForIsSpam()
+    {
+        return array(
+            array("some text without urls", false), // no spam detection in text without urls
+            array("Hello. \nDolphin lives on http://www.boonex.com site", false), // no spam for good urls
+            array("Hello. \nDolphin lives on <a href=\"http://www.boonex.com\">BoonEx</a> site", false), // no spam for good urls
+            array("Hello. \nDolphin lives on <a href='http://www.boonex.com'>BoonEx</a> site", false), // no spam for good urls
+            array("Hello. \nDolphin lives on <a href=http://www.boonex.com>BoonEx</a> site", false), // no spam for good urls
+            array("Hello. \nThere is spam on http://surbl-org-permanent-test-point.com site", true), // text with spammer URL
+            array("Hello. \nThere is spam on <a href=\"http://surbl-org-permanent-test-point.com\">test point</a> site", true), // text with spammer URL
+            array("Hello. \nThere is spam on <a href='http://surbl-org-permanent-test-point.com'>test point</a> site", true), // text with spammer URL
+            array("Hello. \nThere is spam on <a href=http://surbl-org-permanent-test-point.com>test point</a> site", true), // text with spammer URL
+        );
+    }
+
+    /**
+     * @dataProvider providerForIsSpam
+     */
+    public function testIsSpam($sText, $bRes)
+    {
+        // check result boolean value
+        $this->assertEquals($bRes, $this->_oDNSURIBlacklists->isSpam($sText));
+    }
+}
+