Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.153.4

Version Description

Mar 10 2021 = * New: SFW. Log could be sent not more often than 3 minutes. * New: SFW. Possibility to use DELETE instead of TRUNCATE to delete SFW log. * New: Show response for all AJAX forms. * Fix: SFW. Sending log. Committing transaction after TRUNCATE log table. * Fix: Integration. CF7 different versions compatibility fixed. * Fix: Exclusion for WooCommerce. * Fix: Possible SQL-injections fixed.

Download this release

Release Info

Developer glomberg
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 5.153.4
Comparing to
See all releases

Code changes from version 5.153.3 to 5.153.4

cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
- Version: 5.153.3
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
@@ -967,26 +967,34 @@ function ct_sfw_update( $api_key = '', $immediate = false ){
967
  function ct_sfw_send_logs($api_key = '')
968
  {
969
  global $apbct;
970
-
971
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
972
-
973
- if( empty( $api_key ) || $apbct->settings['spam_firewall'] != 1 ){
 
 
 
 
974
  return true;
975
  }
976
 
 
 
 
977
  $result = SFW::send_log(
978
  DB::getInstance(),
979
  APBCT_TBL_FIREWALL_LOG,
980
- $api_key
 
981
  );
982
 
983
  if(empty($result['error'])){
984
- $apbct->stats['sfw']['last_send_time'] = time();
985
- $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
986
- $apbct->save('stats');
987
  $apbct->error_delete( 'sfw_send_logs', 'save_settings' );
 
988
  }
989
-
990
  return $result;
991
  }
992
 
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: https://cleantalk.org
5
  Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
6
+ Version: 5.153.4
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: https://cleantalk.org
9
  Text Domain: cleantalk-spam-protect
967
  function ct_sfw_send_logs($api_key = '')
968
  {
969
  global $apbct;
970
+
971
  $api_key = !empty($apbct->api_key) ? $apbct->api_key : $api_key;
972
+
973
+ if(
974
+ time() - $apbct->stats['sfw']['sending_logs__timestamp'] < 180 ||
975
+ empty( $api_key ) ||
976
+ $apbct->settings['spam_firewall'] != 1
977
+ ){
978
  return true;
979
  }
980
 
981
+ $apbct->stats['sfw']['sending_logs__timestamp'] = time();
982
+ $apbct->save('stats');
983
+
984
  $result = SFW::send_log(
985
  DB::getInstance(),
986
  APBCT_TBL_FIREWALL_LOG,
987
+ $api_key,
988
+ (bool) $apbct->settings['sfw__use_delete_to_clear_table']
989
  );
990
 
991
  if(empty($result['error'])){
992
+ $apbct->stats['sfw']['last_send_time'] = time();
993
+ $apbct->stats['sfw']['last_send_amount'] = $result['rows'];
 
994
  $apbct->error_delete( 'sfw_send_logs', 'save_settings' );
995
+ $apbct->save('stats');
996
  }
997
+
998
  return $result;
999
  }
1000
 
inc/cleantalk-public.php CHANGED
@@ -181,7 +181,9 @@ function apbct_init() {
181
  if(defined('WPCF7_VERSION')){
182
  add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
183
  add_filter('wpcf7_validate', 'apbct_form__contactForm7__tesSpam__before_validate', 999, 2);
184
- add_filter(WPCF7_VERSION >= '3.0.0' ? 'wpcf7_spam' : 'wpcf7_acceptance', 'apbct_form__contactForm7__testSpam', 9999, 2);
 
 
185
  }
186
 
187
  // Formidable
@@ -1068,6 +1070,7 @@ function apbct_rorm__formidable__testSpam ( $errors, $form ) {
1068
  $contact_form = $ct_temp_msg_data['contact'] ?: true;
1069
  $message = $ct_temp_msg_data['message'] ?: array();
1070
 
 
1071
  // Adding 'input_meta[]' to every field /Formidable fix/
1072
  // because filed names is 'input_meta[NUM]'
1073
  // Get all scalar values
@@ -2360,7 +2363,7 @@ function apbct_form__contactForm7__tesSpam__before_validate($result = null, $tag
2360
  $invalid_fields = $result->get_invalid_fields();
2361
  if(!empty($invalid_fields) && is_array($invalid_fields)){
2362
  $apbct->validation_error = $invalid_fields[key($invalid_fields)]['reason'];
2363
- apbct_form__contactForm7__testSpam( false, null );
2364
  }
2365
  }
2366
 
@@ -2370,7 +2373,7 @@ function apbct_form__contactForm7__tesSpam__before_validate($result = null, $tag
2370
  /**
2371
  * Test CF7 message for spam
2372
  */
2373
- function apbct_form__contactForm7__testSpam($spam, $submission ) {
2374
 
2375
  global $ct_checkjs_cf7, $apbct;
2376
 
@@ -3333,7 +3336,7 @@ function ct_contact_form_validate() {
3333
  isset($_POST['bbp_topic_content']) ||
3334
  isset($_POST['bbp_reply_content']) ||
3335
  isset($_POST['fscf_submitted']) ||
3336
- apbct_is_in_uri('/wc-api/') ||
3337
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit']) ||
3338
  isset($_POST[$ct_checkjs_frm]) && $apbct->settings['contact_forms_test'] == 1 ||// Formidable forms
3339
  ( isset($_POST['comment_post_ID']) && ! isset($_POST['comment-submit'] ) ) || // The comment form && ! DW Question & Answer
@@ -3608,7 +3611,7 @@ function ct_contact_form_validate_postdata() {
3608
  isset($_POST['bbp_reply_content']) ||
3609
  isset($_POST['fscf_submitted']) ||
3610
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
3611
- apbct_is_in_uri('/wc-api/') ||
3612
  (isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || //WooCommerce recovery password form
3613
  (isset($_POST['woocommerce-login-nonce'], $_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || //WooCommerce login form
3614
  (isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
181
  if(defined('WPCF7_VERSION')){
182
  add_filter('wpcf7_form_elements', 'apbct_form__contactForm7__addField');
183
  add_filter('wpcf7_validate', 'apbct_form__contactForm7__tesSpam__before_validate', 999, 2);
184
+ $hook = WPCF7_VERSION >= '3.0.0' ? 'wpcf7_spam' : 'wpcf7_acceptance';
185
+ $num_arg = WPCF7_VERSION >= '5.3.0' ? 2 : 1;
186
+ add_filter( $hook, 'apbct_form__contactForm7__testSpam', 9999, $num_arg );
187
  }
188
 
189
  // Formidable
1070
  $contact_form = $ct_temp_msg_data['contact'] ?: true;
1071
  $message = $ct_temp_msg_data['message'] ?: array();
1072
 
1073
+ // @todo convert key 'NUM' to 'input_meta[NUM]'
1074
  // Adding 'input_meta[]' to every field /Formidable fix/
1075
  // because filed names is 'input_meta[NUM]'
1076
  // Get all scalar values
2363
  $invalid_fields = $result->get_invalid_fields();
2364
  if(!empty($invalid_fields) && is_array($invalid_fields)){
2365
  $apbct->validation_error = $invalid_fields[key($invalid_fields)]['reason'];
2366
+ apbct_form__contactForm7__testSpam( false );
2367
  }
2368
  }
2369
 
2373
  /**
2374
  * Test CF7 message for spam
2375
  */
2376
+ function apbct_form__contactForm7__testSpam( $spam, $submission = null ) {
2377
 
2378
  global $ct_checkjs_cf7, $apbct;
2379
 
3336
  isset($_POST['bbp_topic_content']) ||
3337
  isset($_POST['bbp_reply_content']) ||
3338
  isset($_POST['fscf_submitted']) ||
3339
+ apbct_is_in_uri('/wc-api') ||
3340
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit']) ||
3341
  isset($_POST[$ct_checkjs_frm]) && $apbct->settings['contact_forms_test'] == 1 ||// Formidable forms
3342
  ( isset($_POST['comment_post_ID']) && ! isset($_POST['comment-submit'] ) ) || // The comment form && ! DW Question & Answer
3611
  isset($_POST['bbp_reply_content']) ||
3612
  isset($_POST['fscf_submitted']) ||
3613
  isset($_POST['log']) && isset($_POST['pwd']) && isset($_POST['wp-submit'])||
3614
+ apbct_is_in_uri('/wc-api') ||
3615
  (isset($_POST['wc_reset_password'], $_POST['_wpnonce'], $_POST['_wp_http_referer'])) || //WooCommerce recovery password form
3616
  (isset($_POST['woocommerce-login-nonce'], $_POST['login'], $_POST['password'], $_POST['_wp_http_referer'])) || //WooCommerce login form
3617
  (isset($_POST['provider'], $_POST['authcode']) && $_POST['provider'] == 'Two_Factor_Totp') || //TwoFactor authorization
inc/cleantalk-settings.php CHANGED
@@ -102,7 +102,7 @@ function apbct_settings__set_fileds( $fields ){
102
  'type' => 'checkbox',
103
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
104
  'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
105
- 'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler'),
106
  ),
107
  'sfw__anti_crawler' => array(
108
  'type' => 'checkbox',
@@ -307,6 +307,11 @@ function apbct_settings__set_fileds( $fields ){
307
  'title' => __("Use Wordpress HTTP API", 'cleantalk-spam-protect'),
308
  'description' => __('Alternative way to connect the Cloud. Use this if you have connection problems.', 'cleantalk-spam-protect'),
309
  ),
 
 
 
 
 
310
  ),
311
  ),
312
 
102
  'type' => 'checkbox',
103
  'title' => __('SpamFireWall', 'cleantalk-spam-protect'),
104
  'description' => __("This option allows to filter spam bots before they access website. Also reduces CPU usage on hosting server and accelerates pages load time.", 'cleantalk-spam-protect'),
105
+ 'childrens' => array('sfw__anti_flood', 'sfw__anti_crawler', 'sfw__use_delete_to_clear_table'),
106
  ),
107
  'sfw__anti_crawler' => array(
108
  'type' => 'checkbox',
307
  'title' => __("Use Wordpress HTTP API", 'cleantalk-spam-protect'),
308
  'description' => __('Alternative way to connect the Cloud. Use this if you have connection problems.', 'cleantalk-spam-protect'),
309
  ),
310
+ 'sfw__use_delete_to_clear_table' => array(
311
+ 'title' => __("Use DELETE SQL-command instead TRUNCATE to clear tables", 'cleantalk-spam-protect'),
312
+ 'description' => __('Could help if you have blocked SpamFireWall tables in your database.', 'cleantalk-spam-protect'),
313
+ 'parent' => 'spam_firewall',
314
+ ),
315
  ),
316
  ),
317
 
inc/cleantalk-updater.php CHANGED
@@ -740,3 +740,12 @@ function apbct_update_to_5_151_6 ()
740
  global $apbct;
741
  $apbct->error_delete( 'sfw_update', true );
742
  }
 
 
 
 
 
 
 
 
 
740
  global $apbct;
741
  $apbct->error_delete( 'sfw_update', true );
742
  }
743
+
744
+ function apbct_update_to_5_153_4(){
745
+
746
+ // Adding cooldown to sending SFW logs
747
+ global $apbct;
748
+ $apbct->stats['sfw']['sending_logs__timestamp'] = 0;
749
+ $apbct->save('stats');
750
+
751
+ }
js/apbct-public.min.js CHANGED
@@ -1,2 +1,2 @@
1
- function ctSetCookie(e,t){document.cookie=e+"="+encodeURIComponent(t)+"; path=/; samesite=lax"}function apbct_collect_visible_fields(e){var t=[],o="",n=0,i=[];for(var a in e.elements)isNaN(+a)||(t[a]=e.elements[a]);return(t=t.filter(function(e){return"none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")&&"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&-1===i.indexOf(e.getAttribute("name"))&&(n++,-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(i.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){o+=" "+e.getAttribute("name")}),{visible_fields:o=o.trim(),visible_fields_count:n}}function apbct_visible_fields_set_cookie(e){var t="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(t))}function apbct_js_keys__set_input_value(e,t,n,o){var i;null!==document.getElementById(n.input_name)&&(i=document.getElementById(n.input_name).value,document.getElementById(n.input_name).value=document.getElementById(n.input_name).value.replace(i,e.js_key))}function apbct_public_sendAJAX(t,n,o){var i=n.callback||null,a=n.callback_context||null,c=n.callback_params||null,e=n.async||!0,s=n.notJson||null,l=n.timeout||15e3,o=o||null,r=n.button||null,u=n.spinner||null,p=n.progressbar||null,d=n.silent||null,m=n.no_nonce||null;"string"==typeof t?(m||(t=t+"&_ajax_nonce="+ctPublic._ajax_nonce),t=t+"&no_cache="+Math.random()):(m||(t._ajax_nonce=ctPublic._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:ctPublic._ajax_url,data:t,async:e,success:function(e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),s||(e=JSON.parse(e)),e.error?(setTimeout(function(){p&&p.fadeOut("slow")},1e3),alert("Error happens: "+(e.error||"Unkown"))):i&&(c?i.apply(a,c.concat(e,t,n,o)):i(e,t,n,o))},error:function(e,t,n){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),n&&!d&&(console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"),alert("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:l})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0;function a(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function c(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}ctSetCookie("ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)),ctSetCookie("ct_fkp_timestamp","0"),ctSetCookie("ct_pointer_data","0"),ctSetCookie("ct_timezone","0"),setTimeout(function(){ctSetCookie("ct_timezone",e.getTimezoneOffset()/60*-1)},1e3);var s=function(){ctSetCookie("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),c(window,"mousedown",s),c(window,"keydown",s)},l=setInterval(function(){n=!0},150),r=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),u=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(c(window,"mousemove",u),clearInterval(l),clearInterval(r)))};a(window,"mousemove",u),a(window,"mousedown",s),a(window,"keydown",s),a(window,"DOMContentLoaded",function(){ctSetCookie("apbct_visible_fields",0),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var n=document.forms[t];n.classList.contains("slp_search_form")||n.parentElement.classList.contains("mec-booking")||-1!==n.action.toString().indexOf("activehosted.com")||n.id&&"caspioform"==n.id||n.name.classList&&n.name.classList.contains("tinkoffPayRow")||(e[t]=apbct_collect_visible_fields(n),n.onsubmit_prev=n.onsubmit,n.onsubmit=function(e){var t={};t[0]=apbct_collect_visible_fields(this),apbct_visible_fields_set_cookie(t),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}apbct_visible_fields_set_cookie(e)},1e3)})}(),"undefined"!=typeof jQuery&&jQuery(document).ajaxComplete(function(e,t,n){var o,i;!t.responseText||-1===t.responseText.indexOf('"apbct')||void 0!==(i=JSON.parse(t.responseText)).apbct&&(i=i.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:i.comment}})),(o=document.createElement("div")).setAttribute("id","apbct-result"),o.style.display="none",o.innerHTML=i.comment,document.body.append(o),cleantalkModal.open("apbct-result"),1==+i.stop_script&&window.stop())});
2
  //# sourceMappingURL=apbct-public.min.js.map
1
+ function ctSetCookie(e,t){document.cookie=e+"="+encodeURIComponent(t)+"; path=/; samesite=lax"}function apbct_collect_visible_fields(e){var t,n=[],o="",i=0,a=[];for(t in e.elements)isNaN(+t)||(n[t]=e.elements[t]);return(n=n.filter(function(e){return"none"!==getComputedStyle(e).display&&"hidden"!==getComputedStyle(e).visibility&&"0"!==getComputedStyle(e).opacity&&"hidden"!==e.getAttribute("type")&&"submit"!==e.getAttribute("type")&&null!==e.getAttribute("name")&&-1===a.indexOf(e.getAttribute("name"))&&(i++,-1===["radio","checkbox"].indexOf(e.getAttribute("type"))||(a.push(e.getAttribute("name")),!1))})).forEach(function(e,t,n){o+=" "+e.getAttribute("name")}),{visible_fields:o=o.trim(),visible_fields_count:i}}function apbct_visible_fields_set_cookie(e){e="object"==typeof e&&null!==e?e:{};ctSetCookie("apbct_visible_fields",JSON.stringify(e))}function apbct_js_keys__set_input_value(e,t,n,o){var i;null!==document.getElementById(n.input_name)&&(i=document.getElementById(n.input_name).value,document.getElementById(n.input_name).value=document.getElementById(n.input_name).value.replace(i,e.js_key))}function apbct_public_sendAJAX(t,n,o){var i=n.callback||null,a=n.callback_context||null,c=n.callback_params||null,e=n.async||!0,s=n.notJson||null,l=n.timeout||15e3,o=o||null,r=n.button||null,u=n.spinner||null,p=n.progressbar||null,d=n.silent||null,m=n.no_nonce||null;"string"==typeof t?t=(t=!m?t+"&_ajax_nonce="+ctPublic._ajax_nonce:t)+"&no_cache="+Math.random():(m||(t._ajax_nonce=ctPublic._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:ctPublic._ajax_url,data:t,async:e,success:function(e){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),(e=!s?JSON.parse(e):e).error?(setTimeout(function(){p&&p.fadeOut("slow")},1e3),alert("Error happens: "+(e.error||"Unkown"))):i&&(c?i.apply(a,c.concat(e,t,n,o)):i(e,t,n,o))},error:function(e,t,n){r&&(r.removeAttribute("disabled"),r.style.cursor="pointer"),u&&jQuery(u).css("display","none"),n&&!d&&(console.log("APBCT_AJAX_ERROR"),console.log(e),console.log(t),console.log("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"),alert("Anti-spam by Cleantalk plugin error: "+n+"Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/"))},timeout:l})}!function(){var e=new Date,t=(new Date).getTime(),n=!0,o=[],i=0;function a(e,t,n){"function"==typeof window.addEventListener?e.addEventListener(t,n):e.attachEvent(t,n)}function c(e,t,n){"function"==typeof window.removeEventListener?e.removeEventListener(t,n):e.detachEvent(t,n)}ctSetCookie("ct_ps_timestamp",Math.floor((new Date).getTime()/1e3)),ctSetCookie("ct_fkp_timestamp","0"),ctSetCookie("ct_pointer_data","0"),ctSetCookie("ct_timezone","0"),setTimeout(function(){ctSetCookie("ct_timezone",e.getTimezoneOffset()/60*-1)},1e3);var s=function(e){ctSetCookie("ct_fkp_timestamp",Math.floor((new Date).getTime()/1e3)),c(window,"mousedown",s),c(window,"keydown",s)},l=setInterval(function(){n=!0},150),r=setInterval(function(){ctSetCookie("ct_pointer_data",JSON.stringify(o))},1200),u=function(e){!0===n&&(o.push([Math.round(e.clientY),Math.round(e.clientX),Math.round((new Date).getTime()-t)]),n=!1,50<=++i&&(c(window,"mousemove",u),clearInterval(l),clearInterval(r)))};a(window,"mousemove",u),a(window,"mousedown",s),a(window,"keydown",s),a(window,"DOMContentLoaded",function(){ctSetCookie("apbct_visible_fields",0),setTimeout(function(){for(var e={},t=0;t<document.forms.length;t++){var n=document.forms[t];n.classList.contains("slp_search_form")||n.parentElement.classList.contains("mec-booking")||-1!==n.action.toString().indexOf("activehosted.com")||n.id&&"caspioform"==n.id||n.name.classList&&n.name.classList.contains("tinkoffPayRow")||(e[t]=apbct_collect_visible_fields(n),n.onsubmit_prev=n.onsubmit,n.onsubmit=function(e){var t={};t[0]=apbct_collect_visible_fields(this),apbct_visible_fields_set_cookie(t),e.target.onsubmit_prev instanceof Function&&setTimeout(function(){e.target.onsubmit_prev.call(e.target,e)},500)})}apbct_visible_fields_set_cookie(e)},1e3)})}();var accessor=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"responseText");Object.defineProperty(XMLHttpRequest.prototype,"responseText",{get:function(){return apbct_showBlockedResponse(this.response),accessor.get.call(this)},configurable:!0}),apbct_showBlockedResponse=function(e){var t;return void 0!==(e=JSON.parse(e)).apbct&&(e=e.apbct).blocked&&(document.dispatchEvent(new CustomEvent("apbctAjaxBockAlert",{bubbles:!0,detail:{message:e.comment}})),(t=document.createElement("div")).setAttribute("id","apbct-result"),t.style.display="none",t.innerHTML=e.comment,document.body.append(t),cleantalkModal.open("apbct-result"),1==+e.stop_script&&window.stop()),!0};
2
  //# sourceMappingURL=apbct-public.min.js.map
js/apbct-public.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0;\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookie(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\n\tctSetCookie(\"ct_fkp_timestamp\", \"0\");\n\tctSetCookie(\"ct_pointer_data\", \"0\");\n\tctSetCookie(\"ct_timezone\", \"0\");\n\n\tsetTimeout(function(){\n\t\tctSetCookie(\"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1));\n\t},1000);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookie(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookie(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\n\t\tctSetCookie(\"apbct_visible_fields\", 0);\n\n\t\tsetTimeout(function(){\n\n\t\t\tvar visible_fields_collection = {};\n\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for forms\n\t\t\t\tif (\n\t\t\t\t\tform.classList.contains('slp_search_form') || //StoreLocatorPlus form\n\t\t\t\t\tform.parentElement.classList.contains('mec-booking') ||\n\t\t\t\t\tform.action.toString().indexOf('activehosted.com') !== -1 || // Active Campaign\n\t\t\t\t\t(form.id && form.id == 'caspioform') || //Caspio Form\n\t\t\t\t\tform.name.classList && form.name.classList.contains('tinkoffPayRow') //TinkoffPayForm\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tvisible_fields_collection[i] = apbct_collect_visible_fields( form );\n\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function (event) {\n\n\t\t\t\t\tvar visible_fields = {};\n\t\t\t\t\tvisible_fields[0] = apbct_collect_visible_fields(this);\n\t\t\t\t\tapbct_visible_fields_set_cookie( visible_fields );\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif (event.target.onsubmit_prev instanceof Function) {\n\t\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tapbct_visible_fields_set_cookie( visible_fields_collection );\n\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction ctSetCookie(c_name, value) {\n\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/; samesite=lax\";\n}\n\nfunction apbct_collect_visible_fields( form ) {\n\n\t// Get only fields\n\tvar inputs = [],\n\t\tinputs_visible = '',\n\t\tinputs_visible_count = 0,\n\t\tinputs_with_duplicate_names = [];\n\n\tfor(var key in form.elements){\n\t\tif(!isNaN(+key))\n\t\t\tinputs[key] = form.elements[key];\n\t}\n\n\t// Filter fields\n\tinputs = inputs.filter(function(elem){\n\n\t\t// Filter fields\n\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\n\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\n\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\t//elem.value === \"\" || // empty value\n\t\t\telem.getAttribute('name') === null ||\n\t\t\tinputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 // name already added\n\t\t){\n\t\t\treturn false;\n\t\t}\n\n\t\t// Visible fields count\n\t\tinputs_visible_count++;\n\n\t\t// Filter inputs with same names for type == radio\n\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\n\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t});\n\n\t// Visible fields\n\tinputs.forEach(function(elem, i, elements){\n\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t});\n\tinputs_visible = inputs_visible.trim();\n\n\treturn {\n\t\tvisible_fields : inputs_visible,\n\t\tvisible_fields_count : inputs_visible_count,\n\t}\n\n}\n\nfunction apbct_visible_fields_set_cookie( visible_fields_collection ) {\n\n\tvar collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {};\n\n\tctSetCookie(\"apbct_visible_fields\", JSON.stringify( collection ) );\n\n}\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif (document.getElementById(params.input_name) !== null) {\n\t\tvar ct_input_value = document.getElementById(params.input_name).value;\n\t\tdocument.getElementById(params.input_name).value = document.getElementById(params.input_name).value.replace(ct_input_value, result.js_key);\n\t}\n}\nfunction apbct_public_sendAJAX(data, params, obj){\n\n\t// Default params\n\tvar callback = params.callback || null;\n\tvar callback_context = params.callback_context || null;\n\tvar callback_params = params.callback_params || null;\n\tvar async = params.async || true;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar silent = params.silent || null;\n\tvar no_nonce = params.no_nonce || null;\n\n\tif(typeof (data) === 'string') {\n\t\tif( ! no_nonce )\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce;\n\t\tdata = data + '&no_cache=' + Math.random()\n\t} else {\n\t\tif( ! no_nonce )\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\t\tdata.no_cache = Math.random();\n\t}\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ctPublic._ajax_url,\n\t\tdata: data,\n\t\tasync: async,\n\t\tsuccess: function(result){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif(!notJson) result = JSON.parse(result);\n\t\t\tif(result.error){\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\t\talert('Error happens: ' + (result.error || 'Unkown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tif (callback_params)\n\t\t\t\t\t\tcallback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n\t\t\t\t\telse\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif( errorThrown && ! silent ) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t\talert('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t\ttimeout: timeout,\n\t});\n}\nif(typeof jQuery !== 'undefined') {\n\n\t// Capturing responses and output block message for unknown AJAX forms\n\tjQuery(document).ajaxComplete(function (event, xhr, settings) {\n\t\tif (xhr.responseText && xhr.responseText.indexOf('\"apbct') !== -1) {\n\t\t\tvar response = JSON.parse(xhr.responseText);\n\t\t\tif (typeof response.apbct !== 'undefined') {\n\t\t\t\tresponse = response.apbct;\n\t\t\t\tif (response.blocked) {\n\t\t\t\t\tdocument.dispatchEvent(\n\t\t\t\t\t\tnew CustomEvent( \"apbctAjaxBockAlert\", {\n\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\tdetail: { message: response.comment }\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\t// Create hidden element contains result.\n\t\t\t\t\tvar apbct_result = document.createElement( 'div' );\n\t\t\t\t\tapbct_result.setAttribute( 'id', 'apbct-result' );\n\t\t\t\t\tapbct_result.style.display = 'none';\n\t\t\t\t\tapbct_result.innerHTML = response.comment;\n\t\t\t\t\tdocument.body.append( apbct_result );\n\n\t\t\t\t\t// Show the element\n\t\t\t\t\tcleantalkModal.open('apbct-result');\n\n\t\t\t\t\tif(+response.stop_script == 1)\n\t\t\t\t\t\twindow.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}"],"names":["ctSetCookie","c_name","value","document","cookie","encodeURIComponent","apbct_collect_visible_fields","form","inputs","inputs_visible","inputs_visible_count","inputs_with_duplicate_names","key","elements","isNaN","filter","elem","getComputedStyle","display","visibility","opacity","getAttribute","indexOf","push","forEach","i","visible_fields","trim","visible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","ct_input_value","getElementById","input_name","replace","js_key","apbct_public_sendAJAX","callback","callback_context","callback_params","async","notJson","timeout","button","spinner","progressbar","silent","no_nonce","ctPublic","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","alert","apply","concat","jqXHR","textStatus","errorThrown","console","log","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","forms","length","classList","contains","parentElement","action","toString","id","name","onsubmit_prev","onsubmit","this","target","Function","call","ajaxComplete","xhr","settings","apbct_result","response","responseText","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","createElement","innerHTML","body","append","cleantalkModal","open","stop_script","stop"],"mappings":"AA+HA,SAASA,YAAYC,EAAQC,GAC5BC,SAASC,OAASH,EAAS,IAAMI,mBAAmBH,GAAS,yBAG9D,SAASI,6BAA8BC,GAGtC,IAAIC,EAAS,GACZC,EAAiB,GACjBC,EAAuB,EACvBC,EAA8B,GAE/B,IAAI,IAAIC,KAAOL,EAAKM,SACfC,OAAOF,KACVJ,EAAOI,GAAOL,EAAKM,SAASD,IAqC9B,OAjCAJ,EAASA,EAAOO,OAAO,SAASC,GAG/B,MAA0C,SAAtCC,iBAAiBD,GAAME,SACY,WAAtCD,iBAAiBD,GAAMG,YACe,MAAtCF,iBAAiBD,GAAMI,SACe,WAAtCJ,EAAKK,aAAa,SACoB,WAAtCL,EAAKK,aAAa,SAEoB,OAAtCL,EAAKK,aAAa,UACoD,IAAtEV,EAA4BW,QAASN,EAAKK,aAAa,WAMxDX,KAGK,IAAM,CAAC,QAAS,YAAYY,QAASN,EAAKK,aAAa,WAC3DV,EAA4BY,KAAMP,EAAKK,aAAa,UAC7C,OAOFG,QAAQ,SAASR,EAAMS,EAAGZ,GAChCJ,GAAkB,IAAMO,EAAKK,aAAa,UAIpC,CACNK,eAHDjB,EAAiBA,EAAekB,OAI/BC,qBAAuBlB,GAKzB,SAASmB,gCA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GAuQqB,oBAAXkC,QAGTA,OAAO7D,UAAU0H,aAAa,SAAUjC,EAAOkC,EAAKC,GACnD,IAaOC,EAVLC,GAHEH,EAAII,eAAwD,IAAxCJ,EAAII,aAAa5G,QAAQ,gBAElB,KAD1B2G,EAAWjG,KAAKwC,MAAMsD,EAAII,eACVC,QACnBF,EAAWA,EAASE,OACPC,UACZjI,SAASkI,cACR,IAAIC,YAAa,qBAAsB,CACtCC,SAAS,EACTC,OAAQ,CAAEC,QAASR,EAASS,aAK1BV,EAAe7H,SAASwI,cAAe,QAC9B9E,aAAc,KAAM,gBACjCmE,EAAalE,MAAM5C,QAAU,OAC7B8G,EAAaY,UAAYX,EAASS,QAClCvI,SAAS0I,KAAKC,OAAQd,GAGtBe,eAAeC,KAAK,gBAEQ,IAAxBf,EAASgB,aACZpD,OAAOqD"}
1
+ {"version":3,"file":"apbct-public.min.js","sources":["apbct-public.js"],"sourcesContent":["(function() {\n\n\tvar ct_date = new Date(),\n\t\tctTimeMs = new Date().getTime(),\n\t\tctMouseEventTimerFlag = true, //Reading interval flag\n\t\tctMouseData = [],\n\t\tctMouseDataCounter = 0;\n\n\tfunction apbct_attach_event_handler(elem, event, callback){\n\t\tif(typeof window.addEventListener === \"function\") elem.addEventListener(event, callback);\n\t\telse elem.attachEvent(event, callback);\n\t}\n\n\tfunction apbct_remove_event_handler(elem, event, callback){\n\t\tif(typeof window.removeEventListener === \"function\") elem.removeEventListener(event, callback);\n\t\telse elem.detachEvent(event, callback);\n\t}\n\n\tctSetCookie(\"ct_ps_timestamp\", Math.floor(new Date().getTime()/1000));\n\tctSetCookie(\"ct_fkp_timestamp\", \"0\");\n\tctSetCookie(\"ct_pointer_data\", \"0\");\n\tctSetCookie(\"ct_timezone\", \"0\");\n\n\tsetTimeout(function(){\n\t\tctSetCookie(\"ct_timezone\", ct_date.getTimezoneOffset()/60*(-1));\n\t},1000);\n\n\t//Writing first key press timestamp\n\tvar ctFunctionFirstKey = function output(event){\n\t\tvar KeyTimestamp = Math.floor(new Date().getTime()/1000);\n\t\tctSetCookie(\"ct_fkp_timestamp\", KeyTimestamp);\n\t\tctKeyStopStopListening();\n\t};\n\n\t//Reading interval\n\tvar ctMouseReadInterval = setInterval(function(){\n\t\tctMouseEventTimerFlag = true;\n\t}, 150);\n\n\t//Writting interval\n\tvar ctMouseWriteDataInterval = setInterval(function(){\n\t\tctSetCookie(\"ct_pointer_data\", JSON.stringify(ctMouseData));\n\t}, 1200);\n\n\t//Logging mouse position each 150 ms\n\tvar ctFunctionMouseMove = function output(event){\n\t\tif(ctMouseEventTimerFlag === true){\n\n\t\t\tctMouseData.push([\n\t\t\t\tMath.round(event.clientY),\n\t\t\t\tMath.round(event.clientX),\n\t\t\t\tMath.round(new Date().getTime() - ctTimeMs)\n\t\t\t]);\n\n\t\t\tctMouseDataCounter++;\n\t\t\tctMouseEventTimerFlag = false;\n\t\t\tif(ctMouseDataCounter >= 50){\n\t\t\t\tctMouseStopData();\n\t\t\t}\n\t\t}\n\t};\n\n\t//Stop mouse observing function\n\tfunction ctMouseStopData(){\n\t\tapbct_remove_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\t\tclearInterval(ctMouseReadInterval);\n\t\tclearInterval(ctMouseWriteDataInterval);\n\t}\n\n\t//Stop key listening function\n\tfunction ctKeyStopStopListening(){\n\t\tapbct_remove_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\t\tapbct_remove_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\t}\n\n\tapbct_attach_event_handler(window, \"mousemove\", ctFunctionMouseMove);\n\tapbct_attach_event_handler(window, \"mousedown\", ctFunctionFirstKey);\n\tapbct_attach_event_handler(window, \"keydown\", ctFunctionFirstKey);\n\n\t// Ready function\n\tfunction apbct_ready(){\n\n\t\tctSetCookie(\"apbct_visible_fields\", 0);\n\n\t\tsetTimeout(function(){\n\n\t\t\tvar visible_fields_collection = {};\n\n\t\t\tfor(var i = 0; i < document.forms.length; i++){\n\t\t\t\tvar form = document.forms[i];\n\n\t\t\t\t//Exclusion for forms\n\t\t\t\tif (\n\t\t\t\t\tform.classList.contains('slp_search_form') || //StoreLocatorPlus form\n\t\t\t\t\tform.parentElement.classList.contains('mec-booking') ||\n\t\t\t\t\tform.action.toString().indexOf('activehosted.com') !== -1 || // Active Campaign\n\t\t\t\t\t(form.id && form.id == 'caspioform') || //Caspio Form\n\t\t\t\t\tform.name.classList && form.name.classList.contains('tinkoffPayRow') //TinkoffPayForm\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tvisible_fields_collection[i] = apbct_collect_visible_fields( form );\n\n\t\t\t\tform.onsubmit_prev = form.onsubmit;\n\t\t\t\tform.onsubmit = function (event) {\n\n\t\t\t\t\tvar visible_fields = {};\n\t\t\t\t\tvisible_fields[0] = apbct_collect_visible_fields(this);\n\t\t\t\t\tapbct_visible_fields_set_cookie( visible_fields );\n\n\t\t\t\t\t// Call previous submit action\n\t\t\t\t\tif (event.target.onsubmit_prev instanceof Function) {\n\t\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\t\tevent.target.onsubmit_prev.call(event.target, event);\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tapbct_visible_fields_set_cookie( visible_fields_collection );\n\n\t\t}, 1000);\n\t}\n\tapbct_attach_event_handler(window, \"DOMContentLoaded\", apbct_ready);\n\n}());\n\nfunction ctSetCookie(c_name, value) {\n\tdocument.cookie = c_name + \"=\" + encodeURIComponent(value) + \"; path=/; samesite=lax\";\n}\n\nfunction apbct_collect_visible_fields( form ) {\n\n\t// Get only fields\n\tvar inputs = [],\n\t\tinputs_visible = '',\n\t\tinputs_visible_count = 0,\n\t\tinputs_with_duplicate_names = [];\n\n\tfor(var key in form.elements){\n\t\tif(!isNaN(+key))\n\t\t\tinputs[key] = form.elements[key];\n\t}\n\n\t// Filter fields\n\tinputs = inputs.filter(function(elem){\n\n\t\t// Filter fields\n\t\tif( getComputedStyle(elem).display === \"none\" || // hidden\n\t\t\tgetComputedStyle(elem).visibility === \"hidden\" || // hidden\n\t\t\tgetComputedStyle(elem).opacity === \"0\" || // hidden\n\t\t\telem.getAttribute(\"type\") === \"hidden\" || // type == hidden\n\t\t\telem.getAttribute(\"type\") === \"submit\" || // type == submit\n\t\t\t//elem.value === \"\" || // empty value\n\t\t\telem.getAttribute('name') === null ||\n\t\t\tinputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 // name already added\n\t\t){\n\t\t\treturn false;\n\t\t}\n\n\t\t// Visible fields count\n\t\tinputs_visible_count++;\n\n\t\t// Filter inputs with same names for type == radio\n\t\tif( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute(\"type\") )){\n\t\t\tinputs_with_duplicate_names.push( elem.getAttribute('name') );\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t});\n\n\t// Visible fields\n\tinputs.forEach(function(elem, i, elements){\n\t\tinputs_visible += \" \" + elem.getAttribute(\"name\");\n\t});\n\tinputs_visible = inputs_visible.trim();\n\n\treturn {\n\t\tvisible_fields : inputs_visible,\n\t\tvisible_fields_count : inputs_visible_count,\n\t}\n\n}\n\nfunction apbct_visible_fields_set_cookie( visible_fields_collection ) {\n\n\tvar collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {};\n\n\tctSetCookie(\"apbct_visible_fields\", JSON.stringify( collection ) );\n\n}\n\nfunction apbct_js_keys__set_input_value(result, data, params, obj){\n\tif (document.getElementById(params.input_name) !== null) {\n\t\tvar ct_input_value = document.getElementById(params.input_name).value;\n\t\tdocument.getElementById(params.input_name).value = document.getElementById(params.input_name).value.replace(ct_input_value, result.js_key);\n\t}\n}\nfunction apbct_public_sendAJAX(data, params, obj){\n\n\t// Default params\n\tvar callback = params.callback || null;\n\tvar callback_context = params.callback_context || null;\n\tvar callback_params = params.callback_params || null;\n\tvar async = params.async || true;\n\tvar notJson = params.notJson || null;\n\tvar timeout = params.timeout || 15000;\n\tvar obj = obj || null;\n\tvar button = params.button || null;\n\tvar spinner = params.spinner || null;\n\tvar progressbar = params.progressbar || null;\n\tvar silent = params.silent || null;\n\tvar no_nonce = params.no_nonce || null;\n\n\tif(typeof (data) === 'string') {\n\t\tif( ! no_nonce )\n\t\t\tdata = data + '&_ajax_nonce=' + ctPublic._ajax_nonce;\n\t\tdata = data + '&no_cache=' + Math.random()\n\t} else {\n\t\tif( ! no_nonce )\n\t\t\tdata._ajax_nonce = ctPublic._ajax_nonce;\n\t\tdata.no_cache = Math.random();\n\t}\n\t// Button and spinner\n\tif(button) {button.setAttribute('disabled', 'disabled'); button.style.cursor = 'not-allowed'; }\n\tif(spinner) jQuery(spinner).css('display', 'inline');\n\n\tjQuery.ajax({\n\t\ttype: \"POST\",\n\t\turl: ctPublic._ajax_url,\n\t\tdata: data,\n\t\tasync: async,\n\t\tsuccess: function(result){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif(!notJson) result = JSON.parse(result);\n\t\t\tif(result.error){\n\t\t\t\tsetTimeout(function(){ if(progressbar) progressbar.fadeOut('slow'); }, 1000);\n\t\t\t\talert('Error happens: ' + (result.error || 'Unkown'));\n\t\t\t}else{\n\t\t\t\tif(callback) {\n\t\t\t\t\tif (callback_params)\n\t\t\t\t\t\tcallback.apply( callback_context, callback_params.concat( result, data, params, obj ) );\n\t\t\t\t\telse\n\t\t\t\t\t\tcallback(result, data, params, obj);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\terror: function(jqXHR, textStatus, errorThrown){\n\t\t\tif(button){ button.removeAttribute('disabled'); button.style.cursor = 'pointer'; }\n\t\t\tif(spinner) jQuery(spinner).css('display', 'none');\n\t\t\tif( errorThrown && ! silent ) {\n\t\t\t\tconsole.log('APBCT_AJAX_ERROR');\n\t\t\t\tconsole.log(jqXHR);\n\t\t\t\tconsole.log(textStatus);\n\t\t\t\tconsole.log('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t\talert('Anti-spam by Cleantalk plugin error: ' + errorThrown + 'Please, contact Cleantalk tech support https://wordpress.org/support/plugin/cleantalk-spam-protect/');\n\t\t\t}\n\t\t},\n\t\ttimeout: timeout,\n\t});\n}\n\n// Capturing responses and output block message for unknown AJAX forms\nvar accessor = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'responseText');\nObject.defineProperty(XMLHttpRequest.prototype, 'responseText', {\n\n\tget: function(){\n\t\tapbct_showBlockedResponse( this.response );\n\t\treturn accessor.get.call(this);\n\t},\n\tconfigurable: true\n\n});\napbct_showBlockedResponse = function( response ){\n\n\tvar response = JSON.parse(response);\n\tif (typeof response.apbct !== 'undefined') {\n\t\tresponse = response.apbct;\n\t\tif (response.blocked) {\n\t\t\tdocument.dispatchEvent(\n\t\t\t\tnew CustomEvent( \"apbctAjaxBockAlert\", {\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tdetail: { message: response.comment }\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\t// Create hidden element contains result.\n\t\t\tvar apbct_result = document.createElement( 'div' );\n\t\t\tapbct_result.setAttribute( 'id', 'apbct-result' );\n\t\t\tapbct_result.style.display = 'none';\n\t\t\tapbct_result.innerHTML = response.comment;\n\t\t\tdocument.body.append( apbct_result );\n\n\t\t\t// Show the element\n\t\t\tcleantalkModal.open('apbct-result');\n\n\t\t\tif(+response.stop_script == 1)\n\t\t\t\twindow.stop();\n\t\t}\n\t}\n\n\treturn true;\n\n};"],"names":["ctSetCookie","c_name","value","document","cookie","encodeURIComponent","apbct_collect_visible_fields","form","key","inputs","inputs_visible","inputs_visible_count","inputs_with_duplicate_names","elements","isNaN","filter","elem","getComputedStyle","display","visibility","opacity","getAttribute","indexOf","push","forEach","i","visible_fields","trim","visible_fields_count","apbct_visible_fields_set_cookie","visible_fields_collection","collection","JSON","stringify","apbct_js_keys__set_input_value","result","data","params","obj","ct_input_value","getElementById","input_name","replace","js_key","apbct_public_sendAJAX","callback","callback_context","callback_params","async","notJson","timeout","button","spinner","progressbar","silent","no_nonce","ctPublic","_ajax_nonce","Math","random","no_cache","setAttribute","style","cursor","jQuery","css","ajax","type","url","_ajax_url","success","removeAttribute","parse","error","setTimeout","fadeOut","alert","apply","concat","jqXHR","textStatus","errorThrown","console","log","ct_date","Date","ctTimeMs","getTime","ctMouseEventTimerFlag","ctMouseData","ctMouseDataCounter","apbct_attach_event_handler","event","window","addEventListener","attachEvent","apbct_remove_event_handler","removeEventListener","detachEvent","floor","getTimezoneOffset","ctFunctionFirstKey","ctMouseReadInterval","setInterval","ctMouseWriteDataInterval","ctFunctionMouseMove","round","clientY","clientX","clearInterval","forms","length","classList","contains","parentElement","action","toString","id","name","onsubmit_prev","onsubmit","this","target","Function","call","accessor","Object","getOwnPropertyDescriptor","XMLHttpRequest","prototype","defineProperty","get","apbct_showBlockedResponse","response","configurable","apbct_result","apbct","blocked","dispatchEvent","CustomEvent","bubbles","detail","message","comment","createElement","innerHTML","body","append","cleantalkModal","open","stop_script","stop"],"mappings":"AA+HA,SAASA,YAAYC,EAAQC,GAC5BC,SAASC,OAASH,EAAS,IAAMI,mBAAmBH,GAAS,yBAG9D,SAASI,6BAA8BC,GAGtC,IAKQC,EALJC,EAAS,GACZC,EAAiB,GACjBC,EAAuB,EACvBC,EAA8B,GAE/B,IAAQJ,KAAOD,EAAKM,SACfC,OAAON,KACVC,EAAOD,GAAOD,EAAKM,SAASL,IAqC9B,OAjCAC,EAASA,EAAOM,OAAO,SAASC,GAG/B,MAA0C,SAAtCC,iBAAiBD,GAAME,SACY,WAAtCD,iBAAiBD,GAAMG,YACe,MAAtCF,iBAAiBD,GAAMI,SACe,WAAtCJ,EAAKK,aAAa,SACoB,WAAtCL,EAAKK,aAAa,SAEoB,OAAtCL,EAAKK,aAAa,UACoD,IAAtET,EAA4BU,QAASN,EAAKK,aAAa,WAMxDV,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C1BjH,EAAKiH,SAAW,SAAU5B,GAEzB,IAAIlE,EAAiB,GACrBA,EAAe,GAAKpB,6BAA6BmH,MACjD5F,gCAAiCH,GAG7BkE,EAAM8B,OAAOH,yBAAyBI,UACzCjD,WAAW,WACVkB,EAAM8B,OAAOH,cAAcK,KAAKhC,EAAM8B,OAAQ9B,IAC5C,OAKN/D,gCAAiCC,IAE/B,OAzHL,GAyQA,IAAI+F,SAAWC,OAAOC,yBAAyBC,eAAeC,UAAW,gBACzEH,OAAOI,eAAeF,eAAeC,UAAW,eAAgB,CAE/DE,IAAK,WAEJ,OADAC,0BAA2BX,KAAKY,UACzBR,SAASM,IAAIP,KAAKH,OAE1Ba,cAAc,IAGfF,0BAA4B,SAAUC,GAErC,IAYME,EAcN,YAzB8B,KAD1BF,EAAWrG,KAAKwC,MAAM6D,IACNG,QACnBH,EAAWA,EAASG,OACPC,UACZtI,SAASuI,cACR,IAAIC,YAAa,qBAAsB,CACtCC,SAAS,EACTC,OAAQ,CAAEC,QAAST,EAASU,aAK1BR,EAAepI,SAAS6I,cAAe,QAC9BnF,aAAc,KAAM,gBACjC0E,EAAazE,MAAM5C,QAAU,OAC7BqH,EAAaU,UAAYZ,EAASU,QAClC5I,SAAS+I,KAAKC,OAAQZ,GAGtBa,eAAeC,KAAK,gBAEQ,IAAxBhB,EAASiB,aACZzD,OAAO0D,SAIH"}
lib/Cleantalk/ApbctWP/DB.php CHANGED
@@ -59,6 +59,7 @@ class DB extends \Cleantalk\Common\DB
59
  global $apbct;
60
  $this->prefix = $apbct->db_prefix;
61
  }
 
62
  /**
63
  * Set $this->query string for next uses
64
  *
@@ -70,6 +71,16 @@ class DB extends \Cleantalk\Common\DB
70
  $this->query = $query;
71
  return $this;
72
  }
 
 
 
 
 
 
 
 
 
 
73
 
74
  /**
75
  * Safely replace place holders
59
  global $apbct;
60
  $this->prefix = $apbct->db_prefix;
61
  }
62
+
63
  /**
64
  * Set $this->query string for next uses
65
  *
71
  $this->query = $query;
72
  return $this;
73
  }
74
+
75
+ /**
76
+ * Set $this->query string for next uses
77
+ *
78
+ * @return string
79
+ */
80
+ public function get_query()
81
+ {
82
+ return $this->query;
83
+ }
84
 
85
  /**
86
  * Safely replace place holders
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php CHANGED
@@ -311,7 +311,7 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
311
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
312
  entries_timestamp = '" . intval( $time ) . "',
313
  ua_id = " . $this->ua_id . ",
314
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
315
  ON DUPLICATE KEY
316
  UPDATE
317
  status = '$status',
@@ -319,9 +319,10 @@ class AntiCrawler extends \Cleantalk\Common\Firewall\FirewallModule{
319
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
320
  entries_timestamp = '" . intval( $time ) . "',
321
  ua_id = " . $this->ua_id . ",
322
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'";
323
-
324
- $this->db->execute( $query );
 
325
  }
326
 
327
  public function _die( $result ){
311
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
312
  entries_timestamp = '" . intval( $time ) . "',
313
  ua_id = " . $this->ua_id . ",
314
+ ua_name = %s
315
  ON DUPLICATE KEY
316
  UPDATE
317
  status = '$status',
319
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
320
  entries_timestamp = '" . intval( $time ) . "',
321
  ua_id = " . $this->ua_id . ",
322
+ ua_name = %s";
323
+
324
+ $this->db->prepare( $query, array( Server::get('HTTP_USER_AGENT'), Server::get('HTTP_USER_AGENT') ) );
325
+ $this->db->execute( $this->db->get_query() );
326
  }
327
 
328
  public function _die( $result ){
lib/Cleantalk/ApbctWP/Firewall/AntiFlood.php CHANGED
@@ -152,16 +152,17 @@ class AntiFlood extends \Cleantalk\Common\Firewall\FirewallModule{
152
  all_entries = 1,
153
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
154
  entries_timestamp = '" . intval( $time ) . "',
155
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'
156
  ON DUPLICATE KEY
157
  UPDATE
158
  status = '$status',
159
  all_entries = all_entries + 1,
160
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
161
  entries_timestamp = '" . intval( $time ) . "',
162
- ua_name = '" . Server::get('HTTP_USER_AGENT') . "'";
163
-
164
- $this->db->execute( $query );
 
165
  }
166
 
167
  public function _die( $result ) {
152
  all_entries = 1,
153
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
154
  entries_timestamp = '" . intval( $time ) . "',
155
+ ua_name = %s
156
  ON DUPLICATE KEY
157
  UPDATE
158
  status = '$status',
159
  all_entries = all_entries + 1,
160
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
161
  entries_timestamp = '" . intval( $time ) . "',
162
+ ua_name = %s";
163
+
164
+ $this->db->prepare( $query, array( Server::get('HTTP_USER_AGENT'), Server::get('HTTP_USER_AGENT') ) );
165
+ $this->db->execute( $this->db->get_query() );
166
  }
167
 
168
  public function _die( $result ) {
lib/Cleantalk/ApbctWP/Firewall/SFW.php CHANGED
@@ -175,16 +175,17 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
175
  all_entries = 1,
176
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
177
  entries_timestamp = '" . $time . "',
178
- ua_name = '" . sanitize_text_field( Server::get('HTTP_USER_AGENT') ) . "'
179
  ON DUPLICATE KEY
180
  UPDATE
181
  status = '$status',
182
  all_entries = all_entries + 1,
183
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
184
  entries_timestamp = '" . intval( $time ) . "',
185
- ua_name = '" . sanitize_text_field( Server::get('HTTP_USER_AGENT') ) . "'";
186
-
187
- $this->db->execute( $query );
 
188
  }
189
 
190
  public function actions_for_denied( $result ){
@@ -296,18 +297,19 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
296
  }
297
 
298
  }
299
-
300
- /**
301
- * Sends and wipe SFW log
302
- *
303
- * @param $db
304
- * @param $log_table
305
- * @param string $ct_key API key
306
- *
307
- * @return array|bool array('error' => STRING)
308
- */
309
- public static function send_log( $db, $log_table, $ct_key ) {
310
-
 
311
  //Getting logs
312
  $query = "SELECT * FROM " . $log_table . ";";
313
  $db->fetch_all( $query );
@@ -349,8 +351,15 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
349
  //Checking answer and deleting all lines from the table
350
  if( empty( $result['error'] ) ){
351
  if( $result['rows'] == count( $data ) ){
352
- $db->execute( "TRUNCATE TABLE " . $log_table . ";" );
353
-
 
 
 
 
 
 
 
354
  return $result;
355
  }
356
 
@@ -360,7 +369,7 @@ class SFW extends \Cleantalk\Common\Firewall\FirewallModule {
360
  }
361
 
362
  } else{
363
- return $result = array( 'rows' => 0 );
364
  }
365
  }
366
 
175
  all_entries = 1,
176
  blocked_entries = " . ( strpos( $status, 'DENY' ) !== false ? 1 : 0 ) . ",
177
  entries_timestamp = '" . $time . "',
178
+ ua_name = %s
179
  ON DUPLICATE KEY
180
  UPDATE
181
  status = '$status',
182
  all_entries = all_entries + 1,
183
  blocked_entries = blocked_entries" . ( strpos( $status, 'DENY' ) !== false ? ' + 1' : '' ) . ",
184
  entries_timestamp = '" . intval( $time ) . "',
185
+ ua_name = %s";
186
+
187
+ $this->db->prepare( $query, array( Server::get('HTTP_USER_AGENT'), Server::get('HTTP_USER_AGENT') ) );
188
+ $this->db->execute( $this->db->get_query() );
189
  }
190
 
191
  public function actions_for_denied( $result ){
297
  }
298
 
299
  }
300
+
301
+ /**
302
+ * Sends and wipe SFW log
303
+ *
304
+ * @param $db
305
+ * @param $log_table
306
+ * @param string $ct_key API key
307
+ * @param bool $use_delete_command Determs whether use DELETE or TRUNCATE to delete the logs table data
308
+ *
309
+ * @return array|bool array('error' => STRING)
310
+ */
311
+ public static function send_log( $db, $log_table, $ct_key, $use_delete_command ) {
312
+
313
  //Getting logs
314
  $query = "SELECT * FROM " . $log_table . ";";
315
  $db->fetch_all( $query );
351
  //Checking answer and deleting all lines from the table
352
  if( empty( $result['error'] ) ){
353
  if( $result['rows'] == count( $data ) ){
354
+
355
+ $db->execute( "BEGIN;" );
356
+ if( $use_delete_command ){
357
+ $db->execute( "DELETE FROM " . $log_table . ";" );
358
+ }else{
359
+ $db->execute( "TRUNCATE TABLE " . $log_table . ";" );
360
+ }
361
+ $db->execute( "COMMIT;" );
362
+
363
  return $result;
364
  }
365
 
369
  }
370
 
371
  } else{
372
+ return array( 'rows' => 0 );
373
  }
374
  }
375
 
lib/Cleantalk/ApbctWP/State.php CHANGED
@@ -56,11 +56,13 @@ class State
56
  public $storage = array();
57
  public $integrations = array();
58
  public $def_settings = array(
 
 
 
 
 
 
59
 
60
- 'spam_firewall' => 1,
61
- 'sfw__anti_flood' => 0,
62
- 'sfw__anti_flood__view_limit' => 20,
63
- 'sfw__anti_crawler' => 1,
64
  'apikey' => '',
65
  'autoPubRevelantMess' => 0,
66
 
@@ -251,10 +253,11 @@ class State
251
 
252
  public $def_stats = array(
253
  'sfw' => array(
254
- 'last_send_time' => 0,
255
- 'last_send_amount' => 0,
256
- 'last_update_time' => 0,
257
- 'entries' => 0,
 
258
  ),
259
  'last_sfw_block' => array(
260
  'time' => 0,
56
  public $storage = array();
57
  public $integrations = array();
58
  public $def_settings = array(
59
+
60
+ 'spam_firewall' => 1,
61
+ 'sfw__anti_flood' => 0,
62
+ 'sfw__anti_flood__view_limit' => 20,
63
+ 'sfw__anti_crawler' => 1,
64
+ 'sfw__use_delete_to_clear_table' => 0,
65
 
 
 
 
 
66
  'apikey' => '',
67
  'autoPubRevelantMess' => 0,
68
 
253
 
254
  public $def_stats = array(
255
  'sfw' => array(
256
+ 'sending_logs__timestamp' => 0,
257
+ 'last_send_time' => 0,
258
+ 'last_send_amount' => 0,
259
+ 'last_update_time' => 0,
260
+ 'entries' => 0,
261
  ),
262
  'last_sfw_block' => array(
263
  'time' => 0,
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: spam, antispam, anti-spam, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
- Stable tag: 5.153.3
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
@@ -580,6 +580,15 @@ If your website has forms that send data to external sources, you can enable opt
580
 
581
  == Changelog ==
582
 
 
 
 
 
 
 
 
 
 
583
  = 5.153.3 Feb 25 2021 =
584
  * Fix: Security. Preparing UA string for writing to the DB.
585
 
4
  Requires at least: 3.0
5
  Tested up to: 5.7
6
  Requires PHP: 5.4
7
+ Stable tag: 5.153.4
8
  License: GPLv2
9
 
10
  Spam protection, anti-spam, firewall, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
580
 
581
  == Changelog ==
582
 
583
+ = 5.153.4 Mar 10 2021 =
584
+ * New: SFW. Log could be sent not more often than 3 minutes.
585
+ * New: SFW. Possibility to use DELETE instead of TRUNCATE to delete SFW log.
586
+ * New: Show response for all AJAX forms.
587
+ * Fix: SFW. Sending log. Committing transaction after TRUNCATE log table.
588
+ * Fix: Integration. CF7 different versions compatibility fixed.
589
+ * Fix: Exclusion for WooCommerce.
590
+ * Fix: Possible SQL-injections fixed.
591
+
592
  = 5.153.3 Feb 25 2021 =
593
  * Fix: Security. Preparing UA string for writing to the DB.
594