Skip to content

Commit 90d044c

Browse files
authored
Merge pull request #745 from CleanTalk/beta
Beta
2 parents c9a63b6 + 630da0f commit 90d044c

78 files changed

Lines changed: 8291 additions & 2143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cleantalk.php

Lines changed: 35 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Anti-Spam by CleanTalk
55
Plugin URI: https://cleantalk.org
66
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: 6.72
7+
Version: 6.73
88
Author: CleanTalk - Anti-Spam Protection <welcome@cleantalk.org>
99
Author URI: https://cleantalk.org
1010
Text Domain: cleantalk-spam-protect
@@ -1519,92 +1519,13 @@ function apbct_sfw_update__get_multifiles_of_type(array $params)
15191519

15201520
/**
15211521
* Queue stage. Do load multifiles with networks on their urls.
1522-
* @param $urls
1523-
* @return array|array[]|bool|string|string[]
1522+
* @param $all_urls
1523+
* @return array|true
15241524
*/
1525-
function apbct_sfw_update__download_files($urls, $direct_update = false)
1525+
function apbct_sfw_update__download_files($all_urls, $direct_update = false)
15261526
{
1527-
global $apbct;
1528-
1529-
sleep(3);
1530-
1531-
if ( ! is_writable($apbct->fw_stats['updating_folder']) ) {
1532-
return array('error' => 'SFW update folder is not writable.');
1533-
}
1534-
1535-
//Reset keys
1536-
$urls = array_values(array_unique($urls));
1537-
1538-
$results = array();
1539-
$batch_size = 10;
1540-
1541-
/**
1542-
* Reduce batch size of curl multi instanced
1543-
*/
1544-
if (defined('APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE')) {
1545-
if (
1546-
is_int(APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE) &&
1547-
APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE > 0 &&
1548-
APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE < 10
1549-
) {
1550-
$batch_size = APBCT_SERVICE__SFW_UPDATE_CURL_MULTI_BATCH_SIZE;
1551-
};
1552-
}
1553-
1554-
$total_urls = count($urls);
1555-
$batches = ceil($total_urls / $batch_size);
1556-
1557-
for ($i = 0; $i < $batches; $i++) {
1558-
$batch_urls = array_slice($urls, $i * $batch_size, $batch_size);
1559-
if (!empty($batch_urls)) {
1560-
$http_results = Helper::httpMultiRequest($batch_urls, $apbct->fw_stats['updating_folder']);
1561-
if (is_array($http_results)) {
1562-
$results = array_merge($results, $http_results);
1563-
}
1564-
// to handle case if we request only one url, then Helper::httpMultiRequest returns string 'success' instead of array
1565-
if (count($batch_urls) === 1 && $http_results === 'success') {
1566-
$results = array_merge($results, $batch_urls);
1567-
}
1568-
}
1569-
}
1570-
1571-
$results = TT::toArray($results);
1572-
$count_urls = count($urls);
1573-
$count_results = count($results);
1574-
1575-
if ( empty($results['error']) && ($count_urls === $count_results) ) {
1576-
if ( $direct_update ) {
1577-
return true;
1578-
}
1579-
$download_again = array();
1580-
$results = array_values($results);
1581-
for ( $i = 0; $i < $count_results; $i++ ) {
1582-
if ( $results[$i] === 'error' ) {
1583-
$download_again[] = $urls[$i];
1584-
}
1585-
}
1586-
1587-
if ( count($download_again) !== 0 ) {
1588-
return array(
1589-
'error' => 'Files download not completed.',
1590-
'update_args' => array(
1591-
'args' => $download_again
1592-
)
1593-
);
1594-
}
1595-
1596-
return array(
1597-
'next_stage' => array(
1598-
'name' => 'apbct_sfw_update__create_tables'
1599-
)
1600-
);
1601-
}
1602-
1603-
if ( ! empty($results['error']) ) {
1604-
return $results;
1605-
}
1606-
1607-
return array('error' => 'Files download not completed.');
1527+
$downloader = new \Cleantalk\ApbctWP\Firewall\SFWFilesDownloader();
1528+
return $downloader->downloadFiles($all_urls, $direct_update);
16081529
}
16091530

16101531
/**
@@ -2175,6 +2096,11 @@ function apbct_rc__install_plugin($_wp = null, $plugin = null)
21752096
$plugin = Get::get('plugin') ? Get::get('plugin') : '';
21762097
}
21772098

2099+
$allowed_plugin = 'security-malware-firewall/security-malware-firewall.php';
2100+
if ( !empty($plugin) && TT::toString($plugin) !== $allowed_plugin ) {
2101+
die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED')));
2102+
}
2103+
21782104
if ( !empty($plugin) ) {
21792105
$plugin = TT::toString($plugin);
21802106
if ( preg_match('/[a-zA-Z-\d]+[\/\\][a-zA-Z-\d]+\.php/', $plugin) ) {
@@ -2238,6 +2164,12 @@ function apbct_rc__activate_plugin($plugin)
22382164
$plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null;
22392165
}
22402166

2167+
// Only allow activation of Security by CleanTalk plugin via remote call
2168+
$allowed_plugin = 'security-malware-firewall/security-malware-firewall.php';
2169+
if ( $plugin && $plugin !== $allowed_plugin ) {
2170+
return array('error' => 'PLUGIN_NOT_ALLOWED');
2171+
}
2172+
22412173
if ( $plugin ) {
22422174
if ( preg_match('@[a-zA-Z-\d]+[\\\/][a-zA-Z-\d]+\.php@', $plugin) ) {
22432175
require_once(ABSPATH . '/wp-admin/includes/plugin.php');
@@ -2278,6 +2210,15 @@ function apbct_rc__deactivate_plugin($plugin = null)
22782210
$plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null;
22792211
}
22802212

2213+
// Only allow deactivation of CleanTalk plugins via remote call
2214+
$allowed_plugins = array(
2215+
'cleantalk-spam-protect/cleantalk.php',
2216+
'security-malware-firewall/security-malware-firewall.php',
2217+
);
2218+
if ( $plugin && !in_array($plugin, $allowed_plugins, true) ) {
2219+
die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED')));
2220+
}
2221+
22812222
if ( $plugin ) {
22822223
// Switching complete deactivation for security
22832224
if ( $plugin === 'security-malware-firewall/security-malware-firewall.php' && ! empty(Get::get('misc__complete_deactivation')) ) {
@@ -2324,6 +2265,15 @@ function apbct_rc__uninstall_plugin($plugin = null)
23242265
$plugin = Get::get('plugin') ? TT::toString(Get::get('plugin')) : null;
23252266
}
23262267

2268+
// Only allow uninstallation of CleanTalk plugins via remote call
2269+
$allowed_plugins = array(
2270+
'cleantalk-spam-protect/cleantalk.php',
2271+
'security-malware-firewall/security-malware-firewall.php',
2272+
);
2273+
if ( $plugin && !in_array($plugin, $allowed_plugins, true) ) {
2274+
die('FAIL ' . json_encode(array('error' => 'PLUGIN_NOT_ALLOWED')));
2275+
}
2276+
23272277
if ( $plugin ) {
23282278
// Switching complete deactivation for security
23292279
if ( $plugin === 'security-malware-firewall/security-malware-firewall.php' && ! empty(Get::get('misc__complete_deactivation')) ) {

gulpfile.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function minify_all_js_files_except_already_bundled() {
3535
'!js/src/cleantalk-admin.js',
3636
'!js/src/common-decoder.js',
3737
'js/src/public-3-trp.js',
38+
'js/src/public-2-gathering-data.js',
3839
])
3940
.pipe(sourcemaps.init())
4041
.pipe(uglify())
@@ -67,6 +68,9 @@ function bundle_public_default() {
6768
'js/src/common-decoder.js',
6869
'js/src/common-cleantalk-modal.js',
6970
'js/src/public-0*.js',
71+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
72+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
73+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
7074
'js/src/public-1*.js',
7175
'js/src/public-3*.js',
7276
])
@@ -82,6 +86,9 @@ function bundle_public_default_with_gathering() {
8286
'js/src/common-decoder.js',
8387
'js/src/common-cleantalk-modal.js',
8488
'js/src/public-0*.js',
89+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
90+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
91+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
8592
'js/src/public-1*.js',
8693
'js/src/public-2-gathering-data.js',
8794
'js/src/public-3*.js',
@@ -98,6 +105,9 @@ function bundle_public_external_protection() {
98105
'js/src/common-decoder.js',
99106
'js/src/common-cleantalk-modal.js',
100107
'js/src/public-0*.js',
108+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
109+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
110+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
101111
'js/src/public-1*.js',
102112
'js/src/public-2-external-forms.js',
103113
'!js/src/public-2-gathering-data.js',
@@ -115,6 +125,9 @@ function bundle_public_external_protection_with_gathering() {
115125
'js/src/common-decoder.js',
116126
'js/src/common-cleantalk-modal.js',
117127
'js/src/public-0*.js',
128+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
129+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
130+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
118131
'js/src/public-1*.js',
119132
'js/src/public-2-external-forms.js',
120133
'js/src/public-2-gathering-data.js',
@@ -132,6 +145,9 @@ function bundle_public_internal_protection() {
132145
'js/src/common-decoder.js',
133146
'js/src/common-cleantalk-modal.js',
134147
'js/src/public-0*.js',
148+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
149+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
150+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
135151
'js/src/public-1*.js',
136152
'js/src/public-2-internal-forms.js',
137153
'js/src/public-3*.js',
@@ -148,6 +164,9 @@ function bundle_public_internal_protection_with_gathering() {
148164
'js/src/common-decoder.js',
149165
'js/src/common-cleantalk-modal.js',
150166
'js/src/public-0*.js',
167+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
168+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
169+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
151170
'js/src/public-1*.js',
152171
'js/src/public-2-internal-forms.js',
153172
'js/src/public-2-gathering-data.js',
@@ -165,6 +184,9 @@ function bundle_public_full_protection() {
165184
'js/src/common-decoder.js',
166185
'js/src/common-cleantalk-modal.js',
167186
'js/src/public-0*.js',
187+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
188+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
189+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
168190
'js/src/public-1*.js',
169191
'js/src/public-2*.js',
170192
'!js/src/public-2-gathering-data.js',
@@ -182,6 +204,9 @@ function bundle_public_full_protection_with_gathering() {
182204
'js/src/common-decoder.js',
183205
'js/src/common-cleantalk-modal.js',
184206
'js/src/public-0*.js',
207+
'js/src/ShadowrootProtection/ApbctShadowRootCallbacks.js',
208+
'js/src/ShadowrootProtection/ApbctShadowRootConfig.js',
209+
'js/src/ShadowrootProtection/ApbctShadowRootProtection.js',
185210
'js/src/public-1*.js',
186211
'js/src/public-2*.js',
187212
'js/src/public-3*.js',

inc/cleantalk-admin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,10 @@ function apbct_action_adjust_change()
15511551
{
15521552
AJAXService::checkAdminNonce();
15531553

1554+
if (!current_user_can('activate_plugins')) {
1555+
wp_send_json_error('Permission denied');
1556+
}
1557+
15541558
if (in_array(Post::get('adjust'), array_keys(AdjustToEnvironmentHandler::SET_OF_ADJUST))) {
15551559
try {
15561560
$adjust = Post::getString('adjust');
@@ -1570,6 +1574,10 @@ function apbct_action_adjust_reverse()
15701574
{
15711575
AJAXService::checkAdminNonce();
15721576

1577+
if (!current_user_can('activate_plugins')) {
1578+
wp_send_json_error('Permission denied');
1579+
}
1580+
15731581
if (in_array(Post::getString('adjust'), array_keys(AdjustToEnvironmentHandler::SET_OF_ADJUST))) {
15741582
$adjust = Post::getString('adjust');
15751583
try {
@@ -1586,6 +1594,10 @@ function apbct_action_adjust_reverse()
15861594

15871595
function apbct_action__create_support_user()
15881596
{
1597+
if (!current_user_can('activate_plugins')) {
1598+
wp_send_json_error('Permission denied');
1599+
}
1600+
15891601
$support_user = new SupportUser();
15901602
$result = $support_user->ajaxProcess();
15911603
wp_send_json($result);

inc/cleantalk-common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ function apbct_get_sender_info()
684684
'bot_detector_prepared_form_exclusions' => apbct__bot_detector_get_prepared_exclusion(),
685685
'bot_detector_frontend_data_log' => apbct__bot_detector_get_fd_log(),
686686
'submit_time_calculation_enabled' => SubmitTimeHandler::isCalculationDisabled() ? 0 : 1,
687+
'ct_gathering_loaded' => Cookie::getBool('ct_gathering_loaded'),
687688
);
688689

689690
// Unset cookies_enabled from sender_info if cookies_type === none

inc/cleantalk-integrations-by-hook.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@
338338
'setting' => 'forms__registrations_test',
339339
'ajax' => false
340340
),
341+
'MailChimpShadowRoot' => array(
342+
'hook' => 'cleantalk_force_mailchimp_shadowroot_check',
343+
'setting' => 'forms__check_external',
344+
'ajax' => true
345+
),
341346
'BloomForms' => array(
342347
'hook' => 'bloom_subscribe',
343348
'setting' => 'forms__contact_forms_test',

inc/cleantalk-pluggable.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
714714
'nasa_process_login', //Nasa login
715715
'leaky_paywall_validate_registration', //Leaky Paywall validation request
716716
'cleantalk_force_ajax_check', //Force ajax check has direct integration
717+
'cleantalk_force_mailchimp_shadowroot_check', // Mailchimp ShadowRoot has direct integration
717718
'cscf-submitform', // CSCF has direct integration
718719
'mailpoet', // Mailpoet has direct integration
719720
'wpcommunity_auth_login', // WPCommunity login
@@ -783,6 +784,14 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
783784
return 'WS Form submit service request';
784785
}
785786

787+
// UNIT OK https://wordpress.org/plugins/woocommerce-sendinblue-newsletter-subscription/
788+
if (
789+
apbct_is_plugin_active('woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php') &&
790+
Post::getString('action') === 'the_ajax_hook'
791+
) {
792+
return 'woocommerce-sendinblue-newsletter-subscription';
793+
}
794+
786795
// Paid Memberships Pro - Login Form
787796
if (
788797
apbct_is_plugin_active('paid-memberships-pro/paid-memberships-pro.php') &&
@@ -1675,6 +1684,38 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
16751684
) {
16761685
return 'spoki_abandoned_card_for_woocommerce';
16771686
}
1687+
1688+
//UNIT OK https://wordpress.org/plugins/woocommerce-abandoned-cart/
1689+
if (
1690+
apbct_is_plugin_active('woocommerce-abandoned-cart\woocommerce-ac.php') &&
1691+
Post::equal('action', 'save_data')
1692+
) {
1693+
return 'woocommerce-abandoned-cart';
1694+
}
1695+
1696+
//UNIT OK https://wordpress.org/plugins/woo-abandoned-cart-recovery/
1697+
if (
1698+
apbct_is_plugin_active('woo-abandoned-cart-recovery/woo-abandoned-cart-recovery.php') &&
1699+
Post::equal('action', 'wacv_get_info')
1700+
) {
1701+
return 'woo-abandoned-cart-recovery';
1702+
}
1703+
1704+
//UNIT OK unknown wc plugin from https://app.doboard.com/1/task/41205
1705+
if (
1706+
apbct_is_plugin_active('abandoned-cart-capture/abandoned-cart-capture.php') &&
1707+
Post::equal('action', 'acc_save_data')
1708+
) {
1709+
return 'abandoned-cart-capture';
1710+
}
1711+
1712+
//UNIT OK https://wordpress.org/plugins/wp-multi-step-checkout/ multipage request
1713+
if (
1714+
apbct_is_plugin_active('wp-multi-step-checkout/wp-multi-step-checkout.php') &&
1715+
Post::equal('action', 'wpms_checkout_errors')
1716+
) {
1717+
return 'wp-multi-step-checkout';
1718+
}
16781719
} else {
16791720
/*****************************************/
16801721
/* Here is non-ajax requests skipping */

inc/cleantalk-public-validate-skip-functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ function skip_for_ct_contact_form_validate()
253253
'86' => (isset($_POST['action']) && $_POST['action'] === 'check_email_exists'),
254254
// Handling an unknown action check_email_exists
255255
'87' => Server::inUri('cleantalk-antispam/v1/alt_sessions'),
256-
'88' => apbct_is_in_uri('wc-api') && apbct_is_in_uri('WC_Invoice4U'),
256+
'88' => (
257+
(apbct_is_in_uri('wc-api') && apbct_is_in_uri('WC_Invoice4U')) ||
258+
(apbct_is_in_uri('wp-json') && apbct_is_in_uri('invoice4u/v1/callback'))
259+
),
257260
// has direct integration lib/Cleantalk/Antispam/Integrations/MemberPress.php
258261
'89' => apbct_is_plugin_active('memberpress/memberpress.php') && Post::get('mepr_process_signup_form'),
259262
// WooCommerce recovery password form

0 commit comments

Comments
 (0)