Skip to content
Open
19 changes: 9 additions & 10 deletions cleantalk.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,6 @@ function apbct_sfw_update__init($delay = 0)

$wp_upload_dir = wp_upload_dir();
$base_dir = TT::getArrayValueAsString($wp_upload_dir, 'basedir');
$apbct->fw_stats['updating_folder'] = $base_dir . DIRECTORY_SEPARATOR . 'cleantalk_fw_files_for_blog_' . get_current_blog_id() . DIRECTORY_SEPARATOR;
//update only common tables if moderate 0
if ( ! $apbct->moderate ) {
$apbct->data['sfw_load_type'] = 'common';
Expand All @@ -1153,18 +1152,18 @@ function apbct_sfw_update__init($delay = 0)
$apbct->save('data');
}

if (apbct_sfw_update__switch_to_direct()) {
return SFWUpdateHelper::directUpdate();
}

// Set a new update ID and an update time start
// Flush fw stats data
$apbct->fw_stats = $apbct->default_fw_stats;
$apbct->fw_stats['calls'] = 0;
$apbct->fw_stats['firewall_updating_id'] = md5((string)rand(0, 100000));
$apbct->fw_stats['firewall_updating_last_start'] = time();
$apbct->fw_stats['common_lists_url_id'] = '';
$apbct->fw_stats['personal_lists_url_id'] = '';
$apbct->fw_stats['updating_folder'] = $base_dir . DIRECTORY_SEPARATOR . 'cleantalk_fw_files_for_blog_' . get_current_blog_id() . DIRECTORY_SEPARATOR;
$apbct->save('fw_stats');

if (apbct_sfw_update__switch_to_direct()) {
return SFWUpdateHelper::directUpdate();
}

$apbct->sfw_update_sentinel->seekId($apbct->fw_stats['firewall_updating_id']);

// Delete update errors
Expand Down Expand Up @@ -1575,11 +1574,11 @@ function apbct_sfw_update__create_tables($direct_update = false, $return_new_tab
$db_tables_creator->createTable($common_table_name);
$apbct->data['sfw_common_table_name'] = $common_table_name;
//personal table
$table_name_personal = $apbct->db_prefix . Schema::getSchemaTablePrefix() . 'sfw_personal';
$table_name_personal = $wpdb->prefix . Schema::getSchemaTablePrefix() . 'sfw_personal';
$db_tables_creator->createTable($table_name_personal);
$apbct->data['sfw_personal_table_name'] = $table_name_personal;
//ua table
$personal_ua_bl_table_name = $apbct->db_prefix . Schema::getSchemaTablePrefix() . 'ua_bl';
$personal_ua_bl_table_name = $wpdb->prefix . Schema::getSchemaTablePrefix() . 'ua_bl';
$db_tables_creator->createTable($personal_ua_bl_table_name);
$apbct->data['sfw_personal_ua_bl_table_name'] = $personal_ua_bl_table_name;

Expand Down
2 changes: 1 addition & 1 deletion inc/cleantalk-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ function apbct_settings__set_fields()
),
'data__email_check_exist_post' => array(
'title' => __('Show email existence alert when filling in the field', 'cleantalk-spam-protect'),
'description' => __('Checks the email address and shows the result as an icon in the email field before submitting the form. Works for WooCommerce checkout form, FluentForms, Contact Form 7, standard WordPress comment form and registration form.', 'cleantalk-spam-protect'),
'description' => __('Checks the email address and shows the result as an icon in the email field before submitting the form. Works for WooCommerce checkout form, FluentForms, Contact Form 7, Gravity Forms, Ninja Forms, WPForms, standard WordPress comment form and registration form.', 'cleantalk-spam-protect'),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion js/apbct-public-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection_gathering.min.js

Large diffs are not rendered by default.

49 changes: 38 additions & 11 deletions js/prebuild/apbct-public-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ function initParams() {
apbct('form.wpcf7-form input[type = "email"]')
.on('blur', ctDebounceFuncExec(checkEmailExist, 300) );
apbct('form.wpforms-form input[type = "email"]').on('blur', checkEmailExist);
apbct('form[id^="gform_"] input[type = "email"]').on('blur', checkEmailExist);
apbctIntegrateDynamicEmailCheck({
formSelector: '.nf-form-content',
emailSelector: 'input[type="email"], input[type="email"].ninja-forms-field',
Expand Down Expand Up @@ -2925,13 +2926,14 @@ class ApbctHandler {
args[0] &&
typeof args[0].includes === 'function' &&
(args[0].includes('/wp-json/metform/') ||
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})()))
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})())
)
) {
if (args && args[1] && args[1].body) {
if (+ctPublic.settings__data__bot_detector_enabled) {
Expand All @@ -2945,6 +2947,31 @@ class ApbctHandler {
}
}

// WooCommerce add to cart request, like:
// /index.php?rest_route=/wc/store/v1/cart/add-item
if (args && args[0] &&
args[0].includes('/wc/store/v1/cart/add-item') &&
args && args[1] && args[1].body
) {
if (
+ctPublic.settings__data__bot_detector_enabled &&
+ctPublic.settings__forms__wc_add_to_cart
) {
try {
let bodyObj = JSON.parse(args[1].body);
if (!bodyObj.hasOwnProperty('ct_bot_detector_event_token')) {
bodyObj.ct_bot_detector_event_token =
apbctLocalStorage.get('ct_bot_detector_event_token');
args[1].body = JSON.stringify(bodyObj);
}
} catch (e) {
return false;
}
} else {
args[1].body.append('ct_no_cookie_hidden_field', getNoCookieData());
}
}

return defaultFetch.apply(window, args);
};
}
Expand Down Expand Up @@ -3791,15 +3818,15 @@ function ctEmailExistSetElementsPositions(inputEmail) {
backgroundSize = 'inherit';
}
const envelope = document.getElementById('apbct-check_email_exist-block');

if (envelope) {
let offset = 0;
let offsetAfterSize = 0;
if (useAfterSize) {
offset = parseFloat(fontSizeOrWidthAfterStyle);
offsetAfterSize = parseFloat(fontSizeOrWidthAfterStyle);
}
envelope.style.cssText = `
top: ${inputRect.top}px;
left: ${(inputRect.right - envelopeWidth) - offset}px;
left: ${(inputRect.right - envelopeWidth) - offsetAfterSize}px;
height: ${inputHeight}px;
width: ${envelopeWidth}px;
background-size: ${backgroundSize};
Expand Down
49 changes: 38 additions & 11 deletions js/prebuild/apbct-public-bundle_ext-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ function initParams() {
apbct('form.wpcf7-form input[type = "email"]')
.on('blur', ctDebounceFuncExec(checkEmailExist, 300) );
apbct('form.wpforms-form input[type = "email"]').on('blur', checkEmailExist);
apbct('form[id^="gform_"] input[type = "email"]').on('blur', checkEmailExist);
apbctIntegrateDynamicEmailCheck({
formSelector: '.nf-form-content',
emailSelector: 'input[type="email"], input[type="email"].ninja-forms-field',
Expand Down Expand Up @@ -2925,13 +2926,14 @@ class ApbctHandler {
args[0] &&
typeof args[0].includes === 'function' &&
(args[0].includes('/wp-json/metform/') ||
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})()))
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})())
)
) {
if (args && args[1] && args[1].body) {
if (+ctPublic.settings__data__bot_detector_enabled) {
Expand All @@ -2945,6 +2947,31 @@ class ApbctHandler {
}
}

// WooCommerce add to cart request, like:
// /index.php?rest_route=/wc/store/v1/cart/add-item
if (args && args[0] &&
args[0].includes('/wc/store/v1/cart/add-item') &&
args && args[1] && args[1].body
) {
if (
+ctPublic.settings__data__bot_detector_enabled &&
+ctPublic.settings__forms__wc_add_to_cart
) {
try {
let bodyObj = JSON.parse(args[1].body);
if (!bodyObj.hasOwnProperty('ct_bot_detector_event_token')) {
bodyObj.ct_bot_detector_event_token =
apbctLocalStorage.get('ct_bot_detector_event_token');
args[1].body = JSON.stringify(bodyObj);
}
} catch (e) {
return false;
}
} else {
args[1].body.append('ct_no_cookie_hidden_field', getNoCookieData());
}
}

return defaultFetch.apply(window, args);
};
}
Expand Down Expand Up @@ -5082,15 +5109,15 @@ function ctEmailExistSetElementsPositions(inputEmail) {
backgroundSize = 'inherit';
}
const envelope = document.getElementById('apbct-check_email_exist-block');

if (envelope) {
let offset = 0;
let offsetAfterSize = 0;
if (useAfterSize) {
offset = parseFloat(fontSizeOrWidthAfterStyle);
offsetAfterSize = parseFloat(fontSizeOrWidthAfterStyle);
}
envelope.style.cssText = `
top: ${inputRect.top}px;
left: ${(inputRect.right - envelopeWidth) - offset}px;
left: ${(inputRect.right - envelopeWidth) - offsetAfterSize}px;
height: ${inputHeight}px;
width: ${envelopeWidth}px;
background-size: ${backgroundSize};
Expand Down
49 changes: 38 additions & 11 deletions js/prebuild/apbct-public-bundle_ext-protection_gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ function initParams() {
apbct('form.wpcf7-form input[type = "email"]')
.on('blur', ctDebounceFuncExec(checkEmailExist, 300) );
apbct('form.wpforms-form input[type = "email"]').on('blur', checkEmailExist);
apbct('form[id^="gform_"] input[type = "email"]').on('blur', checkEmailExist);
apbctIntegrateDynamicEmailCheck({
formSelector: '.nf-form-content',
emailSelector: 'input[type="email"], input[type="email"].ninja-forms-field',
Expand Down Expand Up @@ -2925,13 +2926,14 @@ class ApbctHandler {
args[0] &&
typeof args[0].includes === 'function' &&
(args[0].includes('/wp-json/metform/') ||
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})()))
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})())
)
) {
if (args && args[1] && args[1].body) {
if (+ctPublic.settings__data__bot_detector_enabled) {
Expand All @@ -2945,6 +2947,31 @@ class ApbctHandler {
}
}

// WooCommerce add to cart request, like:
// /index.php?rest_route=/wc/store/v1/cart/add-item
if (args && args[0] &&
args[0].includes('/wc/store/v1/cart/add-item') &&
args && args[1] && args[1].body
) {
if (
+ctPublic.settings__data__bot_detector_enabled &&
+ctPublic.settings__forms__wc_add_to_cart
) {
try {
let bodyObj = JSON.parse(args[1].body);
if (!bodyObj.hasOwnProperty('ct_bot_detector_event_token')) {
bodyObj.ct_bot_detector_event_token =
apbctLocalStorage.get('ct_bot_detector_event_token');
args[1].body = JSON.stringify(bodyObj);
}
} catch (e) {
return false;
}
} else {
args[1].body.append('ct_no_cookie_hidden_field', getNoCookieData());
}
}

return defaultFetch.apply(window, args);
};
}
Expand Down Expand Up @@ -5957,15 +5984,15 @@ function ctEmailExistSetElementsPositions(inputEmail) {
backgroundSize = 'inherit';
}
const envelope = document.getElementById('apbct-check_email_exist-block');

if (envelope) {
let offset = 0;
let offsetAfterSize = 0;
if (useAfterSize) {
offset = parseFloat(fontSizeOrWidthAfterStyle);
offsetAfterSize = parseFloat(fontSizeOrWidthAfterStyle);
}
envelope.style.cssText = `
top: ${inputRect.top}px;
left: ${(inputRect.right - envelopeWidth) - offset}px;
left: ${(inputRect.right - envelopeWidth) - offsetAfterSize}px;
height: ${inputHeight}px;
width: ${envelopeWidth}px;
background-size: ${backgroundSize};
Expand Down
49 changes: 38 additions & 11 deletions js/prebuild/apbct-public-bundle_full-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ function initParams() {
apbct('form.wpcf7-form input[type = "email"]')
.on('blur', ctDebounceFuncExec(checkEmailExist, 300) );
apbct('form.wpforms-form input[type = "email"]').on('blur', checkEmailExist);
apbct('form[id^="gform_"] input[type = "email"]').on('blur', checkEmailExist);
apbctIntegrateDynamicEmailCheck({
formSelector: '.nf-form-content',
emailSelector: 'input[type="email"], input[type="email"].ninja-forms-field',
Expand Down Expand Up @@ -2925,13 +2926,14 @@ class ApbctHandler {
args[0] &&
typeof args[0].includes === 'function' &&
(args[0].includes('/wp-json/metform/') ||
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})()))
(ctPublicFunctions._rest_url && (() => {
try {
return args[0].includes(new URL(ctPublicFunctions._rest_url).pathname + 'metform/');
} catch (e) {
return false;
}
})())
)
) {
if (args && args[1] && args[1].body) {
if (+ctPublic.settings__data__bot_detector_enabled) {
Expand All @@ -2945,6 +2947,31 @@ class ApbctHandler {
}
}

// WooCommerce add to cart request, like:
// /index.php?rest_route=/wc/store/v1/cart/add-item
if (args && args[0] &&
args[0].includes('/wc/store/v1/cart/add-item') &&
args && args[1] && args[1].body
) {
if (
+ctPublic.settings__data__bot_detector_enabled &&
+ctPublic.settings__forms__wc_add_to_cart
) {
try {
let bodyObj = JSON.parse(args[1].body);
if (!bodyObj.hasOwnProperty('ct_bot_detector_event_token')) {
bodyObj.ct_bot_detector_event_token =
apbctLocalStorage.get('ct_bot_detector_event_token');
args[1].body = JSON.stringify(bodyObj);
}
} catch (e) {
return false;
}
} else {
args[1].body.append('ct_no_cookie_hidden_field', getNoCookieData());
}
}

return defaultFetch.apply(window, args);
};
}
Expand Down Expand Up @@ -5325,15 +5352,15 @@ function ctEmailExistSetElementsPositions(inputEmail) {
backgroundSize = 'inherit';
}
const envelope = document.getElementById('apbct-check_email_exist-block');

if (envelope) {
let offset = 0;
let offsetAfterSize = 0;
if (useAfterSize) {
offset = parseFloat(fontSizeOrWidthAfterStyle);
offsetAfterSize = parseFloat(fontSizeOrWidthAfterStyle);
}
envelope.style.cssText = `
top: ${inputRect.top}px;
left: ${(inputRect.right - envelopeWidth) - offset}px;
left: ${(inputRect.right - envelopeWidth) - offsetAfterSize}px;
height: ${inputHeight}px;
width: ${envelopeWidth}px;
background-size: ${backgroundSize};
Expand Down
Loading
Loading