WordPress Zero Spam - Version 5.2.2

Version Description

Download this release

Release Info

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

Code changes from version 5.2.1 to 5.2.2

assets/css/admin.css CHANGED
@@ -239,7 +239,8 @@
239
  .zerospam-type-registration::before,
240
  .zerospam-type-comment::before,
241
  .zerospam-type-fluent_form::before,
242
- .zerospam-type-wpforms::before {
 
243
  background-repeat: no-repeat;
244
  background-size: contain;
245
  content: "";
@@ -276,6 +277,11 @@
276
  background-image: url('../img/icon-wpforms.svg');
277
  }
278
 
 
 
 
 
 
279
  @media (min-width: 768px) {
280
  .zerospam-callout {
281
  flex-wrap: nowrap;
239
  .zerospam-type-registration::before,
240
  .zerospam-type-comment::before,
241
  .zerospam-type-fluent_form::before,
242
+ .zerospam-type-wpforms::before,
243
+ .zerospam-type-contactform7::before {
244
  background-repeat: no-repeat;
245
  background-size: contain;
246
  content: "";
277
  background-image: url('../img/icon-wpforms.svg');
278
  }
279
 
280
+ /* Type: contactform7 */
281
+ .zerospam-type-contactform7::before {
282
+ background-image: url('../img/icon-cf7.png');
283
+ }
284
+
285
  @media (min-width: 768px) {
286
  .zerospam-callout {
287
  flex-wrap: nowrap;
assets/img/icon-cf7.png ADDED
Binary file
core/class-utilities.php CHANGED
@@ -17,6 +17,46 @@ defined( 'ABSPATH' ) || die();
17
  */
18
  class Utilities {
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Returns list of recommended blocked email domains.
22
  */
@@ -531,7 +571,9 @@ class Utilities {
531
  * @access public
532
  */
533
  public static function current_url() {
534
- return ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
 
 
535
  }
536
 
537
  /**
17
  */
18
  class Utilities {
19
 
20
+ /**
21
+ * Recursive sanitation for an array.
22
+ *
23
+ * @param array $array Array to sanitize.
24
+ * @param string $type Type of sanitization.
25
+ */
26
+ public static function sanitize_array( $array, $type = 'sanitize_text_field' ) {
27
+ if ( ! is_array( $array ) ) {
28
+ switch ( $type ) {
29
+ case 'sanitize_text_field':
30
+ $array = sanitize_text_field( $array );
31
+ break;
32
+ case 'esc_html':
33
+ $array = esc_html( $array );
34
+ break;
35
+ default:
36
+ $array = sanitize_text_field( $array );
37
+ }
38
+ } else {
39
+ foreach ( $array as $key => &$value ) {
40
+ if ( is_array( $value ) ) {
41
+ $value = self::sanitize_array( $value );
42
+ } else {
43
+ switch ( $type ) {
44
+ case 'sanitize_text_field':
45
+ $value = sanitize_text_field( $value );
46
+ break;
47
+ case 'esc_html':
48
+ $value = esc_html( $value );
49
+ break;
50
+ default:
51
+ $value = sanitize_text_field( $value );
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ return $array;
58
+ }
59
+
60
  /**
61
  * Returns list of recommended blocked email domains.
62
  */
571
  * @access public
572
  */
573
  public static function current_url() {
574
+ $url = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
575
+
576
+ return $url;
577
  }
578
 
579
  /**
includes/class-db.php CHANGED
@@ -84,7 +84,7 @@ class DB {
84
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
85
  dbDelta( $sql );
86
 
87
- update_option( 'zerospam_db_version', self::DB_VERSION );
88
  }
89
  }
90
 
@@ -151,15 +151,15 @@ class DB {
151
  }
152
 
153
  /**
154
- * Log.
155
  *
156
- * @since 5.0.0
157
- * @access public
158
  */
159
  public static function log( $type, $details ) {
160
  global $wpdb;
161
 
162
- $page_url = ZeroSpam\Core\Utilities::current_url();
163
  $extension = substr( $page_url, strrpos( $page_url, '.' ) + 1 );
164
  $ignore = array( 'map', 'js', 'css', 'ico' );
165
  if ( in_array( $extension, $ignore, true ) ) {
@@ -171,16 +171,20 @@ class DB {
171
  * Check the total number of entries and delete the oldest if the maximum
172
  * has been reached.
173
  */
174
- $total = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $wpdb->prefix . self::$tables['log'] );
175
- $max = ZeroSpam\Core\Settings::get_settings( 'max_logs' );
176
- if ( $total > $max ) {
177
- $difference = $total - $max;
178
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . self::$tables['log'] . ' ORDER BY date_recorded ASC LIMIT ' . $difference );
 
 
179
  }
180
 
181
- $record = array(
182
- 'user_ip' => ZeroSpam\Core\User::get_ip(),
183
- 'log_type' => $type,
 
 
184
  'date_recorded' => current_time( 'mysql' ),
185
  'page_url' => $page_url,
186
  'submission_data' => wp_json_encode( $details ),
84
  require_once ABSPATH . 'wp-admin/includes/upgrade.php';
85
  dbDelta( $sql );
86
 
87
+ update_site_option( 'zerospam_db_version', self::DB_VERSION );
88
  }
89
  }
90
 
151
  }
152
 
153
  /**
154
+ * Log
155
  *
156
+ * @param string $type Type of log.
157
+ * @param array $details Array of details for the log entry.
158
  */
159
  public static function log( $type, $details ) {
160
  global $wpdb;
161
 
162
+ $page_url = \ZeroSpam\Core\Utilities::current_url();
163
  $extension = substr( $page_url, strrpos( $page_url, '.' ) + 1 );
164
  $ignore = array( 'map', 'js', 'css', 'ico' );
165
  if ( in_array( $extension, $ignore, true ) ) {
171
  * Check the total number of entries and delete the oldest if the maximum
172
  * has been reached.
173
  */
174
+ $log_table = $wpdb->prefix . self::$tables['log'];
175
+ $total_entries = $wpdb->get_var( "SELECT COUNT(*) FROM $log_table" );
176
+ $maximum_entries = \ZeroSpam\Core\Settings::get_settings( 'max_logs' );
177
+
178
+ if ( $total_entries > $maximum_entries ) {
179
+ $difference = $total_entries - $maximum_entries;
180
+ $wpdb->query( "DELETE FROM $log_table ORDER BY date_recorded ASC LIMIT $difference" );
181
  }
182
 
183
+ // Sanitize details array.
184
+ $details = \ZeroSpam\Core\Utilities::sanitize_array( $details );
185
+ $record = array(
186
+ 'user_ip' => \ZeroSpam\Core\User::get_ip(),
187
+ 'log_type' => sanitize_text_field( $type ),
188
  'date_recorded' => current_time( 'mysql' ),
189
  'page_url' => $page_url,
190
  'submission_data' => wp_json_encode( $details ),
includes/templates/admin-modal-details.php CHANGED
@@ -5,33 +5,58 @@
5
  * @package ZeroSpam
6
  * @since 5.0.0
7
  */
8
- ?>
9
 
 
10
  <div class="zerospam-modal-details">
11
  <div class="zerospam-modal-title">
12
- <h3>ID #<?php echo $item['log_id']; ?></h3>
13
  </div>
14
  <div class="zerospam-modal-subtitle">
15
- <?php echo gmdate( 'M j, Y g:ia' , strtotime( $item[ 'date_recorded' ] ) ); ?>
 
 
 
 
 
 
 
16
  </div>
17
 
18
  <ul class="zerospam-modal-list">
19
  <li>
20
- <strong><?php echo __( 'IP Address', 'zerospam' ); ?></strong>
21
- <span><?php echo '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item['user_ip'] ) .'" target="_blank" rel="noopener noreferrer">' . $item['user_ip'] . '</a>'; ?></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </li>
23
  <li>
24
- <strong><?php echo __( 'Type', 'zerospam' ); ?></strong>
25
- <span><?php echo $item['log_type']; ?></span>
26
  </li>
27
  </ul>
28
 
29
- <button class="button action zerospam-block-trigger" data-id="<?php echo esc_attr( $item['log_id'] ); ?>"><?php _e( 'Block IP', 'zerospam' ); ?></button>
 
 
30
 
31
- <?php
32
- if ( ! empty( $item['latitude'] ) && ! empty( $item['longitude'] ) ) {
33
- ?>
34
- <h4 class="zerospam-modal-headline"><?php echo __( 'Location', 'zerospam' ); ?></h4>
35
  <?php
36
  $coordinates = $item['latitude'] . ',' . $item['longitude'];
37
  do_action( 'zerospam_google_map', $coordinates );
@@ -39,84 +64,100 @@
39
  <ul class="zerospam-modal-list">
40
  <?php if ( ! empty( $item['country'] ) ) : ?>
41
  <li>
42
- <strong><?php echo __( 'Country', 'zerospam' ); ?></strong>
43
  <span>
44
  <?php
45
  $country_name = ! empty( $item['country_name'] ) ? $item['country_name'] : false;
46
  $flag = ZeroSpam\Core\Utilities::country_flag_url( $item['country'] );
47
 
48
- $country = '<img src="' . $flag . '" width="16" height="16" alt="' . esc_attr( $country_name . ' (' . $item['country'] . ')' ) . '" class="zerospam-flag" />';
49
  if ( $country_name ) {
50
- $country .= $country_name . ' (' . $item['country'] . ')';
51
  } else {
52
- $country .= $item['country'];
53
  }
54
 
55
- echo $country;
 
 
 
 
 
 
 
 
 
 
56
  ?>
57
  </span>
58
  </li>
59
  <?php endif; ?>
60
  <?php if ( ! empty( $item['region'] ) || ! empty( $item['region_name'] ) ) : ?>
61
  <li>
62
- <strong><?php echo __( 'Region', 'zerospam' ); ?></strong>
63
  <span>
64
  <?php if ( ! empty( $item['region_name'] ) ) : ?>
65
- <?php echo $item['region_name']; ?>
66
  <?php endif; ?>
67
  <?php if ( ! empty( $item['region'] ) ) : ?>
68
- (<?php echo $item['region']; ?>)
69
  <?php endif; ?>
70
  </span>
71
  </li>
72
  <?php endif; ?>
73
  <?php if ( ! empty( $item['city'] ) ) : ?>
74
  <li>
75
- <strong><?php echo __( 'City', 'zerospam' ); ?></strong>
76
- <span><?php echo $item['city']; ?>
77
  </span>
78
  </li>
79
  <?php endif; ?>
80
  <?php if ( ! empty( $item['zip'] ) ) : ?>
81
  <li>
82
- <strong><?php echo __( 'Zip/Postal Code', 'zerospam' ); ?></strong>
83
- <span><?php echo $item['zip']; ?>
84
  </span>
85
  </li>
86
  <?php endif; ?>
87
  <?php if ( ! empty( $item['latitude'] ) || ! empty( $item['region_name'] ) ) : ?>
88
  <li>
89
- <strong><?php echo __( 'Coordinates', 'zerospam' ); ?></strong>
90
  <span>
91
  <?php if ( ! empty( $item['latitude'] ) ) : ?>
92
- <?php echo $item['latitude']; ?>&deg;,
93
  <?php endif; ?>
94
  <?php if ( ! empty( $item['longitude'] ) ) : ?>
95
- <?php echo $item['longitude']; ?>&deg;
96
  <?php endif; ?>
97
  </span>
98
  </li>
99
  <?php endif; ?>
100
  </ul>
101
  <?php
102
- }
103
  ?>
104
 
105
- <h4 class="zerospam-modal-headline"><?php echo __( 'Additional Details', 'zerospam' ); ?></h4>
106
  <?php
107
 
108
  if ( ! empty( $item['submission_data'] ) ) :
 
109
  $submission_data = json_decode( $item['submission_data'], true );
 
110
  echo '<ul class="zerospam-modal-list">';
111
  foreach ( $submission_data as $key => $value ) :
112
  ?>
113
  <li>
114
- <strong><?php echo $key; ?></strong>
115
  <span>
116
- <?php if ( is_array( $value ) ) : ?>
 
 
 
 
117
  <?php echo wp_json_encode( $value ); ?>
118
  <?php else : ?>
119
- <?php echo $value; ?>
120
  <?php endif; ?>
121
  </span>
122
  </li>
5
  * @package ZeroSpam
6
  * @since 5.0.0
7
  */
 
8
 
9
+ ?>
10
  <div class="zerospam-modal-details">
11
  <div class="zerospam-modal-title">
12
+ <h3>ID #<?php echo esc_html( $item['log_id'] ); ?></h3>
13
  </div>
14
  <div class="zerospam-modal-subtitle">
15
+ <?php
16
+ echo esc_html(
17
+ gmdate(
18
+ 'M j, Y g:ia',
19
+ strtotime( $item['date_recorded'] )
20
+ )
21
+ );
22
+ ?>
23
  </div>
24
 
25
  <ul class="zerospam-modal-list">
26
  <li>
27
+ <strong><?php esc_html_e( 'IP Address', 'zerospam' ); ?></strong>
28
+ <span>
29
+ <?php
30
+ echo sprintf(
31
+ wp_kses(
32
+ /* translators: %1s: IP URL lookup, %2$2 IP address, %2s: IP address */
33
+ __( '<a href="%1$s" target="_blank" rel="noreferrer noopener">%2$s</a>', 'zerospam' ),
34
+ array(
35
+ 'a' => array(
36
+ 'target' => array(),
37
+ 'href' => array(),
38
+ 'rel' => array(),
39
+ ),
40
+ )
41
+ ),
42
+ esc_url( ZEROSPAM_URL . 'ip-lookup/' . rawurlencode( esc_html( $item['user_ip'] ) ) ),
43
+ esc_html( $item['user_ip'] )
44
+ );
45
+ ?>
46
+ </span>
47
  </li>
48
  <li>
49
+ <strong><?php esc_html_e( 'Type', 'zerospam' ); ?></strong>
50
+ <span><?php echo esc_html( $item['log_type'] ); ?></span>
51
  </li>
52
  </ul>
53
 
54
+ <button class="button action zerospam-block-trigger" data-id="<?php echo esc_attr( $item['log_id'] ); ?>">
55
+ <?php esc_html_e( 'Block IP', 'zerospam' ); ?>
56
+ </button>
57
 
58
+ <?php if ( ! empty( $item['latitude'] ) && ! empty( $item['longitude'] ) ) : ?>
59
+ <h4 class="zerospam-modal-headline"><?php esc_html_e( 'Location', 'zerospam' ); ?></h4>
 
 
60
  <?php
61
  $coordinates = $item['latitude'] . ',' . $item['longitude'];
62
  do_action( 'zerospam_google_map', $coordinates );
64
  <ul class="zerospam-modal-list">
65
  <?php if ( ! empty( $item['country'] ) ) : ?>
66
  <li>
67
+ <strong><?php esc_html_e( 'Country', 'zerospam' ); ?></strong>
68
  <span>
69
  <?php
70
  $country_name = ! empty( $item['country_name'] ) ? $item['country_name'] : false;
71
  $flag = ZeroSpam\Core\Utilities::country_flag_url( $item['country'] );
72
 
73
+ $country = '<img src="' . esc_url( $flag ) . '" width="16" height="16" alt="' . esc_attr( $country_name . ' (' . $item['country'] . ')' ) . '" class="zerospam-flag" />';
74
  if ( $country_name ) {
75
+ $country .= esc_html( $country_name . ' (' . $item['country'] . ')' );
76
  } else {
77
+ $country .= esc_html( $item['country'] );
78
  }
79
 
80
+ echo wp_kses(
81
+ $country,
82
+ array(
83
+ 'img' => array(
84
+ 'width' => array(),
85
+ 'height' => array(),
86
+ 'alt' => array(),
87
+ 'class' => array(),
88
+ ),
89
+ )
90
+ );
91
  ?>
92
  </span>
93
  </li>
94
  <?php endif; ?>
95
  <?php if ( ! empty( $item['region'] ) || ! empty( $item['region_name'] ) ) : ?>
96
  <li>
97
+ <strong><?php esc_html_e( 'Region', 'zerospam' ); ?></strong>
98
  <span>
99
  <?php if ( ! empty( $item['region_name'] ) ) : ?>
100
+ <?php echo esc_html( $item['region_name'] ); ?>
101
  <?php endif; ?>
102
  <?php if ( ! empty( $item['region'] ) ) : ?>
103
+ (<?php echo esc_html( $item['region'] ); ?>)
104
  <?php endif; ?>
105
  </span>
106
  </li>
107
  <?php endif; ?>
108
  <?php if ( ! empty( $item['city'] ) ) : ?>
109
  <li>
110
+ <strong><?php echo esc_html_e( 'City', 'zerospam' ); ?></strong>
111
+ <span><?php echo esc_html( $item['city'] ); ?>
112
  </span>
113
  </li>
114
  <?php endif; ?>
115
  <?php if ( ! empty( $item['zip'] ) ) : ?>
116
  <li>
117
+ <strong><?php echo esc_html_e( 'Zip/Postal Code', 'zerospam' ); ?></strong>
118
+ <span><?php echo esc_html( $item['zip'] ); ?>
119
  </span>
120
  </li>
121
  <?php endif; ?>
122
  <?php if ( ! empty( $item['latitude'] ) || ! empty( $item['region_name'] ) ) : ?>
123
  <li>
124
+ <strong><?php echo esc_html_e( 'Coordinates', 'zerospam' ); ?></strong>
125
  <span>
126
  <?php if ( ! empty( $item['latitude'] ) ) : ?>
127
+ <?php echo esc_html( $item['latitude'] ); ?>&deg;,
128
  <?php endif; ?>
129
  <?php if ( ! empty( $item['longitude'] ) ) : ?>
130
+ <?php echo esc_html( $item['longitude'] ); ?>&deg;
131
  <?php endif; ?>
132
  </span>
133
  </li>
134
  <?php endif; ?>
135
  </ul>
136
  <?php
137
+ endif;
138
  ?>
139
 
140
+ <h4 class="zerospam-modal-headline"><?php echo esc_html_e( 'Additional Details', 'zerospam' ); ?></h4>
141
  <?php
142
 
143
  if ( ! empty( $item['submission_data'] ) ) :
144
+ // Sanatize the array.
145
  $submission_data = json_decode( $item['submission_data'], true );
146
+ $submission_data = \ZeroSpam\Core\Utilities::sanitize_array( $submission_data, 'esc_html' );
147
  echo '<ul class="zerospam-modal-list">';
148
  foreach ( $submission_data as $key => $value ) :
149
  ?>
150
  <li>
151
+ <strong><?php echo esc_html( $key ); ?></strong>
152
  <span>
153
+ <?php
154
+ if ( is_array( $value ) ) :
155
+ // Sanatize the array.
156
+ $value = \ZeroSpam\Core\Utilities::sanitize_array( $value, 'esc_html' );
157
+ ?>
158
  <?php echo wp_json_encode( $value ); ?>
159
  <?php else : ?>
160
+ <?php echo esc_html( $value ); ?>
161
  <?php endif; ?>
162
  </span>
163
  </li>
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.8.2
7
  Requires PHP: 7.3
8
- Stable tag: 5.2.1
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -94,6 +94,12 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
97
  = v5.2.1 =
98
 
99
  * fix(woocommerce): resolves #280, fixes login integration breaking woocommerce login form
5
  Requires at least: 5.2
6
  Tested up to: 5.8.2
7
  Requires PHP: 7.3
8
+ Stable tag: 5.2.2
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
94
 
95
  == Changelog ==
96
 
97
+ = v5.2.2 =
98
+
99
+ * fix(db): resolves #281, fixes db update error for multisite installations
100
+ * fix(db): fix for unsanitized db log entries
101
+ * style(admin): new cf7 icon added for blocked log
102
+
103
  = v5.2.1 =
104
 
105
  * fix(woocommerce): resolves #280, fixes login integration breaking woocommerce login form
wordpress-zero-spam.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
  * Description: Tired of all the worthless and bloated WordPress anti-spam plugins? The WordPress Zero Spam plugin makes blocking spam &amp; malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
16
- * Version: 5.2.1
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.2.1' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
  * Description: Tired of all the worthless and bloated WordPress anti-spam plugins? The WordPress Zero Spam plugin makes blocking spam &amp; malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
16
+ * Version: 5.2.2
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.2.2' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );