WordPress Zero Spam - Version 5.3.3

Version Description

Download this release

Release Info

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

Code changes from version 5.3.2 to 5.3.3

core/admin/tables/class-blockedlocations.php CHANGED
@@ -51,7 +51,8 @@ class BlockedLocations extends WP_List_Table {
51
  return 'N/A';
52
  }
53
 
54
- return gmdate( 'M j, Y g:ia' , strtotime( $item[ $column_name ] ) );
 
55
  break;
56
  case 'location':
57
  if ( empty( $item['blocked_key'] ) ) {
51
  return 'N/A';
52
  }
53
 
54
+ $date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
55
+ return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', strtotime( $item[ $column_name ] ) ), $date_time_format );
56
  break;
57
  case 'location':
58
  if ( empty( $item['blocked_key'] ) ) {
core/admin/tables/class-blockedtable.php CHANGED
@@ -61,7 +61,8 @@ class BlockedTable extends WP_List_Table {
61
  if ( empty( $item[ $column_name ] ) || '0000-00-00 00:00:00' === $item[ $column_name ] ) {
62
  return 'N/A';
63
  } else {
64
- return gmdate( 'M j, Y g:ia' , strtotime( $item[ $column_name ] ) );
 
65
  }
66
  break;
67
  case 'actions':
61
  if ( empty( $item[ $column_name ] ) || '0000-00-00 00:00:00' === $item[ $column_name ] ) {
62
  return 'N/A';
63
  } else {
64
+ $date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
65
+ return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', strtotime( $item[ $column_name ] ) ), $date_time_format );
66
  }
67
  break;
68
  case 'actions':
core/admin/tables/class-logtable.php CHANGED
@@ -59,7 +59,8 @@ class LogTable extends WP_List_Table {
59
  return '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item[ $column_name ] ) .'" target="_blank" rel="noopener noreferrer">' . $item[ $column_name ] . '</a>';
60
  break;
61
  case 'date_recorded':
62
- return get_date_from_gmt( date( 'Y-m-d H:i:s', strtotime( $item[ $column_name ] )), 'm/d/y g:ia' );
 
63
  break;
64
  case 'actions':
65
  ob_start();
59
  return '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item[ $column_name ] ) .'" target="_blank" rel="noopener noreferrer">' . $item[ $column_name ] . '</a>';
60
  break;
61
  case 'date_recorded':
62
+ $date_time_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
63
+ return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', strtotime( $item[ $column_name ] ) ), $date_time_format );
64
  break;
65
  case 'actions':
66
  ob_start();
core/class-utilities.php CHANGED
@@ -17,6 +17,21 @@ defined( 'ABSPATH' ) || die();
17
  */
18
  class Utilities {
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Recursive sanitation for an array.
22
  *
17
  */
18
  class Utilities {
19
 
20
+ /**
21
+ * Returns the time since two dates.
22
+ *
23
+ * @param string $date1 First date.
24
+ * @param string $date2 Second date.
25
+ * @param string $period Period to return (d = days, y = years, m = months, h = hours, i = minutes, s = seconds, f = microseconds).
26
+ */
27
+ public static function time_since( $date1, $date2, $period = 'd' ) {
28
+ $first_date = new \DateTime( $date1 );
29
+ $second_date = new \DateTime( $date2 );
30
+ $diff = $first_date->diff( $second_date );
31
+
32
+ return $diff->$period;
33
+ }
34
+
35
  /**
36
  * Recursive sanitation for an array.
37
  *
includes/class-plugin.php CHANGED
@@ -70,13 +70,6 @@ class Plugin {
70
  * Initializes modules
71
  */
72
  private function init_modules() {
73
- // We support the Ukrainians!
74
- $ukraine = new \ZeroSpam\Modules\Ukraine();
75
-
76
- if ( $ukraine->supports_putin() ) {
77
- return false;
78
- }
79
-
80
  if ( is_admin() ) {
81
  // Plugin admin module.
82
  new \ZeroSpam\Core\Admin\Admin();
70
  * Initializes modules
71
  */
72
  private function init_modules() {
 
 
 
 
 
 
 
73
  if ( is_admin() ) {
74
  // Plugin admin module.
75
  new \ZeroSpam\Core\Admin\Admin();
modules/class-ukraine.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * Ukraine support class
4
- *
5
- * As the invasion of Ukraine continues, we at Zero Spam support those fighting
6
- * to preserve freedom, democracy, and sovereignty in their country. Because of
7
- * this unlawful invasion by Russia, supported by Belarus, we will no longer
8
- * provide protection for .ru, .su, and .by domains that have the plugin
9
- * installed and will display a Ukrainian support banner on those sites.
10
- *
11
- * Not a fan, please feel free to deactivate and uninstall the plugin.
12
- *
13
- * @package ZeroSpam
14
- */
15
-
16
- namespace ZeroSpam\Modules;
17
-
18
- // Security Note: Blocks direct access to the plugin PHP files.
19
- defined( 'ABSPATH' ) || die();
20
-
21
- /**
22
- * Ukrainian support class
23
- */
24
- class Ukraine {
25
- /**
26
- * Constructor
27
- */
28
- public function __construct() {
29
- $host = $this->get_site_host();
30
-
31
- if ( $this->supports_putin() ) {
32
- add_action( 'wp_footer', array( $this, 'output_banner' ), 1 );
33
- }
34
- }
35
-
36
- /**
37
- * Determines if the domain is .ru or .by
38
- */
39
- public function supports_putin() {
40
- $host = $this->get_site_host();
41
-
42
- if ( rest_is_ip_address( $host ) || strpos( $host, '.' ) === false ) {
43
- return false;
44
- }
45
-
46
- $tld = substr( $host, strrpos( $host, '.' ) + 1 );
47
-
48
- if ( in_array( $tld, array( 'ru', 'by', 'su' ), true ) ) {
49
- return true;
50
- }
51
-
52
- return false;
53
- }
54
-
55
- /**
56
- * Returns the site host.
57
- */
58
- public function get_site_host() {
59
- if ( function_exists( 'get_clean_basedomain' ) ) {
60
- return get_clean_basedomain();
61
- }
62
-
63
- return wp_parse_url( get_site_url(), PHP_URL_HOST );
64
- }
65
-
66
- /**
67
- * Displays the Ukrainian support banner.
68
- */
69
- public function output_banner() {
70
- ob_start();
71
- ?>
72
- <aside style="display:flex !important;align-items:center !important;position:fixed !important;bottom:40px !important;left:40px !important;z-index:99999999999999 !important;background:#fff !important;padding:15px 20px 15px !important;border-radius:3px !important;box-shadow: 2px 2px 4px rgb(0 0 0 / 10%) !important;visibility:visible !important;opacity:1 !important;">
73
- <svg width="1200px" height="800px" viewBox="0 0 1200 800" style="width:65px !important;height:auto !important;display:inline-block !important;vertical-align:middle !important;margin-right:10px !important;visibility:visible !important;opacity:1 !important;box-shadow: 1px 1px 2px rgb(0 0 0 / 20%) !important;">
74
- <title><?php esc_html_e( 'Flag of Ukraine' ); ?></title>
75
- <g>
76
- <rect fill="#005BBB" x="0" y="0" width="1200" height="800"></rect>
77
- <rect fill="#FFD500" x="0" y="400" width="1200" height="400"></rect>
78
- </g>
79
- </svg>
80
- <div style="display:block !important;visibility:visible !important;line-height:1 !important;opacity:1 !important;">
81
- <strong style="font-weight:bold !important;display:block !important;visibility:visible !important;font-size:14px !important;margin-bottom:5px !important;line-height:1 !important;color:#000 !important;opacity:1 !important;"><?php esc_html_e( 'We stand with the Ukrainian people' ); ?></strong>
82
- <a href="https://www.highfivery.com/united-with-ukraine/" target="_blank" rel="noreferrer noopener" style="color:#1a0dab !important;text-decoration:underline !important;display:block !important;visibility:visible !important;font-size:13px !important;line-height:1 !important;opacity:1 !important;"><?php esc_html_e( 'Learn how you can support the civilians of Ukraine.' ); ?></a>
83
- </div>
84
- </aside>
85
- <?php
86
- echo ob_get_clean();
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/class-zerospam.php CHANGED
@@ -34,6 +34,10 @@ class Zero_Spam {
34
  add_filter( 'zerospam_setting_sections', array( $this, 'sections' ) );
35
  add_filter( 'zerospam_settings', array( $this, 'settings' ), 10, 2 );
36
 
 
 
 
 
37
  // Fires when a user submission has been detected as spam.
38
  add_action( 'zerospam_share_detection', array( $this, 'share_detection' ), 10, 1 );
39
  }
@@ -309,6 +313,133 @@ class Zero_Spam {
309
  update_site_option( 'zero_spam_last_api_request', current_time( 'mysql' ) );
310
  }
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  /**
313
  * Query the Zero Spam Blacklist API
314
  *
34
  add_filter( 'zerospam_setting_sections', array( $this, 'sections' ) );
35
  add_filter( 'zerospam_settings', array( $this, 'settings' ), 10, 2 );
36
 
37
+ // Displays any available admin notices.
38
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
39
+ add_action( 'admin_init', array( $this, 'check_notice_dismissal' ) );
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
  }
313
  update_site_option( 'zero_spam_last_api_request', current_time( 'mysql' ) );
314
  }
315
 
316
+ /**
317
+ * Returns license key data from the API
318
+ *
319
+ * @param string $license The license key.
320
+ */
321
+ public static function get_license( $license ) {
322
+ $cache_key = sanitize_title( 'license_' . $license );
323
+ $license_data = wp_cache_get( $cache_key );
324
+ if ( false === $license_data ) {
325
+ $endpoint = ZEROSPAM_URL . 'wp-json/v1/get-license';
326
+ $args = array(
327
+ 'body' => array( 'license_key' => $license ),
328
+ );
329
+
330
+ $license_data = \ZeroSpam\Core\Utilities::remote_post( $endpoint, $args );
331
+
332
+ if ( $license_data ) {
333
+ $license_data = json_decode( $license_data, true );
334
+
335
+ if ( ! empty( $license_data['license_key'] ) ) {
336
+ $expiration = 1 * MONTH_IN_SECONDS;
337
+ wp_cache_set( $cache_key, $license_data, 'zero_spam_store', $expiration );
338
+ }
339
+ }
340
+ }
341
+
342
+ return $license_data;
343
+ }
344
+
345
+ /**
346
+ * Checks if a notice should be dismissed.
347
+ */
348
+ public function check_notice_dismissal() {
349
+ // @codingStandardsIgnoreLine
350
+ if ( isset( $_GET['zero-spam-dismiss-notice-enhanced-protection'] ) ) {
351
+ $user_id = get_current_user_id();
352
+ add_user_meta( $user_id, 'zero_spam_dismiss_notice_enhanced_protection', current_time( 'mysql' ), true );
353
+ // @codingStandardsIgnoreLine
354
+ } elseif ( isset( $_GET['zero-spam-dismiss-notice-license'] ) ) {
355
+ add_user_meta( $user_id, 'zero_spam_dismiss_notice_missing_license', current_time( 'mysql' ), true );
356
+ }
357
+ }
358
+
359
+ /**
360
+ * Outputs any available admin notices.
361
+ */
362
+ public function admin_notices() {
363
+ $settings = \ZeroSpam\Core\Settings::get_settings();
364
+ $user_id = get_current_user_id();
365
+
366
+ $is_zerospam_enabled = 'enabled' === $settings['zerospam']['value'] ? true : false;
367
+
368
+ $classes = array();
369
+
370
+ if ( $is_zerospam_enabled ) {
371
+ $license = ! empty( $settings['zerospam_license']['value'] ) ? $settings['zerospam_license']['value'] : false;
372
+ if ( ! $license ) {
373
+ $message_dismissed = get_user_meta( $user_id, 'zero_spam_dismiss_notice_missing_license', true );
374
+ if ( $message_dismissed ) {
375
+ $days_since_last_dismissed = \ZeroSpam\Core\Utilities::time_since( $message_dismissed, current_time( 'mysql' ), 'd' );
376
+
377
+ if ( $days_since_last_dismissed <= 7 ) {
378
+ return;
379
+ }
380
+ }
381
+ } else {
382
+ // Check license.
383
+ $license_data = self::get_license( $license );
384
+ if ( ! empty( $license_data['license_key'] ) ) {
385
+ return;
386
+ }
387
+ }
388
+
389
+ $classes[] = 'notice-error';
390
+
391
+ $content = '<p>' . sprintf(
392
+ wp_kses(
393
+ /* translators: %1$s: Zero Spam settings URL, %2$s: dismiss message URL */
394
+ __( '<strong>Your site is vulnerable to attacks.</strong> Please enter a valid <a href="%1$s" target="_blank" rel="noreferrer noopener"><strong>Zero Spam license key</strong></a> under <a href="%2$s">Zero Spam Enhanced Protection</a>. <a href="%3$s">Dismiss</a>', 'zero-spam' ),
395
+ array(
396
+ 'strong' => array(),
397
+ 'a' => array(
398
+ 'href' => array(),
399
+ ),
400
+ )
401
+ ),
402
+ esc_url( esc_url( ZEROSPAM_URL . 'subscribe/' ), ),
403
+ esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ) ),
404
+ esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&zero-spam-dismiss-notice-license' ) ),
405
+ ) . '</p>';
406
+ } else {
407
+ $message_dismissed = get_user_meta( $user_id, 'zero_spam_dismiss_notice_enhanced_protection', true );
408
+ if ( $message_dismissed ) {
409
+ $days_since_last_dismissed = \ZeroSpam\Core\Utilities::time_since( $message_dismissed, current_time( 'mysql' ), 'd' );
410
+
411
+ if ( $days_since_last_dismissed <= 7 ) {
412
+ return false;
413
+ }
414
+ }
415
+
416
+ $classes[] = 'notice-warning';
417
+
418
+ $content = '<p>' . sprintf(
419
+ wp_kses(
420
+ /* translators: %1$s: Zero Spam settings URL, %2$s: dismiss message URL */
421
+ __( '<strong>Your site is vulnerable to attacks.</strong> For enhanced protection, please enable <a href="%1$s"><strong>Zero Spam Enhanced Protection</strong></a>. <a href="%2$s">Dismiss</a>', 'zero-spam' ),
422
+ array(
423
+ 'strong' => array(),
424
+ 'a' => array(
425
+ 'href' => array(),
426
+ ),
427
+ )
428
+ ),
429
+ esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ) ),
430
+ esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&zero-spam-dismiss-notice-enhanced-protection' ) ),
431
+ ) . '</p>';
432
+ }
433
+ ?>
434
+ <div class="notice is-dismissible <?php echo implode( ' ', $classes ); ?>">
435
+ <?php
436
+ // @codingStandardsIgnoreLine
437
+ echo $content;
438
+ ?>
439
+ </div>
440
+ <?php
441
+ }
442
+
443
  /**
444
  * Query the Zero Spam Blacklist API
445
  *
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: bmarshall511
3
  Tags: protection, firewall, security, spam, spam blocker
4
  Donate link: https://www.zerospam.org/subscribe/
5
  Requires at least: 5.2
6
- Tested up to: 5.9.2
7
  Requires PHP: 7.3
8
- Stable tag: 5.3.2
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -13,8 +13,6 @@ No captcha needed, behind the scenes protection against spam & malicious attacks
13
 
14
  == Description ==
15
 
16
- **We stand with the Ukrainian people.** We at Zero Spam support those fighting to preserve freedom, democracy, and sovereignty in Ukraine. Because of this unlawful invasion by Russia, supported by Belarus, we will no longer provide protection for .ru, .su, and .by domains that have the plugin installed and will display a Ukrainian support banner on those sites.
17
-
18
  Quit forcing people to answer questions or confusing captchas to prove they're not spam. Stop malicious users before they ever have a chance to infiltrate your site &mdash; **introducing Zero Spam for WordPress**.
19
 
20
  [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.
@@ -106,6 +104,12 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
 
109
  = v5.3.2 =
110
 
111
  * feat(zero spam api): now reports spam and malicious email addresses
3
  Tags: protection, firewall, security, spam, spam blocker
4
  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.3
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
13
 
14
  == Description ==
15
 
 
 
16
  Quit forcing people to answer questions or confusing captchas to prove they're not spam. Stop malicious users before they ever have a chance to infiltrate your site &mdash; **introducing Zero Spam for WordPress**.
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.
104
 
105
  == Changelog ==
106
 
107
+ = v5.3.3 =
108
+
109
+ * feat(zero spam settings): displays dismissible notices for enhanced protection and invalid license keys
110
+ * feat(dates): updated the admin tables to display dates based on the site settings, resolves #305
111
+ * fix(ukraine): removed the ukraine banner
112
+
113
  = v5.3.2 =
114
 
115
  * feat(zero spam api): now reports spam and malicious email addresses
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.2
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.2' );
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.3
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.3' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );