Version Description
Aug 6 2021 = * Fix: SpamFirewall update.
Download this release
Release Info
Developer | Safronik |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.160.1 |
Comparing to | |
See all releases |
Code changes from version 5.160 to 5.160.1
- cleantalk.php +56 -37
- lib/Cleantalk/ApbctWP/Queue.php +1 -1
- lib/Cleantalk/ApbctWP/RemoteCalls.php +7 -6
- lib/Cleantalk/Common/Helper.php +3 -3
- lib/Cleantalk/Common/Queue.php +14 -10
- readme.txt +4 -1
cleantalk.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: https://cleantalk.org
|
5 |
Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
|
6 |
-
Version: 5.160
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: https://cleantalk.org
|
9 |
Text Domain: cleantalk-spam-protect
|
@@ -696,8 +696,14 @@ function apbct_sfw_update__init( $delay = 0 ){
|
|
696 |
if( ! $apbct->data['key_is_ok'] ){
|
697 |
return array( 'error' => 'SFW UPDATE INIT: KEY_IS_NOT_VALID' );
|
698 |
}
|
699 |
-
|
|
|
|
|
|
|
|
|
|
|
700 |
// Set a new update ID and an update time start
|
|
|
701 |
$apbct->fw_stats['firewall_updating_id'] = md5( (string) rand( 0, 100000 ) );
|
702 |
$apbct->fw_stats['firewall_updating_last_start'] = time();
|
703 |
$apbct->save( 'fw_stats' );
|
@@ -705,20 +711,21 @@ function apbct_sfw_update__init( $delay = 0 ){
|
|
705 |
// Delete update errors
|
706 |
$apbct->error_delete( 'sfw_update', 'save_data' );
|
707 |
$apbct->error_delete( 'sfw_update', 'save_data', 'cron' );
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
$queue = new \Cleantalk\ApbctWP\Queue();
|
712 |
$queue->addStage( 'apbct_sfw_update__get_multifiles' );
|
713 |
-
|
714 |
-
apbct_prepare_upd_dir();
|
715 |
-
|
716 |
$cron = new Cron();
|
717 |
-
$cron->addTask('sfw_update_checker', 'apbct_sfw_update__checker', 15
|
718 |
|
719 |
return Helper::http__request__rc_to_host(
|
720 |
'sfw_update__worker',
|
721 |
-
array(
|
|
|
|
|
|
|
722 |
array( 'async' )
|
723 |
);
|
724 |
}
|
@@ -739,10 +746,32 @@ function apbct_sfw_update__worker() {
|
|
739 |
|
740 |
global $apbct;
|
741 |
|
|
|
|
|
742 |
if( ! $apbct->data['key_is_ok'] ){
|
743 |
return array( 'error' => 'Worker: KEY_IS_NOT_VALID' );
|
744 |
}
|
745 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
$queue = new \Cleantalk\ApbctWP\Queue();
|
747 |
|
748 |
if( count( $queue->queue['stages'] ) === 0 ) {
|
@@ -769,22 +798,16 @@ function apbct_sfw_update__worker() {
|
|
769 |
}
|
770 |
// Do logging the queue process here
|
771 |
return true;
|
772 |
-
|
773 |
}
|
774 |
|
|
|
775 |
if( stripos( Get::get('stage'), 'Repeat' ) !== false ) {
|
776 |
-
// This is the repeat stage request, do not generate any new RC
|
777 |
return true;
|
778 |
}
|
779 |
|
780 |
-
$cron = new Cron();
|
781 |
-
if( ! $cron->updateTask('sfw_update_checker', 'apbct_sfw_update__checker', 15, time() + 15 ) ) {
|
782 |
-
$cron->addTask('sfw_update_checker', 'apbct_sfw_update__checker', 15, time() + 15 );
|
783 |
-
}
|
784 |
-
|
785 |
return Helper::http__request__rc_to_host(
|
786 |
'sfw_update__worker',
|
787 |
-
array(),
|
788 |
array( 'async' )
|
789 |
);
|
790 |
|
@@ -905,15 +928,12 @@ function apbct_sfw_update__create_temp_tables() {
|
|
905 |
);
|
906 |
}
|
907 |
|
908 |
-
|
909 |
-
* @psalm-suppress UnusedParam
|
910 |
-
*/
|
911 |
-
function apbct_sfw_update__process_files( $concrete_file = null ) {
|
912 |
|
913 |
global $apbct;
|
914 |
|
915 |
$dir_name = APBCT_DIR_PATH . '/fw_files/';
|
916 |
-
|
917 |
$files = array_filter( $files, static function( $element ) {
|
918 |
return strpos( $element, 'list' ) !== false;
|
919 |
} );
|
@@ -945,7 +965,6 @@ function apbct_sfw_update__process_files( $concrete_file = null ) {
|
|
945 |
return array(
|
946 |
'next_stage' => array(
|
947 |
'name' => 'apbct_sfw_update__process_files',
|
948 |
-
'args' => $concrete_file
|
949 |
)
|
950 |
);
|
951 |
}
|
@@ -1150,7 +1169,7 @@ function apbct_sfw_update__end_of_update() {
|
|
1150 |
$update_period = (int) $update_period > 14400 ? (int) $update_period : 14400;
|
1151 |
$cron = new Cron();
|
1152 |
$cron->updateTask('sfw_update', 'apbct_sfw_update__init', $update_period );
|
1153 |
-
$cron->
|
1154 |
|
1155 |
/**
|
1156 |
* Update fw data if update completed
|
@@ -1174,22 +1193,20 @@ function apbct_prepare_upd_dir() {
|
|
1174 |
$dir_name = APBCT_DIR_PATH . '/fw_files/';
|
1175 |
if( ! is_dir( $dir_name ) ) {
|
1176 |
if( ! mkdir( $dir_name ) && ! is_dir( $dir_name ) ) {
|
1177 |
-
return array( 'error'
|
1178 |
}
|
1179 |
} else {
|
1180 |
$files = glob( $dir_name . '/*' );
|
1181 |
if( $files === false ) {
|
1182 |
-
return array( 'error'
|
1183 |
}
|
1184 |
if( count( $files ) === 0 ) {
|
1185 |
return (bool) file_put_contents( $dir_name . 'index.php', '<?php' . PHP_EOL );
|
1186 |
}
|
1187 |
foreach( $files as $file ){
|
1188 |
-
if( is_file( $file ) ) {
|
1189 |
-
|
1190 |
-
|
1191 |
-
}
|
1192 |
-
}
|
1193 |
}
|
1194 |
}
|
1195 |
return (bool) file_put_contents( $dir_name . 'index.php', '<?php' );
|
@@ -1204,6 +1221,8 @@ function apbct_sfw_update__checker() {
|
|
1204 |
}
|
1205 |
}
|
1206 |
}
|
|
|
|
|
1207 |
}
|
1208 |
|
1209 |
function apbct_sfw_update__cleanData(){
|
@@ -2048,16 +2067,16 @@ function apbct_log($message = 'empty', $func = null, $params = array())
|
|
2048 |
}
|
2049 |
|
2050 |
if($message) {
|
2051 |
-
$debug[ date( "H:i:s"
|
2052 |
}
|
2053 |
if($cron) {
|
2054 |
-
$debug[ date( "H:i:s"
|
2055 |
}
|
2056 |
if($data) {
|
2057 |
-
$debug[ date( "H:i:s"
|
2058 |
}
|
2059 |
if($settings) {
|
2060 |
-
$debug[ date( "H:i:s"
|
2061 |
}
|
2062 |
|
2063 |
update_option(APBCT_DEBUG, $debug);
|
3 |
Plugin Name: Anti-Spam by CleanTalk
|
4 |
Plugin URI: https://cleantalk.org
|
5 |
Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
|
6 |
+
Version: 5.160.1
|
7 |
Author: СleanTalk <welcome@cleantalk.org>
|
8 |
Author URI: https://cleantalk.org
|
9 |
Text Domain: cleantalk-spam-protect
|
696 |
if( ! $apbct->data['key_is_ok'] ){
|
697 |
return array( 'error' => 'SFW UPDATE INIT: KEY_IS_NOT_VALID' );
|
698 |
}
|
699 |
+
|
700 |
+
$prepare_dir__result = apbct_prepare_upd_dir();
|
701 |
+
if( ! empty( $prepare_dir__result['error'] ) ){
|
702 |
+
return $prepare_dir__result;
|
703 |
+
}
|
704 |
+
|
705 |
// Set a new update ID and an update time start
|
706 |
+
$apbct->fw_stats['calls'] = 0;
|
707 |
$apbct->fw_stats['firewall_updating_id'] = md5( (string) rand( 0, 100000 ) );
|
708 |
$apbct->fw_stats['firewall_updating_last_start'] = time();
|
709 |
$apbct->save( 'fw_stats' );
|
711 |
// Delete update errors
|
712 |
$apbct->error_delete( 'sfw_update', 'save_data' );
|
713 |
$apbct->error_delete( 'sfw_update', 'save_data', 'cron' );
|
714 |
+
|
715 |
+
\Cleantalk\ApbctWP\Queue::clearQueue();
|
716 |
+
|
717 |
$queue = new \Cleantalk\ApbctWP\Queue();
|
718 |
$queue->addStage( 'apbct_sfw_update__get_multifiles' );
|
719 |
+
|
|
|
|
|
720 |
$cron = new Cron();
|
721 |
+
$cron->addTask('sfw_update_checker', 'apbct_sfw_update__checker', 15 );
|
722 |
|
723 |
return Helper::http__request__rc_to_host(
|
724 |
'sfw_update__worker',
|
725 |
+
array(
|
726 |
+
'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
|
727 |
+
'delay' => $delay
|
728 |
+
),
|
729 |
array( 'async' )
|
730 |
);
|
731 |
}
|
746 |
|
747 |
global $apbct;
|
748 |
|
749 |
+
usleep( 10000 );
|
750 |
+
|
751 |
if( ! $apbct->data['key_is_ok'] ){
|
752 |
return array( 'error' => 'Worker: KEY_IS_NOT_VALID' );
|
753 |
}
|
754 |
+
|
755 |
+
if(
|
756 |
+
Get::equal( 'firewall_updating_id', '' ) ||
|
757 |
+
! Get::equal( 'firewall_updating_id', $apbct->fw_stats['firewall_updating_id'] )
|
758 |
+
){
|
759 |
+
return 'SFW UPDATE WORKER: WRONG_UPDATE_ID';
|
760 |
+
}
|
761 |
+
|
762 |
+
if( ! isset( $apbct->fw_stats['calls'] ) ){
|
763 |
+
$apbct->fw_stats['calls'] = 0;
|
764 |
+
}
|
765 |
+
|
766 |
+
$apbct->fw_stats['calls']++;
|
767 |
+
$apbct->save('fw_stats');
|
768 |
+
|
769 |
+
if( $apbct->fw_stats['calls'] > 600 ){
|
770 |
+
$apbct->error_add('sfw_update', 'WORKER_CALL_LIMIT_EXCEEDED' );
|
771 |
+
$apbct->saveErrors();
|
772 |
+
return 'WORKER_CALL_LIMIT_EXCEEDED';
|
773 |
+
}
|
774 |
+
|
775 |
$queue = new \Cleantalk\ApbctWP\Queue();
|
776 |
|
777 |
if( count( $queue->queue['stages'] ) === 0 ) {
|
798 |
}
|
799 |
// Do logging the queue process here
|
800 |
return true;
|
|
|
801 |
}
|
802 |
|
803 |
+
// This is the repeat stage request, do not generate any new RC
|
804 |
if( stripos( Get::get('stage'), 'Repeat' ) !== false ) {
|
|
|
805 |
return true;
|
806 |
}
|
807 |
|
|
|
|
|
|
|
|
|
|
|
808 |
return Helper::http__request__rc_to_host(
|
809 |
'sfw_update__worker',
|
810 |
+
array( 'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'] ),
|
811 |
array( 'async' )
|
812 |
);
|
813 |
|
928 |
);
|
929 |
}
|
930 |
|
931 |
+
function apbct_sfw_update__process_files() {
|
|
|
|
|
|
|
932 |
|
933 |
global $apbct;
|
934 |
|
935 |
$dir_name = APBCT_DIR_PATH . '/fw_files/';
|
936 |
+
$files = glob( $dir_name . '/*csv.gz' );
|
937 |
$files = array_filter( $files, static function( $element ) {
|
938 |
return strpos( $element, 'list' ) !== false;
|
939 |
} );
|
965 |
return array(
|
966 |
'next_stage' => array(
|
967 |
'name' => 'apbct_sfw_update__process_files',
|
|
|
968 |
)
|
969 |
);
|
970 |
}
|
1169 |
$update_period = (int) $update_period > 14400 ? (int) $update_period : 14400;
|
1170 |
$cron = new Cron();
|
1171 |
$cron->updateTask('sfw_update', 'apbct_sfw_update__init', $update_period );
|
1172 |
+
$cron->removeTask('sfw_update_checker' );
|
1173 |
|
1174 |
/**
|
1175 |
* Update fw data if update completed
|
1193 |
$dir_name = APBCT_DIR_PATH . '/fw_files/';
|
1194 |
if( ! is_dir( $dir_name ) ) {
|
1195 |
if( ! mkdir( $dir_name ) && ! is_dir( $dir_name ) ) {
|
1196 |
+
return array( 'error' => 'Can not to make FW dir.' );
|
1197 |
}
|
1198 |
} else {
|
1199 |
$files = glob( $dir_name . '/*' );
|
1200 |
if( $files === false ) {
|
1201 |
+
return array( 'error' => 'Can not find FW files.' );
|
1202 |
}
|
1203 |
if( count( $files ) === 0 ) {
|
1204 |
return (bool) file_put_contents( $dir_name . 'index.php', '<?php' . PHP_EOL );
|
1205 |
}
|
1206 |
foreach( $files as $file ){
|
1207 |
+
if( is_file( $file ) && unlink( $file ) === false ){
|
1208 |
+
return array( 'error' => 'Can not delete the FW file: ' . $file );
|
1209 |
+
}
|
|
|
|
|
1210 |
}
|
1211 |
}
|
1212 |
return (bool) file_put_contents( $dir_name . 'index.php', '<?php' );
|
1221 |
}
|
1222 |
}
|
1223 |
}
|
1224 |
+
|
1225 |
+
return true;
|
1226 |
}
|
1227 |
|
1228 |
function apbct_sfw_update__cleanData(){
|
2067 |
}
|
2068 |
|
2069 |
if($message) {
|
2070 |
+
$debug[ date( "H:i:s" ) . (int) microtime() . "_ACTION_" . current_filter() . "_FUNCTION_" . $function ] = $message;
|
2071 |
}
|
2072 |
if($cron) {
|
2073 |
+
$debug[ date( "H:i:s" ) . (int) microtime() . "_ACTION_" . current_filter() . "_FUNCTION_" . $function . '_cron' ] = $apbct->cron;
|
2074 |
}
|
2075 |
if($data) {
|
2076 |
+
$debug[ date( "H:i:s" ) . (int) microtime() . "_ACTION_" . current_filter() . "_FUNCTION_" . $function . '_data' ] = $apbct->data;
|
2077 |
}
|
2078 |
if($settings) {
|
2079 |
+
$debug[ date( "H:i:s" ) . (int) microtime() . "_ACTION_" . current_filter() . "_FUNCTION_" . $function . '_settings' ] = $apbct->settings;
|
2080 |
}
|
2081 |
|
2082 |
update_option(APBCT_DEBUG, $debug);
|
lib/Cleantalk/ApbctWP/Queue.php
CHANGED
@@ -18,7 +18,7 @@ class Queue extends \Cleantalk\Common\Queue {
|
|
18 |
return delete_option( self::QUEUE_NAME );
|
19 |
}
|
20 |
|
21 |
-
function saveQueue( $queue )
|
22 |
{
|
23 |
return update_option( self::QUEUE_NAME, $queue );
|
24 |
}
|
18 |
return delete_option( self::QUEUE_NAME );
|
19 |
}
|
20 |
|
21 |
+
public function saveQueue( $queue )
|
22 |
{
|
23 |
return update_option( self::QUEUE_NAME, $queue );
|
24 |
}
|
lib/Cleantalk/ApbctWP/RemoteCalls.php
CHANGED
@@ -211,14 +211,15 @@ class RemoteCalls
|
|
211 |
public static function action__debug(){
|
212 |
|
213 |
global $apbct;
|
214 |
-
|
215 |
-
$out['stats']
|
216 |
$out['settings'] = $apbct->settings;
|
217 |
$out['fw_stats'] = $apbct->fw_stats;
|
218 |
-
$out['data']
|
219 |
-
$out['cron']
|
220 |
-
$out['errors']
|
221 |
-
|
|
|
222 |
array_walk( $out, function(&$val, $_key){
|
223 |
$val = (array) $val;
|
224 |
});
|
211 |
public static function action__debug(){
|
212 |
|
213 |
global $apbct;
|
214 |
+
|
215 |
+
$out['stats'] = $apbct->stats;
|
216 |
$out['settings'] = $apbct->settings;
|
217 |
$out['fw_stats'] = $apbct->fw_stats;
|
218 |
+
$out['data'] = $apbct->data;
|
219 |
+
$out['cron'] = $apbct->cron;
|
220 |
+
$out['errors'] = $apbct->errors;
|
221 |
+
$out['queue'] = get_option( 'cleantalk_sfw_update_queue' );
|
222 |
+
|
223 |
array_walk( $out, function(&$val, $_key){
|
224 |
$val = (array) $val;
|
225 |
});
|
lib/Cleantalk/Common/Helper.php
CHANGED
@@ -733,9 +733,9 @@ class Helper
|
|
733 |
$info = curl_getinfo($curl_arr[$i], CURLINFO_HTTP_CODE);
|
734 |
if( 200 == $info ) {
|
735 |
if( ! empty( $write_to ) && is_dir( $write_to ) && is_writable( $write_to ) ) {
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
} else {
|
740 |
$results[] = curl_multi_getcontent( $curl_arr[$i] );
|
741 |
}
|
733 |
$info = curl_getinfo($curl_arr[$i], CURLINFO_HTTP_CODE);
|
734 |
if( 200 == $info ) {
|
735 |
if( ! empty( $write_to ) && is_dir( $write_to ) && is_writable( $write_to ) ) {
|
736 |
+
$results[] = file_put_contents( $write_to . self::getFilenameFromUrl( $urls[$i] ), curl_multi_getcontent( $curl_arr[$i] ) )
|
737 |
+
? 'success'
|
738 |
+
: 'error';
|
739 |
} else {
|
740 |
$results[] = curl_multi_getcontent( $curl_arr[$i] );
|
741 |
}
|
lib/Cleantalk/Common/Queue.php
CHANGED
@@ -10,7 +10,7 @@ abstract class Queue {
|
|
10 |
|
11 |
public $queue;
|
12 |
|
13 |
-
function __construct()
|
14 |
{
|
15 |
$queue = $this->getQueue();
|
16 |
if( $queue !== false && isset( $queue['stages'] ) ) {
|
@@ -24,15 +24,14 @@ abstract class Queue {
|
|
24 |
}
|
25 |
}
|
26 |
|
27 |
-
abstract function getQueue();
|
28 |
|
29 |
-
abstract
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
*/
|
36 |
public function addStage( $stage_name, $args = array() )
|
37 |
{
|
38 |
$this->queue['stages'][] = array(
|
@@ -46,6 +45,8 @@ abstract class Queue {
|
|
46 |
|
47 |
public function executeStage()
|
48 |
{
|
|
|
|
|
49 |
if( count( $this->queue['stages'] ) > 0 ) {
|
50 |
foreach ( $this->queue['stages'] as & $stage ) {
|
51 |
if( ( $stage['status'] === 'NULL' ) ) {
|
@@ -76,7 +77,10 @@ abstract class Queue {
|
|
76 |
}
|
77 |
return \Cleantalk\ApbctWP\Helper::http__request__rc_to_host(
|
78 |
'sfw_update__worker',
|
79 |
-
array(
|
|
|
|
|
|
|
80 |
array( 'async' )
|
81 |
);
|
82 |
}
|
10 |
|
11 |
public $queue;
|
12 |
|
13 |
+
public function __construct()
|
14 |
{
|
15 |
$queue = $this->getQueue();
|
16 |
if( $queue !== false && isset( $queue['stages'] ) ) {
|
24 |
}
|
25 |
}
|
26 |
|
27 |
+
abstract public function getQueue();
|
28 |
|
29 |
+
abstract public function saveQueue( $queue );
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param string $stage_name
|
33 |
+
* @param array $args
|
34 |
+
*/
|
|
|
35 |
public function addStage( $stage_name, $args = array() )
|
36 |
{
|
37 |
$this->queue['stages'][] = array(
|
45 |
|
46 |
public function executeStage()
|
47 |
{
|
48 |
+
global $apbct;
|
49 |
+
|
50 |
if( count( $this->queue['stages'] ) > 0 ) {
|
51 |
foreach ( $this->queue['stages'] as & $stage ) {
|
52 |
if( ( $stage['status'] === 'NULL' ) ) {
|
77 |
}
|
78 |
return \Cleantalk\ApbctWP\Helper::http__request__rc_to_host(
|
79 |
'sfw_update__worker',
|
80 |
+
array(
|
81 |
+
'firewall_updating_id' => $apbct->fw_stats['firewall_updating_id'],
|
82 |
+
'stage' => 'Repeat ' . $stage['name']
|
83 |
+
),
|
84 |
array( 'async' )
|
85 |
);
|
86 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
|
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.8
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 5.160
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
@@ -573,6 +573,9 @@ If your website has forms that send data to external sources, you can enable opt
|
|
573 |
|
574 |
== Changelog ==
|
575 |
|
|
|
|
|
|
|
576 |
= 5.160 Jul 29 2021 =
|
577 |
* New: SFW. SFW alternative cookie implemented.
|
578 |
* New: SFW. AC alternative cookie implemented.
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.8
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 5.160.1
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
573 |
|
574 |
== Changelog ==
|
575 |
|
576 |
+
= 5.160.1 Aug 6 2021 =
|
577 |
+
* Fix: SpamFirewall update.
|
578 |
+
|
579 |
= 5.160 Jul 29 2021 =
|
580 |
* New: SFW. SFW alternative cookie implemented.
|
581 |
* New: SFW. AC alternative cookie implemented.
|