Version Description
Jun 02 2022 =
Comment moderation option added, cookies prefix added, RemoteCalls stability improved and some minor issues fixed.
- New. Options. Comment moderation option added on discussion page.
- New. Settings. Encode contact data long description added.
- New. Cookies. Getting prefix function implemented.
- New. Cookies. Get and set cookies with prefix.
- New. Cookies. Using cookie prefix on client code.
- Mod: Created RemoteCallsCounter::class to limit remote calls
- Mod: Created RemoteCallsLogger::class for logging last remote calls
- Upd. Comments. Comment moderation logic modified.
- Fix: webto.salesforce.com extended form
- Fix. SFW. Statistics fixed.
- Fix: secure2.convio.net external
- Fix: hookb.in external
- Fix: fixed test for wpforms
- Fix. Pluggable. Getting REST url fixed.
- Fix: Formidable Pro Multistep Fixed
- Fix: Formidable Form Pro ajax response - fixed
- Fix. Settings. Alternative cookies option renamed.
- Fix. Common. Cookies test function fixed.
- Fix. External forms. JS logic fixed.
- Fix. External forms. Force ajax check action handler added.
- Fix. cleantalk.php. VisualFormBuilder hook change.
- Delete RC update plugin
- Fix. cleantalk.php. Visual Form Builder integration: add legacy support.
- Fix. Helper. Fatal error (Call to private method) fixed.
- Fix. WooCommerce. WC checking order hook changed.
- Fix. Settings. Validate URL exclusions.
- Fix. cleantalk-public-integrations.php->apbct_form_gravityForms_testSpam. Gravity forms multiple email fields fix.
- Fix. SFW updating. Writing update errors fixed.
- Fix. cleantalk.php-> apbct_sfw_update__worker() Convert errors array to a string if set in a stage.
Download this release
Release Info
Developer | glomberg |
Plugin | Spam protection, AntiSpam, FireWall by CleanTalk |
Version | 5.178 |
Comparing to | |
See all releases |
Code changes from version 5.177.2 to 5.178
- cleantalk.php +15 -156
- inc/cleantalk-common.php +5 -12
- inc/cleantalk-pluggable.php +8 -0
- inc/cleantalk-public-integrations.php +98 -22
- inc/cleantalk-public.php +2 -1
- inc/cleantalk-settings.php +55 -8
- inc/cleantalk-updater.php +19 -0
- js/apbct-public--functions.min.js +1 -1
- js/apbct-public--functions.min.js.map +1 -1
- js/cleantalk_external.min.js +1 -1
- js/cleantalk_external.min.js.map +1 -1
- lib/Cleantalk/ApbctWP/CleantalkUpgrader.php +7 -0
- lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php +5 -3
- lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php +2 -1
- lib/Cleantalk/ApbctWP/Firewall/SFW.php +16 -11
- lib/Cleantalk/ApbctWP/HTTP/Request.php +2 -2
- lib/Cleantalk/ApbctWP/Helper.php +16 -0
- lib/Cleantalk/ApbctWP/RemoteCalls.php +0 -8
- lib/Cleantalk/ApbctWP/RemoteCallsCounter.php +147 -0
- lib/Cleantalk/ApbctWP/RemoteCallsLogger.php +72 -0
- lib/Cleantalk/ApbctWP/State.php +3 -1
- lib/Cleantalk/ApbctWP/Variables/Cookie.php +2 -1
- lib/Cleantalk/Common/HTTP/Request.php +2 -2
- lib/Cleantalk/Common/Helper.php +1 -1
- lib/Cleantalk/Common/Validate.php +15 -3
- readme.txt +39 -1
cleantalk.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Anti-Spam by CleanTalk
|
5 |
Plugin URI: https://cleantalk.org
|
6 |
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.
|
7 |
-
Version: 5.
|
8 |
Author: СleanTalk <welcome@cleantalk.org>
|
9 |
Author URI: https://cleantalk.org
|
10 |
Text Domain: cleantalk-spam-protect
|
@@ -172,6 +172,10 @@ add_action('wp_ajax_apbct_js_keys__get', 'apbct_js_keys__get__ajax');
|
|
172 |
add_action('wp_ajax_nopriv_apbct_get_pixel_url', 'apbct_get_pixel_url__ajax');
|
173 |
add_action('wp_ajax_apbct_apbct_get_pixel_url', 'apbct_get_pixel_url__ajax');
|
174 |
|
|
|
|
|
|
|
|
|
175 |
// Checking email before POST
|
176 |
add_action('wp_ajax_nopriv_apbct_email_check_before_post', 'apbct_email_check_before_post');
|
177 |
|
@@ -340,7 +344,7 @@ $apbct_active_integrations = array(
|
|
340 |
'ajax' => false
|
341 |
),
|
342 |
'VisualFormBuilder' => array(
|
343 |
-
'hook' => 'vfb_isBot',
|
344 |
'setting' => 'forms__contact_forms_test',
|
345 |
'ajax' => false
|
346 |
),
|
@@ -1005,7 +1009,7 @@ function apbct_sfw_update__worker($checker_work = false)
|
|
1005 |
|
1006 |
$result = $queue->executeStage();
|
1007 |
|
1008 |
-
if ( isset($result['error']) ) {
|
1009 |
$apbct->errorAdd('sfw_update', $result['error']);
|
1010 |
$apbct->saveErrors();
|
1011 |
|
@@ -1019,7 +1023,13 @@ function apbct_sfw_update__worker($checker_work = false)
|
|
1019 |
$queue->saveQueue($queue->queue);
|
1020 |
foreach ( $queue->queue['stages'] as $stage ) {
|
1021 |
if ( isset($stage['error']) ) {
|
1022 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1023 |
}
|
1024 |
}
|
1025 |
|
@@ -1916,157 +1926,6 @@ function apbct_rc__uninstall_plugin__check_deactivate()
|
|
1916 |
$apbct->plugin_deactivated = true;
|
1917 |
}
|
1918 |
|
1919 |
-
/**
|
1920 |
-
* @throws JsonException
|
1921 |
-
* @psalm-suppress UndefinedClass
|
1922 |
-
*/
|
1923 |
-
function apbct_rc__update()
|
1924 |
-
{
|
1925 |
-
global $wp_version;
|
1926 |
-
|
1927 |
-
// Check download_source if set
|
1928 |
-
if ( Get::get('download_source') ) {
|
1929 |
-
switch ( Get::get('download_source') ) {
|
1930 |
-
case 'cleantalk':
|
1931 |
-
$download_url = 'https://download.cleantalk.org/antispam/wordpress/cleantalk-spam-protect._VERSION_.zip';
|
1932 |
-
break;
|
1933 |
-
case 'wordpress':
|
1934 |
-
$download_url = 'https://downloads.wordpress.org/plugin/cleantalk-spam-protect._VERSION_.zip';
|
1935 |
-
break;
|
1936 |
-
case 'github':
|
1937 |
-
$download_url = 'https://github.com/CleanTalk/wordpress-antispam/releases/download/_VERSION_/cleantalk-spam-protect._VERSION_.zip';
|
1938 |
-
break;
|
1939 |
-
default:
|
1940 |
-
apbct_update__outputResult('CHECK_INPUT', false, array('error' => 'download_source is wrong'));
|
1941 |
-
break;
|
1942 |
-
}
|
1943 |
-
}
|
1944 |
-
|
1945 |
-
// Check download_version if set
|
1946 |
-
if ( Get::get('download_version') ) {
|
1947 |
-
if ( ! preg_match('@^\d+\.\d+(\.\d+)?$@', Get::get('download_version')) ) {
|
1948 |
-
apbct_update__outputResult(
|
1949 |
-
'CHECK_INPUT',
|
1950 |
-
false,
|
1951 |
-
array('error' => 'Download version (' . Get::get('download_version') . ') is wrong')
|
1952 |
-
);
|
1953 |
-
}
|
1954 |
-
$download_version = Get::get('download_version');
|
1955 |
-
}
|
1956 |
-
|
1957 |
-
if ( isset($download_url, $download_version) ) {
|
1958 |
-
$download_url = str_replace('_VERSION_', $download_version, $download_url);
|
1959 |
-
|
1960 |
-
if ( Helper::httpRequestGetResponseCode($download_url) !== 200 ) {
|
1961 |
-
apbct_update__outputResult(
|
1962 |
-
'CHECK_SOURCE',
|
1963 |
-
false,
|
1964 |
-
array('error' => 'Package is unavailable', 'package' => $download_url)
|
1965 |
-
);
|
1966 |
-
}
|
1967 |
-
|
1968 |
-
add_filter(
|
1969 |
-
'site_transient_update_plugins',
|
1970 |
-
function ($value, $_transient) use ($download_url) {
|
1971 |
-
$value->response['cleantalk-spam-protect/cleantalk.php'] = (object)array(
|
1972 |
-
'package' => $download_url,
|
1973 |
-
);
|
1974 |
-
|
1975 |
-
return $value;
|
1976 |
-
},
|
1977 |
-
1000,
|
1978 |
-
2
|
1979 |
-
);
|
1980 |
-
}
|
1981 |
-
|
1982 |
-
//Upgrade params
|
1983 |
-
$plugin = 'cleantalk-spam-protect/cleantalk.php';
|
1984 |
-
$plugin_slug = 'cleantalk-spam-protect';
|
1985 |
-
$title = __('Update Plugin');
|
1986 |
-
$nonce = 'upgrade-plugin_' . $plugin;
|
1987 |
-
$url = 'update.php?action=upgrade-plugin&plugin=' . urlencode($plugin);
|
1988 |
-
$activate_for_network = false;
|
1989 |
-
if ( APBCT_WPMS && is_main_site() && array_key_exists($plugin, get_site_option('active_sitewide_plugins')) ) {
|
1990 |
-
$activate_for_network = true;
|
1991 |
-
}
|
1992 |
-
|
1993 |
-
$prev_version = APBCT_VERSION;
|
1994 |
-
|
1995 |
-
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
1996 |
-
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
|
1997 |
-
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
1998 |
-
include_once(ABSPATH . 'wp-admin/includes/misc.php');
|
1999 |
-
|
2000 |
-
apbct_maintenance_mode__enable(30);
|
2001 |
-
|
2002 |
-
if ( version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0 ) {
|
2003 |
-
$upgrader = new CleantalkUpgrader(new CleantalkUpgraderSkin(compact('title', 'nonce', 'url', 'plugin')));
|
2004 |
-
} else {
|
2005 |
-
$upgrader = new CleantalkUpgrader(
|
2006 |
-
new CleantalkUpgraderSkinDeprecated(compact('title', 'nonce', 'url', 'plugin'))
|
2007 |
-
);
|
2008 |
-
}
|
2009 |
-
|
2010 |
-
$upgrader_result = $upgrader->upgrade($plugin);
|
2011 |
-
if ( is_wp_error($upgrader_result) ) {
|
2012 |
-
error_log('CleanTalk debug message:');
|
2013 |
-
error_log(var_export($upgrader_result->get_error_message(), true));
|
2014 |
-
}
|
2015 |
-
|
2016 |
-
apbct_maintenance_mode__disable();
|
2017 |
-
|
2018 |
-
apbct_update__outputResult(
|
2019 |
-
'UPDATE',
|
2020 |
-
$upgrader->apbct_result
|
2021 |
-
);
|
2022 |
-
|
2023 |
-
if ( $upgrader->apbct_result === 'OK' ) {
|
2024 |
-
$result = activate_plugins($plugin);
|
2025 |
-
|
2026 |
-
apbct_update__outputResult(
|
2027 |
-
'PLUGIN_ACTIVATING',
|
2028 |
-
is_wp_error($result) || $result === false ? 'FAIL' : 'OK',
|
2029 |
-
array('wp_error' => is_wp_error($result) ? $result->get_error_message() : '')
|
2030 |
-
);
|
2031 |
-
|
2032 |
-
$httpResponseCode = Helper::httpRequestGetResponseCode(get_option('home'));
|
2033 |
-
|
2034 |
-
if ( $httpResponseCode != 200 ) {
|
2035 |
-
// Rollback
|
2036 |
-
apbct_maintenance_mode__enable(30);
|
2037 |
-
|
2038 |
-
$rollback = version_compare(PHP_VERSION, '5.6.0') >= 0 && version_compare($wp_version, '5.3') >= 0
|
2039 |
-
? new CleantalkUpgrader(new CleantalkUpgraderSkin(compact('title', 'nonce', 'url', 'plugin')))
|
2040 |
-
: new CleantalkUpgrader(
|
2041 |
-
new CleantalkUpgraderSkinDeprecated(compact('title', 'nonce', 'url', 'plugin'))
|
2042 |
-
);
|
2043 |
-
$rollback->rollback($plugin);
|
2044 |
-
|
2045 |
-
apbct_maintenance_mode__disable();
|
2046 |
-
|
2047 |
-
apbct_update__outputResult(
|
2048 |
-
'CHECK_RESPONSE',
|
2049 |
-
'FAIL',
|
2050 |
-
array(
|
2051 |
-
'error' => 'BAD_HTTP_CODE',
|
2052 |
-
'http_code' => $httpResponseCode,
|
2053 |
-
'output' => htmlspecialchars(
|
2054 |
-
substr(Helper::httpRequestGetContent(get_option('home')), 0, 900)
|
2055 |
-
),
|
2056 |
-
'rollback_result' => $rollback->apbct_result,
|
2057 |
-
)
|
2058 |
-
);
|
2059 |
-
}
|
2060 |
-
|
2061 |
-
apbct_update__outputResult(
|
2062 |
-
'CHECK_RESPONSE',
|
2063 |
-
'OK'
|
2064 |
-
);
|
2065 |
-
}
|
2066 |
-
|
2067 |
-
die('FUNCTION IS COMPLETE. OK.');
|
2068 |
-
}
|
2069 |
-
|
2070 |
/**
|
2071 |
* @param $source
|
2072 |
*
|
@@ -2441,7 +2300,7 @@ function apbct_cookies_test()
|
|
2441 |
|
2442 |
$check_string = $apbct->api_key;
|
2443 |
foreach ( $cookie_test['cookies_names'] as $cookie_name ) {
|
2444 |
-
$check_string .=
|
2445 |
}
|
2446 |
|
2447 |
if ( $cookie_test['check_value'] == md5($check_string) ) {
|
4 |
Plugin Name: Anti-Spam by CleanTalk
|
5 |
Plugin URI: https://cleantalk.org
|
6 |
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.
|
7 |
+
Version: 5.178
|
8 |
Author: СleanTalk <welcome@cleantalk.org>
|
9 |
Author URI: https://cleantalk.org
|
10 |
Text Domain: cleantalk-spam-protect
|
172 |
add_action('wp_ajax_nopriv_apbct_get_pixel_url', 'apbct_get_pixel_url__ajax');
|
173 |
add_action('wp_ajax_apbct_apbct_get_pixel_url', 'apbct_get_pixel_url__ajax');
|
174 |
|
175 |
+
// Force ajax checking for external forms
|
176 |
+
add_action('wp_ajax_nopriv_cleantalk_force_ajax_check', 'ct_ajax_hook');
|
177 |
+
add_action('wp_ajax_cleantalk_force_ajax_check', 'ct_ajax_hook');
|
178 |
+
|
179 |
// Checking email before POST
|
180 |
add_action('wp_ajax_nopriv_apbct_email_check_before_post', 'apbct_email_check_before_post');
|
181 |
|
344 |
'ajax' => false
|
345 |
),
|
346 |
'VisualFormBuilder' => array(
|
347 |
+
'hook' => array('vfb_isbot','vfb_isBot'),
|
348 |
'setting' => 'forms__contact_forms_test',
|
349 |
'ajax' => false
|
350 |
),
|
1009 |
|
1010 |
$result = $queue->executeStage();
|
1011 |
|
1012 |
+
if ( isset($result['error']) && $result['status'] === 'FINISHED' ) {
|
1013 |
$apbct->errorAdd('sfw_update', $result['error']);
|
1014 |
$apbct->saveErrors();
|
1015 |
|
1023 |
$queue->saveQueue($queue->queue);
|
1024 |
foreach ( $queue->queue['stages'] as $stage ) {
|
1025 |
if ( isset($stage['error']) ) {
|
1026 |
+
//there could be an array of errors of files processed
|
1027 |
+
if (is_array($stage['error'])){
|
1028 |
+
$error = implode(" ",array_values($stage['error']));
|
1029 |
+
} else {
|
1030 |
+
$error = $result['error'];
|
1031 |
+
}
|
1032 |
+
$apbct->errorAdd('sfw_update', $error);
|
1033 |
}
|
1034 |
}
|
1035 |
|
1926 |
$apbct->plugin_deactivated = true;
|
1927 |
}
|
1928 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1929 |
/**
|
1930 |
* @param $source
|
1931 |
*
|
2300 |
|
2301 |
$check_string = $apbct->api_key;
|
2302 |
foreach ( $cookie_test['cookies_names'] as $cookie_name ) {
|
2303 |
+
$check_string .= Cookie::get($cookie_name);
|
2304 |
}
|
2305 |
|
2306 |
if ( $cookie_test['check_value'] == md5($check_string) ) {
|
inc/cleantalk-common.php
CHANGED
@@ -419,6 +419,11 @@ function apbct_exclusions_check__url()
|
|
419 |
)
|
420 |
: apbct_get_server_variable('REQUEST_URI');
|
421 |
|
|
|
|
|
|
|
|
|
|
|
422 |
foreach ( $exclusions as $exclusion ) {
|
423 |
if (
|
424 |
(
|
@@ -1026,18 +1031,6 @@ function ct_get_fields_any_postdata($arr, $message = array())
|
|
1026 |
return $message;
|
1027 |
}
|
1028 |
|
1029 |
-
/**
|
1030 |
-
* Checks if given string is valid regular expression
|
1031 |
-
*
|
1032 |
-
* @param string $regexp
|
1033 |
-
*
|
1034 |
-
* @return bool
|
1035 |
-
*/
|
1036 |
-
function apbct_is_regexp($regexp)
|
1037 |
-
{
|
1038 |
-
return @preg_match('/' . $regexp . '/', '') !== false;
|
1039 |
-
}
|
1040 |
-
|
1041 |
function cleantalk_debug($key, $value)
|
1042 |
{
|
1043 |
if ( Cookie::get('cleantalk_debug')) {
|
419 |
)
|
420 |
: apbct_get_server_variable('REQUEST_URI');
|
421 |
|
422 |
+
if ( $apbct->data['check_exclusion_as_url'] ) {
|
423 |
+
$protocol = ! in_array(Server::get('HTTPS'), ['off', '']) || Server::get('SERVER_PORT') == 443 ? 'https://' : 'http://';
|
424 |
+
$haystack = $protocol . Server::get('SERVER_NAME') . $haystack;
|
425 |
+
}
|
426 |
+
|
427 |
foreach ( $exclusions as $exclusion ) {
|
428 |
if (
|
429 |
(
|
1031 |
return $message;
|
1032 |
}
|
1033 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1034 |
function cleantalk_debug($key, $value)
|
1035 |
{
|
1036 |
if ( Cookie::get('cleantalk_debug')) {
|
inc/cleantalk-pluggable.php
CHANGED
@@ -987,3 +987,11 @@ function apbct_settings__get_ajax_type()
|
|
987 |
|
988 |
return false;
|
989 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
987 |
|
988 |
return false;
|
989 |
}
|
990 |
+
|
991 |
+
function apbct__get_cookie_prefix()
|
992 |
+
{
|
993 |
+
if ( defined('CLEANTALK_COOKIE_PREFIX') ) {
|
994 |
+
return preg_replace('/[^A-Za-z1-9_-]/', '', CLEANTALK_COOKIE_PREFIX);
|
995 |
+
}
|
996 |
+
return '';
|
997 |
+
}
|
inc/cleantalk-public-integrations.php
CHANGED
@@ -451,12 +451,15 @@ function apbct_search_add_noindex()
|
|
451 |
|
452 |
/**
|
453 |
* Test woocommerce checkout form for spam
|
454 |
-
* @psalm-suppress UnusedVariable
|
455 |
*/
|
456 |
-
function ct_woocommerce_checkout_check()
|
457 |
{
|
458 |
global $apbct, $cleantalk_executed;
|
459 |
|
|
|
|
|
|
|
|
|
460 |
/**
|
461 |
* Filter for POST
|
462 |
*/
|
@@ -712,6 +715,15 @@ function apbct_form__formidable__testSpam($errors, $_form)
|
|
712 |
return $errors;
|
713 |
}
|
714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
/**
|
716 |
* Filter for POST
|
717 |
*/
|
@@ -769,14 +781,7 @@ function apbct_form__formidable__testSpam($errors, $_form)
|
|
769 |
$ct_comment = $ct_result->comment;
|
770 |
if (apbct_is_ajax()) {
|
771 |
// search for a suitable field
|
772 |
-
$key_field =
|
773 |
-
|
774 |
-
foreach ($_form['item_meta'] as $key => $value) {
|
775 |
-
if ($value) {
|
776 |
-
$key_field = $key;
|
777 |
-
break;
|
778 |
-
}
|
779 |
-
}
|
780 |
|
781 |
$result = array (
|
782 |
'errors' =>
|
@@ -798,6 +803,30 @@ function apbct_form__formidable__testSpam($errors, $_form)
|
|
798 |
return $errors;
|
799 |
}
|
800 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
/**
|
802 |
* Public filter 'bbp_*' - Get new topic name to global $ct_bbp_topic
|
803 |
*
|
@@ -1117,8 +1146,34 @@ function ct_preprocess_comment($comment)
|
|
1117 |
}
|
1118 |
|
1119 |
if ( $ct_result->allow ) { // Pass if allowed
|
1120 |
-
|
|
|
1121 |
add_filter('pre_comment_approved', 'ct_set_not_approved', 999, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1122 |
} else {
|
1123 |
add_filter('pre_comment_approved', 'ct_set_approved', 999, 2);
|
1124 |
}
|
@@ -1469,19 +1524,34 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
|
|
1469 |
/**
|
1470 |
* Changing the type of check for BuddyPress
|
1471 |
*/
|
1472 |
-
if (Post::get('signup_username') && Post::get('signup_email')) {
|
1473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1474 |
}
|
1475 |
|
1476 |
$base_call_result = apbct_base_call(
|
1477 |
-
|
1478 |
-
'sender_email' => $user_email,
|
1479 |
-
'sender_nickname' => $sanitized_user_login,
|
1480 |
-
'sender_info' => $sender_info,
|
1481 |
-
'js_on' => $checkjs,
|
1482 |
-
),
|
1483 |
$reg_flag
|
1484 |
);
|
|
|
1485 |
$ct_result = $base_call_result['ct_result'];
|
1486 |
ct_hash($ct_result->id);
|
1487 |
// Change mail notification if license is out of date
|
@@ -2361,8 +2431,14 @@ function apbct_form__WPForms__testSpam()
|
|
2361 |
|
2362 |
$checkjs = apbct_js_test('ct_checkjs_wpforms', $_POST);
|
2363 |
|
2364 |
-
$email
|
2365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2366 |
$apbct->form_data['name']
|
2367 |
) : null;
|
2368 |
$form_data = $apbct->form_data;
|
@@ -2769,7 +2845,7 @@ function apbct_form__gravityForms__testSpam($is_spam, $form, $entry)
|
|
2769 |
}
|
2770 |
|
2771 |
foreach ( $form_fields_intermediate as $field ) {
|
2772 |
-
if ( $field['f_type'] === 'email' ) {
|
2773 |
$email = $field['f_data'];
|
2774 |
}
|
2775 |
|
451 |
|
452 |
/**
|
453 |
* Test woocommerce checkout form for spam
|
|
|
454 |
*/
|
455 |
+
function ct_woocommerce_checkout_check($_data, $errors)
|
456 |
{
|
457 |
global $apbct, $cleantalk_executed;
|
458 |
|
459 |
+
if ( count($errors->errors) ) {
|
460 |
+
return;
|
461 |
+
}
|
462 |
+
|
463 |
/**
|
464 |
* Filter for POST
|
465 |
*/
|
715 |
return $errors;
|
716 |
}
|
717 |
|
718 |
+
// Skipping, if not sending, but filling out the form step by step. For Formidable Pro
|
719 |
+
if (apbct_is_plugin_active('formidable-pro/formidable-pro.php')) {
|
720 |
+
foreach (array_keys($_POST) as $key) {
|
721 |
+
if (strpos($key, 'frm_page_order') === 0) {
|
722 |
+
return $errors;
|
723 |
+
}
|
724 |
+
}
|
725 |
+
}
|
726 |
+
|
727 |
/**
|
728 |
* Filter for POST
|
729 |
*/
|
781 |
$ct_comment = $ct_result->comment;
|
782 |
if (apbct_is_ajax()) {
|
783 |
// search for a suitable field
|
784 |
+
$key_field = apbct__formidable_get_key_field_for_ajax_response($_form);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
|
786 |
$result = array (
|
787 |
'errors' =>
|
803 |
return $errors;
|
804 |
}
|
805 |
|
806 |
+
/**
|
807 |
+
* Get field key for ajax response of formidable form
|
808 |
+
*/
|
809 |
+
function apbct__formidable_get_key_field_for_ajax_response($_form = array())
|
810 |
+
{
|
811 |
+
$key_field = '113';
|
812 |
+
|
813 |
+
if (
|
814 |
+
isset($_POST['item_meta']) &&
|
815 |
+
is_array($_POST['item_meta'])
|
816 |
+
) {
|
817 |
+
$key_field = array_keys($_POST['item_meta'])[1];
|
818 |
+
} elseif (is_array($_form) && isset($_form['item_meta'])) {
|
819 |
+
foreach ($_form['item_meta'] as $key => $value) {
|
820 |
+
if ($value) {
|
821 |
+
$key_field = $key;
|
822 |
+
break;
|
823 |
+
}
|
824 |
+
}
|
825 |
+
}
|
826 |
+
|
827 |
+
return $key_field;
|
828 |
+
}
|
829 |
+
|
830 |
/**
|
831 |
* Public filter 'bbp_*' - Get new topic name to global $ct_bbp_topic
|
832 |
*
|
1146 |
}
|
1147 |
|
1148 |
if ( $ct_result->allow ) { // Pass if allowed
|
1149 |
+
// If moderation is required
|
1150 |
+
if ( get_option('comment_moderation') === '1' ) {
|
1151 |
add_filter('pre_comment_approved', 'ct_set_not_approved', 999, 2);
|
1152 |
+
// If new author have to be moderated
|
1153 |
+
} elseif ( get_option('comment_previously_approved') === '1' && get_option('cleantalk_allowed_moderation', 1) != 1 ) {
|
1154 |
+
$comment_author = isset($comment['comment_author']) ? $comment['comment_author'] : '';
|
1155 |
+
$comment_author_email = isset($comment['comment_author_email']) ? $comment['comment_author_email'] : '';
|
1156 |
+
$comment_author_url = isset($comment['comment_author_url']) ? $comment['comment_author_url'] : '';
|
1157 |
+
$comment_content = isset($comment['comment_content']) ? $comment['comment_content'] : '';
|
1158 |
+
$comment_author_IP = isset($comment['comment_author_IP']) ? $comment['comment_author_IP'] : '';
|
1159 |
+
$comment_agent = isset($comment['comment_agent']) ? $comment['comment_agent'] : '';
|
1160 |
+
$comment_type = isset($comment['comment_type']) ? $comment['comment_type'] : '';
|
1161 |
+
if (
|
1162 |
+
check_comment(
|
1163 |
+
$comment_author,
|
1164 |
+
$comment_author_email,
|
1165 |
+
$comment_author_url,
|
1166 |
+
$comment_content,
|
1167 |
+
$comment_author_IP,
|
1168 |
+
$comment_agent,
|
1169 |
+
$comment_type
|
1170 |
+
)
|
1171 |
+
) {
|
1172 |
+
add_filter('pre_comment_approved', 'ct_set_approved', 999, 2);
|
1173 |
+
} else {
|
1174 |
+
add_filter('pre_comment_approved', 'ct_set_not_approved', 999, 2);
|
1175 |
+
}
|
1176 |
+
// Allowed comment will be published
|
1177 |
} else {
|
1178 |
add_filter('pre_comment_approved', 'ct_set_approved', 999, 2);
|
1179 |
}
|
1524 |
/**
|
1525 |
* Changing the type of check for BuddyPress
|
1526 |
*/
|
1527 |
+
if ( Post::get('signup_username') && Post::get('signup_email') ) {
|
1528 |
+
// if buddy press set up custom fields
|
1529 |
+
$reg_flag = empty(Post::get('signup_profile_field_ids'));
|
1530 |
+
}
|
1531 |
+
|
1532 |
+
$base_call_array = array(
|
1533 |
+
'sender_email' => $user_email,
|
1534 |
+
'sender_nickname' => $sanitized_user_login,
|
1535 |
+
'sender_info' => $sender_info,
|
1536 |
+
'js_on' => $checkjs,
|
1537 |
+
);
|
1538 |
+
|
1539 |
+
if ( !$reg_flag ) {
|
1540 |
+
$field_values = '';
|
1541 |
+
$fields_numbers_to_check = explode(',', Post::get('signup_profile_field_ids'));
|
1542 |
+
foreach ( $fields_numbers_to_check as $field_number ) {
|
1543 |
+
$field_name = 'field_' . $field_number;
|
1544 |
+
$field_value = Post::get($field_name) ? Post::get($field_name) : '';
|
1545 |
+
$field_values .= $field_value . "\n";
|
1546 |
+
}
|
1547 |
+
$base_call_array['message'] = $field_values;
|
1548 |
}
|
1549 |
|
1550 |
$base_call_result = apbct_base_call(
|
1551 |
+
$base_call_array,
|
|
|
|
|
|
|
|
|
|
|
1552 |
$reg_flag
|
1553 |
);
|
1554 |
+
|
1555 |
$ct_result = $base_call_result['ct_result'];
|
1556 |
ct_hash($ct_result->id);
|
1557 |
// Change mail notification if license is out of date
|
2431 |
|
2432 |
$checkjs = apbct_js_test('ct_checkjs_wpforms', $_POST);
|
2433 |
|
2434 |
+
$email = $apbct->form_data['email'] ?: null;
|
2435 |
+
|
2436 |
+
# Fixed if the 'Enable email address confirmation' option is enabled
|
2437 |
+
if ( is_array($email) ) {
|
2438 |
+
$email = reset($email);
|
2439 |
+
}
|
2440 |
+
|
2441 |
+
$nickname = $apbct->form_data['name'] && is_array($apbct->form_data['name']) ? array_shift(
|
2442 |
$apbct->form_data['name']
|
2443 |
) : null;
|
2444 |
$form_data = $apbct->form_data;
|
2845 |
}
|
2846 |
|
2847 |
foreach ( $form_fields_intermediate as $field ) {
|
2848 |
+
if ( $field['f_type'] === 'email' && $field['f_visibility'] === 'visible') {
|
2849 |
$email = $field['f_data'];
|
2850 |
}
|
2851 |
|
inc/cleantalk-public.php
CHANGED
@@ -167,7 +167,7 @@ function apbct_init()
|
|
167 |
if ( class_exists('WooCommerce') ) {
|
168 |
add_filter('woocommerce_registration_errors', 'ct_registration_errors', 1, 3);
|
169 |
if ( $apbct->settings['forms__wc_checkout_test'] == 1 ) {
|
170 |
-
|
171 |
}
|
172 |
if ( Request::get('wc-ajax') === 'checkout' && empty($apbct->settings['forms__wc_register_from_order']) ) {
|
173 |
remove_filter('woocommerce_registration_errors', 'ct_registration_errors', 1);
|
@@ -1319,6 +1319,7 @@ function apbct_enqueue_and_localize_public_scripts()
|
|
1319 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
1320 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
1321 |
'text__wait_for_decoding' => esc_html__('Wait for decoding...', 'cleantalk-spam-protect'),
|
|
|
1322 |
));
|
1323 |
|
1324 |
wp_localize_script('ct_public', 'ctPublic', array(
|
167 |
if ( class_exists('WooCommerce') ) {
|
168 |
add_filter('woocommerce_registration_errors', 'ct_registration_errors', 1, 3);
|
169 |
if ( $apbct->settings['forms__wc_checkout_test'] == 1 ) {
|
170 |
+
add_action('woocommerce_after_checkout_validation', 'ct_woocommerce_checkout_check', 1, 2);
|
171 |
}
|
172 |
if ( Request::get('wc-ajax') === 'checkout' && empty($apbct->settings['forms__wc_register_from_order']) ) {
|
173 |
remove_filter('woocommerce_registration_errors', 'ct_registration_errors', 1);
|
1319 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
1320 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
1321 |
'text__wait_for_decoding' => esc_html__('Wait for decoding...', 'cleantalk-spam-protect'),
|
1322 |
+
'cookiePrefix' => apbct__get_cookie_prefix(),
|
1323 |
));
|
1324 |
|
1325 |
wp_localize_script('ct_public', 'ctPublic', array(
|
inc/cleantalk-settings.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use Cleantalk\Variables\Post;
|
4 |
use Cleantalk\ApbctWP\Cron;
|
5 |
use Cleantalk\Variables\Server;
|
@@ -24,6 +25,19 @@ function apbct_settings_add_page()
|
|
24 |
$callback
|
25 |
);
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
if ( ! in_array($pagenow, array('options.php', 'options-general.php', 'settings.php', 'admin.php')) ) {
|
28 |
return;
|
29 |
}
|
@@ -441,7 +455,7 @@ function apbct_settings__set_fileds()
|
|
441 |
array(
|
442 |
'val' => 2,
|
443 |
'label' => __(
|
444 |
-
'
|
445 |
'cleantalk-spam-protect'
|
446 |
),
|
447 |
'childrens_enable' => 1,
|
@@ -522,6 +536,7 @@ function apbct_settings__set_fileds()
|
|
522 |
'data__email_decoder' => array(
|
523 |
'title' => __('Encode contact data', 'cleantalk-spam-protect'),
|
524 |
'description' => __('Turn on this option to prevent crawlers grab contact data (emails) from website content.', 'cleantalk-spam-protect'),
|
|
|
525 |
),
|
526 |
),
|
527 |
),
|
@@ -539,7 +554,7 @@ function apbct_settings__set_fileds()
|
|
539 |
'type' => 'textarea',
|
540 |
'title' => __('URL exclusions', 'cleantalk-spam-protect'),
|
541 |
'description' => __(
|
542 |
-
'You could type here a part of the URL you want to exclude.
|
543 |
'cleantalk-spam-protect'
|
544 |
),
|
545 |
),
|
@@ -1796,6 +1811,21 @@ function apbct_settings__field__debug_tab()
|
|
1796 |
echo '</div>';
|
1797 |
}
|
1798 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1799 |
function apbct_get_all_child_domains($except_main_site = false)
|
1800 |
{
|
1801 |
global $wpdb;
|
@@ -2116,9 +2146,14 @@ function apbct_settings__validate($settings)
|
|
2116 |
|
2117 |
// Validate Exclusions
|
2118 |
// URLs
|
|
|
|
|
|
|
|
|
2119 |
$result = apbct_settings__sanitize__exclusions(
|
2120 |
$settings['exclusions__urls'],
|
2121 |
-
$settings['exclusions__urls__use_regexp']
|
|
|
2122 |
);
|
2123 |
$result === false
|
2124 |
? $apbct->errorAdd(
|
@@ -2549,7 +2584,7 @@ function apbct_update_blogs_options($settings)
|
|
2549 |
*
|
2550 |
* @return bool|string
|
2551 |
*/
|
2552 |
-
function apbct_settings__sanitize__exclusions($exclusions, $regexp = false)
|
2553 |
{
|
2554 |
if ( ! is_string($exclusions) ) {
|
2555 |
return false;
|
@@ -2576,13 +2611,18 @@ function apbct_settings__sanitize__exclusions($exclusions, $regexp = false)
|
|
2576 |
foreach ($exclusions as $exclusion) {
|
2577 |
//Cut exclusion if more than 128 symbols gained
|
2578 |
$sanitized_exclusion = substr($exclusion, 0, 128);
|
2579 |
-
$sanitized_exclusion = trim($sanitized_exclusion
|
2580 |
|
2581 |
if ( ! empty($sanitized_exclusion) ) {
|
2582 |
-
if ( $regexp
|
2583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2584 |
}
|
2585 |
-
|
2586 |
$result[] = $sanitized_exclusion;
|
2587 |
}
|
2588 |
}
|
@@ -2670,6 +2710,13 @@ function apbct_settings__get__long_description()
|
|
2670 |
'<a href="https://cleantalk.org/help/anti-flood-and-anti-crawler{utm_mark}" target="_blank">' . __('here.', 'cleantalk-spam-protect') . '</a>'
|
2671 |
)
|
2672 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2673 |
);
|
2674 |
|
2675 |
if ( ! empty($setting_id) ) {
|
1 |
<?php
|
2 |
|
3 |
+
use Cleantalk\ApbctWP\Validate;
|
4 |
use Cleantalk\Variables\Post;
|
5 |
use Cleantalk\ApbctWP\Cron;
|
6 |
use Cleantalk\Variables\Server;
|
25 |
$callback
|
26 |
);
|
27 |
|
28 |
+
// Add CleanTalk Moderation option to the Discussion page
|
29 |
+
add_settings_field(
|
30 |
+
'cleantalk_allowed_moderation',
|
31 |
+
esc_html__('CleanTalk allowed comments moderation', 'cleantalk-spam-protect'),
|
32 |
+
'apbct_discussion_settings__field__moderation',
|
33 |
+
'discussion'
|
34 |
+
);
|
35 |
+
add_filter('allowed_options', function ($options) {
|
36 |
+
$options['discussion'][] = 'cleantalk_allowed_moderation';
|
37 |
+
return $options;
|
38 |
+
});
|
39 |
+
// End modification Discussion page
|
40 |
+
|
41 |
if ( ! in_array($pagenow, array('options.php', 'options-general.php', 'settings.php', 'admin.php')) ) {
|
42 |
return;
|
43 |
}
|
455 |
array(
|
456 |
'val' => 2,
|
457 |
'label' => __(
|
458 |
+
'Store data in the website database (alternative mechanism)',
|
459 |
'cleantalk-spam-protect'
|
460 |
),
|
461 |
'childrens_enable' => 1,
|
536 |
'data__email_decoder' => array(
|
537 |
'title' => __('Encode contact data', 'cleantalk-spam-protect'),
|
538 |
'description' => __('Turn on this option to prevent crawlers grab contact data (emails) from website content.', 'cleantalk-spam-protect'),
|
539 |
+
'long_description' => true,
|
540 |
),
|
541 |
),
|
542 |
),
|
554 |
'type' => 'textarea',
|
555 |
'title' => __('URL exclusions', 'cleantalk-spam-protect'),
|
556 |
'description' => __(
|
557 |
+
'You could type here a part of the URL you want to exclude. Use comma or new lines as separator. Exclusion value will be sliced to 128 chars, exclusions number is restricted by 20 values.',
|
558 |
'cleantalk-spam-protect'
|
559 |
),
|
560 |
),
|
1811 |
echo '</div>';
|
1812 |
}
|
1813 |
|
1814 |
+
function apbct_discussion_settings__field__moderation()
|
1815 |
+
{
|
1816 |
+
$output = '<label for="cleantalk_allowed_moderation">';
|
1817 |
+
$output .= '<input
|
1818 |
+
type="checkbox"
|
1819 |
+
name="cleantalk_allowed_moderation"
|
1820 |
+
id="cleantalk_allowed_moderation"
|
1821 |
+
value="1" ' .
|
1822 |
+
checked('1', get_option('cleantalk_allowed_moderation', 1), false) .
|
1823 |
+
'/> ';
|
1824 |
+
$output .= esc_html__('Skip manual approving for the very first comment if a comment has been allowed by CleanTalk Anti-Spam protection', 'cleantalk-spam-protect');
|
1825 |
+
$output .= '</label>';
|
1826 |
+
echo $output;
|
1827 |
+
}
|
1828 |
+
|
1829 |
function apbct_get_all_child_domains($except_main_site = false)
|
1830 |
{
|
1831 |
global $wpdb;
|
2146 |
|
2147 |
// Validate Exclusions
|
2148 |
// URLs
|
2149 |
+
if ( empty($apbct->settings['exclusions__urls']) ) {
|
2150 |
+
// If the field is empty, the new way checking by URL will be activated.
|
2151 |
+
$apbct->data['check_exclusion_as_url'] = true;
|
2152 |
+
}
|
2153 |
$result = apbct_settings__sanitize__exclusions(
|
2154 |
$settings['exclusions__urls'],
|
2155 |
+
$settings['exclusions__urls__use_regexp'],
|
2156 |
+
$apbct->data['check_exclusion_as_url']
|
2157 |
);
|
2158 |
$result === false
|
2159 |
? $apbct->errorAdd(
|
2584 |
*
|
2585 |
* @return bool|string
|
2586 |
*/
|
2587 |
+
function apbct_settings__sanitize__exclusions($exclusions, $regexp = false, $urls = false)
|
2588 |
{
|
2589 |
if ( ! is_string($exclusions) ) {
|
2590 |
return false;
|
2611 |
foreach ($exclusions as $exclusion) {
|
2612 |
//Cut exclusion if more than 128 symbols gained
|
2613 |
$sanitized_exclusion = substr($exclusion, 0, 128);
|
2614 |
+
$sanitized_exclusion = trim($sanitized_exclusion);
|
2615 |
|
2616 |
if ( ! empty($sanitized_exclusion) ) {
|
2617 |
+
if ( $regexp ) {
|
2618 |
+
if ( ! Validate::isRegexp($exclusion) ) {
|
2619 |
+
return false;
|
2620 |
+
}
|
2621 |
+
} elseif ( $urls ) {
|
2622 |
+
if ( ! Validate::isUrl($exclusion) ) {
|
2623 |
+
return false;
|
2624 |
+
}
|
2625 |
}
|
|
|
2626 |
$result[] = $sanitized_exclusion;
|
2627 |
}
|
2628 |
}
|
2710 |
'<a href="https://cleantalk.org/help/anti-flood-and-anti-crawler{utm_mark}" target="_blank">' . __('here.', 'cleantalk-spam-protect') . '</a>'
|
2711 |
)
|
2712 |
),
|
2713 |
+
'data__email_decoder' => array(
|
2714 |
+
'title' => __('Encode contact data', 'cleantalk-spam-protect'),
|
2715 |
+
'desc' => sprintf(
|
2716 |
+
__('This option allows you to encode contacts on the public pages of the site. This prevents robots from automatically collecting such data and prevents it from being included in spam lists. %s', 'cleantalk-spam-protect'),
|
2717 |
+
'<a href="https://cleantalk.org/help/email-encode{utm_mark}" target="_blank">' . __('Learn more.', 'cleantalk-spam-protect') . '</a>'
|
2718 |
+
)
|
2719 |
+
),
|
2720 |
);
|
2721 |
|
2722 |
if ( ! empty($setting_id) ) {
|
inc/cleantalk-updater.php
CHANGED
@@ -1119,3 +1119,22 @@ function apbct_update_to_5_176_1()
|
|
1119 |
$apbct->saveSettings();
|
1120 |
}
|
1121 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1119 |
$apbct->saveSettings();
|
1120 |
}
|
1121 |
}
|
1122 |
+
|
1123 |
+
function apbct_update_to_5_177_2()
|
1124 |
+
{
|
1125 |
+
global $apbct;
|
1126 |
+
|
1127 |
+
if ( isset($apbct->remote_calls['update_plugin']) ) {
|
1128 |
+
unset($apbct->remote_calls['update_plugin']);
|
1129 |
+
$apbct->save('remote_calls');
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
function apbct_update_to_5_177_3()
|
1134 |
+
{
|
1135 |
+
global $apbct;
|
1136 |
+
if ( ! empty($apbct->settings['exclusions__urls']) ) {
|
1137 |
+
$apbct->data['check_exclusion_as_url'] = false;
|
1138 |
+
$apbct->saveData();
|
1139 |
+
}
|
1140 |
+
}
|
js/apbct-public--functions.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
function ctSetCookie(t,
|
2 |
//# sourceMappingURL=apbct-public--functions.min.js.map
|
1 |
+
function ctSetCookie(o,t,e){var n;("string"==typeof o&&"string"==typeof t||"number"==typeof t)&&(n="ct_pointer_data"===o,o=[[o,t,e]]),"none"!==ctPublicFunctions.data__cookies_type&&("native"===ctPublicFunctions.data__cookies_type?o.forEach(function(o,t,e){var n=void 0!==o[2]?"expires="+n+"; ":"",c="https:"===location.protocol?"; secure":"";document.cookie=ctPublicFunctions.cookiePrefix+o[0]+"="+encodeURIComponent(o[1])+"; "+n+"path=/; samesite=lax"+c}):"alternative"!==ctPublicFunctions.data__cookies_type||n||("rest"===ctPublicFunctions.data__ajax_type?apbct_public_sendREST("alt_sessions",{method:"POST",data:{cookies:o}}):"admin_ajax"===ctPublicFunctions.data__ajax_type&&apbct_public_sendAJAX({action:"apbct_alt_session__save__AJAX",cookies:o},{notJson:1})))}function ctDeleteCookie(o){var t;"none"!==ctPublicFunctions.data__cookies_type&&("native"===ctPublicFunctions.data__cookies_type?(t="https:"===location.protocol?"; secure":"",document.cookie=o+'=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax'+t):ctPublicFunctions.data__cookies_type)}function apbct_public_sendAJAX(t,e,n){var c=e.callback||null,a=e.callback_context||null,l=e.callback_params||null,o=e.async||!0,s=e.notJson||null,i=e.timeout||15e3,n=n||null,r=e.button||null,u=e.spinner||null,p=e.progressbar||null,_=e.silent||null,d=e.no_nonce||null;"string"==typeof t?t=(t=d?t:t+"&_ajax_nonce="+ctPublicFunctions._ajax_nonce)+"&no_cache="+Math.random():(d||(t._ajax_nonce=ctPublicFunctions._ajax_nonce),t.no_cache=Math.random()),r&&(r.setAttribute("disabled","disabled"),r.style.cursor="not-allowed"),u&&jQuery(u).css("display","inline"),jQuery.ajax({type:"POST",url:ctPublicFunctions._ajax_url,data:t,async:o,success:function(o){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),(o=s?o:JSON.parse(o)).error?(setTimeout(function(){p&&p.fadeOut("slow")},1e3),console.log("Error happens: "+(o.error||"Unkown"))):c&&(l?c.apply(a,l.concat(o,t,e,n)):c(o,t,e,n))},error:function(o,t,e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),e&&!_&&(console.log("APBCT_AJAX_ERROR"),console.log(o),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+e+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:i})}function apbct_public_sendREST(t,e){var n=e.callback||null,o=e.data||[],c=e.method||"POST";jQuery.ajax({type:c,url:ctPublicFunctions._rest_url+"cleantalk-antispam/v1/"+t,data:o,beforeSend:function(o){o.setRequestHeader("X-WP-Nonce",ctPublicFunctions._rest_nonce)},success:function(o){o.error?console.log("Error happens: "+(o.error||"Unknown")):n&&n(o,t,e,null)},error:function(o,t,e){e&&(console.log("APBCT_REST_ERROR"),console.log(o),console.log(t),console.log("Anti-spam by Cleantalk plugin REST API error: "+e+" Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))}})}
|
2 |
//# sourceMappingURL=apbct-public--functions.min.js.map
|
js/apbct-public--functions.min.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"file":"apbct-public--functions.min.js","sources":["apbct-public--functions.js"],"sourcesContent":["function ctSetCookie( cookies, value, expires ){\n\n if( typeof cookies === 'string' && typeof value === 'string' || typeof value === 'number'){\n var skip_alt = cookies === 'ct_pointer_data';\n cookies = [ [ cookies, value, expires ] ];\n }\n\n // Cookies disabled\n if( ctPublicFunctions.data__cookies_type === 'none' ){\n return;\n\n // Using traditional cookies\n }else if( ctPublicFunctions.data__cookies_type === 'native' ){\n cookies.forEach( function (item, i, arr\t) {\n var expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\n });\n\n // Using alternative cookies\n }else if( ctPublicFunctions.data__cookies_type === 'alternative' && ! skip_alt ){\n\n // Using REST API handler\n if( ctPublicFunctions.data__ajax_type === 'rest' ){\n apbct_public_sendREST(\n 'alt_sessions',\n {\n method: 'POST',\n data: { cookies: cookies }\n }\n );\n\n // Using AJAX request and handler\n } else if( ctPublicFunctions.data__ajax_type === 'admin_ajax' ) {\n apbct_public_sendAJAX(\n {\n action: 'apbct_alt_session__save__AJAX',\n cookies: cookies,\n },\n {\n notJson: 1,\n }\n );\n }\n }\n}\n\nfunction ctDeleteCookie(cookieName) {\n // Cookies disabled\n if( ctPublicFunctions.data__cookies_type === 'none' ){\n return;\n\n // Using traditional cookies\n }else if( ctPublicFunctions.data__cookies_type === 'native' ){\n\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = cookieName + \"=\\\"\\\"; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax\" + ctSecure;\n\n // Using alternative cookies\n }else if( ctPublicFunctions.data__cookies_type === 'alternative' ){\n // @ToDo implement this logic\n }\n}\n\nfunction apbct_public_sendAJAX(data, params, obj){\n\n // Default params\n var callback = params.callback || null;\n var callback_context = params.callback_context || null;\n var callback_params = params.callback_params || null;\n var async = params.async || true;\n var notJson = params.notJson || null;\n var timeout = params.timeout || 15000;\n var obj = obj || null;\n var button = params.button || null;\n var spinner = params.spinner || null;\n var progressbar = params.progressbar || null;\n var silent = params.silent || null;\n var no_nonce = params.no_nonce || null;\n\n if(typeof (data) === 'string') {\n if( ! no_nonce )\n data = data + '&_ajax_nonce=' + ctPublicFunctions._ajax_nonce;\n data = data + '&no_cache=' + Math.random()\n } else {\n if( ! no_nonce )\n data._ajax_nonce = ctPublicFunctions._ajax_nonce;\n data.no_cache = Math.random();\n }\n // Button and spinner\n if(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n if(spinner) jQuery(spinner).css('display', 'inline');\n\n jQuery.ajax({\n type: \"POST\",\n url: ctPublicFunctions._ajax_url,\n data: data,\n async: async,\n success: function(result){\n if(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n if(spinner) jQuery(spinner).css('display', 'none');\n if(!notJson) result = JSON.parse(result);\n if(result.error){\n setTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n console.log('Error happens: ' + (result.error || 'Unkown'));\n }else{\n if(callback) {\n if (callback_params)\n callback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n else\n callback(result, data, params, obj);\n }\n }\n },\n error: function(jqXHR, textStatus, errorThrown){\n if(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n if(spinner) jQuery(spinner).css('display', 'none');\n if( errorThrown && ! silent ) {\n console.log('APBCT_AJAX_ERROR');\n console.log(jqXHR);\n console.log(textStatus);\n console.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n }\n },\n timeout: timeout,\n });\n}\n\nfunction apbct_public_sendREST( route, params ) {\n\n var callback = params.callback || null;\n var data = params.data || [];\n var method = params.method || 'POST';\n\n jQuery.ajax({\n type: method,\n url: ctPublicFunctions._rest_url + 'cleantalk-antispam/v1/' + route,\n data: data,\n beforeSend : function ( xhr ) {\n xhr.setRequestHeader( 'X-WP-Nonce', ctPublicFunctions._rest_nonce );\n },\n success: function(result){\n if(result.error){\n console.log('Error happens: ' + (result.error || 'Unknown'));\n }else{\n if(callback) {\n var obj = null;\n callback(result, route, params, obj);\n }\n }\n },\n error: function(jqXHR, textStatus, errorThrown){\n if( errorThrown ) {\n console.log('APBCT_REST_ERROR');\n console.log(jqXHR);\n console.log(textStatus);\n console.log('Anti-spam by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n }\n },\n });\n\n}\n"],"names":["ctSetCookie","cookies","value","expires","skip_alt","ctPublicFunctions","data__cookies_type","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","encodeURIComponent","data__ajax_type","apbct_public_sendREST","method","data","apbct_public_sendAJAX","action","notJson","ctDeleteCookie","cookieName","params","obj","callback","callback_context","callback_params","async","timeout","button","spinner","progressbar","silent","no_nonce","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","result","removeAttribute","JSON","parse","error","setTimeout","fadeOut","console","log","apply","concat","jqXHR","textStatus","errorThrown","route","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce"],"mappings":"AAAA,SAASA,YAAaC,EAASC,EAAOC,GAElC,IACQC,GADe,iBAAZH,GAAyC,iBAAVC,GAAuC,iBAAVA,KAC/DE,EAAuB,oBAAZH,EACfA,EAAU,CAAE,CAAEA,EAASC,EAAOC,KAIW,SAAzCE,kBAAkBC,qBAI6B,WAAzCD,kBAAkBC,mBACxBL,EAAQM,QAAS,SAAUC,EAAMC,EAAGC,GAChC,IAAIP,OAA6B,IAAZK,EAAK,GAAqB,WAAaL,EAAU,KAAO,GACzEQ,EAAiC,WAAtBC,SAASC,SAAwB,WAAa,GAC7DC,SAASC,
|
1 |
+
{"version":3,"file":"apbct-public--functions.min.js","sources":["apbct-public--functions.js"],"sourcesContent":["function ctSetCookie( cookies, value, expires ){\n\n if( typeof cookies === 'string' && typeof value === 'string' || typeof value === 'number'){\n var skip_alt = cookies === 'ct_pointer_data';\n cookies = [ [ cookies, value, expires ] ];\n }\n\n // Cookies disabled\n if( ctPublicFunctions.data__cookies_type === 'none' ){\n return;\n\n // Using traditional cookies\n }else if( ctPublicFunctions.data__cookies_type === 'native' ){\n cookies.forEach( function (item, i, arr\t) {\n var expires = typeof item[2] !== 'undefined' ? \"expires=\" + expires + '; ' : '';\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = ctPublicFunctions.cookiePrefix + item[0] + \"=\" + encodeURIComponent(item[1]) + \"; \" + expires + \"path=/; samesite=lax\" + ctSecure;\n });\n\n // Using alternative cookies\n }else if( ctPublicFunctions.data__cookies_type === 'alternative' && ! skip_alt ){\n\n // Using REST API handler\n if( ctPublicFunctions.data__ajax_type === 'rest' ){\n apbct_public_sendREST(\n 'alt_sessions',\n {\n method: 'POST',\n data: { cookies: cookies }\n }\n );\n\n // Using AJAX request and handler\n } else if( ctPublicFunctions.data__ajax_type === 'admin_ajax' ) {\n apbct_public_sendAJAX(\n {\n action: 'apbct_alt_session__save__AJAX',\n cookies: cookies,\n },\n {\n notJson: 1,\n }\n );\n }\n }\n}\n\nfunction ctDeleteCookie(cookieName) {\n // Cookies disabled\n if( ctPublicFunctions.data__cookies_type === 'none' ){\n return;\n\n // Using traditional cookies\n }else if( ctPublicFunctions.data__cookies_type === 'native' ){\n\n var ctSecure = location.protocol === 'https:' ? '; secure' : '';\n document.cookie = cookieName + \"=\\\"\\\"; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax\" + ctSecure;\n\n // Using alternative cookies\n }else if( ctPublicFunctions.data__cookies_type === 'alternative' ){\n // @ToDo implement this logic\n }\n}\n\nfunction apbct_public_sendAJAX(data, params, obj){\n\n // Default params\n var callback = params.callback || null;\n var callback_context = params.callback_context || null;\n var callback_params = params.callback_params || null;\n var async = params.async || true;\n var notJson = params.notJson || null;\n var timeout = params.timeout || 15000;\n var obj = obj || null;\n var button = params.button || null;\n var spinner = params.spinner || null;\n var progressbar = params.progressbar || null;\n var silent = params.silent || null;\n var no_nonce = params.no_nonce || null;\n\n if(typeof (data) === 'string') {\n if( ! no_nonce )\n data = data + '&_ajax_nonce=' + ctPublicFunctions._ajax_nonce;\n data = data + '&no_cache=' + Math.random()\n } else {\n if( ! no_nonce )\n data._ajax_nonce = ctPublicFunctions._ajax_nonce;\n data.no_cache = Math.random();\n }\n // Button and spinner\n if(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n if(spinner) jQuery(spinner).css('display', 'inline');\n\n jQuery.ajax({\n type: \"POST\",\n url: ctPublicFunctions._ajax_url,\n data: data,\n async: async,\n success: function(result){\n if(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n if(spinner) jQuery(spinner).css('display', 'none');\n if(!notJson) result = JSON.parse(result);\n if(result.error){\n setTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n console.log('Error happens: ' + (result.error || 'Unkown'));\n }else{\n if(callback) {\n if (callback_params)\n callback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n else\n callback(result, data, params, obj);\n }\n }\n },\n error: function(jqXHR, textStatus, errorThrown){\n if(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n if(spinner) jQuery(spinner).css('display', 'none');\n if( errorThrown && ! silent ) {\n console.log('APBCT_AJAX_ERROR');\n console.log(jqXHR);\n console.log(textStatus);\n console.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n }\n },\n timeout: timeout,\n });\n}\n\nfunction apbct_public_sendREST( route, params ) {\n\n var callback = params.callback || null;\n var data = params.data || [];\n var method = params.method || 'POST';\n\n jQuery.ajax({\n type: method,\n url: ctPublicFunctions._rest_url + 'cleantalk-antispam/v1/' + route,\n data: data,\n beforeSend : function ( xhr ) {\n xhr.setRequestHeader( 'X-WP-Nonce', ctPublicFunctions._rest_nonce );\n },\n success: function(result){\n if(result.error){\n console.log('Error happens: ' + (result.error || 'Unknown'));\n }else{\n if(callback) {\n var obj = null;\n callback(result, route, params, obj);\n }\n }\n },\n error: function(jqXHR, textStatus, errorThrown){\n if( errorThrown ) {\n console.log('APBCT_REST_ERROR');\n console.log(jqXHR);\n console.log(textStatus);\n console.log('Anti-spam by Cleantalk plugin REST API error: ' + errorThrown + ' Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n }\n },\n });\n\n}\n"],"names":["ctSetCookie","cookies","value","expires","skip_alt","ctPublicFunctions","data__cookies_type","forEach","item","i","arr","ctSecure","location","protocol","document","cookie","cookiePrefix","encodeURIComponent","data__ajax_type","apbct_public_sendREST","method","data","apbct_public_sendAJAX","action","notJson","ctDeleteCookie","cookieName","params","obj","callback","callback_context","callback_params","async","timeout","button","spinner","progressbar","silent","no_nonce","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","result","removeAttribute","JSON","parse","error","setTimeout","fadeOut","console","log","apply","concat","jqXHR","textStatus","errorThrown","route","_rest_url","beforeSend","xhr","setRequestHeader","_rest_nonce"],"mappings":"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"}
|
js/cleantalk_external.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
function ct_protect_external(){for(var e,t,n,a,o,c
|
2 |
//# sourceMappingURL=cleantalk_external.min.js.map
|
1 |
+
function ct_protect_external(){for(var e,t,n,a,o,i,c=0;c<document.forms.length;c++)void 0!==document.forms[c].cleantalk_hidden_action||void 0!==document.forms[c].cleantalk_hidden_method||"string"==typeof(e=document.forms[c]).action&&(isIntegratedForm(e)?(jQuery(e).before('<i class="cleantalk_placeholder" style="display: none;"></i>'),t=jQuery(e).prev(),o=e.outerHTML,n=jQuery(e).detach(),t.after(o),(o=document.createElement("input")).name="action",o.value="cleantalk_force_ajax_check",o.type="hidden",(a=document.forms[c]).appendChild(o),void 0!==a.classList&&a.classList.contains("ml-block-form")?void 0!==(o=jQuery("form.ml-block-form").find('button[type="submit"]'))&&o.click(function(e){e.preventDefault(),sendAjaxCheckingFormData(a,t,n)}):document.forms[c].onsubmit=function(e){e.preventDefault();var t=jQuery(e.currentTarget).prev(),n=jQuery(e.currentTarget).clone();sendAjaxCheckingFormData(e.currentTarget,t,n)}):-1===e.action.indexOf("http://")&&-1===e.action.indexOf("https://")||e.action.split("//")[1].split("/")[0].toLowerCase()!==location.hostname.toLowerCase()&&((o=document.createElement("input")).name="cleantalk_hidden_action",o.value=e.action,o.type="hidden",e.appendChild(o),(i=document.createElement("input")).name="cleantalk_hidden_method",i.value=e.method,i.type="hidden",e.method="POST",e.appendChild(i),e.action=document.location))}function apbct_replace_inputs_values_from_other_form(e,t){var e=jQuery(e).find("button, input, textarea, select"),n=jQuery(t).find("button, input, textarea, select");e.each(function(e,a){var o=jQuery(a);n.each(function(e,t){var n=jQuery(t);a.outerHTML===t.outerHTML&&n.val(o.val())})})}function isIntegratedForm(e){var t=e.action;return!!(-1!==t.indexOf("activehosted.com")||-1!==t.indexOf("app.convertkit.com")||void 0!==e.firstChild.classList&&e.firstChild.classList.contains("cb-form-group")||-1!==t.indexOf("mailerlite.com")||-1!==t.indexOf("colcolmail.co.uk")||-1!==t.indexOf("paypal.com")||-1!==t.indexOf("infusionsoft.com")||-1!==t.indexOf("webto.salesforce.com")||-1!==t.indexOf("secure2.convio.net")||-1!==t.indexOf("hookb.in")||-1!==t.indexOf("external.url"))}function sendAjaxCheckingFormData(a,e,t){var n={},o=(n[0]=apbct_collect_visible_fields(a),apbct_visible_fields_set_cookie(n),{}),n=a.elements;(n=Array.prototype.slice.call(n)).forEach(function(e,t){""===e.name?o["input_"+t]=e.value:o[e.name]=e.value}),apbct_public_sendAJAX(o,{async:!1,callback:function(e,t,n){void 0!==n.apbct&&+n.apbct.blocked||(apbct_replace_inputs_values_from_other_form(jQuery(a).detach(),t),e.after(t),0===(n=jQuery(t).find("button[type=submit]")).length&&0===(n=jQuery(t).find("input[type=submit]")).length&&0===(n=jQuery(t).find('button[data-element="submit"]')).length&&0===(n=jQuery(t).find('input[type="image"][name="submit"]')).length||n[0].click())},callback_context:null,callback_params:[e,t]})}window.onload=function(){setTimeout(function(){ct_protect_external()},1500)};
|
2 |
//# sourceMappingURL=cleantalk_external.min.js.map
|
js/cleantalk_external.min.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"file":"cleantalk_external.min.js","sources":["cleantalk_external.js"],"sourcesContent":["/**\n * Handle external forms\n */\nfunction ct_protect_external() {\n for(var i = 0; i < document.forms.length; i++) {\n\n if (document.forms[i].cleantalk_hidden_action === undefined && document.forms[i].cleantalk_hidden_method === undefined) {\n\n // current form\n var currentForm = document.forms[i];\n\n if(typeof(currentForm.action) == 'string') {\n\n if(isIntegratedForm(currentForm)) {\n jQuery( currentForm ).before('<i class=\"cleantalk_placeholder\" style=\"display: none;\"></i>');\n\n // Deleting form to prevent submit event\n var prev = jQuery(currentForm).prev(),\n form_html = currentForm.outerHTML,\n form_original = jQuery(currentForm).detach();\n\n prev.after( form_html );\n\n var force_action = document.createElement(\"input\");\n force_action.name = 'action';\n force_action.value = 'cleantalk_force_ajax_check';\n force_action.type = 'hidden';\n\n var reUseCurrentForm = document.forms[i];\n\n reUseCurrentForm.appendChild(force_action);\n\n // mailerlite integration - disable click on submit button\n if(reUseCurrentForm.classList !== undefined && reUseCurrentForm.classList.contains('ml-block-form')) {\n var mailerliteSubmitButton = jQuery('form.ml-block-form').find('button[type=\"submit\"]');\n\n if(mailerliteSubmitButton !== undefined) {\n mailerliteSubmitButton.click(function (event) {\n event.preventDefault();\n sendAjaxCheckingFormData(reUseCurrentForm, prev, form_original);\n });\n }\n } else {\n document.forms[i].onsubmit = function ( event ){\n event.preventDefault();\n\n const prev = jQuery(event.currentTarget).prev();\n const form_original = jQuery(event.currentTarget).clone();\n\n sendAjaxCheckingFormData(event.currentTarget, prev, form_original);\n };\n }\n\n // Common flow\n }else if(currentForm.action.indexOf('http://') !== -1 || currentForm.action.indexOf('https://') !== -1) {\n\n var tmp = currentForm.action.split('//');\n tmp = tmp[1].split('/');\n var host = tmp[0].toLowerCase();\n\n if(host !== location.hostname.toLowerCase()){\n\n var ct_action = document.createElement(\"input\");\n ct_action.name = 'cleantalk_hidden_action';\n ct_action.value = currentForm.action;\n ct_action.type = 'hidden';\n currentForm.appendChild(ct_action);\n\n var ct_method = document.createElement(\"input\");\n ct_method.name = 'cleantalk_hidden_method';\n ct_method.value = currentForm.method;\n ct_method.type = 'hidden';\n\n currentForm.method = 'POST';\n currentForm.appendChild(ct_method);\n\n currentForm.action = document.location;\n }\n }\n }\n }\n\n }\n}\nfunction apbct_replace_inputs_values_from_other_form( form_source, form_target ){\n\n var\tinputs_source = jQuery( form_source ).find( 'button, input, textarea, select' ),\n inputs_target = jQuery( form_target ).find( 'button, input, textarea, select' );\n\n inputs_source.each( function( index, elem_source ){\n\n var source = jQuery( elem_source );\n\n inputs_target.each( function( index2, elem_target ){\n\n var target = jQuery( elem_target );\n\n if( elem_source.outerHTML === elem_target.outerHTML ){\n\n target.val( source.val() );\n }\n });\n });\n\n}\nwindow.onload = function () {\n setTimeout(function () {\n ct_protect_external()\n }, 1500);\n};\n\n/**\n * Checking the form integration\n */\nfunction isIntegratedForm(formObj) {\n var formAction = formObj.action;\n\n if(\n formAction.indexOf('activehosted.com') !== -1 || // ActiveCampaign form\n formAction.indexOf('app.convertkit.com') !== -1 || // ConvertKit form\n ( formObj.firstChild.classList !== undefined && formObj.firstChild.classList.contains('cb-form-group') ) || // Convertbox form\n formAction.indexOf('mailerlite.com') !== -1 || // Mailerlite integration\n formAction.indexOf('colcolmail.co.uk') !== -1 || // colcolmail.co.uk integration\n formAction.indexOf('paypal.com') !== -1 ||\n formAction.indexOf('infusionsoft.com') !== -1\n ) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Sending Ajax for checking form data\n */\nfunction sendAjaxCheckingFormData(form, prev, formOriginal) {\n // Get visible fields and set cookie\n var visible_fields = {};\n visible_fields[0] = apbct_collect_visible_fields(form);\n apbct_visible_fields_set_cookie( visible_fields );\n\n var data = {};\n var elems = form.elements;\n elems = Array.prototype.slice.call(elems);\n\n elems.forEach( function( elem, y ) {\n if( elem.name === '' ) {\n data['input_' + y] = elem.value;\n } else {\n data[elem.name] = elem.value;\n }\n });\n\n apbct_public_sendAJAX(\n data,\n {\n async: false,\n callback: function( prev, formOriginal, result ){\n\n if( ! +result.apbct.blocked ) {\n\n var form_new = jQuery(form).detach();\n\n apbct_replace_inputs_values_from_other_form(form_new, formOriginal);\n\n prev.after( formOriginal );\n\n // Common click event\n var subm_button = jQuery(formOriginal).find('button[type=submit]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n }\n\n // ConvertKit direct integration\n subm_button = jQuery(formOriginal).find('button[data-element=\"submit\"]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n }\n\n // Paypal integration\n subm_button = jQuery(formOriginal).find('input[type=\"image\"][name=\"submit\"]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n }\n\n }\n },\n callback_context: null,\n callback_params: [prev, formOriginal],\n }\n );\n}\n"],"names":["ct_protect_external","currentForm","prev","form_original","reUseCurrentForm","ct_action","ct_method","i","document","forms","length","undefined","cleantalk_hidden_action","cleantalk_hidden_method","isIntegratedForm","jQuery","before","form_html","outerHTML","detach","after","force_action","createElement","name","value","type","appendChild","classList","contains","mailerliteSubmitButton","find","click","event","preventDefault","sendAjaxCheckingFormData","onsubmit","currentTarget","clone","action","indexOf","split","toLowerCase","location","hostname","method","apbct_replace_inputs_values_from_other_form","form_source","form_target","inputs_source","inputs_target","each","index","elem_source","source","index2","elem_target","target","val","formObj","formAction","firstChild","form","formOriginal","visible_fields","data","apbct_collect_visible_fields","apbct_visible_fields_set_cookie","elems","elements","Array","prototype","slice","call","forEach","elem","y","apbct_public_sendAJAX","async","callback","result","apbct","blocked","subm_button","callback_context","callback_params","window","onload","setTimeout"],"mappings":"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"}
|
1 |
+
{"version":3,"file":"cleantalk_external.min.js","sources":["cleantalk_external.js"],"sourcesContent":["/**\n * Handle external forms\n */\nfunction ct_protect_external() {\n for(var i = 0; i < document.forms.length; i++) {\n\n if (document.forms[i].cleantalk_hidden_action === undefined && document.forms[i].cleantalk_hidden_method === undefined) {\n\n // current form\n var currentForm = document.forms[i];\n\n if(typeof(currentForm.action) == 'string') {\n\n if(isIntegratedForm(currentForm)) {\n jQuery( currentForm ).before('<i class=\"cleantalk_placeholder\" style=\"display: none;\"></i>');\n\n // Deleting form to prevent submit event\n var prev = jQuery(currentForm).prev(),\n form_html = currentForm.outerHTML,\n form_original = jQuery(currentForm).detach();\n\n prev.after( form_html );\n\n var force_action = document.createElement(\"input\");\n force_action.name = 'action';\n force_action.value = 'cleantalk_force_ajax_check';\n force_action.type = 'hidden';\n\n var reUseCurrentForm = document.forms[i];\n\n reUseCurrentForm.appendChild(force_action);\n\n // mailerlite integration - disable click on submit button\n if(reUseCurrentForm.classList !== undefined && reUseCurrentForm.classList.contains('ml-block-form')) {\n var mailerliteSubmitButton = jQuery('form.ml-block-form').find('button[type=\"submit\"]');\n\n if(mailerliteSubmitButton !== undefined) {\n mailerliteSubmitButton.click(function (event) {\n event.preventDefault();\n sendAjaxCheckingFormData(reUseCurrentForm, prev, form_original);\n });\n }\n } else {\n document.forms[i].onsubmit = function ( event ){\n event.preventDefault();\n\n const prev = jQuery(event.currentTarget).prev();\n const form_original = jQuery(event.currentTarget).clone();\n\n sendAjaxCheckingFormData(event.currentTarget, prev, form_original);\n };\n }\n\n // Common flow\n }else if(currentForm.action.indexOf('http://') !== -1 || currentForm.action.indexOf('https://') !== -1) {\n\n var tmp = currentForm.action.split('//');\n tmp = tmp[1].split('/');\n var host = tmp[0].toLowerCase();\n\n if(host !== location.hostname.toLowerCase()){\n\n var ct_action = document.createElement(\"input\");\n ct_action.name = 'cleantalk_hidden_action';\n ct_action.value = currentForm.action;\n ct_action.type = 'hidden';\n currentForm.appendChild(ct_action);\n\n var ct_method = document.createElement(\"input\");\n ct_method.name = 'cleantalk_hidden_method';\n ct_method.value = currentForm.method;\n ct_method.type = 'hidden';\n\n currentForm.method = 'POST';\n currentForm.appendChild(ct_method);\n\n currentForm.action = document.location;\n }\n }\n }\n }\n\n }\n}\nfunction apbct_replace_inputs_values_from_other_form( form_source, form_target ){\n\n var\tinputs_source = jQuery( form_source ).find( 'button, input, textarea, select' ),\n inputs_target = jQuery( form_target ).find( 'button, input, textarea, select' );\n\n inputs_source.each( function( index, elem_source ){\n\n var source = jQuery( elem_source );\n\n inputs_target.each( function( index2, elem_target ){\n\n var target = jQuery( elem_target );\n\n if( elem_source.outerHTML === elem_target.outerHTML ){\n\n target.val( source.val() );\n }\n });\n });\n\n}\nwindow.onload = function () {\n setTimeout(function () {\n ct_protect_external()\n }, 1500);\n};\n\n/**\n * Checking the form integration\n */\nfunction isIntegratedForm(formObj) {\n var formAction = formObj.action;\n\n if(\n formAction.indexOf('activehosted.com') !== -1 || // ActiveCampaign form\n formAction.indexOf('app.convertkit.com') !== -1 || // ConvertKit form\n ( formObj.firstChild.classList !== undefined && formObj.firstChild.classList.contains('cb-form-group') ) || // Convertbox form\n formAction.indexOf('mailerlite.com') !== -1 || // Mailerlite integration\n formAction.indexOf('colcolmail.co.uk') !== -1 || // colcolmail.co.uk integration\n formAction.indexOf('paypal.com') !== -1 ||\n formAction.indexOf('infusionsoft.com') !== -1 ||\n formAction.indexOf('webto.salesforce.com') !== -1 ||\n formAction.indexOf('secure2.convio.net') !== -1 ||\n formAction.indexOf('hookb.in') !== -1 ||\n formAction.indexOf('external.url') !== -1\n ) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Sending Ajax for checking form data\n */\nfunction sendAjaxCheckingFormData(form, prev, formOriginal) {\n // Get visible fields and set cookie\n var visible_fields = {};\n visible_fields[0] = apbct_collect_visible_fields(form);\n apbct_visible_fields_set_cookie( visible_fields );\n\n var data = {};\n var elems = form.elements;\n elems = Array.prototype.slice.call(elems);\n\n elems.forEach( function( elem, y ) {\n if( elem.name === '' ) {\n data['input_' + y] = elem.value;\n } else {\n data[elem.name] = elem.value;\n }\n });\n\n apbct_public_sendAJAX(\n data,\n {\n async: false,\n callback: function( prev, formOriginal, result ){\n\n if( result.apbct === undefined || ! +result.apbct.blocked ) {\n\n var form_new = jQuery(form).detach();\n\n apbct_replace_inputs_values_from_other_form(form_new, formOriginal);\n\n prev.after( formOriginal );\n\n // Common click event\n var subm_button = jQuery(formOriginal).find('button[type=submit]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n return;\n }\n\n subm_button = jQuery(formOriginal).find('input[type=submit]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n return;\n }\n\n // ConvertKit direct integration\n subm_button = jQuery(formOriginal).find('button[data-element=\"submit\"]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n return;\n }\n\n // Paypal integration\n subm_button = jQuery(formOriginal).find('input[type=\"image\"][name=\"submit\"]');\n if( subm_button.length !== 0 ) {\n subm_button[0].click();\n }\n\n }\n },\n callback_context: null,\n callback_params: [prev, formOriginal],\n }\n );\n}\n"],"names":["ct_protect_external","currentForm","prev","form_original","reUseCurrentForm","ct_action","ct_method","i","document","forms","length","undefined","cleantalk_hidden_action","cleantalk_hidden_method","isIntegratedForm","jQuery","before","form_html","outerHTML","detach","after","force_action","createElement","name","value","type","appendChild","classList","contains","mailerliteSubmitButton","find","click","event","preventDefault","sendAjaxCheckingFormData","onsubmit","currentTarget","clone","action","indexOf","split","toLowerCase","location","hostname","method","apbct_replace_inputs_values_from_other_form","form_source","form_target","inputs_source","inputs_target","each","index","elem_source","source","index2","elem_target","target","val","formObj","formAction","firstChild","form","formOriginal","visible_fields","data","apbct_collect_visible_fields","apbct_visible_fields_set_cookie","elems","elements","Array","prototype","slice","call","forEach","elem","y","apbct_public_sendAJAX","async","callback","result","apbct","blocked","subm_button","callback_context","callback_params","window","onload","setTimeout"],"mappings":"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"}
|
lib/Cleantalk/ApbctWP/CleantalkUpgrader.php
CHANGED
@@ -178,6 +178,13 @@ class CleantalkUpgrader extends \Plugin_Upgrader
|
|
178 |
return $result;
|
179 |
}
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
public function rollback($plugin, $args = array())
|
182 |
{
|
183 |
$defaults = array(
|
178 |
return $result;
|
179 |
}
|
180 |
|
181 |
+
/**
|
182 |
+
* @param $plugin
|
183 |
+
* @param $args
|
184 |
+
*
|
185 |
+
* @return array|bool|string|\WP_Error
|
186 |
+
* @psalm-suppress PossiblyUnusedMethod
|
187 |
+
*/
|
188 |
public function rollback($plugin, $args = array())
|
189 |
{
|
190 |
$defaults = array(
|
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
namespace Cleantalk\ApbctWP\Firewall;
|
4 |
|
|
|
5 |
use Cleantalk\Common\Helper;
|
6 |
use Cleantalk\ApbctWP\Variables\Cookie;
|
7 |
use Cleantalk\Variables\Get;
|
@@ -94,7 +95,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule
|
|
94 |
|
95 |
// Cast result to int
|
96 |
$ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
|
97 |
-
$ua_template = isset($entry[1]) &&
|
98 |
$entry[1]
|
99 |
) : 0;
|
100 |
$ua_status = isset($entry[2]) ? $entry[2] : 0;
|
@@ -153,7 +154,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule
|
|
153 |
// Cast result to int
|
154 |
// @ToDo check the output $entry
|
155 |
$ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
|
156 |
-
$ua_template = isset($entry[1]) &&
|
157 |
$ua_status = isset($entry[2]) ? $entry[2] : 0;
|
158 |
|
159 |
$values[] = '(' . $ua_id . ',' . $ua_template . ',' . $ua_status . ')';
|
@@ -501,7 +502,8 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule
|
|
501 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
502 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
503 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
504 |
-
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists())
|
|
|
505 |
);
|
506 |
|
507 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
2 |
|
3 |
namespace Cleantalk\ApbctWP\Firewall;
|
4 |
|
5 |
+
use Cleantalk\ApbctWP\Validate;
|
6 |
use Cleantalk\Common\Helper;
|
7 |
use Cleantalk\ApbctWP\Variables\Cookie;
|
8 |
use Cleantalk\Variables\Get;
|
95 |
|
96 |
// Cast result to int
|
97 |
$ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
|
98 |
+
$ua_template = isset($entry[1]) && Validate::isRegexp($entry[1]) ? Helper::dbPrepareParam(
|
99 |
$entry[1]
|
100 |
) : 0;
|
101 |
$ua_status = isset($entry[2]) ? $entry[2] : 0;
|
154 |
// Cast result to int
|
155 |
// @ToDo check the output $entry
|
156 |
$ua_id = preg_replace('/[^\d]*/', '', $entry[0]);
|
157 |
+
$ua_template = isset($entry[1]) && Validate::isRegexp($entry[1]) ? Helper::dbPrepareParam($entry[1]) : 0;
|
158 |
$ua_status = isset($entry[2]) ? $entry[2] : 0;
|
159 |
|
160 |
$values[] = '(' . $ua_id . ',' . $ua_template . ',' . $ua_status . ')';
|
502 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
503 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
504 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
505 |
+
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists()),
|
506 |
+
'cookiePrefix' => apbct__get_cookie_prefix(),
|
507 |
);
|
508 |
|
509 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php
CHANGED
@@ -263,7 +263,8 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule
|
|
263 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
264 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
265 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
266 |
-
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists())
|
|
|
267 |
);
|
268 |
|
269 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
263 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
264 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
265 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
266 |
+
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists()),
|
267 |
+
'cookiePrefix' => apbct__get_cookie_prefix(),
|
268 |
);
|
269 |
|
270 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
lib/Cleantalk/ApbctWP/Firewall/SFW.php
CHANGED
@@ -19,7 +19,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
19 |
// Additional params
|
20 |
private $sfw_counter = false;
|
21 |
private $api_key = false;
|
22 |
-
private $
|
23 |
private $data__cookies_type = false;
|
24 |
private $cookie_domain = false;
|
25 |
|
@@ -79,6 +79,8 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
79 |
*/
|
80 |
public function check()
|
81 |
{
|
|
|
|
|
82 |
$results = array();
|
83 |
$status = 0;
|
84 |
|
@@ -108,8 +110,8 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
108 |
$this->updateLog($current_ip, 'PASS_SFW');
|
109 |
|
110 |
if ($this->sfw_counter) {
|
111 |
-
$
|
112 |
-
$
|
113 |
}
|
114 |
}
|
115 |
|
@@ -168,6 +170,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
168 |
break;
|
169 |
}
|
170 |
if ((int)$db_result['status'] === 0) {
|
|
|
171 |
$result_entry['status'] = 'DENY_SFW';
|
172 |
}
|
173 |
}
|
@@ -239,9 +242,10 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
239 |
|
240 |
public function actionsForDenied($result)
|
241 |
{
|
|
|
242 |
if ($this->sfw_counter) {
|
243 |
-
$
|
244 |
-
$
|
245 |
}
|
246 |
}
|
247 |
|
@@ -272,9 +276,9 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
272 |
// Statistics
|
273 |
if ( ! empty($this->blocked_ips)) {
|
274 |
reset($this->blocked_ips);
|
275 |
-
$
|
276 |
-
$
|
277 |
-
$
|
278 |
}
|
279 |
|
280 |
// File exists?
|
@@ -318,7 +322,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
318 |
'cleantalk-spam-protect'
|
319 |
) : ''),
|
320 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
321 |
-
'{SERVICE_ID}' => $
|
322 |
'{HOST}' => get_home_url() . ', ' . APBCT_VERSION,
|
323 |
'{GENERATED}' => '<p>The page was generated at ' . date('D, d M Y H:i:s') . '</p>',
|
324 |
'{REQUEST_URI}' => Server::get('REQUEST_URI'),
|
@@ -411,7 +415,8 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
411 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
412 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
413 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
414 |
-
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists())
|
|
|
415 |
);
|
416 |
|
417 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
@@ -432,7 +437,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule
|
|
432 |
die($this->sfw_die_page);
|
433 |
}
|
434 |
|
435 |
-
die("IP BLACKLISTED. Blocked by SFW " . $
|
436 |
}
|
437 |
|
438 |
/**
|
19 |
// Additional params
|
20 |
private $sfw_counter = false;
|
21 |
private $api_key = false;
|
22 |
+
private $blocked_ips = array();
|
23 |
private $data__cookies_type = false;
|
24 |
private $cookie_domain = false;
|
25 |
|
79 |
*/
|
80 |
public function check()
|
81 |
{
|
82 |
+
global $apbct;
|
83 |
+
|
84 |
$results = array();
|
85 |
$status = 0;
|
86 |
|
110 |
$this->updateLog($current_ip, 'PASS_SFW');
|
111 |
|
112 |
if ($this->sfw_counter) {
|
113 |
+
$apbct->data['admin_bar__sfw_counter']['all']++;
|
114 |
+
$apbct->saveData();
|
115 |
}
|
116 |
}
|
117 |
|
170 |
break;
|
171 |
}
|
172 |
if ((int)$db_result['status'] === 0) {
|
173 |
+
$this->blocked_ips[] = Helper::ipLong2ip($db_result['network']);
|
174 |
$result_entry['status'] = 'DENY_SFW';
|
175 |
}
|
176 |
}
|
242 |
|
243 |
public function actionsForDenied($result)
|
244 |
{
|
245 |
+
global $apbct;
|
246 |
if ($this->sfw_counter) {
|
247 |
+
$apbct->data['admin_bar__sfw_counter']['blocked']++;
|
248 |
+
$apbct->saveData();
|
249 |
}
|
250 |
}
|
251 |
|
276 |
// Statistics
|
277 |
if ( ! empty($this->blocked_ips)) {
|
278 |
reset($this->blocked_ips);
|
279 |
+
$apbct->stats['last_sfw_block']['time'] = time();
|
280 |
+
$apbct->stats['last_sfw_block']['ip'] = $result['ip'];
|
281 |
+
$apbct->save('stats');
|
282 |
}
|
283 |
|
284 |
// File exists?
|
322 |
'cleantalk-spam-protect'
|
323 |
) : ''),
|
324 |
'{REMOTE_ADDRESS}' => $result['ip'],
|
325 |
+
'{SERVICE_ID}' => $apbct->data['service_id'] . ', ' . $net_count,
|
326 |
'{HOST}' => get_home_url() . ', ' . APBCT_VERSION,
|
327 |
'{GENERATED}' => '<p>The page was generated at ' . date('D, d M Y H:i:s') . '</p>',
|
328 |
'{REQUEST_URI}' => Server::get('REQUEST_URI'),
|
415 |
'data__cookies_type' => $apbct->data['cookies_type'],
|
416 |
'data__ajax_type' => $apbct->data['ajax_type'],
|
417 |
'sfw__random_get' => $apbct->settings['sfw__random_get'] === '1' ||
|
418 |
+
($apbct->settings['sfw__random_get'] === '-1' && apbct_is_cache_plugins_exists()),
|
419 |
+
'cookiePrefix' => apbct__get_cookie_prefix(),
|
420 |
);
|
421 |
|
422 |
$js_jquery_url = includes_url() . 'js/jquery/jquery.min.js';
|
437 |
die($this->sfw_die_page);
|
438 |
}
|
439 |
|
440 |
+
die("IP BLACKLISTED. Blocked by SFW " . $apbct->stats['last_sfw_block']['ip']);
|
441 |
}
|
442 |
|
443 |
/**
|
lib/Cleantalk/ApbctWP/HTTP/Request.php
CHANGED
@@ -132,8 +132,8 @@ class Request extends \Cleantalk\Common\HTTP\Request
|
|
132 |
|
133 |
case 'ssl':
|
134 |
$this->options['verifyname'] = true;
|
135 |
-
if ( defined('
|
136 |
-
$this->options['verify'] =
|
137 |
}
|
138 |
break;
|
139 |
|
132 |
|
133 |
case 'ssl':
|
134 |
$this->options['verifyname'] = true;
|
135 |
+
if ( defined('APBCT_CASERT_PATH') && APBCT_CASERT_PATH ) {
|
136 |
+
$this->options['verify'] = APBCT_CASERT_PATH;
|
137 |
}
|
138 |
break;
|
139 |
|
lib/Cleantalk/ApbctWP/Helper.php
CHANGED
@@ -97,6 +97,14 @@ class Helper extends \Cleantalk\Common\Helper
|
|
97 |
{
|
98 |
global $apbct;
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
$request_params = array_merge(array(
|
101 |
'spbc_remote_call_token' => md5($apbct->api_key),
|
102 |
'spbc_remote_call_action' => $rc_action,
|
@@ -136,6 +144,14 @@ class Helper extends \Cleantalk\Common\Helper
|
|
136 |
*/
|
137 |
public static function httpRequestRcToHostTest($rc_action, $request_params, $patterns = array())
|
138 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
// Delete async pattern to get the result in this process
|
140 |
$key = array_search('async', $patterns, true);
|
141 |
if ($key) {
|
97 |
{
|
98 |
global $apbct;
|
99 |
|
100 |
+
// RemoteCallsCounter
|
101 |
+
$logging_data = array(
|
102 |
+
'rc_action' => $rc_action,
|
103 |
+
'request_params' => $request_params
|
104 |
+
);
|
105 |
+
$RCCounter = new RemoteCallsCounter($logging_data);
|
106 |
+
$RCCounter->execute();
|
107 |
+
|
108 |
$request_params = array_merge(array(
|
109 |
'spbc_remote_call_token' => md5($apbct->api_key),
|
110 |
'spbc_remote_call_action' => $rc_action,
|
144 |
*/
|
145 |
public static function httpRequestRcToHostTest($rc_action, $request_params, $patterns = array())
|
146 |
{
|
147 |
+
// RemoteCallsCounter
|
148 |
+
$logging_data = array(
|
149 |
+
'rc_action' => $rc_action,
|
150 |
+
'request_params' => $request_params
|
151 |
+
);
|
152 |
+
$RCCounter = new RemoteCallsCounter($logging_data);
|
153 |
+
$RCCounter->execute();
|
154 |
+
|
155 |
// Delete async pattern to get the result in this process
|
156 |
$key = array_search('async', $patterns, true);
|
157 |
if ($key) {
|
lib/Cleantalk/ApbctWP/RemoteCalls.php
CHANGED
@@ -152,14 +152,6 @@ class RemoteCalls
|
|
152 |
return ct_sfw_send_logs();
|
153 |
}
|
154 |
|
155 |
-
/**
|
156 |
-
* Update plugin
|
157 |
-
*/
|
158 |
-
public static function action__update_plugin() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
|
159 |
-
{
|
160 |
-
add_action('wp', 'apbct_rc__update', 1);
|
161 |
-
}
|
162 |
-
|
163 |
/**
|
164 |
* Install plugin
|
165 |
*/
|
152 |
return ct_sfw_send_logs();
|
153 |
}
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
/**
|
156 |
* Install plugin
|
157 |
*/
|
lib/Cleantalk/ApbctWP/RemoteCallsCounter.php
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Cleantalk\ApbctWP;
|
4 |
+
|
5 |
+
class RemoteCallsCounter
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Counter reset period in seconds
|
9 |
+
*/
|
10 |
+
const RESET_PERIOD = 86400;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Number of allowed calls during the reset period
|
14 |
+
*/
|
15 |
+
const CALL_LIMIT = 600;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Maximum number of blocked calls
|
19 |
+
*/
|
20 |
+
const LOG_LIMIT = 10;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Current counter state
|
24 |
+
*/
|
25 |
+
private $state;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* WP option name
|
29 |
+
*/
|
30 |
+
private $option_name = 'cleantalk_rc_counter';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Data for logger
|
34 |
+
*/
|
35 |
+
private $logging_data;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor:
|
39 |
+
* getting or create counter state
|
40 |
+
*
|
41 |
+
* @param array | string | null $logging_data
|
42 |
+
*/
|
43 |
+
public function __construct($logging_data = null)
|
44 |
+
{
|
45 |
+
$current_state = $this->getCounterState();
|
46 |
+
|
47 |
+
// Create new counter, first start
|
48 |
+
if (!$current_state) {
|
49 |
+
$current_state = $this->createCounterState();
|
50 |
+
}
|
51 |
+
|
52 |
+
$this->state = $current_state;
|
53 |
+
|
54 |
+
// Logger
|
55 |
+
if ($logging_data) {
|
56 |
+
$this->logging_data = $logging_data;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get counter state from DB
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
private function getCounterState()
|
66 |
+
{
|
67 |
+
return get_option($this->option_name);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Set counter state to DB
|
72 |
+
*
|
73 |
+
* @param array $state
|
74 |
+
*
|
75 |
+
* @return boolean
|
76 |
+
*/
|
77 |
+
private function setCounterState($state)
|
78 |
+
{
|
79 |
+
return update_option($this->option_name, $state);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Create counter state
|
84 |
+
*
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
private function createCounterState()
|
88 |
+
{
|
89 |
+
$this->state = array(
|
90 |
+
'counter_start_time' => time(),
|
91 |
+
'count_calls' => 1
|
92 |
+
);
|
93 |
+
|
94 |
+
$this->setCounterState($this->state);
|
95 |
+
|
96 |
+
return $this->state;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* What happens when the number of calls is exceeded
|
101 |
+
*
|
102 |
+
* @return void
|
103 |
+
*/
|
104 |
+
private function actionExceedingLimit()
|
105 |
+
{
|
106 |
+
// Logger
|
107 |
+
if (($this->state['count_calls'] - self::CALL_LIMIT) <= self::LOG_LIMIT) {
|
108 |
+
$logger = new RemoteCallsLogger($this->logging_data);
|
109 |
+
$logger->writeLog();
|
110 |
+
}
|
111 |
+
|
112 |
+
die;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Full counter launch with script shutdown
|
117 |
+
*
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function execute()
|
121 |
+
{
|
122 |
+
// Checking the expiration time of the reset period
|
123 |
+
$current_time = time();
|
124 |
+
$counter_start_time = $this->state['counter_start_time'];
|
125 |
+
$time_difference = $current_time - $counter_start_time;
|
126 |
+
|
127 |
+
if ($time_difference > self::RESET_PERIOD) {
|
128 |
+
$this->createCounterState();
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
|
132 |
+
// Checking for exceeding the number of calls
|
133 |
+
$current_count_calls = $this->state['count_calls'];
|
134 |
+
|
135 |
+
if ($current_count_calls >= self::CALL_LIMIT) {
|
136 |
+
// We save the number of calls to log the last few calls
|
137 |
+
++$this->state['count_calls'];
|
138 |
+
$this->setCounterState($this->state);
|
139 |
+
|
140 |
+
$this->actionExceedingLimit();
|
141 |
+
}
|
142 |
+
|
143 |
+
// All right, set updated state
|
144 |
+
++$this->state['count_calls'];
|
145 |
+
$this->setCounterState($this->state);
|
146 |
+
}
|
147 |
+
}
|
lib/Cleantalk/ApbctWP/RemoteCallsLogger.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Cleantalk\ApbctWP;
|
4 |
+
|
5 |
+
class RemoteCallsLogger
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* Data for logging
|
9 |
+
*/
|
10 |
+
private $logging_data;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Message
|
14 |
+
*/
|
15 |
+
private $message;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor: fill logging_data
|
19 |
+
*
|
20 |
+
* @param array | string | null $logging_data
|
21 |
+
*/
|
22 |
+
public function __construct($logging_data)
|
23 |
+
{
|
24 |
+
$this->logging_data = $logging_data;
|
25 |
+
$this->message = $this->createMessage();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Write log
|
30 |
+
*
|
31 |
+
* @return void
|
32 |
+
*/
|
33 |
+
public function writeLog()
|
34 |
+
{
|
35 |
+
error_log(
|
36 |
+
$this->message
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Create message
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
private function createMessage()
|
46 |
+
{
|
47 |
+
$substring = '';
|
48 |
+
|
49 |
+
// logging_data - string
|
50 |
+
if (is_string($this->logging_data)) {
|
51 |
+
return $this->logging_data;
|
52 |
+
}
|
53 |
+
|
54 |
+
// logging_data - array
|
55 |
+
foreach ($this->logging_data as $key => $data) {
|
56 |
+
// if data is array
|
57 |
+
if (is_array($data)) {
|
58 |
+
$substring2 = '';
|
59 |
+
|
60 |
+
foreach ($data as $param => $value) {
|
61 |
+
$substring2 .= "$param: $value; ";
|
62 |
+
}
|
63 |
+
|
64 |
+
$substring .= "[$key]: $substring2; ";
|
65 |
+
} else {
|
66 |
+
$substring .= "$key: $data; ";
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $substring;
|
71 |
+
}
|
72 |
+
}
|
lib/Cleantalk/ApbctWP/State.php
CHANGED
@@ -213,6 +213,9 @@ class State extends \Cleantalk\Common\State
|
|
213 |
// User's test
|
214 |
'count_checked_users' => 0,
|
215 |
'count_bad_users' => 0,
|
|
|
|
|
|
|
216 |
);
|
217 |
|
218 |
public $def_network_settings = array(
|
@@ -254,7 +257,6 @@ class State extends \Cleantalk\Common\State
|
|
254 |
'sfw_send_logs' => array('last_call' => 0, 'cooldown' => 0),
|
255 |
|
256 |
// Installation
|
257 |
-
'update_plugin' => array('last_call' => 0, 'cooldown' => 0),
|
258 |
'install_plugin' => array('last_call' => 0, 'cooldown' => 0),
|
259 |
'activate_plugin' => array('last_call' => 0, 'cooldown' => 0),
|
260 |
'insert_auth_key' => array('last_call' => 0, 'cooldown' => 0),
|
213 |
// User's test
|
214 |
'count_checked_users' => 0,
|
215 |
'count_bad_users' => 0,
|
216 |
+
|
217 |
+
// Check URL exclusion by the new way - as URL
|
218 |
+
'check_exclusion_as_url' => true,
|
219 |
);
|
220 |
|
221 |
public $def_network_settings = array(
|
257 |
'sfw_send_logs' => array('last_call' => 0, 'cooldown' => 0),
|
258 |
|
259 |
// Installation
|
|
|
260 |
'install_plugin' => array('last_call' => 0, 'cooldown' => 0),
|
261 |
'activate_plugin' => array('last_call' => 0, 'cooldown' => 0),
|
262 |
'insert_auth_key' => array('last_call' => 0, 'cooldown' => 0),
|
lib/Cleantalk/ApbctWP/Variables/Cookie.php
CHANGED
@@ -26,6 +26,7 @@ class Cookie extends \Cleantalk\Variables\Cookie
|
|
26 |
$value = AltSessions::get($name);
|
27 |
// The old way
|
28 |
} else {
|
|
|
29 |
if (function_exists('filter_input')) {
|
30 |
$value = filter_input(INPUT_COOKIE, $name);
|
31 |
}
|
@@ -84,7 +85,7 @@ class Cookie extends \Cleantalk\Variables\Cookie
|
|
84 |
} elseif ($apbct->data['cookies_type'] === 'alternative') {
|
85 |
AltSessions::set($name, $value);
|
86 |
} else {
|
87 |
-
self::setNativeCookie($name, $value, $expires, $path, $domain, $secure, $httponly, $samesite);
|
88 |
}
|
89 |
}
|
90 |
|
26 |
$value = AltSessions::get($name);
|
27 |
// The old way
|
28 |
} else {
|
29 |
+
$name = apbct__get_cookie_prefix() . $name;
|
30 |
if (function_exists('filter_input')) {
|
31 |
$value = filter_input(INPUT_COOKIE, $name);
|
32 |
}
|
85 |
} elseif ($apbct->data['cookies_type'] === 'alternative') {
|
86 |
AltSessions::set($name, $value);
|
87 |
} else {
|
88 |
+
self::setNativeCookie(apbct__get_cookie_prefix() . $name, $value, $expires, $path, $domain, $secure, $httponly, $samesite);
|
89 |
}
|
90 |
}
|
91 |
|
lib/Cleantalk/Common/HTTP/Request.php
CHANGED
@@ -506,8 +506,8 @@ class Request
|
|
506 |
case 'ssl':
|
507 |
$this->options[CURLOPT_SSL_VERIFYPEER] = true;
|
508 |
$this->options[CURLOPT_SSL_VERIFYHOST] = 2;
|
509 |
-
if ( defined('
|
510 |
-
$this->options[CURLOPT_CAINFO] =
|
511 |
}
|
512 |
break;
|
513 |
|
506 |
case 'ssl':
|
507 |
$this->options[CURLOPT_SSL_VERIFYPEER] = true;
|
508 |
$this->options[CURLOPT_SSL_VERIFYHOST] = 2;
|
509 |
+
if ( defined('APBCT_CASERT_PATH') && APBCT_CASERT_PATH ) {
|
510 |
+
$this->options[CURLOPT_CAINFO] = APBCT_CASERT_PATH;
|
511 |
}
|
512 |
break;
|
513 |
|
lib/Cleantalk/Common/Helper.php
CHANGED
@@ -1063,7 +1063,7 @@ class Helper
|
|
1063 |
*
|
1064 |
* @return string
|
1065 |
*/
|
1066 |
-
|
1067 |
{
|
1068 |
$array = explode('/', $url);
|
1069 |
|
1063 |
*
|
1064 |
* @return string
|
1065 |
*/
|
1066 |
+
protected static function getFilenameFromUrl($url)
|
1067 |
{
|
1068 |
$array = explode('/', $url);
|
1069 |
|
lib/Cleantalk/Common/Validate.php
CHANGED
@@ -80,9 +80,21 @@ class Validate
|
|
80 |
// TODO
|
81 |
}
|
82 |
|
83 |
-
public static function isUrl($
|
84 |
{
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
}
|
80 |
// TODO
|
81 |
}
|
82 |
|
83 |
+
public static function isUrl($url)
|
84 |
{
|
85 |
+
return ( strpos($url, 'http://') !== false || strpos($url, 'https://') !== false ) &&
|
86 |
+
filter_var($url, FILTER_VALIDATE_URL);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Checks if given string is valid regular expression
|
91 |
+
*
|
92 |
+
* @param string $regexp
|
93 |
+
*
|
94 |
+
* @return bool
|
95 |
+
*/
|
96 |
+
public static function isRegexp($regexp)
|
97 |
+
{
|
98 |
+
return @preg_match('/' . $regexp . '/', '') !== false;
|
99 |
}
|
100 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
|
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 6.0
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 5.
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
@@ -36,6 +36,7 @@ No CAPTCHA, no questions, no animal counting, no puzzles, no math and no spam bo
|
|
36 |
20. Spam FireWall: Anti-Crawler
|
37 |
21. Hide «Website» field for comments
|
38 |
22. Block messages by languages, countries, networks.
|
|
|
39 |
|
40 |
= Free trial then $8 per year =
|
41 |
CleanTalk is an anti-spam plugin which works with the premium Cloud Anti-Spam service cleantalk.org. This plugin as a service <a href="https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#6-software-as-a-service-is-permitted">https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#6-software-as-a-service-is-permitted</a>
|
@@ -293,6 +294,11 @@ This option disables comments on your site. You can choose one or several option
|
|
293 |
|
294 |
When using Disables comments, existing comments will not be deleted and will remain on the pages.
|
295 |
|
|
|
|
|
|
|
|
|
|
|
296 |
= Translations =
|
297 |
* Albanian (sq_AL) - thanks to fjalaime https://wordpress.org/support/users/fjalaime/
|
298 |
* French (fr_FR) - thanks to Gilles Santacreu http://net-ik.net
|
@@ -596,6 +602,38 @@ If your website has forms that send data to external sources, you can enable opt
|
|
596 |
|
597 |
== Changelog ==
|
598 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
= 5.177.2 May 27 2022 =
|
600 |
* Fix. EmailEncoder.php. Fix accident encoding.
|
601 |
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 6.0
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 5.178
|
8 |
License: GPLv2
|
9 |
|
10 |
Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
|
36 |
20. Spam FireWall: Anti-Crawler
|
37 |
21. Hide «Website» field for comments
|
38 |
22. Block messages by languages, countries, networks.
|
39 |
+
23. Email Address Encoder
|
40 |
|
41 |
= Free trial then $8 per year =
|
42 |
CleanTalk is an anti-spam plugin which works with the premium Cloud Anti-Spam service cleantalk.org. This plugin as a service <a href="https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#6-software-as-a-service-is-permitted">https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#6-software-as-a-service-is-permitted</a>
|
294 |
|
295 |
When using Disables comments, existing comments will not be deleted and will remain on the pages.
|
296 |
|
297 |
+
= Email Address Encoder =
|
298 |
+
|
299 |
+
CleanTalk Anti-Spam offers a feature called "Encode contact data" that is designed to encode all email addresses on the website pages. Encoding the email addresses increases the level of protection of contact data from being abused, parsed, getting spammed and used in spam mailing lists by bots and online criminals.
|
300 |
+
To reveal the encoded email address simply click on it and it will be decoded instantly.
|
301 |
+
|
302 |
= Translations =
|
303 |
* Albanian (sq_AL) - thanks to fjalaime https://wordpress.org/support/users/fjalaime/
|
304 |
* French (fr_FR) - thanks to Gilles Santacreu http://net-ik.net
|
602 |
|
603 |
== Changelog ==
|
604 |
|
605 |
+
= 5.178 Jun 02 2022 =
|
606 |
+
#### Comment moderation option added, cookies prefix added, RemoteCalls stability improved and some minor issues fixed.
|
607 |
+
* New. Options. Comment moderation option added on discussion page.
|
608 |
+
* New. Settings. Encode contact data long description added.
|
609 |
+
* New. Cookies. Getting prefix function implemented.
|
610 |
+
* New. Cookies. Get and set cookies with prefix.
|
611 |
+
* New. Cookies. Using cookie prefix on client code.
|
612 |
+
* Mod: Created RemoteCallsCounter::class to limit remote calls
|
613 |
+
* Mod: Created RemoteCallsLogger::class for logging last remote calls
|
614 |
+
* Upd. Comments. Comment moderation logic modified.
|
615 |
+
* Fix: webto.salesforce.com extended form
|
616 |
+
* Fix. SFW. Statistics fixed.
|
617 |
+
* Fix: secure2.convio.net external
|
618 |
+
* Fix: hookb.in external
|
619 |
+
* Fix: fixed test for wpforms
|
620 |
+
* Fix. Pluggable. Getting REST url fixed.
|
621 |
+
* Fix: Formidable Pro Multistep Fixed
|
622 |
+
* Fix: Formidable Form Pro ajax response - fixed
|
623 |
+
* Fix. Settings. Alternative cookies option renamed.
|
624 |
+
* Fix. Common. Cookies test function fixed.
|
625 |
+
* Fix. External forms. JS logic fixed.
|
626 |
+
* Fix. External forms. Force ajax check action handler added.
|
627 |
+
* Fix. cleantalk.php. VisualFormBuilder hook change.
|
628 |
+
* Delete RC update plugin
|
629 |
+
* Fix. cleantalk.php. Visual Form Builder integration: add legacy support.
|
630 |
+
* Fix. Helper. Fatal error (Call to private method) fixed.
|
631 |
+
* Fix. WooCommerce. WC checking order hook changed.
|
632 |
+
* Fix. Settings. Validate URL exclusions.
|
633 |
+
* Fix. cleantalk-public-integrations.php->apbct_form__gravityForms__testSpam. Gravity forms multiple email fields fix.
|
634 |
+
* Fix. SFW updating. Writing update errors fixed.
|
635 |
+
* Fix. cleantalk.php-> apbct_sfw_update__worker() Convert errors array to a string if set in a stage.
|
636 |
+
|
637 |
= 5.177.2 May 27 2022 =
|
638 |
* Fix. EmailEncoder.php. Fix accident encoding.
|
639 |
|