Spam protection, AntiSpam, FireWall by CleanTalk - Version 5.116.3

Version Description

March 14 2019 = * Fix: "Headers already sent" error. * Fix: Images paths. * Fix: IP detection. * Fix: Skip lost password form check * Fix: Skip mobile requests (push settings) * Fix: PHP notice when detecting BuddyPress template.

Download this release

Release Info

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

Code changes from version 5.116.2 to 5.116.3

Files changed (4) hide show
  1. cleantalk.php +37 -21
  2. inc/cleantalk-public.php +4 -2
  3. lib/CleantalkHelper.php +4 -4
  4. readme.txt +18 -2
cleantalk.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://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.116.2
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
@@ -65,9 +65,9 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
65
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
66
  $apbct->plugin_name = defined('APBCT_WHITELABEL_NAME') ? APBCT_WHITELABEL_NAME : APBCT_NAME; // For test purposes
67
 
68
- $apbct->logo = plugin_dir_url(__FILE__) . '/inc/images/logo.png';
69
- $apbct->logo__small = plugin_dir_url(__FILE__) . '/inc/images/logo_small.png';
70
- $apbct->logo__small__colored = plugin_dir_url(__FILE__) . '/inc/images/logo_color.png';
71
 
72
  $apbct->key_is_ok = !empty($apbct->data['key_is_ok']) ? $apbct->data['key_is_ok'] : 0;
73
  $apbct->key_is_ok = isset($apbct->data['testing_failed']) && $apbct->data['testing_failed'] == 0 ? 1 : $apbct->key_is_ok;
@@ -119,8 +119,8 @@ if(!defined('CLEANTALK_PLUGIN_DIR')){
119
  //Delete cookie for admin trial notice
120
  add_action('wp_logout', 'apbct__hook__wp_logout__delete_trial_notice_cookie');
121
 
122
- // Set cookie only for unauthorized users and for non-AJAX requests
123
- if (!is_admin()){
124
  add_action('wp','apbct_cookie', 2);
125
  add_action('wp','apbct_store__urls', 2);
126
  if (empty($_POST) && empty($_GET['action'])){
@@ -463,7 +463,7 @@ function apbct_sfw__check()
463
  $apbct->saveData();
464
  $sfw->sfw_die($apbct->api_key);
465
  }else{
466
- if(!empty($apbct->settings['set_cookies']))
467
  setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$apbct->api_key), 0, "/");
468
  }
469
  }
@@ -799,8 +799,8 @@ function apbct_cookie(){
799
  global $apbct;
800
 
801
  if(
802
- empty($apbct->settings['set_cookies']) || // Do not set cookies if option is disabled (for Varnish cache).
803
- !empty($apbct->flags__cookies_setuped) // Cookies already set
804
  )
805
  return false;
806
 
@@ -872,18 +872,19 @@ function apbct_alt_session__save($name, $value){
872
  global $wpdb;
873
 
874
  $session_id = apbct_alt_session__id__get();
875
-
876
  $wpdb->query(
877
  $wpdb->prepare(
878
  'INSERT INTO '. APBCT_TBL_SESSIONS .'
879
- (id, name, value)
880
- VALUES (%s, %s, %s)
881
  ON DUPLICATE KEY UPDATE
882
  value = %s,
883
- last_update = NOW()',
884
- $session_id, $name, $value, $value
885
  )
886
- );
 
887
  }
888
 
889
  function apbct_alt_session__get($name){
@@ -913,30 +914,45 @@ function apbct_store__urls(){
913
  global $apbct;
914
 
915
  if($apbct->settings['store_urls'] && empty($apbct->flags__url_stored)){
916
-
 
 
917
  $current_url = filter_input(INPUT_SERVER, 'HTTP_HOST').filter_input(INPUT_SERVER, 'REQUEST_URI');
 
918
 
 
919
  $urls = $apbct->settings['store_urls__sessions']
920
  ? (array)apbct_alt_session__get('apbct_urls')
921
  : (array)json_decode(filter_input(INPUT_COOKIE, 'apbct_urls'), true);
922
 
923
  $urls[$current_url][] = time();
924
 
 
925
  $urls[$current_url] = count($urls[$current_url]) > 10 ? array_slice($urls[$current_url], 1, 10) : $urls[$current_url];
926
  $urls = count($urls) > 10 ? array_slice($urls, 1, 10) : $urls;
927
 
 
928
  $apbct->settings['store_urls__sessions']
929
  ? apbct_alt_session__save('apbct_urls', json_encode($urls))
930
  : setcookie('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true);
931
 
 
 
 
 
 
 
932
  $site_referer = $apbct->settings['store_urls__sessions']
933
- ? (array)apbct_alt_session__get('apbct_site_referer')
934
- : (array)json_decode(filter_input(INPUT_COOKIE, 'apbct_site_referer'), true);
935
 
936
- if(!$site_referer)
 
 
937
  $apbct->settings['store_urls__sessions']
938
- ? apbct_alt_session__save('apbct_site_referer', $current_url)
939
- : setcookie('apbct_site_referer', $current_url, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true);
 
940
 
941
  $apbct->flags__url_stored = true;
942
 
3
  Plugin Name: Anti-Spam by CleanTalk
4
  Plugin URI: http://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.116.3
7
  Author: СleanTalk <welcome@cleantalk.org>
8
  Author URI: http://cleantalk.org
9
  */
65
  $apbct->base_name = 'cleantalk-spam-protect/cleantalk.php';
66
  $apbct->plugin_name = defined('APBCT_WHITELABEL_NAME') ? APBCT_WHITELABEL_NAME : APBCT_NAME; // For test purposes
67
 
68
+ $apbct->logo = plugin_dir_url(__FILE__) . 'inc/images/logo.png';
69
+ $apbct->logo__small = plugin_dir_url(__FILE__) . 'inc/images/logo_small.png';
70
+ $apbct->logo__small__colored = plugin_dir_url(__FILE__) . 'inc/images/logo_color.png';
71
 
72
  $apbct->key_is_ok = !empty($apbct->data['key_is_ok']) ? $apbct->data['key_is_ok'] : 0;
73
  $apbct->key_is_ok = isset($apbct->data['testing_failed']) && $apbct->data['testing_failed'] == 0 ? 1 : $apbct->key_is_ok;
119
  //Delete cookie for admin trial notice
120
  add_action('wp_logout', 'apbct__hook__wp_logout__delete_trial_notice_cookie');
121
 
122
+ // Set cookie only for public pages and for non-AJAX requests
123
+ if (!is_admin() && !apbct_is_ajax() && !defined('DOING_CRON') && !headers_sent()){
124
  add_action('wp','apbct_cookie', 2);
125
  add_action('wp','apbct_store__urls', 2);
126
  if (empty($_POST) && empty($_GET['action'])){
463
  $apbct->saveData();
464
  $sfw->sfw_die($apbct->api_key);
465
  }else{
466
+ if(!empty($apbct->settings['set_cookies']) && !headers_sent())
467
  setcookie ('ct_sfw_pass_key', md5($sfw->passed_ip.$apbct->api_key), 0, "/");
468
  }
469
  }
799
  global $apbct;
800
 
801
  if(
802
+ empty($apbct->settings['set_cookies']) || // Do not set cookies if option is disabled (for Varnish cache).
803
+ !empty($apbct->flags__cookies_setuped) // Cookies already set
804
  )
805
  return false;
806
 
872
  global $wpdb;
873
 
874
  $session_id = apbct_alt_session__id__get();
875
+
876
  $wpdb->query(
877
  $wpdb->prepare(
878
  'INSERT INTO '. APBCT_TBL_SESSIONS .'
879
+ (id, name, value, last_update)
880
+ VALUES (%s, %s, %s, %s)
881
  ON DUPLICATE KEY UPDATE
882
  value = %s,
883
+ last_update = %s',
884
+ $session_id, $name, $value, date('Y-m-d H:i:s'), $value, date('Y-m-d H:i:s')
885
  )
886
+ );
887
+
888
  }
889
 
890
  function apbct_alt_session__get($name){
914
  global $apbct;
915
 
916
  if($apbct->settings['store_urls'] && empty($apbct->flags__url_stored)){
917
+
918
+ // URLs HISTORY
919
+ // Get current url
920
  $current_url = filter_input(INPUT_SERVER, 'HTTP_HOST').filter_input(INPUT_SERVER, 'REQUEST_URI');
921
+ $current_url = $current_url ? $current_url : 'UNKNOWN';
922
 
923
+ // Get already stored URLs
924
  $urls = $apbct->settings['store_urls__sessions']
925
  ? (array)apbct_alt_session__get('apbct_urls')
926
  : (array)json_decode(filter_input(INPUT_COOKIE, 'apbct_urls'), true);
927
 
928
  $urls[$current_url][] = time();
929
 
930
+ // Rotating. Saving only latest 10
931
  $urls[$current_url] = count($urls[$current_url]) > 10 ? array_slice($urls[$current_url], 1, 10) : $urls[$current_url];
932
  $urls = count($urls) > 10 ? array_slice($urls, 1, 10) : $urls;
933
 
934
+ // Saving
935
  $apbct->settings['store_urls__sessions']
936
  ? apbct_alt_session__save('apbct_urls', json_encode($urls))
937
  : setcookie('apbct_urls', json_encode($urls), time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true);
938
 
939
+ // REFERER
940
+ // Get current fererer
941
+ $new_site_referer = filter_input(INPUT_SERVER, 'HTTP_REFERER');
942
+ $new_site_referer = $new_site_referer ? $new_site_referer : 'UNKNOWN';
943
+
944
+ // Get already stored referer
945
  $site_referer = $apbct->settings['store_urls__sessions']
946
+ ? apbct_alt_session__get('apbct_site_referer')
947
+ : filter_input(INPUT_COOKIE, 'apbct_site_referer');
948
 
949
+ // Save if empty
950
+ if(!$site_referer || parse_url($new_site_referer, PHP_URL_HOST) !== filter_input(INPUT_SERVER, 'HTTP_HOST')){
951
+
952
  $apbct->settings['store_urls__sessions']
953
+ ? apbct_alt_session__save('apbct_site_referer', $new_site_referer)
954
+ : setcookie('apbct_site_referer', $new_site_referer, time()+86400*3, '/', parse_url(get_option('siteurl'),PHP_URL_HOST), false, true);
955
+ }
956
 
957
  $apbct->flags__url_stored = true;
958
 
inc/cleantalk-public.php CHANGED
@@ -405,7 +405,7 @@ function ct_woocommerce_wishlist_check($args){
405
  function apbct_integration__buddyPres__getTemplateName( $located, $template_name, $template_names, $template_locations, $load, $require_once ) {
406
  global $apbct;
407
  preg_match("/\/([a-z-_]+)\/buddypress-functions\.php$/", $located, $matches);
408
- $apbct->buddy_press_tmpl = $matches[1];
409
  }
410
 
411
  /**
@@ -2512,7 +2512,9 @@ function ct_contact_form_validate() {
2512
  (isset($_POST['action']) && $_POST['action'] == 'grunion-contact-form') || // JetPack
2513
  (isset($_POST['action']) && $_POST['action'] == 'bbp-update-user') || //BBP update user info page
2514
  (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'?wc-api=WC_Gateway_Transferuj') !== false) || //WC Gateway
2515
- (isset($_GET['mbr'], $_GET['amp;appname'], $_GET['amp;master'])) // ticket_id=10773
 
 
2516
  ) {
2517
  return null;
2518
  }
405
  function apbct_integration__buddyPres__getTemplateName( $located, $template_name, $template_names, $template_locations, $load, $require_once ) {
406
  global $apbct;
407
  preg_match("/\/([a-z-_]+)\/buddypress-functions\.php$/", $located, $matches);
408
+ $apbct->buddy_press_tmpl = isset($matches[1]) ? $matches[1] : 'unknown';
409
  }
410
 
411
  /**
2512
  (isset($_POST['action']) && $_POST['action'] == 'grunion-contact-form') || // JetPack
2513
  (isset($_POST['action']) && $_POST['action'] == 'bbp-update-user') || //BBP update user info page
2514
  (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'?wc-api=WC_Gateway_Transferuj') !== false) || //WC Gateway
2515
+ (isset($_GET['mbr'], $_GET['amp;appname'], $_GET['amp;master'])) || // ticket_id=10773
2516
+ (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'],'lost-password') !== false) || //Skip lost-password form check
2517
+ (isset($_POST['call_function']) && $_POST['call_function'] == 'push_notification_settings') // Skip mobile requests (push settings)
2518
  ) {
2519
  return null;
2520
  }
lib/CleantalkHelper.php CHANGED
@@ -144,10 +144,10 @@ class CleantalkHelper
144
  */
145
  static public function ip_validate($ip)
146
  {
147
- if(!$ip) return false; // NULL || FALSE || '' || so on...
148
- if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) return 'v4'; // IPv4
149
- if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) return 'v6'; // IPv6
150
- return false; // Unknown
151
  }
152
 
153
  /**
144
  */
145
  static public function ip_validate($ip)
146
  {
147
+ if(!$ip) return false; // NULL || FALSE || '' || so on...
148
+ if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && $ip != '0.0.0.0') return 'v4'; // IPv4
149
+ if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) return 'v6'; // IPv6
150
+ return false; // Unknown
151
  }
152
 
153
  /**
readme.txt CHANGED
@@ -3,14 +3,14 @@ Contributors: safronik
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.1
6
- Stable tag: 5.116.2
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
10
 
11
  == Description ==
12
 
13
- **Supports: Contact Form 7, Contact Form by WPForms, Ninja Forms, Gravity Forms, MailChimp, Formidable forms, WooCommerce, JetPack comments and contact form, BuddyPress, bbPress, Fast Secure Contact form, S2Member, MailPoet, any WordPress registrations & contact forms and themes. Just setup and forget the spam!**
14
 
15
  No CAPTCHA, no questions, no animal counting, no puzzles, no math and no spam bots. Universal AntiSpam plugin.
16
 
@@ -558,6 +558,14 @@ If your website has forms that send data to external sources, you can enable opt
558
  10. Website's options.
559
 
560
  == Changelog ==
 
 
 
 
 
 
 
 
561
  = 5.116.2 March 7 2019 =
562
  * Fix: Creating tables in MariaDB.
563
 
@@ -1815,6 +1823,14 @@ If your website has forms that send data to external sources, you can enable opt
1815
  * First version
1816
 
1817
  == Upgrade Notice ==
 
 
 
 
 
 
 
 
1818
  = 5.116.2 March 7 2019 =
1819
  * Fix: Creating tables in MariaDB.
1820
 
3
  Tags: spam, antispam, protection, comments, firewall
4
  Requires at least: 3.0
5
  Tested up to: 5.1
6
+ Stable tag: 5.116.3
7
  License: GPLv2
8
 
9
  Spam protection, antispam, all-in-one, premium plugin. No spam comments & users, no spam contact form & WooCommerce anti-spam.
10
 
11
  == Description ==
12
 
13
+ **Supports: Contact Form 7, Contact Form by WPForms, Ninja Forms, Gravity Forms, MailChimp, Formidable forms, WooCommerce, JetPack comments and contact form, BuddyPress, bbPress, Fast Secure Contact form, S2Member, MailPoet, wpDiscuz, any WordPress registrations & contact forms and themes. Just setup and forget the spam!**
14
 
15
  No CAPTCHA, no questions, no animal counting, no puzzles, no math and no spam bots. Universal AntiSpam plugin.
16
 
558
  10. Website's options.
559
 
560
  == Changelog ==
561
+ = 5.116.3 March 14 2019 =
562
+ * Fix: "Headers already sent" error.
563
+ * Fix: Images paths.
564
+ * Fix: IP detection.
565
+ * Fix: Skip lost password form check
566
+ * Fix: Skip mobile requests (push settings)
567
+ * Fix: PHP notice when detecting BuddyPress template.
568
+
569
  = 5.116.2 March 7 2019 =
570
  * Fix: Creating tables in MariaDB.
571
 
1823
  * First version
1824
 
1825
  == Upgrade Notice ==
1826
+ = 5.116.3 March 14 2019 =
1827
+ * Fix: "Headers already sent" error.
1828
+ * Fix: Images paths.
1829
+ * Fix: IP detection.
1830
+ * Fix: Skip lost password form check
1831
+ * Fix: Skip mobile requests (push settings)
1832
+ * Fix: PHP notice when detecting BuddyPress template.
1833
+
1834
  = 5.116.2 March 7 2019 =
1835
  * Fix: Creating tables in MariaDB.
1836