AntonLV 10 лет назад
Родитель
Сommit
6e0886da85

+ 51 - 0
modules/boonex/antispam/updates/8.0.5_9.0.0/install/config.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'title' => 'Antispam',
+    'version_from' => '8.0.5',
+	'version_to' => '9.0.0',
+    'vendor' => 'BoonEx',
+
+	'compatible_with' => array(
+        '9.0.0-B1'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/antispam/updates/update_8.0.5_9.0.0/',
+	'home_uri' => 'antispam_update_805_900',
+
+	'module_dir' => 'boonex/antispam/',
+	'module_uri' => 'antispam',
+
+    'db_prefix' => 'bx_antispam_',
+    'class_prefix' => 'BxAntispam',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+		'execute_sql' => 0,
+        'update_files' => 1,
+        'update_languages' => 0,
+		'clear_db_cache' => 0,
+    ),
+
+	/**
+     * Category for language keys.
+     */
+    'language_category' => 'Antispam',
+
+	/**
+     * Files Section
+     */
+    'delete_files' => array(),
+);

+ 13 - 0
modules/boonex/antispam/updates/8.0.5_9.0.0/install/installer.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+class BxAntispamUpdater extends BxDolStudioUpdater
+{
+    function __construct($aConfig)
+	{
+        parent::__construct($aConfig);
+    }
+}

+ 316 - 0
modules/boonex/antispam/updates/8.0.5_9.0.0/source/classes/BxAntispamGridDNSBL.php

@@ -0,0 +1,316 @@
+<?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     TridentModules
+ *
+ * @{
+ */
+
+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();
+
+        $this->_oTemplate->addJs('jquery.form.min.js');
+
+        $oForm = new BxTemplFormView(array());
+        $oForm->addCssJs();
+    }
+
+    /**
+     * 'help' action handler
+     */
+    public function performActionHelp()
+    {
+        $s = BxTemplFunctions::getInstance()->popupBox(
+            'bx_antispam_poppup_help',
+            _t('_bx_antispam_popup_help'),
+            _t('_bx_antispam_help_dnsbl')
+        );
+
+        echoJson(array('popup' => array('html' => $s)));
+    }
+
+    /**
+     * 'log' action handler
+     */
+    public function performActionLog()
+    {
+        $oModule = BxDolModule::getInstance('bx_antispam');
+        $sGrid = $oModule->serviceBlockLog();
+
+        if (!$sGrid) {
+            echoJson(array('msg' => _t('_sys_txt_error_occured')));
+            exit;
+        }
+
+        $s = BxTemplFunctions::getInstance()->popupBox(
+            'bx_antispam_popup_block_log',
+            _t('_bx_antispam_popup_block_log'),
+            $sGrid . '<button class="bx-btn" style="float:none;" onclick ="$(\'.bx-popup-applied:visible\').dolPopupHide();">' . _t('_sys_close') . '</button>'
+        );
+
+        echoJson(array('popup' => array('html' => $s)));
+
+    }
+
+    /**
+     * 'recheck' action handler
+     */
+    public function performActionRecheckItem()
+    {
+        $oModule = BxDolModule::getInstance('bx_antispam');
+        $o = bx_instance('BxAntispamDNSBlacklists', array(), $oModule->_aModule);
+
+        $aChain = $o->getRule((int)bx_get('id'));
+
+        $iRet = BX_DOL_DNSBL_FAILURE;
+        if ($aChain) {
+            if (bx_get('chain') == 'dnsbl') {
+                $iRet = $o->dnsbl_lookup_ip($aChain, bx_process_input(bx_get('test')));
+            } elseif (bx_get('chain') == 'uridnsbl') {
+                $sUrl = preg_replace('/^\w+:\/\//', '', bx_process_input(bx_get('test')));
+                $sUrl = preg_replace('/^www\./', '', $sUrl);
+                $oBxDolDNSURIBlacklists = bx_instance('BxAntispamDNSURIBlacklists', array(), $oModule->_aModule);
+                $aUrls = $oBxDolDNSURIBlacklists->validateUrls(array($sUrl));
+                if ($aUrls)
+                    $iRet = $o->dnsbl_lookup_uri($aUrls[0], $aChain);
+            }
+        }
+
+        $s = '';
+        switch ($iRet) {
+            case BX_DOL_DNSBL_POSITIVE:
+                $s = 'LISTED';
+                break;
+            case BX_DOL_DNSBL_NEGATIVE:
+                $s = 'NOT LISTED';
+                break;
+            default:
+            case BX_DOL_DNSBL_FAILURE:
+                $s = 'FAIL';
+        }
+
+        echo $s;
+        exit;
+    }
+
+    /**
+     * 'recheck' action handler
+     */
+    public function performActionRecheck()
+    {
+        $oModule = BxDolModule::getInstance('bx_antispam');
+        $oDNSBlacklists = bx_instance('BxAntispamDNSBlacklists', array(), $oModule->_aModule);
+
+        $aForm = array(
+            'form_attrs' => array(
+                'id' => 'bx_antispam_form_dnsbl_recheck',
+                'action' => BX_DOL_URL_ROOT . 'grid.php?o=bx_antispam_grid_dnsbl&a=recheck',
+                'onsubmit' => "return bx_antispam_recheck($('#bx_antispam_ip_url').val(), $('[name=dnsbl_uridnsbl]:checked').val());",
+                'method' => 'post',
+            ),
+            'params' => array (
+                'db' => array(
+                    'submit_name' => 'do_submit',
+                ),
+            ),
+            'inputs' => array(
+
+                'ip_url' => array(
+                    'type' => 'text',
+                    'name' => 'ip_url',
+                    'value' => getVisitorIP(),
+                    'caption' => _t('_bx_antispam_field_ip_url'),
+                    'attrs' => array('id' => 'bx_antispam_ip_url'),
+                ),
+
+                'dnsbl_uridnsbl' => array(
+                    'type' => 'radio_set',
+                    'name' => 'dnsbl_uridnsbl',
+                    'caption' => _t('_bx_antispam_field_dnsbl_uridnsbl'),
+                    'values' => array ('dnsbl' => _t('_bx_antispam_dnsbl'), 'uridnsbl' => _t('_bx_antispam_uri_dnsbl')),
+                    'value' => 'dnsbl',
+                ),
+
+                'submit' => array(
+                    'type' => 'input_set',
+                    0 => array (
+                        'type' => 'submit',
+                        'name' => 'do_submit',
+                        'value' => _t('_sys_submit'),
+                    ),
+                    1 => array (
+                        'type' => 'reset',
+                        'name' => 'close',
+                        'value' => _t('_sys_close'),
+                        'attrs' => array('class' => 'bx-def-margin-sec-left', 'onclick' => '$(\'.bx-popup-applied:visible\').dolPopupHide();'),
+                    ),
+                ),
+
+            ),
+        );
+
+        $oForm = new BxTemplFormView($aForm);
+
+        $s = $oModule->_oTemplate->parseHtmlByName('recheck.html', array (
+            'form' => $oForm->getCode(),
+            'url_recheck_item' => BX_DOL_URL_ROOT . 'grid.php?o=bx_antispam_grid_dnsbl&a=recheck_item',
+            'bx_repeat:items' => $oDNSBlacklists->getRules(array(BX_DOL_DNSBL_CHAIN_SPAMMERS, BX_DOL_DNSBL_CHAIN_WHITELIST, BX_DOL_DNSBL_CHAIN_URIDNS)),
+        ));
+
+        $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_popup_dnsbl_recheck'), $s);
+
+        echoJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))));
+    }
+
+    /**
+     * 'recheck' action handler
+     */
+    public function performActionAdd()
+    {
+        $aForm = array(
+            'form_attrs' => array(
+                'id' => 'bx_antispam_form_dnsbl_add',
+                'action' => BX_DOL_URL_ROOT . 'grid.php?o=bx_antispam_grid_dnsbl&a=add',
+                'method' => 'post',
+            ),
+            'params' => array (
+                'db' => array(
+                    'table' => 'bx_antispam_dnsbl_rules',
+                    'key' => 'id',
+                    'submit_name' => 'do_submit',
+                ),
+            ),
+            'inputs' => array(
+
+                'country' => array(
+                    'type' => 'select',
+                    'name' => 'country',
+                    'caption' => _t('_bx_antispam_field_country'),
+                    'values' => BxDolForm::getDataItems('Country'),
+                ),
+
+                'chain' => array(
+                    'type' => 'radio_set',
+                    'name' => 'chain',
+                    'caption' => _t('_bx_antispam_field_action'),
+                    'values' => array ('spammers' => _t('_bx_antispam_chain_spammers'), 'whitelist' => _t('_bx_antispam_chain_whitelist')),
+                    'value' => 'spammers',
+                ),
+
+                'submit' => array(
+                    'type' => 'input_set',
+                    0 => array (
+                        'type' => 'submit',
+                        'name' => 'do_submit',
+                        'value' => _t('_sys_submit'),
+                    ),
+                    1 => array (
+                        'type' => 'reset',
+                        'name' => 'close',
+                        'value' => _t('_sys_close'),
+                        'attrs' => array('class' => 'bx-def-margin-sec-left', 'onclick' => '$(\'.bx-popup-applied:visible\').dolPopupHide();'),
+                    ),
+                ),
+
+            ),
+        );
+
+        $oForm = new BxTemplFormView($aForm);
+        $oForm->initChecker();
+
+        if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid
+
+            $aCustomValues = array(
+                'chain' => $oForm->getCleanValue('chain'),
+                'zonedomain' => sprintf("%s.countries.nerd.dk.", strtolower($oForm->getCleanValue('country'))),
+                'postvresp' => '127.0.0.2',
+                'url' => 'http://countries.nerd.dk/',
+                'comment' => '_bx_antispam_rule_note_country',
+                'added' => time(),
+                'active' => 1,
+
+            );
+
+            $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
+
+            echoJson($aRes);
+
+        } else { // if form is not submitted or some fields are invalid, display popup with form
+
+            $s = BxTemplFunctions::getInstance()->popupBox($oForm->getId() . '_form', _t('_bx_antispam_popup_dnsbl_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, "add");
+                            }
+                        });
+                    });
+                </script>');
+
+            echoJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))));
+
+        }
+    }
+
+    protected function _getCellChain ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault (_t('_bx_antispam_chain_' . $mixedValue), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellZonedomain ($mixedValue, $sKey, $aField, $aRow)
+    {
+        $s = $mixedValue;
+        if ($aRow['url'])
+            $s = '<a target="_blank" href="' . $aRow['url'] . '">' . $mixedValue . '</a>';
+        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);
+    }
+
+    protected function _getCellActions ($mixedValue, $sKey, $aField, $aRow)
+    {
+        if (preg_match('/^(\w{2})\.countries\.nerd\.dk\.$/', $aRow['zonedomain'], $aMatches)) {
+            $aRow['active'] = 1;
+            return parent::_getCellActions ($mixedValue, $sKey, $aField, $aRow);
+        }
+
+        return parent::_getCellDefault ('', $sKey, $aField, $aRow);
+    }
+
+}
+
+/** @} */

+ 151 - 0
modules/boonex/antispam/updates/8.0.5_9.0.0/source/classes/BxAntispamGridIpTable.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     TridentModules
+ *
+ * @{
+ */
+
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+class BxAntispamGridIpTable extends BxTemplGrid
+{
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+    }
+
+    /**
+     * add js file for AJAX form submission
+     */
+    protected function _addJsCss()
+    {
+        parent::_addJsCss();
+
+        $this->_oTemplate->addJs('jquery.form.min.js');
+
+        $oForm = new BxTemplFormView(array());
+        $oForm->addCssJs();
+    }
+
+    /**
+     * 'add' action handler
+     */
+    public function performActionAdd()
+    {
+        $this->_performAction('add', 'bx_antispam_ip_table_form_add');
+    }
+
+    /**
+     * 'edit' action handler
+     */
+    public function performActionEdit()
+    {
+        $iId = 0;
+        $aIds = bx_get('ids');
+        if ($aIds && is_array($aIds))
+            $iId = (int)array_pop($aIds);
+        if (!$iId)
+            $iId = (int)bx_get('ID');
+
+        if (!$iId) {
+            echoJson(array('msg' => _t('_sys_txt_error_occured')));
+            exit;
+        }
+
+        $this->_performAction('edit', 'bx_antispam_ip_table_form_edit', $iId);
+    }
+
+    protected function _performAction($sAction, $sDisplay, $iId = 0)
+    {
+        $oForm = BxDolForm::getObjectInstance('bx_antispam_ip_table_form', $sDisplay); // get form instance for specified form object and display
+        if (!$oForm) {
+            echoJson(array('msg' => _t('_sys_txt_error_occured')));
+            exit;
+        }
+
+        $oForm->addMarkers(array(
+            'grid_object' => $this->_sObject,
+            'grid_action' => $sAction,
+        ));
+
+        $aIpTableDirective = array();
+        if ($iId) {
+            $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
+
+            echoJson($aRes);
+
+        } else { // if form is not submitted or some fields are invalid, display popup with form
+
+            $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>');
+
+            echoJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))));
+
+        }
+    }
+
+    protected function _getCellType ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault ('allow' == $mixedValue ? _t('_bx_antispam_ip_allow') : _t('_bx_antispam_ip_deny'), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellLastDT ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault (bx_time_js($mixedValue, BX_FORMAT_DATE), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellFrom ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault (long2ip($mixedValue), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellTo ($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault (long2ip($mixedValue), $sKey, $aField, $aRow);
+    }
+
+}
+
+/** @} */

+ 68 - 0
modules/boonex/antispam/updates/8.0.5_9.0.0/source/install/config.php

@@ -0,0 +1,68 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Antispam Antispam
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_antispam',
+    'title' => 'Antispam',
+    'note' => 'Antispam tools',
+    'version' => '9.0.0',
+    'vendor' => 'BoonEx',
+	'help_url' => 'http://feed.boonex.com/?section={module_name}',
+
+    'compatible_with' => array(
+        '9.0.x'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/antispam/',
+    'home_uri' => 'antispam',
+
+    'db_prefix' => 'bx_antispam_',
+    'class_prefix' => 'BxAntispam',
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'Antispam',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+    'disable' => array(
+        'execute_sql' => 1,
+        'clear_db_cache' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+);
+
+/** @} */