From e7faf41640eec633773161c0862f590318309fbf Mon Sep 17 00:00:00 2001 From: Glomberg Date: Sun, 13 Sep 2020 18:59:58 +0300 Subject: [PATCH 1/8] Fix: Library connecting fixed. --- 2.3.x/install.xml | 1 + .../admin/controller/extension/module/antispambycleantalk.php | 1 + 2.x - 2.2.x/install.xml | 1 + .../upload/admin/controller/module/antispambycleantalk.php | 1 + 3.x/install.xml | 1 + .../admin/controller/extension/module/antispambycleantalk.php | 1 + 6 files changed, 6 insertions(+) diff --git a/2.3.x/install.xml b/2.3.x/install.xml index be33c3e..7a54234 100644 --- a/2.3.x/install.xml +++ b/2.3.x/install.xml @@ -11,6 +11,7 @@ registry->set('openbay', new Openbay($this->registry));]]> registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); ]]> diff --git a/2.3.x/upload/admin/controller/extension/module/antispambycleantalk.php b/2.3.x/upload/admin/controller/extension/module/antispambycleantalk.php index 3757b89..fe6816e 100644 --- a/2.3.x/upload/admin/controller/extension/module/antispambycleantalk.php +++ b/2.3.x/upload/admin/controller/extension/module/antispambycleantalk.php @@ -6,6 +6,7 @@ public function index() { $this->install(); + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $data = $this->load->language('extension/module/antispambycleantalk'); diff --git a/2.x - 2.2.x/install.xml b/2.x - 2.2.x/install.xml index 20caf40..58d1d89 100644 --- a/2.x - 2.2.x/install.xml +++ b/2.x - 2.2.x/install.xml @@ -12,6 +12,7 @@ document->getTitle();]]> registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); ]]> diff --git a/2.x - 2.2.x/upload/admin/controller/module/antispambycleantalk.php b/2.x - 2.2.x/upload/admin/controller/module/antispambycleantalk.php index 7d599e5..cc80fb9 100644 --- a/2.x - 2.2.x/upload/admin/controller/module/antispambycleantalk.php +++ b/2.x - 2.2.x/upload/admin/controller/module/antispambycleantalk.php @@ -5,6 +5,7 @@ class ControllerModuleAntispamByCleantalk extends Controller { public function index() { $this->install(); + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $data = $this->load->language('module/antispambycleantalk'); diff --git a/3.x/install.xml b/3.x/install.xml index b187635..9bb2399 100644 --- a/3.x/install.xml +++ b/3.x/install.xml @@ -11,6 +11,7 @@ registry->set('cart', new Cart\Cart($this->registry));]]> registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); ]]> diff --git a/3.x/upload/admin/controller/extension/module/antispambycleantalk.php b/3.x/upload/admin/controller/extension/module/antispambycleantalk.php index 3cf219b..058ff7e 100644 --- a/3.x/upload/admin/controller/extension/module/antispambycleantalk.php +++ b/3.x/upload/admin/controller/extension/module/antispambycleantalk.php @@ -6,6 +6,7 @@ public function index() { $this->install(); + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->load->language('extension/module/antispambycleantalk'); From 5837446c8255b54580e3b0250c69ce397084841a Mon Sep 17 00:00:00 2001 From: Glomberg Date: Mon, 5 Oct 2020 10:58:04 +0300 Subject: [PATCH 2/8] Version: 2.1 dev version. --- 2.3.x/install.xml | 2 +- 2.3.x/upload/system/library/antispambycleantalk/Core.php | 2 +- 2.x - 2.2.x/install.xml | 2 +- 2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php | 2 +- 3.x/install.xml | 2 +- 3.x/upload/system/library/antispambycleantalk/Core.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/2.3.x/install.xml b/2.3.x/install.xml index 7a54234..b42e9ae 100644 --- a/2.3.x/install.xml +++ b/2.3.x/install.xml @@ -1,7 +1,7 @@ Antispam by Cleantalk - 2.0 + 2.1 Cleantalk Inc. https://cleantalk.org/ antispambycleantalk diff --git a/2.3.x/upload/system/library/antispambycleantalk/Core.php b/2.3.x/upload/system/library/antispambycleantalk/Core.php index d02384f..26904bf 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Core.php @@ -10,7 +10,7 @@ class Core { - const VERSION = '2.0'; + const VERSION = '2.1'; private $agent; diff --git a/2.x - 2.2.x/install.xml b/2.x - 2.2.x/install.xml index 58d1d89..3670ba4 100644 --- a/2.x - 2.2.x/install.xml +++ b/2.x - 2.2.x/install.xml @@ -1,7 +1,7 @@ Antispam by Cleantalk - 2.0 + 2.1 Cleantalk Inc. https://cleantalk.org/ antispambycleantalk diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php index d02384f..26904bf 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php @@ -10,7 +10,7 @@ class Core { - const VERSION = '2.0'; + const VERSION = '2.1'; private $agent; diff --git a/3.x/install.xml b/3.x/install.xml index 9bb2399..bd59b46 100644 --- a/3.x/install.xml +++ b/3.x/install.xml @@ -1,7 +1,7 @@ Antispam by Cleantalk - 2.0 + 2.1 Cleantalk Inc. https://cleantalk.org/ antispambycleantalk diff --git a/3.x/upload/system/library/antispambycleantalk/Core.php b/3.x/upload/system/library/antispambycleantalk/Core.php index 99f4794..b5fbe94 100644 --- a/3.x/upload/system/library/antispambycleantalk/Core.php +++ b/3.x/upload/system/library/antispambycleantalk/Core.php @@ -10,7 +10,7 @@ class Core { - const VERSION = '2.0'; + const VERSION = '2.1'; private $agent; From c730842e2cc901d3223969c6dadb2c9deb6831ce Mon Sep 17 00:00:00 2001 From: Glomberg Date: Mon, 5 Oct 2020 10:59:42 +0300 Subject: [PATCH 3/8] Fix: PHP object static access fixed. --- 2.3.x/install.xml | 4 ++-- .../Cleantalk/Antispam/RemoteCalls.php | 2 +- .../system/library/antispambycleantalk/Core.php | 11 ++++++++++- 2.x - 2.2.x/install.xml | 4 ++-- .../Cleantalk/Antispam/RemoteCalls.php | 2 +- .../system/library/antispambycleantalk/Core.php | 12 +++++++++++- 3.x/install.xml | 4 ++-- .../Cleantalk/Antispam/RemoteCalls.php | 2 +- .../system/library/antispambycleantalk/Core.php | 11 ++++++++++- 9 files changed, 40 insertions(+), 12 deletions(-) diff --git a/2.3.x/install.xml b/2.3.x/install.xml index b42e9ae..e23bf2e 100644 --- a/2.3.x/install.xml +++ b/2.3.x/install.xml @@ -23,7 +23,7 @@ document->getScripts();]]> apbct::VERSION; + $ver = '?v=' . $this->apbct->get_version(); $this->document->addScript( 'catalog/view/javascript/antispambycleantalk.js' . $ver ); $this->apbct->setCookie(); ]]> @@ -36,7 +36,7 @@ { if ( $this->request->server['REQUEST_METHOD'] == 'GET' && $this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_enable_sfw') ) { - if( $this->apbct->rc::check($this->config->get('module_antispambycleantalk_access_key')) ) { + if( $this->apbct->rc->check($this->config->get('module_antispambycleantalk_access_key')) ) { $this->apbct->rc->perform($this->config->get('module_antispambycleantalk_access_key')); } diff --git a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php index ef05bf7..8cc2620 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php @@ -20,7 +20,7 @@ public function __construct( $db_object, $db_prefix ) $this->table_prefix = $db_prefix; } - public static function check() + public function check() { return isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array(Get::get('plugin_name'), array('antispam','anti-spam', 'apbct')) ? true diff --git a/2.3.x/upload/system/library/antispambycleantalk/Core.php b/2.3.x/upload/system/library/antispambycleantalk/Core.php index 26904bf..c2d3bcc 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Core.php @@ -39,10 +39,19 @@ public static function get_instance( \Registry $registry ) return static::$instance; } + /** + * Getting version number + * + * @return string + */ + public function get_version() { + return self::VERSION; + } + private function __construct( \Registry $registry ) { $this->autoloader(); - $this->agent = 'opencart-' . str_replace( '.', '', self::VERSION ); + $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); } diff --git a/2.x - 2.2.x/install.xml b/2.x - 2.2.x/install.xml index 3670ba4..49266f6 100644 --- a/2.x - 2.2.x/install.xml +++ b/2.x - 2.2.x/install.xml @@ -21,7 +21,7 @@ document->getScripts();]]> apbct::VERSION; + $ver = '?v=' . $this->apbct->get_version(); $this->document->addScript( 'catalog/view/javascript/antispambycleantalk.js' . $ver ); $this->apbct->setCookie(); ]]> @@ -34,7 +34,7 @@ { if ( $this->request->server['REQUEST_METHOD'] == 'GET' && $this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_enable_sfw') ) { - if( $this->apbct->rc::check($this->config->get('module_antispambycleantalk_access_key')) ) { + if( $this->apbct->rc->check($this->config->get('module_antispambycleantalk_access_key')) ) { $this->apbct->rc->perform($this->config->get('module_antispambycleantalk_access_key')); } diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php index ef05bf7..8cc2620 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php @@ -20,7 +20,7 @@ public function __construct( $db_object, $db_prefix ) $this->table_prefix = $db_prefix; } - public static function check() + public function check() { return isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array(Get::get('plugin_name'), array('antispam','anti-spam', 'apbct')) ? true diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php index 26904bf..863a62d 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php @@ -39,10 +39,20 @@ public static function get_instance( \Registry $registry ) return static::$instance; } + /** + * Getting version number + * + * @return string + */ + public function get_version() { + return self::VERSION; + } + + private function __construct( \Registry $registry ) { $this->autoloader(); - $this->agent = 'opencart-' . str_replace( '.', '', self::VERSION ); + $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); } diff --git a/3.x/install.xml b/3.x/install.xml index bd59b46..385b064 100644 --- a/3.x/install.xml +++ b/3.x/install.xml @@ -23,7 +23,7 @@ document->getScripts('header');]]> apbct::VERSION; + $ver = '?v=' . $this->apbct->get_version(); $this->document->addScript( 'catalog/view/javascript/antispambycleantalk.js' . $ver ); $this->apbct->setCookie(); ]]> @@ -36,7 +36,7 @@ { if ( $this->request->server['REQUEST_METHOD'] == 'GET' && $this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_enable_sfw') ) { - if( $this->apbct->rc::check($this->config->get('module_antispambycleantalk_access_key')) ) { + if( $this->apbct->rc->check($this->config->get('module_antispambycleantalk_access_key')) ) { $this->apbct->rc->perform($this->config->get('module_antispambycleantalk_access_key')); } diff --git a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php index ef05bf7..8cc2620 100644 --- a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php +++ b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/RemoteCalls.php @@ -20,7 +20,7 @@ public function __construct( $db_object, $db_prefix ) $this->table_prefix = $db_prefix; } - public static function check() + public function check() { return isset($_GET['spbc_remote_call_token'], $_GET['spbc_remote_call_action'], $_GET['plugin_name']) && in_array(Get::get('plugin_name'), array('antispam','anti-spam', 'apbct')) ? true diff --git a/3.x/upload/system/library/antispambycleantalk/Core.php b/3.x/upload/system/library/antispambycleantalk/Core.php index b5fbe94..768e8a0 100644 --- a/3.x/upload/system/library/antispambycleantalk/Core.php +++ b/3.x/upload/system/library/antispambycleantalk/Core.php @@ -39,10 +39,19 @@ public static function get_instance( \Registry $registry ) return static::$instance; } + /** + * Getting version number + * + * @return string + */ + public function get_version() { + return self::VERSION; + } + private function __construct( \Registry $registry ) { $this->autoloader(); - $this->agent = 'opencart-' . str_replace( '.', '', self::VERSION ); + $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); } From 9587548b97de7d68baa551c0f820dabef46c0339 Mon Sep 17 00:00:00 2001 From: davydovct Date: Mon, 5 Oct 2020 16:21:05 +0500 Subject: [PATCH 4/8] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8a05b9..334991a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # opencart-antispam Opencart anti-spam extension. -# Version 1.9 +# Version 2.1 ## How to install From 3b8332ec4117a68012904e807736d7708a999f45 Mon Sep 17 00:00:00 2001 From: davydovct Date: Mon, 12 Oct 2020 16:26:15 +0500 Subject: [PATCH 5/8] Fix FW construct for correct IP. --- .../library/antispambycleantalk/Cleantalk/Antispam/SFW.php | 2 +- .../library/antispambycleantalk/Cleantalk/Antispam/SFW.php | 2 +- .../library/antispambycleantalk/Cleantalk/Antispam/SFW.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index dbdafc0..3ea15c8 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -70,7 +70,7 @@ public function __construct( $db_object, $db_prefix ) $this->debug = isset($_GET['debug']) && intval($_GET['debug']) === 1 ? true : false; - $this->ip_array = $this->ip__get(); + $this->ip_array = $this->ip__get( array('real'), true ); } /** diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index dbdafc0..3ea15c8 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -70,7 +70,7 @@ public function __construct( $db_object, $db_prefix ) $this->debug = isset($_GET['debug']) && intval($_GET['debug']) === 1 ? true : false; - $this->ip_array = $this->ip__get(); + $this->ip_array = $this->ip__get( array('real'), true ); } /** diff --git a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index dbdafc0..3ea15c8 100644 --- a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -70,7 +70,7 @@ public function __construct( $db_object, $db_prefix ) $this->debug = isset($_GET['debug']) && intval($_GET['debug']) === 1 ? true : false; - $this->ip_array = $this->ip__get(); + $this->ip_array = $this->ip__get( array('real'), true ); } /** From 30ace76d62e60b5efa9503573c7a2a8a2880f22f Mon Sep 17 00:00:00 2001 From: Glomberg Date: Tue, 13 Oct 2020 11:48:20 +0300 Subject: [PATCH 6/8] Fix: Php fix file added. --- .../library/antispambycleantalk/Core.php | 1 + .../library/antispambycleantalk/php_fix.php | 27 +++++++++++++++++++ .../library/antispambycleantalk/Core.php | 1 + .../library/antispambycleantalk/php_fix.php | 27 +++++++++++++++++++ .../library/antispambycleantalk/Core.php | 1 + .../library/antispambycleantalk/php_fix.php | 27 +++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 2.3.x/upload/system/library/antispambycleantalk/php_fix.php create mode 100644 2.x - 2.2.x/upload/system/library/antispambycleantalk/php_fix.php create mode 100644 3.x/upload/system/library/antispambycleantalk/php_fix.php diff --git a/2.3.x/upload/system/library/antispambycleantalk/Core.php b/2.3.x/upload/system/library/antispambycleantalk/Core.php index c2d3bcc..afd16a3 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Core.php @@ -51,6 +51,7 @@ public function get_version() { private function __construct( \Registry $registry ) { $this->autoloader(); + require_once 'php_fix.php'; $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); diff --git a/2.3.x/upload/system/library/antispambycleantalk/php_fix.php b/2.3.x/upload/system/library/antispambycleantalk/php_fix.php new file mode 100644 index 0000000..60407a7 --- /dev/null +++ b/2.3.x/upload/system/library/antispambycleantalk/php_fix.php @@ -0,0 +1,27 @@ + $val){ + if(preg_match('/\AHTTP_/', $key)){ + $server_key = preg_replace('/\AHTTP_/', '', $key); + $key_parts = explode('_', $server_key); + if(count($key_parts) > 0 and strlen($server_key) > 2){ + foreach($key_parts as $part_index => $part){ + $key_parts[$part_index] = function_exists('mb_strtolower') ? mb_strtolower($part) : strtolower($part); + $key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]); + } + $server_key = implode('-', $key_parts); + } + $headers[$server_key] = $val; + } + } + return $headers; + } +} diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php index 863a62d..7ef599d 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Core.php @@ -52,6 +52,7 @@ public function get_version() { private function __construct( \Registry $registry ) { $this->autoloader(); + require_once 'php_fix.php'; $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/php_fix.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/php_fix.php new file mode 100644 index 0000000..60407a7 --- /dev/null +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/php_fix.php @@ -0,0 +1,27 @@ + $val){ + if(preg_match('/\AHTTP_/', $key)){ + $server_key = preg_replace('/\AHTTP_/', '', $key); + $key_parts = explode('_', $server_key); + if(count($key_parts) > 0 and strlen($server_key) > 2){ + foreach($key_parts as $part_index => $part){ + $key_parts[$part_index] = function_exists('mb_strtolower') ? mb_strtolower($part) : strtolower($part); + $key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]); + } + $server_key = implode('-', $key_parts); + } + $headers[$server_key] = $val; + } + } + return $headers; + } +} diff --git a/3.x/upload/system/library/antispambycleantalk/Core.php b/3.x/upload/system/library/antispambycleantalk/Core.php index 768e8a0..177b57f 100644 --- a/3.x/upload/system/library/antispambycleantalk/Core.php +++ b/3.x/upload/system/library/antispambycleantalk/Core.php @@ -51,6 +51,7 @@ public function get_version() { private function __construct( \Registry $registry ) { $this->autoloader(); + require_once 'php_fix.php'; $this->agent = 'opencart-' . str_replace( '.', '', $this->get_version() ); $this->rc = new RemoteCalls( $registry->get('db'), DB_PREFIX ); $this->sfw = new SFW( $registry->get('db'), DB_PREFIX ); diff --git a/3.x/upload/system/library/antispambycleantalk/php_fix.php b/3.x/upload/system/library/antispambycleantalk/php_fix.php new file mode 100644 index 0000000..60407a7 --- /dev/null +++ b/3.x/upload/system/library/antispambycleantalk/php_fix.php @@ -0,0 +1,27 @@ + $val){ + if(preg_match('/\AHTTP_/', $key)){ + $server_key = preg_replace('/\AHTTP_/', '', $key); + $key_parts = explode('_', $server_key); + if(count($key_parts) > 0 and strlen($server_key) > 2){ + foreach($key_parts as $part_index => $part){ + $key_parts[$part_index] = function_exists('mb_strtolower') ? mb_strtolower($part) : strtolower($part); + $key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]); + } + $server_key = implode('-', $key_parts); + } + $headers[$server_key] = $val; + } + } + return $headers; + } +} From a6557ba04c23a7d985d01f0f4358b8b6552c6915 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Tue, 13 Oct 2020 16:04:46 +0300 Subject: [PATCH 7/8] Upd: Large list of networks while SFW updating supported. --- .../Cleantalk/Antispam/SFW.php | 74 ++++++++++++------- .../Cleantalk/Antispam/SFW.php | 74 ++++++++++++------- .../Cleantalk/Antispam/SFW.php | 74 ++++++++++++------- 3 files changed, 138 insertions(+), 84 deletions(-) diff --git a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index 3ea15c8..9036079 100644 --- a/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/2.3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -2,6 +2,7 @@ namespace Cleantalk\Antispam; +use Cleantalk\Common\Get; use Cleantalk\Common\Server; /** @@ -294,10 +295,12 @@ public function sfw_update( $api_key, $immediate = false ) { if( ! empty( $api_key ) ) { - $file_urls = isset( $_GET['file_urls'] ) ? urldecode( $_GET['file_urls'] ) : null; - $file_urls = isset( $file_urls ) ? explode( ',', $file_urls ) : null; + $api_server = !empty( Get::get( 'api_server' ) ) ? urldecode( Get::get( 'api_server' ) ) : null; + $data_id = !empty( Get::get( 'data_id' ) ) ? urldecode( Get::get( 'data_id' ) ) : null; + $file_url_nums = !empty( Get::get( 'file_url_nums' ) ) ? urldecode( Get::get( 'file_url_nums' ) ) : null; + $file_url_nums = isset($file_url_nums) ? explode(',', $file_url_nums) : null; - if( ! $file_urls ){ + if( ! isset( $api_server, $data_id, $file_url_nums ) ){ $result = $this->get_sfw_file( $api_key, $immediate ); @@ -305,22 +308,24 @@ public function sfw_update( $api_key, $immediate = false ) ? $result : true; - }elseif( is_array( $file_urls ) && count( $file_urls ) ){ + }elseif( $api_server && $data_id && is_array( $file_url_nums ) && count( $file_url_nums ) ){ - $result = $this->sfw_update_db( $file_urls[0] ); + $result = $this->sfw_update_db( $api_server, $data_id, $file_url_nums[0] ); if( empty( $result['error'] ) ){ - array_shift($file_urls); + array_shift( $file_url_nums ); - if (count($file_urls)) { + if ( count( $file_url_nums ) ) { Helper::http__request( Server::get('HTTP_HOST'), array( 'spbc_remote_call_token' => md5($api_key), 'spbc_remote_call_action' => 'sfw_update', 'plugin_name' => 'apbct', - 'file_urls' => implode(',', $file_urls), + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), ), array('get', 'async') ); @@ -364,29 +369,40 @@ private function get_sfw_file( $api_key, $immediate ) } } - $gf = \gzopen($result['file_url'], 'rb'); + if (preg_match('/multifiles/', $result['file_url'])) { - if ($gf) { + $api_server = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$1', $result['file_url'] ); + $data_id = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$2', $result['file_url'] ); - $file_urls = array(); + $gf = \gzopen($result['file_url'], 'rb'); - while( ! \gzeof($gf) ) - $file_urls[] = trim( \gzgets($gf, 1024) ); + if ($gf) { - \gzclose($gf); + $file_url_nums = array(); - return Helper::http__request( - Server::get('HTTP_HOST'), - array( - 'spbc_remote_call_token' => md5( $api_key ), - 'spbc_remote_call_action' => 'sfw_update', - 'plugin_name' => 'apbct', - 'file_urls' => implode( ',', $file_urls ), - ), - $pattenrs - ); - }else - return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + while( ! \gzeof($gf) ) { + $file_url = trim( \gzgets($gf, 1024) ); + $file_url_nums[] = preg_replace( '@(https://.*)\.(\d*)(\.csv\.gz)@', '$2', $file_url ); + } + + \gzclose($gf); + + return Helper::http__request( + Server::get('HTTP_HOST'), + array( + 'spbc_remote_call_token' => md5( $api_key ), + 'spbc_remote_call_action' => 'sfw_update', + 'plugin_name' => 'apbct', + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), + ), + $pattenrs + ); + }else + return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + } else + return array('error' => 'COULD_NOT_GET_MULTIFILE'); }else return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED'); }else @@ -397,9 +413,11 @@ private function get_sfw_file( $api_key, $immediate ) return $result; } - private function sfw_update_db( $file_url ) + private function sfw_update_db( $api_server = null, $data_id = null, $file_url_num = null ) { - if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there + $file_url = 'https://' . $api_server . '.cleantalk.org/store/' . $data_id . '.' . $file_url_num . '.csv.gz'; + + if( Helper::http__request( $file_url, array(), 'get_code') === 200 ){ // Check if it's there $gf = \gzopen($file_url, 'rb'); diff --git a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index 3ea15c8..9036079 100644 --- a/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/2.x - 2.2.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -2,6 +2,7 @@ namespace Cleantalk\Antispam; +use Cleantalk\Common\Get; use Cleantalk\Common\Server; /** @@ -294,10 +295,12 @@ public function sfw_update( $api_key, $immediate = false ) { if( ! empty( $api_key ) ) { - $file_urls = isset( $_GET['file_urls'] ) ? urldecode( $_GET['file_urls'] ) : null; - $file_urls = isset( $file_urls ) ? explode( ',', $file_urls ) : null; + $api_server = !empty( Get::get( 'api_server' ) ) ? urldecode( Get::get( 'api_server' ) ) : null; + $data_id = !empty( Get::get( 'data_id' ) ) ? urldecode( Get::get( 'data_id' ) ) : null; + $file_url_nums = !empty( Get::get( 'file_url_nums' ) ) ? urldecode( Get::get( 'file_url_nums' ) ) : null; + $file_url_nums = isset($file_url_nums) ? explode(',', $file_url_nums) : null; - if( ! $file_urls ){ + if( ! isset( $api_server, $data_id, $file_url_nums ) ){ $result = $this->get_sfw_file( $api_key, $immediate ); @@ -305,22 +308,24 @@ public function sfw_update( $api_key, $immediate = false ) ? $result : true; - }elseif( is_array( $file_urls ) && count( $file_urls ) ){ + }elseif( $api_server && $data_id && is_array( $file_url_nums ) && count( $file_url_nums ) ){ - $result = $this->sfw_update_db( $file_urls[0] ); + $result = $this->sfw_update_db( $api_server, $data_id, $file_url_nums[0] ); if( empty( $result['error'] ) ){ - array_shift($file_urls); + array_shift( $file_url_nums ); - if (count($file_urls)) { + if ( count( $file_url_nums ) ) { Helper::http__request( Server::get('HTTP_HOST'), array( 'spbc_remote_call_token' => md5($api_key), 'spbc_remote_call_action' => 'sfw_update', 'plugin_name' => 'apbct', - 'file_urls' => implode(',', $file_urls), + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), ), array('get', 'async') ); @@ -364,29 +369,40 @@ private function get_sfw_file( $api_key, $immediate ) } } - $gf = \gzopen($result['file_url'], 'rb'); + if (preg_match('/multifiles/', $result['file_url'])) { - if ($gf) { + $api_server = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$1', $result['file_url'] ); + $data_id = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$2', $result['file_url'] ); - $file_urls = array(); + $gf = \gzopen($result['file_url'], 'rb'); - while( ! \gzeof($gf) ) - $file_urls[] = trim( \gzgets($gf, 1024) ); + if ($gf) { - \gzclose($gf); + $file_url_nums = array(); - return Helper::http__request( - Server::get('HTTP_HOST'), - array( - 'spbc_remote_call_token' => md5( $api_key ), - 'spbc_remote_call_action' => 'sfw_update', - 'plugin_name' => 'apbct', - 'file_urls' => implode( ',', $file_urls ), - ), - $pattenrs - ); - }else - return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + while( ! \gzeof($gf) ) { + $file_url = trim( \gzgets($gf, 1024) ); + $file_url_nums[] = preg_replace( '@(https://.*)\.(\d*)(\.csv\.gz)@', '$2', $file_url ); + } + + \gzclose($gf); + + return Helper::http__request( + Server::get('HTTP_HOST'), + array( + 'spbc_remote_call_token' => md5( $api_key ), + 'spbc_remote_call_action' => 'sfw_update', + 'plugin_name' => 'apbct', + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), + ), + $pattenrs + ); + }else + return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + } else + return array('error' => 'COULD_NOT_GET_MULTIFILE'); }else return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED'); }else @@ -397,9 +413,11 @@ private function get_sfw_file( $api_key, $immediate ) return $result; } - private function sfw_update_db( $file_url ) + private function sfw_update_db( $api_server = null, $data_id = null, $file_url_num = null ) { - if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there + $file_url = 'https://' . $api_server . '.cleantalk.org/store/' . $data_id . '.' . $file_url_num . '.csv.gz'; + + if( Helper::http__request( $file_url, array(), 'get_code') === 200 ){ // Check if it's there $gf = \gzopen($file_url, 'rb'); diff --git a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php index 3ea15c8..9036079 100644 --- a/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php +++ b/3.x/upload/system/library/antispambycleantalk/Cleantalk/Antispam/SFW.php @@ -2,6 +2,7 @@ namespace Cleantalk\Antispam; +use Cleantalk\Common\Get; use Cleantalk\Common\Server; /** @@ -294,10 +295,12 @@ public function sfw_update( $api_key, $immediate = false ) { if( ! empty( $api_key ) ) { - $file_urls = isset( $_GET['file_urls'] ) ? urldecode( $_GET['file_urls'] ) : null; - $file_urls = isset( $file_urls ) ? explode( ',', $file_urls ) : null; + $api_server = !empty( Get::get( 'api_server' ) ) ? urldecode( Get::get( 'api_server' ) ) : null; + $data_id = !empty( Get::get( 'data_id' ) ) ? urldecode( Get::get( 'data_id' ) ) : null; + $file_url_nums = !empty( Get::get( 'file_url_nums' ) ) ? urldecode( Get::get( 'file_url_nums' ) ) : null; + $file_url_nums = isset($file_url_nums) ? explode(',', $file_url_nums) : null; - if( ! $file_urls ){ + if( ! isset( $api_server, $data_id, $file_url_nums ) ){ $result = $this->get_sfw_file( $api_key, $immediate ); @@ -305,22 +308,24 @@ public function sfw_update( $api_key, $immediate = false ) ? $result : true; - }elseif( is_array( $file_urls ) && count( $file_urls ) ){ + }elseif( $api_server && $data_id && is_array( $file_url_nums ) && count( $file_url_nums ) ){ - $result = $this->sfw_update_db( $file_urls[0] ); + $result = $this->sfw_update_db( $api_server, $data_id, $file_url_nums[0] ); if( empty( $result['error'] ) ){ - array_shift($file_urls); + array_shift( $file_url_nums ); - if (count($file_urls)) { + if ( count( $file_url_nums ) ) { Helper::http__request( Server::get('HTTP_HOST'), array( 'spbc_remote_call_token' => md5($api_key), 'spbc_remote_call_action' => 'sfw_update', 'plugin_name' => 'apbct', - 'file_urls' => implode(',', $file_urls), + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), ), array('get', 'async') ); @@ -364,29 +369,40 @@ private function get_sfw_file( $api_key, $immediate ) } } - $gf = \gzopen($result['file_url'], 'rb'); + if (preg_match('/multifiles/', $result['file_url'])) { - if ($gf) { + $api_server = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$1', $result['file_url'] ); + $data_id = preg_replace( '@https://(api.*?)\.cleantalk\.org/.*?(bl_list_[0-9a-z]*?)\.multifiles\.csv\.gz@', '$2', $result['file_url'] ); - $file_urls = array(); + $gf = \gzopen($result['file_url'], 'rb'); - while( ! \gzeof($gf) ) - $file_urls[] = trim( \gzgets($gf, 1024) ); + if ($gf) { - \gzclose($gf); + $file_url_nums = array(); - return Helper::http__request( - Server::get('HTTP_HOST'), - array( - 'spbc_remote_call_token' => md5( $api_key ), - 'spbc_remote_call_action' => 'sfw_update', - 'plugin_name' => 'apbct', - 'file_urls' => implode( ',', $file_urls ), - ), - $pattenrs - ); - }else - return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + while( ! \gzeof($gf) ) { + $file_url = trim( \gzgets($gf, 1024) ); + $file_url_nums[] = preg_replace( '@(https://.*)\.(\d*)(\.csv\.gz)@', '$2', $file_url ); + } + + \gzclose($gf); + + return Helper::http__request( + Server::get('HTTP_HOST'), + array( + 'spbc_remote_call_token' => md5( $api_key ), + 'spbc_remote_call_action' => 'sfw_update', + 'plugin_name' => 'apbct', + 'api_server' => $api_server, + 'data_id' => $data_id, + 'file_url_nums' => implode(',', $file_url_nums), + ), + $pattenrs + ); + }else + return array('error' => 'COULD_NOT_OPEN_REMOTE_FILE_SFW'); + } else + return array('error' => 'COULD_NOT_GET_MULTIFILE'); }else return array('error' => 'ERROR_ALLOW_URL_FOPEN_DISABLED'); }else @@ -397,9 +413,11 @@ private function get_sfw_file( $api_key, $immediate ) return $result; } - private function sfw_update_db( $file_url ) + private function sfw_update_db( $api_server = null, $data_id = null, $file_url_num = null ) { - if(Helper::http__request($file_url, array(), 'get_code') === 200){ // Check if it's there + $file_url = 'https://' . $api_server . '.cleantalk.org/store/' . $data_id . '.' . $file_url_num . '.csv.gz'; + + if( Helper::http__request( $file_url, array(), 'get_code') === 200 ){ // Check if it's there $gf = \gzopen($file_url, 'rb'); From d91dc0fe6205dc91e1dd5ece97412a04c843846f Mon Sep 17 00:00:00 2001 From: Glomberg Date: Wed, 14 Oct 2020 09:32:48 +0300 Subject: [PATCH 8/8] Fix: Library connecting fixed. --- 2.x - 2.2.x/install.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/2.x - 2.2.x/install.xml b/2.x - 2.2.x/install.xml index 49266f6..42a9590 100644 --- a/2.x - 2.2.x/install.xml +++ b/2.x - 2.2.x/install.xml @@ -73,6 +73,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_registrations')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -104,6 +105,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_registrations')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -135,6 +137,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_orders')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -155,6 +158,7 @@ if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_return')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -173,6 +177,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_orders')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -191,6 +196,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_reviews')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) ) @@ -209,6 +215,7 @@ { if ($this->config->get('module_antispambycleantalk_status') && $this->config->get('module_antispambycleantalk_check_registrations')) { + require_once(DIR_SYSTEM . 'library/antispambycleantalk/Core.php'); $this->registry->set( 'apbct', AntispamByCleantalk\Core::get_instance( $this->registry ) ); $this->apbct->init( $this->config ); if( $this->apbct->is_spam( $this ) )