WordPress Zero Spam - Version 5.3.8

Version Description

Download this release

Release Info

Developer bmarshall511
Plugin Icon 128x128 WordPress Zero Spam
Version 5.3.8
Comparing to
See all releases

Code changes from version 5.3.7 to 5.3.8

modules/class-zerospam.php CHANGED
@@ -40,6 +40,51 @@ class Zero_Spam {
40
 
41
  // Fires when a user submission has been detected as spam.
42
  add_action( 'zerospam_share_detection', array( $this, 'share_detection' ), 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  /**
@@ -96,7 +141,7 @@ class Zero_Spam {
96
  'desc' => sprintf(
97
  wp_kses(
98
  /* translators: %s: Replaced with the Zero Spam URL */
99
- __( 'Blocks visitor IPs, email addresses &amp; usernames that have been reported to <a href="%s" target="_blank" rel="noopener noreferrer">Zero Spam</a>.', 'zero-spam' ),
100
  array(
101
  'strong' => array(),
102
  'a' => array(
@@ -104,9 +149,10 @@ class Zero_Spam {
104
  'href' => array(),
105
  'rel' => array(),
106
  ),
 
107
  )
108
  ),
109
- esc_url( ZEROSPAM_URL . '?utm_source=wordpresszerospam&utm_medium=admin_link&utm_campaign=wordpresszerospam' )
110
  ),
111
  'value' => ! empty( $options['zerospam'] ) ? $options['zerospam'] : false,
112
  'recommended' => 'enabled',
@@ -452,7 +498,6 @@ class Zero_Spam {
452
  public static function query( $params ) {
453
  if (
454
  empty( $params['ip'] ) &&
455
- empty( $params['username'] ) &&
456
  empty( $params['email'] )
457
  ) {
458
  return false;
@@ -470,7 +515,24 @@ class Zero_Spam {
470
 
471
  $response = wp_cache_get( $cache_key );
472
  if ( false === $response ) {
473
- $endpoint = 'https://www.zerospam.org/wp-json/v1/query';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
 
475
  $args = array(
476
  'body' => array(
@@ -482,6 +544,10 @@ class Zero_Spam {
482
  $args['body']['ip'] = $params['ip'];
483
  }
484
 
 
 
 
 
485
  $args['timeout'] = 5;
486
  if ( ! empty( $settings['zerospam_timeout'] ) ) {
487
  $args['timeout'] = intval( $settings['zerospam_timeout']['value'] );
@@ -495,11 +561,11 @@ class Zero_Spam {
495
  if (
496
  ! is_array( $response ) ||
497
  empty( $response['status'] ) ||
498
- 'success' !== $response['status'] ||
499
- empty( $response['result'] )
500
  ) {
501
- if ( ! empty( $response['result'] ) ) {
502
- \ZeroSpam\Core\Utilities::log( $response['result'] );
503
  } else {
504
  \ZeroSpam\Core\Utilities::log( __( 'There was a problem querying the Zero Spam Blacklist API.', 'zero-spam' ) );
505
  }
@@ -507,7 +573,7 @@ class Zero_Spam {
507
  return false;
508
  }
509
 
510
- $response = $response['result'];
511
 
512
  $expiration = 14 * DAY_IN_SECONDS;
513
  if ( ! empty( $settings['zerospam_confidence_min']['value'] ) ) {
40
 
41
  // Fires when a user submission has been detected as spam.
42
  add_action( 'zerospam_share_detection', array( $this, 'share_detection' ), 10, 1 );
43
+
44
+ if (
45
+ 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'zerospam' ) &&
46
+ \ZeroSpam\Core\Access::process()
47
+ ) {
48
+ add_filter( 'zerospam_access_checks', array( $this, 'access_check' ), 10, 2 );
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Site access check
54
+ *
55
+ * Determines if a visitor should be blocked from accessing the site based off
56
+ * the results of the zerospam.org API query.
57
+ *
58
+ * @param array $access_checks Access check results from previous checks.
59
+ * @param string $user_ip The visitor's IP address.
60
+ */
61
+ public function access_check( $access_checks, $user_ip ) {
62
+ $settings = \ZeroSpam\Core\Settings::get_settings();
63
+
64
+ // Create the access check result for Zero Spam.
65
+ $access_checks['zero_spam'] = array(
66
+ 'blocked' => false,
67
+ );
68
+
69
+ // Query the Zero Spam API for the visitor's IP address.
70
+ $response = self::query( array( 'ip' => $user_ip ) );
71
+ if ( $response && ! empty( $response['ip_addresses'][ $user_ip ] ) ) {
72
+ $ip_data = $response['ip_addresses'][ $user_ip ];
73
+ $min_confidence_score = floatval( $settings['zerospam_confidence_min']['value'] );
74
+
75
+ if ( ! empty( $ip_data['confidence'] ) ) {
76
+ $confidence_score = floatval( $ip_data['confidence'] ) * 100;
77
+
78
+ if ( $confidence_score >= $min_confidence_score ) {
79
+ $access_checks['zero_spam']['blocked'] = true;
80
+ $access_checks['zero_spam']['type'] = 'blocked';
81
+ $access_checks['zero_spam']['details'] = $ip_data;
82
+ }
83
+ }
84
+ }
85
+
86
+ // Return the updated access checks array.
87
+ return $access_checks;
88
  }
89
 
90
  /**
141
  'desc' => sprintf(
142
  wp_kses(
143
  /* translators: %s: Replaced with the Zero Spam URL */
144
+ __( 'Blocks visitor IPs &amp; supported submitted forms with an email address that meets the <a href="%s" target="_blank" rel="noopener noreferrer">Zero Spam</a> <em>Confidence Minimum</em> score.', 'zero-spam' ),
145
  array(
146
  'strong' => array(),
147
  'a' => array(
149
  'href' => array(),
150
  'rel' => array(),
151
  ),
152
+ 'em' => array(),
153
  )
154
  ),
155
+ esc_url( ZEROSPAM_URL )
156
  ),
157
  'value' => ! empty( $options['zerospam'] ) ? $options['zerospam'] : false,
158
  'recommended' => 'enabled',
498
  public static function query( $params ) {
499
  if (
500
  empty( $params['ip'] ) &&
 
501
  empty( $params['email'] )
502
  ) {
503
  return false;
515
 
516
  $response = wp_cache_get( $cache_key );
517
  if ( false === $response ) {
518
+ // Limit the number of requests.
519
+ $last_query_option = get_site_option( 'zero_spam_last_api_query', false );
520
+ if ( $last_query_option ) {
521
+ list( $first_query_date, $num_queries) = explode( '*', $last_query_option );
522
+
523
+ if ( gmdate( 'Y-m-d', strtotime( $first_query_date ) ) !== gmdate( 'Y-m-d' ) ) {
524
+ // New day.
525
+ update_site_option( 'zero_spam_last_api_query', current_time( 'mysql' ) . '*1' );
526
+ } elseif ( $num_queries > 5 ) {
527
+ return false;
528
+ } else {
529
+ update_site_option( 'zero_spam_last_api_query', $first_query_date . '*' . ( $num_queries+1 ) );
530
+ }
531
+ } else {
532
+ update_site_option( 'zero_spam_last_api_query', $first_query_date . '*' . ( $num_queries+1 ) );
533
+ }
534
+
535
+ $endpoint = 'https://www.zerospam.org/wp-json/v2/query';
536
 
537
  $args = array(
538
  'body' => array(
544
  $args['body']['ip'] = $params['ip'];
545
  }
546
 
547
+ if ( ! empty( $params['email'] ) ) {
548
+ $args['body']['email'] = $params['email'];
549
+ }
550
+
551
  $args['timeout'] = 5;
552
  if ( ! empty( $settings['zerospam_timeout'] ) ) {
553
  $args['timeout'] = intval( $settings['zerospam_timeout']['value'] );
561
  if (
562
  ! is_array( $response ) ||
563
  empty( $response['status'] ) ||
564
+ 200 !== $response['status'] ||
565
+ empty( $response['body_response'] )
566
  ) {
567
+ if ( ! empty( $response['response'] ) ) {
568
+ \ZeroSpam\Core\Utilities::log( $response['response'] );
569
  } else {
570
  \ZeroSpam\Core\Utilities::log( __( 'There was a problem querying the Zero Spam Blacklist API.', 'zero-spam' ) );
571
  }
573
  return false;
574
  }
575
 
576
+ $response = $response['body_response'];
577
 
578
  $expiration = 14 * DAY_IN_SECONDS;
579
  if ( ! empty( $settings['zerospam_confidence_min']['value'] ) ) {
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.zerospam.org/subscribe/
5
  Requires at least: 5.2
6
  Tested up to: 5.9.3
7
  Requires PHP: 7.3
8
- Stable tag: 5.3.7
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -15,8 +15,6 @@ Protection against spam & malicious users using cutting-edge AI. Firewall, real-
15
 
16
  Protection against spam & malicious users using cutting-edge AI. Features a highly-configurable firewall, real-time monitoring, integrates with popular blacklists & plugins like [WooCommerce](https://wordpress.org/plugins/woocommerce/), [GiveWP](https://givewp.com/ref/1118/) & more.
17
 
18
- [Zero Spam for WordPress](https://www.highfivery.com/projects/zero-spam/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress_zero_spam) uses AI in combination with proven spam detection techniques and databases of known malicious IPs from around the world to detect and block unwanted visitors.
19
-
20
  **Install, activate, configure, then put your mind at ease!**
21
 
22
  = Worry-free, Powerful Protection =
@@ -53,7 +51,7 @@ Zero Spam allows you to integrate with other services to improve the ability to
53
  * **[Stop Forum Spam](https://www.stopforumspam.com/)** - Sends the visitor's IP to check if they've been reported. Review their [Privacy Policy](https://www.stopforumspam.com/privacy) & [Terms of Use](https://www.stopforumspam.com/legal).
54
  * **[Project Honeypot](https://www.projecthoneypot.org/)** - Sends the visitor's IP to check if they've been reported. Review their [Privacy Policy](https://www.projecthoneypot.org/privacy_policy.php) & [Terms of Use](https://www.projecthoneypot.org/terms_of_use.php).
55
  * **[ipinfo.io](https://ipinfo.io/)** - Sends the visitor's IP to gather detailed geolocation information. Review their [Privacy Policy](https://ipinfo.io/privacy-policy) & [Terms of Use](https://ipinfo.io/terms-of-service).
56
- * **ipstack** - Sends the visitor's IP to gather detailed geolocation information ([privacy policy](https://www.ideracorp.com/Legal/APILayer/PrivacyStatement), [terms of use](https://ipstack.com/terms))
57
  * **[Google Maps](https://developers.google.com/maps)** - Enables the ability to plot attack locations. Review their [Privacy Policy](https://www.ideracorp.com/Legal/APILayer/PrivacyStatement) & [Terms of Use](https://developers.google.com/terms/site-terms).
58
 
59
  Optionally, you can also help improve Zero Spam by enabling sharing detection information. For more info on what's shared, see our [FAQ](https://github.com/Highfivery/zero-spam-for-wordpress/wiki/FAQ)
@@ -108,6 +106,10 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
108
 
109
  == Changelog ==
110
 
 
 
 
 
111
  = v5.3.7 =
112
 
113
  * chore(readme): documentation updates
5
  Requires at least: 5.2
6
  Tested up to: 5.9.3
7
  Requires PHP: 7.3
8
+ Stable tag: 5.3.8
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
15
 
16
  Protection against spam & malicious users using cutting-edge AI. Features a highly-configurable firewall, real-time monitoring, integrates with popular blacklists & plugins like [WooCommerce](https://wordpress.org/plugins/woocommerce/), [GiveWP](https://givewp.com/ref/1118/) & more.
17
 
 
 
18
  **Install, activate, configure, then put your mind at ease!**
19
 
20
  = Worry-free, Powerful Protection =
51
  * **[Stop Forum Spam](https://www.stopforumspam.com/)** - Sends the visitor's IP to check if they've been reported. Review their [Privacy Policy](https://www.stopforumspam.com/privacy) & [Terms of Use](https://www.stopforumspam.com/legal).
52
  * **[Project Honeypot](https://www.projecthoneypot.org/)** - Sends the visitor's IP to check if they've been reported. Review their [Privacy Policy](https://www.projecthoneypot.org/privacy_policy.php) & [Terms of Use](https://www.projecthoneypot.org/terms_of_use.php).
53
  * **[ipinfo.io](https://ipinfo.io/)** - Sends the visitor's IP to gather detailed geolocation information. Review their [Privacy Policy](https://ipinfo.io/privacy-policy) & [Terms of Use](https://ipinfo.io/terms-of-service).
54
+ * **[ipstack](https://ipstack.com/)** - Sends the visitor's IP to gather detailed geolocation information. Review their [Privacy Policy](https://www.ideracorp.com/Legal/APILayer/PrivacyStatement) & [Terms of Use](https://ipstack.com/terms).
55
  * **[Google Maps](https://developers.google.com/maps)** - Enables the ability to plot attack locations. Review their [Privacy Policy](https://www.ideracorp.com/Legal/APILayer/PrivacyStatement) & [Terms of Use](https://developers.google.com/terms/site-terms).
56
 
57
  Optionally, you can also help improve Zero Spam by enabling sharing detection information. For more info on what's shared, see our [FAQ](https://github.com/Highfivery/zero-spam-for-wordpress/wiki/FAQ)
106
 
107
  == Changelog ==
108
 
109
+ = v5.3.8 =
110
+
111
+ * chore(zero spam api): updated the zero spam api to v2
112
+
113
  = v5.3.7 =
114
 
115
  * chore(readme): documentation updates
wordpress-zero-spam.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: Zero Spam for WordPress
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
  * Description: Tired of all the ineffective WordPress anti-spam & security plugins? Zero Spam for WordPress makes blocking spam &amp; malicious activity a cinch. <strong>Just activate, configure, and say goodbye to spam.</strong>
16
- * Version: 5.3.7
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.3
19
  * Author: Highfivery LLC
@@ -31,7 +31,7 @@ defined( 'ABSPATH' ) || die();
31
  define( 'ZEROSPAM', __FILE__ );
32
  define( 'ZEROSPAM_PATH', plugin_dir_path( ZEROSPAM ) );
33
  define( 'ZEROSPAM_PLUGIN_BASE', plugin_basename( ZEROSPAM ) );
34
- define( 'ZEROSPAM_VERSION', '5.3.7' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
13
  * Plugin Name: Zero Spam for WordPress
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
  * Description: Tired of all the ineffective WordPress anti-spam & security plugins? Zero Spam for WordPress makes blocking spam &amp; malicious activity a cinch. <strong>Just activate, configure, and say goodbye to spam.</strong>
16
+ * Version: 5.3.8
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.3
19
  * Author: Highfivery LLC
31
  define( 'ZEROSPAM', __FILE__ );
32
  define( 'ZEROSPAM_PATH', plugin_dir_path( ZEROSPAM ) );
33
  define( 'ZEROSPAM_PLUGIN_BASE', plugin_basename( ZEROSPAM ) );
34
+ define( 'ZEROSPAM_VERSION', '5.3.8' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );