WordPress Zero Spam - Version 3.1.1

Version Description

Download this release

Release Info

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

Code changes from version 3.1.0 to 3.1.1

inc/helpers.php CHANGED
@@ -9,11 +9,6 @@
9
  * @since 1.0.0
10
  */
11
 
12
- /**
13
- * Security Note: Blocks direct access to the plugin PHP files.
14
- */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
16
-
17
  function zerospam_settings() {
18
  if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
19
  // Network plugin settings.
@@ -34,19 +29,19 @@ function zerospam_get_key() {
34
  }
35
 
36
  function zerospam_is_valid() {
37
- if ( ! empty( $_POST['zerospam_key'] ) && $_POST['zerospam_key'] == zerospam_get_key() ) {
38
  return true;
39
  }
40
 
41
  return false;
42
  }
43
 
44
- function zerospam_get_server_var($var)
45
  {
46
- if ( getenv($var) ) {
47
- return getenv($var);
48
- } else if ( isset($_SERVER[$var]) ) {
49
- return $_SERVER[$var];
50
  } else {
51
  return '';
52
  }
@@ -54,15 +49,15 @@ function zerospam_get_server_var($var)
54
 
55
  function zerospam_get_ip() {
56
 
57
- $ipaddress = zerospam_get_server_var('HTTP_CLIENT_IP');
58
- if ( !$ipaddress ) { $ipaddress = zerospam_get_server_var('HTTP_X_FORWARDED_FOR'); }
59
- if ( !$ipaddress ) { $ipaddress = zerospam_get_server_var('HTTP_X_FORWARDED'); }
60
- if ( !$ipaddress ) { $ipaddress = zerospam_get_server_var('HTTP_FORWARDED_FOR'); }
61
- if ( !$ipaddress ) { $ipaddress = zerospam_get_server_var('HTTP_FORWARDED'); }
62
- if ( !$ipaddress ) { $ipaddress = zerospam_get_server_var('REMOTE_ADDR'); }
63
 
64
- $ipaddress = explode(',', $ipaddress, 2);
65
- $ipaddress = trim($ipaddress[0]);
66
 
67
  if ( false === WP_Http::is_ip_address( $ipaddress ) ) {
68
  $ipaddress = 'UNKNOWN';
@@ -81,7 +76,7 @@ function zerospam_log_spam( $key, $url = false ) {
81
  $url = ( $url ) ? $url : zerospam_get_url();
82
  $table_name = $wpdb->prefix . 'zerospam_log';
83
 
84
- switch( $key ) {
85
  case 'registration':
86
  $key = 1;
87
  break;
@@ -117,11 +112,11 @@ function zerospam_log_spam( $key, $url = false ) {
117
  )
118
  );
119
 
120
- if ( ! empty( $settings['auto_block'] ) && $settings['auto_block'] ) {
121
  zerospam_block_ip( array(
122
  'ip' => $ip,
123
  'type' => 'permanent',
124
- 'reason' => __( 'Auto block triggered on ', 'zerospam' ) . date( 'r' ) . '.'
125
  ));
126
  }
127
  }
@@ -254,7 +249,7 @@ function zerospam_get_spam( $args = array() ) {
254
  $limit = isset( $args['limit'] ) ? $args['limit'] : false;
255
  if ( $offset && $limit ) {
256
  $limit = ' LIMIT ' . $offset . ', ' . $limit;
257
- } elseif( $limit ) {
258
  $limit = ' LIMIT ' . $limit;
259
  }
260
 
@@ -284,7 +279,7 @@ function zerospam_parse_spam_ary( $ary ) {
284
  'Wed' => 0,
285
  'Thu' => 0,
286
  'Fri' => 0,
287
- 'Sat' => 0
288
  ),
289
  );
290
 
@@ -321,7 +316,7 @@ function zerospam_parse_spam_ary( $ary ) {
321
  $return['by_spam_count'][ $obj->ip ]++;
322
 
323
  // Spam type
324
- if ( 1 == $obj->type) {
325
 
326
  // Registration spam.
327
  $return['by_date'][ substr( $obj->date, 0, 10 ) ]['registration_spam']++;
@@ -357,11 +352,15 @@ function zerospam_parse_spam_ary( $ary ) {
357
  $return['by_date'][ substr( $obj->date, 0, 10 ) ]['wpf_spam']++;
358
  $return['wpf_spam']++;
359
  } else {
360
- if ( empty( $return['by_date'][ substr( $obj->date, 0, 10 ) ][$obj->type] ) ) $return['by_date'][ substr( $obj->date, 0, 10 ) ][$obj->type] = 0;
361
- $return['by_date'][ substr( $obj->date, 0, 10 ) ][$obj->type]++;
 
 
362
 
363
- if ( empty( $return[$obj->type] ) ) $return[$obj->type] = 0;
364
- $return[$obj->type]++;
 
 
365
  }
366
 
367
  // Unique spammers
@@ -394,17 +393,17 @@ function zerospam_all_spam_ary() {
394
  'Wed' => 0,
395
  'Thu' => 0,
396
  'Fri' => 0,
397
- 'Sat' => 0
398
  ),
399
  );
400
 
401
  $table_name = $wpdb->prefix . 'zerospam_log';
402
 
403
  // Count all
404
- if ( $r = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS zerospam_id FROM $table_name WHERE 1=1 LIMIT 10") ) {
405
  // SELECT COUNT(*) counts, MIN(date) date_start FROM $table_name WHERE 1=1
406
- $return['raw'] = $wpdb->get_var("SELECT FOUND_ROWS()");// array_fill(0, $count_all, 0);// JUST USE $count_all next time...
407
- $return['date_start'] = $wpdb->get_var("SELECT date FROM $table_name WHERE zerospam_id = (SELECT MIN(zerospam_id) FROM $table_name)");
408
  } else {
409
  // there's no spammer logs...
410
  return $return;
@@ -417,7 +416,8 @@ function zerospam_all_spam_ary() {
417
  4 => 'gf_spam',
418
  5 => 'bp_registration_spam',
419
  'nf' => 'nf_spam',
420
- 'Undefined Form' => 'undefined_form' );
 
421
 
422
  // Get spammers by weekday.
423
  $by_weekday_ary = $wpdb->get_results( "SELECT DATE_FORMAT(date, '%a') as day, COUNT(*) num FROM $table_name GROUP BY day", ARRAY_A );
@@ -443,7 +443,7 @@ function zerospam_all_spam_ary() {
443
  $by_type = $wpdb->get_results( "SELECT type, COUNT(*) num FROM $table_name GROUP BY type", ARRAY_A );
444
  if ( $by_type )
445
  {
446
- foreach( $by_type as $key => $ary )
447
  {
448
  $type = ! empty( $type_map[ $ary['type'] ] ) ? $type_map[ $ary['type'] ] : $ary['type'];
449
  $return[ $type ] = $ary['num'];
@@ -461,7 +461,7 @@ function zerospam_all_spam_ary() {
461
  $by_date = $wpdb->get_results( "SELECT type, LEFT(date, 10) day, COUNT(*) num FROM $table_name GROUP BY day, type ORDER BY date DESC LIMIT 100", ARRAY_A );
462
  if ( $by_date )
463
  {
464
- foreach( $by_date as $key => $ary )
465
  {
466
  if ( ! empty( $return['by_date'][ $ary['day'] ] ) )
467
  {
@@ -472,7 +472,7 @@ function zerospam_all_spam_ary() {
472
  'cf7_spam' => 0,
473
  'gf_spam' => 0,
474
  'bp_registration_spam' => 0,
475
- 'nf_spam' => 0
476
  );
477
  }
478
  $return['by_date'][ $ary['day'] ][ $type_map[ $ary['type'] ] ] = $ary['num'];
@@ -558,7 +558,7 @@ function zerospam_pager( $limit = 10, $total_num, $page, $tab ) {
558
  echo '<li><a href="' . zerospam_admin_url() . '?page=zerospam&tab=' . $tab . '&p=' . $i . '"' . $class . '>' . $i . '</a>';
559
  }
560
 
561
- if( isset( $post_html ) ) {
562
  echo $post_html;
563
  }
564
  echo '</ul>';
@@ -634,50 +634,51 @@ function zerospam_get_ip_info( $ip ) {
634
  if ( $ip == '127.0.0.1' || $ip == '::1' ) {
635
  return false;
636
  }
637
-
638
  // Check DB
639
  $table_name = $wpdb->prefix . 'zerospam_ip_data';
640
  $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE ip = %s", $ip ) );
641
 
642
  // Retrieve from API
643
  if ( ! $data ) {
644
- // @ used to suppress API usage block warning.
645
- $json = @file_get_contents( 'http://freegeoip.net/json/' . $ip );
646
-
647
- $data = json_decode( $json );
648
-
649
- if ( $data ) {
650
- $wpdb->insert( $table_name, array(
651
- 'ip' => $ip,
652
- 'country_code' => $data->country_code,
653
- 'country_name' => $data->country_name,
654
- 'region_code' => $data->region_code,
655
- 'region_name' => $data->region_name,
656
- 'city' => $data->city,
657
- 'zipcode' => $data->zipcode,
658
- 'latitude' => $data->latitude,
659
- 'longitude' => $data->longitude,
660
- 'metro_code' => $data->metro_code,
661
- 'area_code' => $data->area_code
662
- ),
663
- array(
664
- '%s',
665
- '%s',
666
- '%s',
667
- '%s',
668
- '%s',
669
- '%s',
670
- '%s',
671
- '%d',
672
- '%d',
673
- '%d',
674
- '%d'
675
- )
676
- );
 
677
  }
678
  }
679
 
680
- if ( FALSE != $data ) {
681
  return $data;
682
  }
683
 
9
  * @since 1.0.0
10
  */
11
 
 
 
 
 
 
12
  function zerospam_settings() {
13
  if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
14
  // Network plugin settings.
29
  }
30
 
31
  function zerospam_is_valid() {
32
+ if ( ! empty( $_POST['zerospam_key'] ) && $_POST['zerospam_key'] == zerospam_get_key() ) {
33
  return true;
34
  }
35
 
36
  return false;
37
  }
38
 
39
+ function zerospam_get_server_var( $var )
40
  {
41
+ if ( getenv( $var ) ) {
42
+ return getenv( $var );
43
+ } elseif ( isset( $_SERVER[ $var ] ) ) {
44
+ return $_SERVER[ $var ];
45
  } else {
46
  return '';
47
  }
49
 
50
  function zerospam_get_ip() {
51
 
52
+ $ipaddress = zerospam_get_server_var( 'HTTP_CLIENT_IP' );
53
+ if ( ! $ipaddress ) { $ipaddress = zerospam_get_server_var( 'HTTP_X_FORWARDED_FOR' ); }
54
+ if ( ! $ipaddress ) { $ipaddress = zerospam_get_server_var( 'HTTP_X_FORWARDED' ); }
55
+ if ( ! $ipaddress ) { $ipaddress = zerospam_get_server_var( 'HTTP_FORWARDED_FOR' ); }
56
+ if ( ! $ipaddress ) { $ipaddress = zerospam_get_server_var( 'HTTP_FORWARDED' ); }
57
+ if ( ! $ipaddress ) { $ipaddress = zerospam_get_server_var( 'REMOTE_ADDR' ); }
58
 
59
+ $ipaddress = explode( ',', $ipaddress, 2 );
60
+ $ipaddress = trim( $ipaddress[0] );
61
 
62
  if ( false === WP_Http::is_ip_address( $ipaddress ) ) {
63
  $ipaddress = 'UNKNOWN';
76
  $url = ( $url ) ? $url : zerospam_get_url();
77
  $table_name = $wpdb->prefix . 'zerospam_log';
78
 
79
+ switch ( $key ) {
80
  case 'registration':
81
  $key = 1;
82
  break;
112
  )
113
  );
114
 
115
+ if ( ! empty( $settings['auto_block'] ) && $settings['auto_block'] ) {
116
  zerospam_block_ip( array(
117
  'ip' => $ip,
118
  'type' => 'permanent',
119
+ 'reason' => __( 'Auto block triggered on ', 'zerospam' ) . date( 'r' ) . '.',
120
  ));
121
  }
122
  }
249
  $limit = isset( $args['limit'] ) ? $args['limit'] : false;
250
  if ( $offset && $limit ) {
251
  $limit = ' LIMIT ' . $offset . ', ' . $limit;
252
+ } elseif ( $limit ) {
253
  $limit = ' LIMIT ' . $limit;
254
  }
255
 
279
  'Wed' => 0,
280
  'Thu' => 0,
281
  'Fri' => 0,
282
+ 'Sat' => 0,
283
  ),
284
  );
285
 
316
  $return['by_spam_count'][ $obj->ip ]++;
317
 
318
  // Spam type
319
+ if ( 1 == $obj->type ) {
320
 
321
  // Registration spam.
322
  $return['by_date'][ substr( $obj->date, 0, 10 ) ]['registration_spam']++;
352
  $return['by_date'][ substr( $obj->date, 0, 10 ) ]['wpf_spam']++;
353
  $return['wpf_spam']++;
354
  } else {
355
+ if ( empty( $return['by_date'][ substr( $obj->date, 0, 10 ) ][ $obj->type ] ) ) {
356
+ $return['by_date'][ substr( $obj->date, 0, 10 ) ][ $obj->type ] = 0;
357
+ }
358
+ $return['by_date'][ substr( $obj->date, 0, 10 ) ][ $obj->type ]++;
359
 
360
+ if ( empty( $return[ $obj->type ] ) ) {
361
+ $return[ $obj->type ] = 0;
362
+ }
363
+ $return[ $obj->type ]++;
364
  }
365
 
366
  // Unique spammers
393
  'Wed' => 0,
394
  'Thu' => 0,
395
  'Fri' => 0,
396
+ 'Sat' => 0,
397
  ),
398
  );
399
 
400
  $table_name = $wpdb->prefix . 'zerospam_log';
401
 
402
  // Count all
403
+ if ( $r = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS zerospam_id FROM $table_name WHERE 1=1 LIMIT 10" ) ) {
404
  // SELECT COUNT(*) counts, MIN(date) date_start FROM $table_name WHERE 1=1
405
+ $return['raw'] = $wpdb->get_var( 'SELECT FOUND_ROWS()' );// array_fill(0, $count_all, 0);// JUST USE $count_all next time...
406
+ $return['date_start'] = $wpdb->get_var( "SELECT date FROM $table_name WHERE zerospam_id = (SELECT MIN(zerospam_id) FROM $table_name)" );
407
  } else {
408
  // there's no spammer logs...
409
  return $return;
416
  4 => 'gf_spam',
417
  5 => 'bp_registration_spam',
418
  'nf' => 'nf_spam',
419
+ 'Undefined Form' => 'undefined_form',
420
+ );
421
 
422
  // Get spammers by weekday.
423
  $by_weekday_ary = $wpdb->get_results( "SELECT DATE_FORMAT(date, '%a') as day, COUNT(*) num FROM $table_name GROUP BY day", ARRAY_A );
443
  $by_type = $wpdb->get_results( "SELECT type, COUNT(*) num FROM $table_name GROUP BY type", ARRAY_A );
444
  if ( $by_type )
445
  {
446
+ foreach ( $by_type as $key => $ary )
447
  {
448
  $type = ! empty( $type_map[ $ary['type'] ] ) ? $type_map[ $ary['type'] ] : $ary['type'];
449
  $return[ $type ] = $ary['num'];
461
  $by_date = $wpdb->get_results( "SELECT type, LEFT(date, 10) day, COUNT(*) num FROM $table_name GROUP BY day, type ORDER BY date DESC LIMIT 100", ARRAY_A );
462
  if ( $by_date )
463
  {
464
+ foreach ( $by_date as $key => $ary )
465
  {
466
  if ( ! empty( $return['by_date'][ $ary['day'] ] ) )
467
  {
472
  'cf7_spam' => 0,
473
  'gf_spam' => 0,
474
  'bp_registration_spam' => 0,
475
+ 'nf_spam' => 0,
476
  );
477
  }
478
  $return['by_date'][ $ary['day'] ][ $type_map[ $ary['type'] ] ] = $ary['num'];
558
  echo '<li><a href="' . zerospam_admin_url() . '?page=zerospam&tab=' . $tab . '&p=' . $i . '"' . $class . '>' . $i . '</a>';
559
  }
560
 
561
+ if ( isset( $post_html ) ) {
562
  echo $post_html;
563
  }
564
  echo '</ul>';
634
  if ( $ip == '127.0.0.1' || $ip == '::1' ) {
635
  return false;
636
  }
637
+
638
  // Check DB
639
  $table_name = $wpdb->prefix . 'zerospam_ip_data';
640
  $data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE ip = %s", $ip ) );
641
 
642
  // Retrieve from API
643
  if ( ! $data ) {
644
+ $settings = zerospam_settings();
645
+ $ipstack_api_key = ! empty( $settings['ipstack_api_key'] ) ? $settings['ipstack_api_key'] : false;
646
+
647
+ if ( $ipstack_api_key ) {
648
+ // @ used to suppress API usage block warning.
649
+ $json = @file_get_contents( 'http://api.ipstack.com/' . $ip . '?access_key=' . $ipstack_api_key );
650
+
651
+ $data = json_decode( $json );
652
+
653
+ if ( $data ) {
654
+ $wpdb->insert( $table_name, array(
655
+ 'ip' => $ip,
656
+ 'country_code' => $data->country_code,
657
+ 'country_name' => $data->country_name,
658
+ 'region_code' => $data->region_code,
659
+ 'region_name' => $data->region_name,
660
+ 'city' => $data->city,
661
+ 'zipcode' => $data->zip,
662
+ 'latitude' => $data->latitude,
663
+ 'longitude' => $data->longitude,
664
+ ),
665
+ array(
666
+ '%s',
667
+ '%s',
668
+ '%s',
669
+ '%s',
670
+ '%s',
671
+ '%s',
672
+ '%s',
673
+ '%d',
674
+ '%d',
675
+ )
676
+ );
677
+ }
678
  }
679
  }
680
 
681
+ if ( false != $data ) {
682
  return $data;
683
  }
684
 
lib/ZeroSpam/Access.php CHANGED
@@ -3,7 +3,7 @@ class ZeroSpam_Access extends ZeroSpam_Plugin {
3
  public function run() {
4
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
5
 
6
- if ( ! empty ( $this->settings['wp_generator'] ) && $this->settings['wp_generator'] ) {
7
  remove_action( 'wp_head', 'wp_generator' );
8
  }
9
  }
@@ -34,4 +34,4 @@ class ZeroSpam_Access extends ZeroSpam_Plugin {
34
  die( __( $this->settings['blocked_ip_msg'], 'zerospam' ) );
35
  }
36
  }
37
- }
3
  public function run() {
4
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
5
 
6
+ if ( ! empty( $this->settings['wp_generator'] ) && $this->settings['wp_generator'] ) {
7
  remove_action( 'wp_head', 'wp_generator' );
8
  }
9
  }
34
  die( __( $this->settings['blocked_ip_msg'], 'zerospam' ) );
35
  }
36
  }
37
+ }
lib/ZeroSpam/Admin.php CHANGED
@@ -95,8 +95,8 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
95
  add_settings_field( 'log_spammers', __( 'Log Spammers', 'zerospam' ), array( $this, 'field_log_spammers' ), 'zerospam_general_settings', 'section_general' );
96
 
97
  if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
98
- // IP location API support.
99
- add_settings_field( 'ip_location_support', __( 'IP Location Support', 'zerospam' ), array( $this, 'field_ip_location_support' ), 'zerospam_general_settings', 'section_general' );
100
 
101
  // Auto IP block support.
102
  add_settings_field( 'auto_block', __( 'Auto IP Block', 'zerospam' ), array( $this, 'field_auto_block' ), 'zerospam_general_settings', 'section_general' );
@@ -169,7 +169,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
169
  public function field_wpf_support() {
170
  ?>
171
  <label for="wpf_support">
172
- <input type="checkbox" id="wpf_support" name="zerospam_general_settings[wpf_support]" value="1" <?php if( isset( $this->settings['wpf_support'] ) ) : checked( $this->settings['wpf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
173
  </label>
174
  <?php
175
  }
@@ -200,7 +200,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
200
  public function field_nf_support() {
201
  ?>
202
  <label for="nf_support">
203
- <input type="checkbox" id="nf_support" name="zerospam_general_settings[nf_support]" value="1" <?php if( isset( $this->settings['nf_support'] ) ) : checked( $this->settings['nf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
204
  </label>
205
  <?php
206
  }
@@ -231,7 +231,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
231
  public function field_bp_support() {
232
  ?>
233
  <label for="bp_support">
234
- <input type="checkbox" id="bp_support" name="zerospam_general_settings[bp_support]" value="1" <?php if( isset( $this->settings['bp_support'] ) ) : checked( $this->settings['bp_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
235
  </label>
236
  <?php
237
  }
@@ -262,7 +262,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
262
  public function field_gf_support() {
263
  ?>
264
  <label for="gf_support">
265
- <input type="checkbox" id="gf_support" name="zerospam_general_settings[gf_support]" value="1" <?php if( isset( $this->settings['gf_support'] ) ) : checked( $this->settings['gf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
266
  </label>
267
  <?php
268
  }
@@ -293,7 +293,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
293
  public function field_cf7_support() {
294
  ?>
295
  <label for="cf7_support">
296
- <input type="checkbox" id="cf7_support" name="zerospam_general_settings[cf7_support]" value="1" <?php if( isset( $this->settings['cf7_support'] ) ) : checked( $this->settings['cf7_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
297
  </label>
298
  <?php
299
  }
@@ -324,7 +324,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
324
  public function field_registration_support() {
325
  ?>
326
  <label for="registration_support">
327
- <input type="checkbox" id="registration_support" name="zerospam_general_settings[registration_support]" value="1" <?php if( isset( $this->settings['registration_support'] ) ) : checked( $this->settings['registration_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
328
  </label>
329
  <?php
330
  }
@@ -355,7 +355,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
355
  public function field_comment_support() {
356
  ?>
357
  <label for="comment_support">
358
- <input type="checkbox" id="comment_support" name="zerospam_general_settings[comment_support]" value="1" <?php if( isset( $this->settings['comment_support'] ) ) : checked( $this->settings['comment_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
359
  </label>
360
  <?php
361
  }
@@ -388,7 +388,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
388
  public function field_auto_block() {
389
  ?>
390
  <label for="auto_block">
391
- <input type="checkbox" id="auto_block" name="zerospam_general_settings[auto_block]" value="1" <?php if ( isset( $this->settings['auto_block']) ): checked( $this->settings['auto_block'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
392
  </label>
393
 
394
  <p class="description"><?php echo __( 'With auto IP block enabled, users who are identified as spam will automatically be blocked from the site.', 'zerospam' ); ?></p>
@@ -396,19 +396,18 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
396
  }
397
 
398
  /**
399
- * IP location API field.
400
  *
401
  * Field callback, renders a checkbox input, note the name and value.
402
  *
403
  * @since 2.0.0
404
  */
405
- public function field_ip_location_support() {
406
  ?>
407
- <label for="ip_location_support">
408
- <input type="checkbox" id="gf_support" name="zerospam_general_settings[ip_location_support]" value="1" <?php if( isset( $this->settings['ip_location_support'] ) ) : checked( $this->settings['ip_location_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
409
  <p class="description">
410
- <?php echo __( 'IP location data provided by', 'zerospam' ); ?> <a href="http://freegeoip.net/" target="_blank">freegeoip.net</a>. <?php echo __( 'API usage is limited to 10,000 queries per hour.', 'zerospam' ); ?><br>
411
- <?php echo __( 'Disable this option if you experience slow load times on the', 'zerospam' ); ?> <a href="<?php echo zerospam_admin_url() . '?page=zerospam&tab=zerospam_spammer_logs'; ?>"><?php echo __( 'Spammer Log', 'zerospam' ); ?></a> <?php echo __( 'page', 'zerospam' ); ?>.
412
  </p>
413
  </label>
414
  <?php
@@ -424,7 +423,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
424
  public function field_wp_generator() {
425
  ?>
426
  <label for="wp_generator_remove">
427
- <input type="checkbox" id="wp_generator_remove" name="zerospam_general_settings[wp_generator]" value="1" <?php if ( isset( $this->settings['wp_generator']) ): checked( $this->settings['wp_generator'] ); endif; ?> /> <?php echo __( 'Hide', 'zerospam' ); ?>
428
  </label>
429
 
430
  <p class="description"><?php echo __( 'It can be considered a security risk to make your WordPress version visible and public you should hide it.', 'zerospam' ); ?></p>
@@ -441,7 +440,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
441
  public function field_log_spammers() {
442
  ?>
443
  <label for="log_spammers">
444
- <input type="checkbox" id="log_spammers" name="zerospam_general_settings[log_spammers]" value="1" <?php if( isset( $this->settings['log_spammers'] ) ) : checked( $this->settings['log_spammers'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
445
  </label>
446
  <?php
447
  }
@@ -543,7 +542,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
543
  /**
544
  * Include the admin sidebar.
545
  */
546
- require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'admin-sidebar.php' );
547
  ?>
548
  </div>
549
  <div class="zerospam__left">
@@ -557,21 +556,21 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
557
  $limit = 10;
558
  $args = array(
559
  'limit' => $limit,
560
- 'offset' => ($page - 1) * $limit
561
  );
562
  $spam = zerospam_get_spam( $args );
563
  $spam = zerospam_parse_spam_ary( $spam );
564
  $all_spam = zerospam_all_spam_ary();
565
 
566
  if ( $all_spam['raw'] ) {
567
- $starting_date = $all_spam['date_start'];// end( $all_spam['raw'] )->date;
568
  $num_days = zerospam_num_days( $starting_date );
569
  $per_day = $num_days ? number_format( ( count( $all_spam['raw'] ) / $num_days ), 2 ) : 0;
570
  }
571
 
572
  if (
573
- isset( $this->settings['ip_location_support'] ) &&
574
- '1' == $this->settings['ip_location_support']
575
  ) {
576
  $ip_location_support = true;
577
  } else {
@@ -581,25 +580,25 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
581
  /**
582
  * Include the Spammer Logs page.
583
  */
584
- require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'spammer-logs.php' );
585
  } elseif ( $tab == 'zerospam_ip_block' ) {
586
  $limit = 10;
587
  $args = array(
588
  'limit' => $limit,
589
- 'offset' => ($page - 1) * $limit
590
  );
591
  $ips = zerospam_get_blocked_ips( $args );
592
 
593
  /**
594
  * Include the Blocked IPs page.
595
  */
596
- require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'ip-block.php' );
597
  } else {
598
 
599
  /**
600
  * General settings page template.
601
  */
602
- require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'general-settings.php' );
603
  } ?>
604
  </div>
605
 
95
  add_settings_field( 'log_spammers', __( 'Log Spammers', 'zerospam' ), array( $this, 'field_log_spammers' ), 'zerospam_general_settings', 'section_general' );
96
 
97
  if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
98
+ // IPStack API Key (https://ipstack.com/)
99
+ add_settings_field( 'ipstack_api_key', __( 'ipstack API Access Key', 'zerospam' ), array( $this, 'field_ipstack_api_key' ), 'zerospam_general_settings', 'section_general' );
100
 
101
  // Auto IP block support.
102
  add_settings_field( 'auto_block', __( 'Auto IP Block', 'zerospam' ), array( $this, 'field_auto_block' ), 'zerospam_general_settings', 'section_general' );
169
  public function field_wpf_support() {
170
  ?>
171
  <label for="wpf_support">
172
+ <input type="checkbox" id="wpf_support" name="zerospam_general_settings[wpf_support]" value="1" <?php if ( isset( $this->settings['wpf_support'] ) ) : checked( $this->settings['wpf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
173
  </label>
174
  <?php
175
  }
200
  public function field_nf_support() {
201
  ?>
202
  <label for="nf_support">
203
+ <input type="checkbox" id="nf_support" name="zerospam_general_settings[nf_support]" value="1" <?php if ( isset( $this->settings['nf_support'] ) ) : checked( $this->settings['nf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
204
  </label>
205
  <?php
206
  }
231
  public function field_bp_support() {
232
  ?>
233
  <label for="bp_support">
234
+ <input type="checkbox" id="bp_support" name="zerospam_general_settings[bp_support]" value="1" <?php if ( isset( $this->settings['bp_support'] ) ) : checked( $this->settings['bp_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
235
  </label>
236
  <?php
237
  }
262
  public function field_gf_support() {
263
  ?>
264
  <label for="gf_support">
265
+ <input type="checkbox" id="gf_support" name="zerospam_general_settings[gf_support]" value="1" <?php if ( isset( $this->settings['gf_support'] ) ) : checked( $this->settings['gf_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
266
  </label>
267
  <?php
268
  }
293
  public function field_cf7_support() {
294
  ?>
295
  <label for="cf7_support">
296
+ <input type="checkbox" id="cf7_support" name="zerospam_general_settings[cf7_support]" value="1" <?php if ( isset( $this->settings['cf7_support'] ) ) : checked( $this->settings['cf7_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
297
  </label>
298
  <?php
299
  }
324
  public function field_registration_support() {
325
  ?>
326
  <label for="registration_support">
327
+ <input type="checkbox" id="registration_support" name="zerospam_general_settings[registration_support]" value="1" <?php if ( isset( $this->settings['registration_support'] ) ) : checked( $this->settings['registration_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
328
  </label>
329
  <?php
330
  }
355
  public function field_comment_support() {
356
  ?>
357
  <label for="comment_support">
358
+ <input type="checkbox" id="comment_support" name="zerospam_general_settings[comment_support]" value="1" <?php if ( isset( $this->settings['comment_support'] ) ) : checked( $this->settings['comment_support'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
359
  </label>
360
  <?php
361
  }
388
  public function field_auto_block() {
389
  ?>
390
  <label for="auto_block">
391
+ <input type="checkbox" id="auto_block" name="zerospam_general_settings[auto_block]" value="1" <?php if ( isset( $this->settings['auto_block'] ) ) : checked( $this->settings['auto_block'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
392
  </label>
393
 
394
  <p class="description"><?php echo __( 'With auto IP block enabled, users who are identified as spam will automatically be blocked from the site.', 'zerospam' ); ?></p>
396
  }
397
 
398
  /**
399
+ * ipstack API Access Key
400
  *
401
  * Field callback, renders a checkbox input, note the name and value.
402
  *
403
  * @since 2.0.0
404
  */
405
+ public function field_ipstack_api_key() {
406
  ?>
407
+ <label for="ipstack_api_key">
408
+ <input type="text" id="ipstack_api_key" name="zerospam_general_settings[ipstack_api_key]" class="regular-text" value="<?php echo $this->settings['ipstack_api_key']; ?>" />
409
  <p class="description">
410
+ <?php echo __( 'IP location data provided by', 'zerospam' ); ?> <a href="https://ipstack.com/" target="_blank">ipstack.com</a>. <?php echo __( 'API usage is limited to 10,000 queries per hour.', 'zerospam' ); ?>
 
411
  </p>
412
  </label>
413
  <?php
423
  public function field_wp_generator() {
424
  ?>
425
  <label for="wp_generator_remove">
426
+ <input type="checkbox" id="wp_generator_remove" name="zerospam_general_settings[wp_generator]" value="1" <?php if ( isset( $this->settings['wp_generator'] ) ) : checked( $this->settings['wp_generator'] ); endif; ?> /> <?php echo __( 'Hide', 'zerospam' ); ?>
427
  </label>
428
 
429
  <p class="description"><?php echo __( 'It can be considered a security risk to make your WordPress version visible and public you should hide it.', 'zerospam' ); ?></p>
440
  public function field_log_spammers() {
441
  ?>
442
  <label for="log_spammers">
443
+ <input type="checkbox" id="log_spammers" name="zerospam_general_settings[log_spammers]" value="1" <?php if ( isset( $this->settings['log_spammers'] ) ) : checked( $this->settings['log_spammers'] ); endif; ?> /> <?php echo __( 'Enabled', 'zerospam' ); ?>
444
  </label>
445
  <?php
446
  }
542
  /**
543
  * Include the admin sidebar.
544
  */
545
+ require_once ZEROSPAM_ROOT . 'tpl/admin-sidebar.php';
546
  ?>
547
  </div>
548
  <div class="zerospam__left">
556
  $limit = 10;
557
  $args = array(
558
  'limit' => $limit,
559
+ 'offset' => ( $page - 1 ) * $limit,
560
  );
561
  $spam = zerospam_get_spam( $args );
562
  $spam = zerospam_parse_spam_ary( $spam );
563
  $all_spam = zerospam_all_spam_ary();
564
 
565
  if ( $all_spam['raw'] ) {
566
+ $starting_date = $all_spam['date_start'];// end( $all_spam['raw'] )->date;
567
  $num_days = zerospam_num_days( $starting_date );
568
  $per_day = $num_days ? number_format( ( count( $all_spam['raw'] ) / $num_days ), 2 ) : 0;
569
  }
570
 
571
  if (
572
+ isset( $this->settings['ipstack_api_key'] ) &&
573
+ '1' == $this->settings['ipstack_api_key']
574
  ) {
575
  $ip_location_support = true;
576
  } else {
580
  /**
581
  * Include the Spammer Logs page.
582
  */
583
+ require_once ZEROSPAM_ROOT . 'tpl/spammer-logs.php';
584
  } elseif ( $tab == 'zerospam_ip_block' ) {
585
  $limit = 10;
586
  $args = array(
587
  'limit' => $limit,
588
+ 'offset' => ( $page - 1 ) * $limit,
589
  );
590
  $ips = zerospam_get_blocked_ips( $args );
591
 
592
  /**
593
  * Include the Blocked IPs page.
594
  */
595
+ require_once ZEROSPAM_ROOT . 'tpl/ip-block.php';
596
  } else {
597
 
598
  /**
599
  * General settings page template.
600
  */
601
+ require_once ZEROSPAM_ROOT . 'tpl/general-settings.php';
602
  } ?>
603
  </div>
604
 
lib/ZeroSpam/Ajax.php CHANGED
@@ -52,7 +52,7 @@ class ZeroSpam_Ajax extends ZeroSpam_Plugin {
52
  ));
53
  }
54
 
55
- $reason = isset( $_POST['zerospam-reason'] ) ? $_POST['zerospam-reason'] : NULL;
56
 
57
  // Add/update the blocked IP.
58
  zerospam_block_ip( array(
@@ -82,7 +82,7 @@ class ZeroSpam_Ajax extends ZeroSpam_Plugin {
82
  $ajax_nonce = wp_create_nonce( 'zero-spam' );
83
 
84
  $date = new DateTime();
85
- $end_date = $date->modify('+1 day');
86
 
87
  $start_date_year = date( 'Y' );
88
  $start_date_month = date( 'n' );
@@ -109,7 +109,7 @@ class ZeroSpam_Ajax extends ZeroSpam_Plugin {
109
  /**
110
  * Include the block IP form.
111
  */
112
- require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'block-ip-form.php' );
113
 
114
  die();
115
  }
@@ -215,38 +215,39 @@ class ZeroSpam_Ajax extends ZeroSpam_Plugin {
215
  $spam = $spam['by_spam_count'];
216
  $return = array(
217
  'by_country' => array(),
218
- 'by_lat_long' => array()
219
  );
220
 
221
  // API usage limit protection.
222
  $limit = 10;
223
  $cnt = 0;
224
- foreach ( $spam as $key => $obj ) {
 
225
  $cnt++;
226
  if ( $cnt > 10 ) {
227
  break;
228
  }
229
- $loc = zerospam_get_ip_info( $obj->ip );
230
 
231
  if ( $loc ) {
232
  if ( ! isset( $return['by_country'][ $loc->country_code ] ) ) {
233
  $return['by_country'][ $loc->country_code ] = array(
234
  'count' => 0,
235
- 'name' => $loc->country_name
236
  );
237
  }
238
  $return['by_country'][ $loc->country_code ]['count']++;
239
 
240
- if ( ! isset( $return['by_lat_long'][ $obj->ip ] ) ) {
241
- $return['by_lat_long'][ $obj->ip ] = array(
242
  'latLng' => array( $loc->latitude, $loc->longitude ),
243
  'name' => $loc->country_name,
244
- 'count' => 1
245
  );
246
  }
247
  }
248
 
249
- sleep(1);
250
  }
251
 
252
  arsort( $return['by_country'] );
52
  ));
53
  }
54
 
55
+ $reason = isset( $_POST['zerospam-reason'] ) ? $_POST['zerospam-reason'] : null;
56
 
57
  // Add/update the blocked IP.
58
  zerospam_block_ip( array(
82
  $ajax_nonce = wp_create_nonce( 'zero-spam' );
83
 
84
  $date = new DateTime();
85
+ $end_date = $date->modify( '+1 day' );
86
 
87
  $start_date_year = date( 'Y' );
88
  $start_date_month = date( 'n' );
109
  /**
110
  * Include the block IP form.
111
  */
112
+ require_once ZEROSPAM_ROOT . 'tpl/block-ip-form.php';
113
 
114
  die();
115
  }
215
  $spam = $spam['by_spam_count'];
216
  $return = array(
217
  'by_country' => array(),
218
+ 'by_lat_long' => array(),
219
  );
220
 
221
  // API usage limit protection.
222
  $limit = 10;
223
  $cnt = 0;
224
+ foreach ( $spam as $ip => $obj ) {
225
+
226
  $cnt++;
227
  if ( $cnt > 10 ) {
228
  break;
229
  }
230
+ $loc = zerospam_get_ip_info( $ip );
231
 
232
  if ( $loc ) {
233
  if ( ! isset( $return['by_country'][ $loc->country_code ] ) ) {
234
  $return['by_country'][ $loc->country_code ] = array(
235
  'count' => 0,
236
+ 'name' => $loc->country_name,
237
  );
238
  }
239
  $return['by_country'][ $loc->country_code ]['count']++;
240
 
241
+ if ( ! isset( $return['by_lat_long'][ $ip ] ) ) {
242
+ $return['by_lat_long'][ $ip ] = array(
243
  'latLng' => array( $loc->latitude, $loc->longitude ),
244
  'name' => $loc->country_name,
245
+ 'count' => 1,
246
  );
247
  }
248
  }
249
 
250
+ sleep( 1 );
251
  }
252
 
253
  arsort( $return['by_country'] );
lib/ZeroSpam/BuddyPress.php CHANGED
@@ -27,4 +27,4 @@ class ZeroSpam_BuddyPress extends ZeroSpam_Plugin {
27
  die( __( $this->settings['buddypress_msg_registration'], 'zerospam' ) );
28
  }
29
  }
30
- }
27
  die( __( $this->settings['buddypress_msg_registration'], 'zerospam' ) );
28
  }
29
  }
30
+ }
lib/ZeroSpam/Comments.php CHANGED
@@ -9,11 +9,6 @@
9
  * @since 1.0.0
10
  */
11
 
12
- /**
13
- * Security Note: Blocks direct access to the plugin PHP files.
14
- */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
16
-
17
  /**
18
  * Processes comments.
19
  *
@@ -59,7 +54,7 @@ class ZeroSpam_Comments extends ZeroSpam_Plugin
59
 
60
  do_action( 'zero_spam_found_spam_comment', $commentdata );
61
 
62
- if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
63
  zerospam_log_spam( 'comment' );
64
  }
65
 
9
  * @since 1.0.0
10
  */
11
 
 
 
 
 
 
12
  /**
13
  * Processes comments.
14
  *
54
 
55
  do_action( 'zero_spam_found_spam_comment', $commentdata );
56
 
57
+ if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
58
  zerospam_log_spam( 'comment' );
59
  }
60
 
lib/ZeroSpam/ContactForm7.php CHANGED
@@ -15,7 +15,7 @@ class ZeroSpam_ContactForm7 extends ZeroSpam_Plugin {
15
  *
16
  */
17
  public function wpcf7_validate( $result ) {
18
- if ( ! zerospam_is_valid() ) {
19
  do_action( 'zero_spam_found_spam_cf7_form_submission' );
20
 
21
  // Temp. fix for the following issue: http://contactform7.com/2015/01/06/contact-form-7-41-beta/
@@ -27,4 +27,4 @@ class ZeroSpam_ContactForm7 extends ZeroSpam_Plugin {
27
 
28
  return $result;
29
  }
30
- }
15
  *
16
  */
17
  public function wpcf7_validate( $result ) {
18
+ if ( ! zerospam_is_valid() ) {
19
  do_action( 'zero_spam_found_spam_cf7_form_submission' );
20
 
21
  // Temp. fix for the following issue: http://contactform7.com/2015/01/06/contact-form-7-41-beta/
27
 
28
  return $result;
29
  }
30
+ }
lib/ZeroSpam/GravityForms.php CHANGED
@@ -18,4 +18,4 @@ class ZeroSpam_GravityForms extends ZeroSpam_Plugin {
18
  die( __( $this->settings['spammer_msg_gf'], 'zerospam' ) );
19
  }
20
  }
21
- }
18
  die( __( $this->settings['spammer_msg_gf'], 'zerospam' ) );
19
  }
20
  }
21
+ }
lib/ZeroSpam/Install.php CHANGED
@@ -9,11 +9,6 @@
9
  * @since 1.0.0
10
  */
11
 
12
- /**
13
- * Security Note: Blocks direct access to the plugin PHP files.
14
- */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
16
-
17
  /**
18
  * Installs the Zero Spam plugin.
19
  *
@@ -121,7 +116,7 @@ class ZeroSpam_Install extends ZeroSpam_Plugin
121
  $sql = false;
122
 
123
  // Check for the log table. If not available, create it.
124
- if ( $wpdb->get_var( 'SHOW TABLES LIKE \'' . $log_table_name . '\'') != $log_table_name )
125
  {
126
  $sql = "CREATE TABLE $log_table_name (
127
  zerospam_id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
@@ -156,7 +151,7 @@ class ZeroSpam_Install extends ZeroSpam_Plugin
156
  * Rather than executing an SQL query directly, we'll use the dbDelta
157
  * function in wp-admin/includes/upgrade.php.
158
  */
159
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
160
  dbDelta( $sql );
161
  }
162
 
9
  * @since 1.0.0
10
  */
11
 
 
 
 
 
 
12
  /**
13
  * Installs the Zero Spam plugin.
14
  *
116
  $sql = false;
117
 
118
  // Check for the log table. If not available, create it.
119
+ if ( $wpdb->get_var( 'SHOW TABLES LIKE \'' . $log_table_name . '\'' ) != $log_table_name )
120
  {
121
  $sql = "CREATE TABLE $log_table_name (
122
  zerospam_id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
151
  * Rather than executing an SQL query directly, we'll use the dbDelta
152
  * function in wp-admin/includes/upgrade.php.
153
  */
154
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
155
  dbDelta( $sql );
156
  }
157
 
lib/ZeroSpam/NinjaForms.php CHANGED
@@ -23,11 +23,11 @@ class ZeroSpam_NinjaForms extends ZeroSpam_Plugin {
23
  if ( ! zerospam_is_valid() ) {
24
  do_action( 'zero_spam_found_spam_nf_form_submission' );
25
 
26
- if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
27
  zerospam_log_spam( 'nf' );
28
  }
29
 
30
  die( __( $this->settings['spammer_msg_nf'], 'zerospam' ) );
31
  }
32
  }
33
- }
23
  if ( ! zerospam_is_valid() ) {
24
  do_action( 'zero_spam_found_spam_nf_form_submission' );
25
 
26
+ if ( ! empty( $this->settings['log_spammers'] ) && $this->settings['log_spammers'] ) {
27
  zerospam_log_spam( 'nf' );
28
  }
29
 
30
  die( __( $this->settings['spammer_msg_nf'], 'zerospam' ) );
31
  }
32
  }
33
+ }
lib/ZeroSpam/Plugin.php CHANGED
@@ -9,11 +9,6 @@
9
  * @since 1.0.0
10
  */
11
 
12
- /**
13
- * Security Note: Blocks direct access to the plugin PHP files.
14
- */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
16
-
17
  /**
18
  * Initializes the Zero Spam plugin.
19
  *
@@ -27,7 +22,7 @@ class ZeroSpam_Plugin implements ArrayAccess
27
  protected $contents;
28
  public $settings = array();
29
 
30
- public $default_settings = array(
31
  'spammer_msg_comment' => 'There was a problem processing your comment.',
32
  'spammer_msg_registration' => '<strong>ERROR</strong>: There was a problem processing your registration.',
33
  'spammer_msg_contact_form_7' => 'There was a problem processing your comment.',
@@ -63,13 +58,13 @@ class ZeroSpam_Plugin implements ArrayAccess
63
  * @see add_action
64
  */
65
  public function run() {
66
- foreach( $this->contents as $key => $content ){ // Loop on contents
67
- if( is_callable($content) ){
68
- $content = $this[$key];
69
  }
70
- if( is_object( $content ) ){
71
  $reflection = new ReflectionClass( $content );
72
- if( $reflection->hasMethod( 'run' ) ){
73
  $content->run(); // Call run method on object
74
  }
75
  }
@@ -121,21 +116,21 @@ class ZeroSpam_Plugin implements ArrayAccess
121
  }
122
 
123
  public function offsetSet( $offset, $value ) {
124
- $this->contents[$offset] = $value;
125
  }
126
 
127
- public function offsetExists($offset) {
128
- return isset( $this->contents[$offset] );
129
  }
130
 
131
- public function offsetUnset($offset) {
132
- unset( $this->contents[$offset] );
133
  }
134
 
135
- public function offsetGet($offset) {
136
- if( is_callable($this->contents[$offset]) ){
137
- return call_user_func( $this->contents[$offset], $this );
138
  }
139
- return isset( $this->contents[$offset] ) ? $this->contents[$offset] : null;
140
  }
141
  }
9
  * @since 1.0.0
10
  */
11
 
 
 
 
 
 
12
  /**
13
  * Initializes the Zero Spam plugin.
14
  *
22
  protected $contents;
23
  public $settings = array();
24
 
25
+ public $default_settings = array(
26
  'spammer_msg_comment' => 'There was a problem processing your comment.',
27
  'spammer_msg_registration' => '<strong>ERROR</strong>: There was a problem processing your registration.',
28
  'spammer_msg_contact_form_7' => 'There was a problem processing your comment.',
58
  * @see add_action
59
  */
60
  public function run() {
61
+ foreach ( $this->contents as $key => $content ) { // Loop on contents
62
+ if ( is_callable( $content ) ) {
63
+ $content = $this[ $key ];
64
  }
65
+ if ( is_object( $content ) ) {
66
  $reflection = new ReflectionClass( $content );
67
+ if ( $reflection->hasMethod( 'run' ) ) {
68
  $content->run(); // Call run method on object
69
  }
70
  }
116
  }
117
 
118
  public function offsetSet( $offset, $value ) {
119
+ $this->contents[ $offset ] = $value;
120
  }
121
 
122
+ public function offsetExists( $offset ) {
123
+ return isset( $this->contents[ $offset ] );
124
  }
125
 
126
+ public function offsetUnset( $offset ) {
127
+ unset( $this->contents[ $offset ] );
128
  }
129
 
130
+ public function offsetGet( $offset ) {
131
+ if ( is_callable( $this->contents[ $offset ] ) ) {
132
+ return call_user_func( $this->contents[ $offset ], $this );
133
  }
134
+ return isset( $this->contents[ $offset ] ) ? $this->contents[ $offset ] : null;
135
  }
136
  }
lib/ZeroSpam/Registration.php CHANGED
@@ -28,4 +28,4 @@ class ZeroSpam_Registration extends ZeroSpam_Plugin {
28
 
29
  return $errors;
30
  }
31
- }
28
 
29
  return $errors;
30
  }
31
+ }
lib/ZeroSpam/Scripts.php CHANGED
@@ -9,11 +9,6 @@
9
  * @since 1.0.0
10
  */
11
 
12
- /**
13
- * Security Note: Blocks direct access to the plugin PHP files.
14
- */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
16
-
17
  /**
18
  * CSS & JS scripts.
19
  *
@@ -47,7 +42,7 @@ class ZeroSpam_Scripts
47
  public function register_scripts() {
48
  $plugin = get_plugin_data( ZEROSPAM_PLUGIN );
49
 
50
- wp_register_script( 'zerospam', plugins_url( '/js/zerospam.js' , ZEROSPAM_PLUGIN ), array( 'jquery' ), $plugin['Version'], true );
51
  }
52
 
53
  public function enqueue_scripts() {
9
  * @since 1.0.0
10
  */
11
 
 
 
 
 
 
12
  /**
13
  * CSS & JS scripts.
14
  *
42
  public function register_scripts() {
43
  $plugin = get_plugin_data( ZEROSPAM_PLUGIN );
44
 
45
+ wp_register_script( 'zerospam', plugins_url( '/js/zerospam.js', ZEROSPAM_PLUGIN ), array( 'jquery' ), $plugin['Version'], true );
46
  }
47
 
48
  public function enqueue_scripts() {
lib/ZeroSpam/WPForms.php CHANGED
@@ -21,4 +21,4 @@ class ZeroSpam_WPForms extends ZeroSpam_Plugin {
21
  }
22
  return $honeypot;
23
  }
24
- }
21
  }
22
  return $honeypot;
23
  }
24
+ }
readme.txt CHANGED
@@ -1,10 +1,11 @@
1
  === WordPress Zero Spam ===
2
- Contributors: bmarshall511, jrf, afragen, tangrufus, leewillis77, macbookandrew, jaredatch, karpstrucking, thiagolcks, geekstreetwp
3
  Donate link: https://www.gittip.com/bmarshall511/
4
  Tags: comments, spam, antispam, anti-spam, comment spam, spambot, spammer, spam free, spam blocker, registration spam
5
  Requires at least: 3.0.0
6
  Tested up to: 5.2.1
7
- Stable tag: 3.1.0
 
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,7 +125,25 @@ Yes! Install [Sunny](https://wphuman.com/go/sunny/) and follow this [guide](http
124
 
125
  == Changelog ==
126
 
127
- = v3.1.0 (June 4, 2019)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  * [bug] install/activation routine would never run, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/148)
129
  * [bug] option may not be set, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/149)
130
  * [enhancement] Improve zerospam_get_ip(), thanks @ben-morin (https://github.com/bmarshall511/wordpress-zero-spam/pull/143)
1
  === WordPress Zero Spam ===
2
+ Contributors: bmarshall511, jrf, benmorin, afragen, tangrufus, leewillis77, macbookandrew, jaredatch, karpstrucking, thiagolcks, geekstreetwp
3
  Donate link: https://www.gittip.com/bmarshall511/
4
  Tags: comments, spam, antispam, anti-spam, comment spam, spambot, spammer, spam free, spam blocker, registration spam
5
  Requires at least: 3.0.0
6
  Tested up to: 5.2.1
7
+ Stable tag: 3.1.1
8
+ Requires PHP: 5.2.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
125
 
126
  == Changelog ==
127
 
128
+ = v3.1.1 (June 6, 2019) =
129
+ * [bug] Fix for IP lookup.
130
+ * [bug] Fix for PHP notice on admin page about count().
131
+ * [bug] Fix for admin dashboard when loading spam.
132
+ * [bug] Bug fix: fix parse error, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/153)
133
+ * [enhancement] Readme: add minimum PHP version tag, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/152)
134
+ * [enhancement] Simplify the uninstall file, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/154)
135
+ * [enhancement] CS: use single-quoted strings, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/163)
136
+ * [enhancement] CS: use lowercase for special PHP constants, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/162)
137
+ * [enhancement] CS: comma after last array item in multiline arrays, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/161)
138
+ * [enhancement] QA: don't even risk overriding a WP global variable, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/160)
139
+ * [enhancement] CS/QA: review of all include and require statements, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/159)
140
+ * [enhancement] QA: remove redundant security check, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/158)
141
+ * [enhancement] QA/performance: remove duplicate function calls, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/157)
142
+ * [enhancement] CS: don't use inline control structures, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/156)
143
+ * [enhancement] QA: adjust security check, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/164)
144
+ * [enhancement] CS: normalize inline whitespace usage, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/165)
145
+
146
+ = v3.1.0 (June 4, 2019) =
147
  * [bug] install/activation routine would never run, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/148)
148
  * [bug] option may not be set, thanks @jrf (https://github.com/bmarshall511/wordpress-zero-spam/pull/149)
149
  * [enhancement] Improve zerospam_get_ip(), thanks @ben-morin (https://github.com/bmarshall511/wordpress-zero-spam/pull/143)
tpl/admin-sidebar.php CHANGED
@@ -12,7 +12,9 @@
12
  /**
13
  * Security Note: Blocks direct access to the plugin PHP files.
14
  */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
16
  ?>
17
  <div class="zero-spam__widget">
18
  <div class="zero-spam__inner">
@@ -32,7 +34,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
32
  ?>
33
  <p><?php echo wp_kses(
34
  __( $plugin['Description'], 'zerospam' ),
35
- array( 'a' => array( 'href' => array() ) )
36
  ); ?></p>
37
  <p><?php
38
  echo sprintf(
@@ -40,9 +42,9 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
40
  __( '<small>If you have suggestions for a new add-on, feel free to email me at <a href="%s">me@benmarshall.me</a>. Want regular updates? Follow me on <a href="%s" target="_blank">Twitter</a> or <a href="%s" target="_blank">visit my blog</a>.</small>', 'zero-spam' ),
41
  array(
42
  'a' => array(
43
- 'href' => array()
44
  ),
45
- 'small' => array()
46
  )
47
  ),
48
  esc_url( 'mailto:me@benmarshall.me' ),
@@ -50,7 +52,6 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
50
  esc_url( 'https://benmarshall.me/' ) );
51
  ?></p>
52
  <p>
53
- <a href="https://www.gittip.com/bmarshall511/" class="zero-spam__button" target="_blank"><?php _e( 'Show Support &mdash; Donate!', 'zerospam' ); ?></a>
54
  <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" class="zero-spam__button" target="_blank"><?php _e( 'Spread the Love &mdash; Rate!', 'zerospam' ); ?></a>
55
  </p>
56
  </div>
12
  /**
13
  * Security Note: Blocks direct access to the plugin PHP files.
14
  */
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit();
17
+ }
18
  ?>
19
  <div class="zero-spam__widget">
20
  <div class="zero-spam__inner">
34
  ?>
35
  <p><?php echo wp_kses(
36
  __( $plugin['Description'], 'zerospam' ),
37
+ array( 'a' => array( 'href' => array() ) )
38
  ); ?></p>
39
  <p><?php
40
  echo sprintf(
42
  __( '<small>If you have suggestions for a new add-on, feel free to email me at <a href="%s">me@benmarshall.me</a>. Want regular updates? Follow me on <a href="%s" target="_blank">Twitter</a> or <a href="%s" target="_blank">visit my blog</a>.</small>', 'zero-spam' ),
43
  array(
44
  'a' => array(
45
+ 'href' => array(),
46
  ),
47
+ 'small' => array(),
48
  )
49
  ),
50
  esc_url( 'mailto:me@benmarshall.me' ),
52
  esc_url( 'https://benmarshall.me/' ) );
53
  ?></p>
54
  <p>
 
55
  <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" class="zero-spam__button" target="_blank"><?php _e( 'Spread the Love &mdash; Rate!', 'zerospam' ); ?></a>
56
  </p>
57
  </div>
tpl/block-ip-form.php CHANGED
@@ -8,7 +8,11 @@
8
  /**
9
  * Security Note: Blocks direct access to the plugin PHP files.
10
  */
11
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
 
 
12
  ?>
13
  <h2><?php echo __( 'Configure Block for', 'zerospam' ); ?> <?php echo $ip; ?></h2>
14
  <form method="post" action="options.php" id="zero-spam__block-ip-form">
@@ -21,80 +25,80 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
21
  <th><label for="zerospam-type"><?php echo __( 'Type', 'zerospam' ); ?>:</th>
22
  <td>
23
  <select name="zerospam-type" id="zerospam-type">
24
- <option value="temporary"<?php if( isset( $data->type ) && 'temporary' == $data->type ): ?> selected="selected"<?php endif; ?>><?php echo __( 'Temporary', 'zerospam' ); ?></option>
25
- <option value="permanent"<?php if( isset( $data->type ) && 'permanent' == $data->type ): ?> selected="selected"<?php endif; ?>><?php echo __( 'Permanent', 'zerospam' ); ?></option>
26
  </select>
27
  </td>
28
  </tr>
29
- <tr class="zero-spam__period"<?php if( isset( $data->type ) && 'permanent' == $data->type ): ?> style="display: none;"<?php endif; ?>>
30
  <th><label for="zerospam-startdate"><?php echo __( 'Start Date', 'zerospam' ); ?>:</th>
31
  <td>
32
  <select name="zerospam-startdate-month" id="zerospam-startdate">
33
- <option value="1"<?php if( isset( $start_date_month ) && '1' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'January', 'zerospam' ); ?></option>
34
- <option value="2"<?php if( isset( $start_date_month ) && '2' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'February', 'zerospam' ); ?></option>
35
- <option value="3"<?php if( isset( $start_date_month ) && '3' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'March', 'zerospam' ); ?></option>
36
- <option value="4"<?php if( isset( $start_date_month ) && '4' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'April', 'zerospam' ); ?></option>
37
- <option value="5"<?php if( isset( $start_date_month ) && '5' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'May', 'zerospam' ); ?></option>
38
- <option value="6"<?php if( isset( $start_date_month ) && '6' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'June', 'zerospam' ); ?></option>
39
- <option value="7"<?php if( isset( $start_date_month ) && '7' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'July', 'zerospam' ); ?></option>
40
- <option value="8"<?php if( isset( $start_date_month ) && '8' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'August', 'zerospam' ); ?></option>
41
- <option value="9"<?php if( isset( $start_date_month ) && '9' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'September', 'zerospam' ); ?></option>
42
- <option value="10"<?php if( isset( $start_date_month ) && '10' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'October', 'zerospam' ); ?></option>
43
- <option value="11"<?php if( isset( $start_date_month ) && '11' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'November', 'zerospam' ); ?></option>
44
- <option value="12"<?php if( isset( $start_date_month ) && '12' == $start_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'December', 'zerospam' ); ?></option>
45
  </select>
46
 
47
  <select name="zerospam-startdate-day">
48
- <?php for ($i = 1; $i <= 31; $i++): ?>
49
- <option value="<?php echo $i; ?>"<?php if( isset( $start_date_day ) && $i == $start_date_day ): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
50
  <?php endfor; ?>
51
  </select>
52
 
53
  <select name="zerospam-startdate-year">
54
- <?php for ( $i = date( 'Y' ); $i <= ( date( 'Y' ) + 50 ); $i++ ): ?>
55
- <option value="<?php echo $i; ?>"<?php if( isset( $start_date_year ) && $i == $start_date_year ): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
56
  <?php endfor; ?>
57
  </select>
58
  </td>
59
  </tr>
60
- <tr class="zero-spam__period"<?php if( isset( $data->type ) && 'permanent' == $data->type ): ?> style="display: none;"<?php endif; ?>>
61
  <th><label for="zerospam-enddate"><?php echo __( 'End Date', 'zerospam' ); ?>:</th>
62
  <td>
63
  <select name="zerospam-enddate-month" id="zerospam-enddate">
64
- <option value="1"<?php if( isset( $end_date_month ) && '1' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'January', 'zerospam' ); ?></option>
65
- <option value="2"<?php if( isset( $end_date_month ) && '2' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'February', 'zerospam' ); ?></option>
66
- <option value="3"<?php if( isset( $end_date_month ) && '3' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'March', 'zerospam' ); ?></option>
67
- <option value="4"<?php if( isset( $end_date_month ) && '4' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'April', 'zerospam' ); ?></option>
68
- <option value="5"<?php if( isset( $end_date_month ) && '5' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'May', 'zerospam' ); ?></option>
69
- <option value="6"<?php if( isset( $end_date_month ) && '6' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'June', 'zerospam' ); ?></option>
70
- <option value="7"<?php if( isset( $end_date_month ) && '7' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'July', 'zerospam' ); ?></option>
71
- <option value="8"<?php if( isset( $end_date_month ) && '8' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'August', 'zerospam' ); ?></option>
72
- <option value="9"<?php if( isset( $end_date_month ) && '9' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'September', 'zerospam' ); ?></option>
73
- <option value="10"<?php if( isset( $end_date_month ) && '10' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'October', 'zerospam' ); ?></option>
74
- <option value="11"<?php if( isset( $end_date_month ) && '11' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'November', 'zerospam' ); ?></option>
75
- <option value="12"<?php if( isset( $end_date_month ) && '12' == $end_date_month ): ?> selected="selected"<?php endif; ?>><?php echo __( 'December', 'zerospam' ); ?></option>
76
  </select>
77
  <select name="zerospam-enddate-day">
78
- <?php for ($i = 1; $i <= 31; $i++): ?>
79
- <option value="<?php echo $i; ?>"<?php if( isset( $end_date_day ) && $i == $end_date_day ): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
80
  <?php endfor; ?>
81
  </select>
82
 
83
  <select name="zerospam-enddate-year">
84
- <?php for ( $i = date( 'Y' ); $i <= ( date( 'Y' ) + 50 ); $i++ ): ?>
85
- <option value="<?php echo $i; ?>"<?php if( isset( $end_date_year ) && $i == $end_date_year ): ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
86
  <?php endfor; ?>
87
  </select>
88
  </td>
89
  </tr>
90
  <tr>
91
  <th><label for="zerospam-reason"><?php echo __( 'Reason', 'zerospam' ); ?>:</th>
92
- <td><input type="text" name="zerospam-reason" id="zerospam-reason" class="large-text" value="<?php if( isset( $data->reason ) ): echo esc_attr( $data->reason ); endif; ?>"></td>
93
  </tr>
94
  </table>
95
  <p class="submit">
96
  <input type="submit" value="<?php echo __( 'Save Changes', 'zerospam' ); ?>" class="button button-primary button-large">
97
- <? if ( $ip ): ?><a href="javascript: closeForms();" class="button button-large"><?php echo __( 'Close', 'zerospam' ); ?></a><?php endif; ?>
98
  </p>
99
  </form>
100
  <script>
@@ -116,7 +120,7 @@ jQuery( document ).ready( function( $ ) {
116
 
117
  form.prepend( "<div class='zero-spam__msg'>This IP address has been updated.</div>" );
118
 
119
- <? if ( $ip ): ?>updateRow( '<?php echo $ip; ?>' );<?php endif; ?>
120
  });
121
  });
122
 
8
  /**
9
  * Security Note: Blocks direct access to the plugin PHP files.
10
  */
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit();
13
+ }
14
+
15
+ $zerospam_year = date( 'Y' );
16
  ?>
17
  <h2><?php echo __( 'Configure Block for', 'zerospam' ); ?> <?php echo $ip; ?></h2>
18
  <form method="post" action="options.php" id="zero-spam__block-ip-form">
25
  <th><label for="zerospam-type"><?php echo __( 'Type', 'zerospam' ); ?>:</th>
26
  <td>
27
  <select name="zerospam-type" id="zerospam-type">
28
+ <option value="temporary"<?php if ( isset( $data->type ) && 'temporary' == $data->type ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'Temporary', 'zerospam' ); ?></option>
29
+ <option value="permanent"<?php if ( isset( $data->type ) && 'permanent' == $data->type ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'Permanent', 'zerospam' ); ?></option>
30
  </select>
31
  </td>
32
  </tr>
33
+ <tr class="zero-spam__period"<?php if ( isset( $data->type ) && 'permanent' == $data->type ) : ?> style="display: none;"<?php endif; ?>>
34
  <th><label for="zerospam-startdate"><?php echo __( 'Start Date', 'zerospam' ); ?>:</th>
35
  <td>
36
  <select name="zerospam-startdate-month" id="zerospam-startdate">
37
+ <option value="1"<?php if ( isset( $start_date_month ) && '1' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'January', 'zerospam' ); ?></option>
38
+ <option value="2"<?php if ( isset( $start_date_month ) && '2' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'February', 'zerospam' ); ?></option>
39
+ <option value="3"<?php if ( isset( $start_date_month ) && '3' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'March', 'zerospam' ); ?></option>
40
+ <option value="4"<?php if ( isset( $start_date_month ) && '4' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'April', 'zerospam' ); ?></option>
41
+ <option value="5"<?php if ( isset( $start_date_month ) && '5' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'May', 'zerospam' ); ?></option>
42
+ <option value="6"<?php if ( isset( $start_date_month ) && '6' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'June', 'zerospam' ); ?></option>
43
+ <option value="7"<?php if ( isset( $start_date_month ) && '7' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'July', 'zerospam' ); ?></option>
44
+ <option value="8"<?php if ( isset( $start_date_month ) && '8' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'August', 'zerospam' ); ?></option>
45
+ <option value="9"<?php if ( isset( $start_date_month ) && '9' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'September', 'zerospam' ); ?></option>
46
+ <option value="10"<?php if ( isset( $start_date_month ) && '10' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'October', 'zerospam' ); ?></option>
47
+ <option value="11"<?php if ( isset( $start_date_month ) && '11' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'November', 'zerospam' ); ?></option>
48
+ <option value="12"<?php if ( isset( $start_date_month ) && '12' == $start_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'December', 'zerospam' ); ?></option>
49
  </select>
50
 
51
  <select name="zerospam-startdate-day">
52
+ <?php for ( $i = 1; $i <= 31; $i++ ) : ?>
53
+ <option value="<?php echo $i; ?>"<?php if ( isset( $start_date_day ) && $i == $start_date_day ) : ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
54
  <?php endfor; ?>
55
  </select>
56
 
57
  <select name="zerospam-startdate-year">
58
+ <?php for ( $i = $zerospam_year; $i <= ( $zerospam_year + 50 ); $i++ ) : ?>
59
+ <option value="<?php echo $i; ?>"<?php if ( isset( $start_date_year ) && $i == $start_date_year ) : ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
60
  <?php endfor; ?>
61
  </select>
62
  </td>
63
  </tr>
64
+ <tr class="zero-spam__period"<?php if ( isset( $data->type ) && 'permanent' == $data->type ) : ?> style="display: none;"<?php endif; ?>>
65
  <th><label for="zerospam-enddate"><?php echo __( 'End Date', 'zerospam' ); ?>:</th>
66
  <td>
67
  <select name="zerospam-enddate-month" id="zerospam-enddate">
68
+ <option value="1"<?php if ( isset( $end_date_month ) && '1' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'January', 'zerospam' ); ?></option>
69
+ <option value="2"<?php if ( isset( $end_date_month ) && '2' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'February', 'zerospam' ); ?></option>
70
+ <option value="3"<?php if ( isset( $end_date_month ) && '3' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'March', 'zerospam' ); ?></option>
71
+ <option value="4"<?php if ( isset( $end_date_month ) && '4' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'April', 'zerospam' ); ?></option>
72
+ <option value="5"<?php if ( isset( $end_date_month ) && '5' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'May', 'zerospam' ); ?></option>
73
+ <option value="6"<?php if ( isset( $end_date_month ) && '6' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'June', 'zerospam' ); ?></option>
74
+ <option value="7"<?php if ( isset( $end_date_month ) && '7' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'July', 'zerospam' ); ?></option>
75
+ <option value="8"<?php if ( isset( $end_date_month ) && '8' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'August', 'zerospam' ); ?></option>
76
+ <option value="9"<?php if ( isset( $end_date_month ) && '9' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'September', 'zerospam' ); ?></option>
77
+ <option value="10"<?php if ( isset( $end_date_month ) && '10' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'October', 'zerospam' ); ?></option>
78
+ <option value="11"<?php if ( isset( $end_date_month ) && '11' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'November', 'zerospam' ); ?></option>
79
+ <option value="12"<?php if ( isset( $end_date_month ) && '12' == $end_date_month ) : ?> selected="selected"<?php endif; ?>><?php echo __( 'December', 'zerospam' ); ?></option>
80
  </select>
81
  <select name="zerospam-enddate-day">
82
+ <?php for ( $i = 1; $i <= 31; $i++ ) : ?>
83
+ <option value="<?php echo $i; ?>"<?php if ( isset( $end_date_day ) && $i == $end_date_day ) : ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
84
  <?php endfor; ?>
85
  </select>
86
 
87
  <select name="zerospam-enddate-year">
88
+ <?php for ( $i = $zerospam_year; $i <= ( $zerospam_year + 50 ); $i++ ) : ?>
89
+ <option value="<?php echo $i; ?>"<?php if ( isset( $end_date_year ) && $i == $end_date_year ) : ?> selected="selected"<?php endif; ?>><?php echo $i; ?></option>
90
  <?php endfor; ?>
91
  </select>
92
  </td>
93
  </tr>
94
  <tr>
95
  <th><label for="zerospam-reason"><?php echo __( 'Reason', 'zerospam' ); ?>:</th>
96
+ <td><input type="text" name="zerospam-reason" id="zerospam-reason" class="large-text" value="<?php if ( isset( $data->reason ) ) : echo esc_attr( $data->reason ); endif; ?>"></td>
97
  </tr>
98
  </table>
99
  <p class="submit">
100
  <input type="submit" value="<?php echo __( 'Save Changes', 'zerospam' ); ?>" class="button button-primary button-large">
101
+ <?php if ( $ip ) : ?><a href="javascript: closeForms();" class="button button-large"><?php echo __( 'Close', 'zerospam' ); ?></a><?php endif; ?>
102
  </p>
103
  </form>
104
  <script>
120
 
121
  form.prepend( "<div class='zero-spam__msg'>This IP address has been updated.</div>" );
122
 
123
+ <?php if ( $ip ) : ?>updateRow( '<?php echo $ip; ?>' );<?php endif; ?>
124
  });
125
  });
126
 
tpl/general-settings.php CHANGED
@@ -8,7 +8,9 @@
8
  /**
9
  * Security Note: Blocks direct access to the plugin PHP files.
10
  */
11
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
12
  ?>
13
  <div class="zero-spam__row">
14
  <div class="zero-spam__widget">
8
  /**
9
  * Security Note: Blocks direct access to the plugin PHP files.
10
  */
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit();
13
+ }
14
  ?>
15
  <div class="zero-spam__row">
16
  <div class="zero-spam__widget">
tpl/ip-block.php CHANGED
@@ -1,7 +1,15 @@
 
 
 
 
 
 
 
 
1
  <div class="zero-spam__row">
2
  <div class="zero-spam__widget">
3
  <div class="zero-spam__inner">
4
- <?php if ( is_array( $ips ) && count( $ips ) > 0 ): ?>
5
  <div id="zerospam-id-container">
6
  <h3><?php echo __( 'Blocked IPs', 'zerospam' ); ?></h3>
7
  <table class="zero-spam__table" id="zerospam--ip-block-table">
@@ -16,37 +24,37 @@
16
  </tr>
17
  </thead>
18
  <tbody>
19
- <?php foreach ( $ips as $key => $data ): ?>
20
  <tr data-ip="<?php echo esc_attr( $data->ip ); ?>" id="row-<?php echo esc_attr( $data->zerospam_ip_id ); ?>">
21
  <td class="zero-spam__ip"><a href="http://ip-lookup.net/index.php?ip=<?php echo esc_attr( $data->ip ); ?>" target="_blank">
22
  <?php echo $data->ip; ?> <i class="fa fa-external-link-square"></i></a></td>
23
  <td class="zero-spam__status">
24
- <?php if ( zerospam_is_blocked( $data->ip ) ): ?>
25
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
26
- <?php else: ?>
27
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
28
  <?php endif; ?>
29
  </td>
30
  <td class="zero-spam__start-date">
31
  <?php
32
- if ( $data->start_date ):
33
  echo date_i18n(
34
  'l, F jS, Y g:ia',
35
  strtotime( $data->start_date )
36
  );
37
- else:
38
  echo '&mdash;';
39
  endif;
40
  ?>
41
  </td>
42
  <td class="zero-spam__end-date">
43
  <?php
44
- if ( $data->start_date ):
45
  echo date_i18n(
46
  'l, F jS, Y g:ia',
47
  strtotime( $data->end_date )
48
  );
49
- else:
50
  echo '&mdash;';
51
  endif;
52
  ?>
@@ -67,7 +75,7 @@
67
  </table>
68
  <?php zerospam_pager( $limit, zerospam_get_blocked_ip_count(), $page, $tab ); ?>
69
  </div>
70
- <?php else: ?>
71
  <?php echo __( 'No blocked IPs found.', 'zerospam' ); ?>
72
  <?php endif; ?>
73
  </div>
1
+ <?php
2
+ /**
3
+ * Security Note: Blocks direct access to the plugin PHP files.
4
+ */
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit();
7
+ }
8
+ ?>
9
  <div class="zero-spam__row">
10
  <div class="zero-spam__widget">
11
  <div class="zero-spam__inner">
12
+ <?php if ( is_array( $ips ) && count( $ips ) > 0 ) : ?>
13
  <div id="zerospam-id-container">
14
  <h3><?php echo __( 'Blocked IPs', 'zerospam' ); ?></h3>
15
  <table class="zero-spam__table" id="zerospam--ip-block-table">
24
  </tr>
25
  </thead>
26
  <tbody>
27
+ <?php foreach ( $ips as $key => $data ) : ?>
28
  <tr data-ip="<?php echo esc_attr( $data->ip ); ?>" id="row-<?php echo esc_attr( $data->zerospam_ip_id ); ?>">
29
  <td class="zero-spam__ip"><a href="http://ip-lookup.net/index.php?ip=<?php echo esc_attr( $data->ip ); ?>" target="_blank">
30
  <?php echo $data->ip; ?> <i class="fa fa-external-link-square"></i></a></td>
31
  <td class="zero-spam__status">
32
+ <?php if ( zerospam_is_blocked( $data->ip ) ) : ?>
33
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
34
+ <?php else : ?>
35
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
36
  <?php endif; ?>
37
  </td>
38
  <td class="zero-spam__start-date">
39
  <?php
40
+ if ( $data->start_date ) :
41
  echo date_i18n(
42
  'l, F jS, Y g:ia',
43
  strtotime( $data->start_date )
44
  );
45
+ else :
46
  echo '&mdash;';
47
  endif;
48
  ?>
49
  </td>
50
  <td class="zero-spam__end-date">
51
  <?php
52
+ if ( $data->start_date ) :
53
  echo date_i18n(
54
  'l, F jS, Y g:ia',
55
  strtotime( $data->end_date )
56
  );
57
+ else :
58
  echo '&mdash;';
59
  endif;
60
  ?>
75
  </table>
76
  <?php zerospam_pager( $limit, zerospam_get_blocked_ip_count(), $page, $tab ); ?>
77
  </div>
78
+ <?php else : ?>
79
  <?php echo __( 'No blocked IPs found.', 'zerospam' ); ?>
80
  <?php endif; ?>
81
  </div>
tpl/spammer-logs.php CHANGED
@@ -12,7 +12,9 @@
12
  /**
13
  * Security Note: Blocks direct access to the plugin PHP files.
14
  */
15
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
 
 
16
  ?>
17
  <div class="zero-spam__row">
18
  <div class="zero-spam__cell">
@@ -20,7 +22,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
20
  <div class="zero-spam__inner">
21
  <h3><?php echo __( 'Summary', 'zerospam' ); ?></h3>
22
  <div class="zero-spam__row">
23
- <?php if ( isset( $num_days ) ): ?>
24
  <div class="zero-spam__stat">
25
  <?php echo __( 'Protected', 'zerospam' ); ?>
26
  <b><?php echo number_format( $num_days, 0 ); ?> <?php echo __( 'days', 'zerospam' ); ?></b>
@@ -30,13 +32,13 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
30
  <?php echo __( 'Total Spam', 'zerospam' ); ?>
31
  <b><?php echo number_format( $all_spam['raw'], 0 ); ?></b>
32
  </div>
33
- <?php if ( isset( $per_day ) ): ?>
34
  <div class="zero-spam__stat">
35
  <?php echo __( 'Per day', 'zerospam' ); ?>
36
  <b><?php echo number_format( $per_day, 0 ); ?></b>
37
  </div>
38
  <?php endif; ?>
39
- <?php if ( count( $all_spam['unique_spammers'] ) ): ?>
40
  <div class="zero-spam__stat">
41
  <?php echo __( 'Unique Spammers', 'zerospam' ); ?>
42
  <b><?php echo number_format( $all_spam['unique_spammers'], 0 ); ?></b>
@@ -64,7 +66,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
64
  <?php if (
65
  zerospam_plugin_check( 'cf7' ) &&
66
  ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support']
67
- ): ?>
68
  <div class="zero-spam__stat">
69
  <?php echo __( 'Contact Form 7', 'zerospam' ); ?>
70
  <b><?php echo number_format( $all_spam['cf7_spam'], 0 ); ?></b>
@@ -74,7 +76,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
74
  <?php if (
75
  zerospam_plugin_check( 'gf' ) &&
76
  ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support']
77
- ): ?>
78
  <div class="zero-spam__stat">
79
  <?php echo __( 'Gravity Forms', 'zerospam' ); ?>
80
  <b><?php echo number_format( $all_spam['gf_spam'], 0 ); ?></b>
@@ -84,7 +86,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
84
  <?php if (
85
  zerospam_plugin_check( 'bp' ) &&
86
  ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support']
87
- ): ?>
88
  <div class="zero-spam__stat">
89
  <?php echo __( 'BP Registrations', 'zerospam' ); ?>
90
  <b><?php echo number_format( $all_spam['bp_registration_spam'], 0 ); ?></b>
@@ -94,7 +96,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
94
  <?php if (
95
  zerospam_plugin_check( 'nf' ) &&
96
  ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support']
97
- ): ?>
98
  <div class="zero-spam__stat">
99
  <?php echo __( 'Ninja Forms', 'zerospam' ); ?>
100
  <b><?php echo number_format( $all_spam['nf_spam'], 0 ); ?></b>
@@ -104,7 +106,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
104
  <?php if (
105
  zerospam_plugin_check( 'wpf' ) &&
106
  ! empty( $this->settings['wpf'] ) && $this->settings['wpf_support']
107
- ): ?>
108
  <div class="zero-spam__stat">
109
  <?php echo __( 'WPForms', 'zerospam' ); ?>
110
  <b><?php echo number_format( $all_spam['wpf_spam'], 0 ); ?></b>
@@ -116,7 +118,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
116
  </div>
117
  </div>
118
 
119
- <?php if ( $ip_location_support ): ?>
120
  <div class="zero-spam__widget">
121
  <div class="zero-spam__overlay">
122
  <div class="zero-spam__inner">
@@ -197,7 +199,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
197
  </div>
198
  <?php endif; ?>
199
 
200
- <?php if ( $all_spam['raw'] ): ?>
201
  <div class="zero-spam__row">
202
  <div class="zero-spam__cell">
203
  <div class="zero-spam__widget">
@@ -213,7 +215,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
213
  </tr>
214
  </thead>
215
  <tbody>
216
- <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
217
  <tr>
218
  <td><b><?php echo $day; ?></b></td>
219
  <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
@@ -229,7 +231,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
229
  Morris.Donut({
230
  element: 'donut',
231
  data: [
232
- <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
233
  {value: <?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>, label: '<?php echo $day; ?>', formatted: '<?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>%'},
234
  <?php endforeach; ?>
235
  ],
@@ -250,7 +252,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
250
  <thead>
251
  <tr>
252
  <th width="100"><?php echo __( 'IP', 'zerospam' ); ?></th>
253
- <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
254
  <th class="zero-spam__text-right">#</th>
255
  <th><?php echo __( 'Status', 'zerospam' ); ?></th>
256
  <th>&nbsp;</th>
@@ -261,22 +263,25 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
261
  arsort( $all_spam['by_spam_count'] );
262
  $cnt = 0;
263
 
264
- foreach( $all_spam['by_spam_count'] as $ip => $count ):
265
- $cnt++; if ( $cnt > 6) break;
 
 
 
266
  ?>
267
  <tr data-ip="<?php echo $ip; ?>">
268
  <td><a href="http://ip-lookup.net/index.php?ip=<?php echo $ip; ?>" target="_blank">
269
  <?php echo $ip; ?> <i class="fa fa-external-link-square"></i></a></td>
270
- <?php if ( $ip_location_support ): ?>
271
  <td>
272
  <div data-ip-location="<?php echo $ip; ?>"><i class="fa fa-search"></i></div>
273
  </td>
274
  <?php endif; ?>
275
  <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
276
  <td class="zero-spam__status">
277
- <?php if( zerospam_is_blocked( $ip ) ): ?>
278
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
279
- <?php else: ?>
280
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
281
  <?php endif; ?>
282
  </td>
@@ -298,7 +303,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
298
 
299
  <div class="zero-spam__widget">
300
  <div class="zero-spam__inner">
301
- <?php if ( count( $all_spam['by_date'] ) ): ?>
302
  <a href="javascript: clearLog();" class="zero-spam__fright button"><?php echo __( 'Reset Log', 'zerospam' ); ?></a>
303
  <h3><?php echo __( 'All Time', 'zerospam' ); ?></h3>
304
  <div id="graph"></div>
@@ -309,11 +314,11 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
309
  element: 'graph',
310
  behaveLikeLine: true,
311
  data: [
312
- <?php foreach( $all_spam['by_date'] as $date => $ary ): ?>
313
  {
314
  'date': '<?php echo $date; ?>',
315
- <?php foreach ( $ary as $key => $val ):
316
- switch ( $key ):
317
  case 'comment_spam': ?>
318
  'spam_comments' : <?php echo $val; ?>,
319
  <?php break;
@@ -321,26 +326,26 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
321
  'spam_registrations' : <?php echo $val; ?>,
322
  <?php break;
323
  case 'cf7_spam':
324
- if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
325
  'spam_cf7' : <?php echo $val; ?>,
326
  <?php endif; break;
327
  case 'gf_spam':
328
- if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
329
  'spam_gf' : <?php echo $val; ?>,
330
  <?php endif; break;
331
  case 'bp_registration_spam':
332
- if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
333
  'bp_registrations' : <?php echo $val; ?>,
334
  <?php endif; break;
335
  case 'nf_spam':
336
- if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
337
  'nf_spam' : <?php echo $val; ?>,
338
  <?php endif; break;
339
  case 'wpf_spam':
340
- if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
341
  'wpf_spam' : <?php echo $val; ?>,
342
  <?php endif; break;
343
- default: if ( $key != 'data' ): ?>
344
  '<?php echo $key; ?>': <?php echo $val; ?>,
345
  <?php endif; endswitch;
346
  endforeach; ?>
@@ -349,37 +354,37 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
349
  ],
350
  xkey: 'date',
351
  ykeys: [
352
- <?php foreach ( $ary as $key => $val ):
353
- switch ( $key ):
354
  case 'comment_spam': ?>
355
  'spam_comments',
356
  <?php break;
357
  case 'registration_spam': ?>
358
  'spam_registrations',
359
  <?php break;
360
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
361
  'spam_cf7',
362
  <?php endif; break;
363
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
364
  'spam_gf',
365
  <?php endif; break;
366
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
367
  'bp_registrations',
368
  <?php endif; break;
369
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
370
  'nf_spam',
371
  <?php endif; break;
372
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
373
  'wpf_spam',
374
  <?php endif; break;
375
- default: if ( $key != 'data' ): ?>
376
  '<?php echo $key; ?>',
377
  <?php endif; endswitch;
378
  endforeach; ?>
379
  ],
380
  labels: [
381
- <?php foreach ( $ary as $key => $val ):
382
- switch ( $key ):
383
  case 'comment_spam': ?>
384
  '<?php echo __( 'Spam Comments', 'zerospam' ); ?>',
385
  <?php break;
@@ -389,52 +394,52 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
389
  case 'registration_spam': ?>
390
  '<?php echo __( 'Spam Registrations', 'zerospam' ); ?>',
391
  <?php break;
392
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
393
  '<?php echo __( 'Contact Form 7', 'zerospam' ); ?>',
394
  <?php endif; break;
395
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
396
  '<?php echo __( 'Gravity Forms', 'zerospam' ); ?>',
397
  <?php endif; break;
398
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
399
  '<?php echo __( 'BuddyPress', 'zerospam' ); ?>',
400
  <?php endif; break;
401
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
402
  '<?php echo __( 'Ninja Forms', 'zerospam' ); ?>',
403
  <?php endif; break;
404
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
405
  '<?php echo __( 'WPForms', 'zerospam' ); ?>',
406
  <?php endif; break;
407
- default: if ( $key != 'data' ): ?>
408
  '<?php echo $key; ?>',
409
  <?php endif; endswitch;
410
  endforeach; ?>
411
  ],
412
  xLabels: 'day',
413
  lineColors: [
414
- <?php foreach ( $ary as $key => $val ):
415
- switch ( $key ):
416
  case 'comment_spam': ?>
417
  '#00639e',
418
  <?php break;
419
  case 'registration_spam': ?>
420
  '#ff183a',
421
  <?php break;
422
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
423
  '#fddb5a',
424
  <?php endif; break;
425
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
426
  '#222d3a'
427
  <?php endif; break;
428
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
429
  '#a0d5f4'
430
  <?php endif; break;
431
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
432
  '#ef4748',
433
  <?php endif; break;
434
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
435
  '#e27730',
436
  <?php endif; break;
437
- default: if ( $key != 'data' ): ?>
438
  '#c2c2c2',
439
  <?php endif; endswitch;
440
  endforeach; ?>
@@ -447,7 +452,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
447
  <tr>
448
  <th><?php echo __( 'Date', 'zerospam' ); ?></th>
449
  <th width="90"><?php echo __( 'Type', 'zerospam' ); ?></th>
450
- <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
451
  <th width="106"><?php echo __( 'IP', 'zerospam' ); ?></th>
452
  <th><?php echo __( 'Page', 'zerospam' ); ?></th>
453
  <th><?php echo __( 'Status', 'zerospam' ); ?></th>
@@ -456,31 +461,31 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
456
  </thead>
457
  <tbody>
458
  <?php
459
- foreach ( $spam['raw'] as $key => $obj ):
460
  switch ( $obj->type ) {
461
  case 1:
462
- $type = '<span class="zero-spam__label zero-spam__bg--primary">' . __( 'Registration', 'zerospam' ) . '</span>';
463
  break;
464
  case 2:
465
- $type = '<span class="zero-spam__label zero-spam__bg--secondary">' . __( 'Comment', 'zerospam' ) . '</span>';
466
  break;
467
  case 3:
468
- $type = '<span class="zero-spam__label zero-spam__bg--trinary">' . __( 'Contact Form 7', 'zerospam' ) . '</span>';
469
  break;
470
  case 4:
471
- $type = '<span class="zero-spam__label zero-spam__bg--gf">' . __( 'Gravity Forms', 'zerospam' ) . '</span>';
472
  break;
473
  case 5:
474
- $type = '<span class="zero-spam__label zero-spam__bg--bpr">' . __( 'BP Registration', 'zerospam' ) . '</span>';
475
  break;
476
  case 6:
477
- $type = '<span class="zero-spam__label zero-spam__bg--nf">' . __( 'Ninja Forms', 'zerospam' ) . '</span>';
478
  break;
479
  case 7:
480
- $type = '<span class="zero-spam__label zero-spam__bg--wpf">' . __( 'WPForms', 'zerospam' ) . '</span>';
481
  break;
482
  default:
483
- $type = '<span class="zero-spam__label zero-spam__bg--misc">' . __( $obj->type, 'zerospam' ) . '</span>';
484
  }
485
  ?>
486
  <tr data-ip="<?php echo $obj->ip; ?>" id="row-<?php echo $obj->zerospam_id; ?>">
@@ -492,8 +497,8 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
492
  );
493
  ?>
494
  </td>
495
- <td><?php echo isset( $type ) ? $type : '&mdash;'; ?></td>
496
- <?php if ( $ip_location_support ): ?>
497
  <td>
498
  <div data-ip-location="<?php echo $obj->ip; ?>"><i class="fa fa-search"></i></div>
499
  </td>
@@ -503,16 +508,16 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
503
  <?php echo $obj->ip; ?> <i class="fa fa-external-link-square"></i></a>
504
  </td>
505
  <td>
506
- <?php if ( isset( $obj->page ) ): ?>
507
  <a href="<?php echo esc_url( $obj->page ); ?>" target="_blank"><?php echo $obj->page; ?> <i class="fa fa-external-link-square"></i></a>
508
- <?php else: ?>
509
  <?php echo __( 'Unknown', 'zerospam' ); ?>
510
  <?php endif; ?>
511
  </td>
512
  <td class="zero-spam__status">
513
- <?php if( zerospam_is_blocked( $obj->ip ) ): ?>
514
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
515
- <?php else: ?>
516
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
517
  <?php endif; ?>
518
  </td>
@@ -527,8 +532,8 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
527
  </tbody>
528
  </table>
529
  <?php zerospam_pager( $limit, zerospam_get_spam_count(), $page, $tab ); ?>
530
- <?php else: ?>
531
- <?php echo __( 'No spammers detected yet!', 'zerospam'); ?>
532
  <?php endif; ?>
533
  </div>
534
  </div>
12
  /**
13
  * Security Note: Blocks direct access to the plugin PHP files.
14
  */
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit();
17
+ }
18
  ?>
19
  <div class="zero-spam__row">
20
  <div class="zero-spam__cell">
22
  <div class="zero-spam__inner">
23
  <h3><?php echo __( 'Summary', 'zerospam' ); ?></h3>
24
  <div class="zero-spam__row">
25
+ <?php if ( isset( $num_days ) ) : ?>
26
  <div class="zero-spam__stat">
27
  <?php echo __( 'Protected', 'zerospam' ); ?>
28
  <b><?php echo number_format( $num_days, 0 ); ?> <?php echo __( 'days', 'zerospam' ); ?></b>
32
  <?php echo __( 'Total Spam', 'zerospam' ); ?>
33
  <b><?php echo number_format( $all_spam['raw'], 0 ); ?></b>
34
  </div>
35
+ <?php if ( isset( $per_day ) ) : ?>
36
  <div class="zero-spam__stat">
37
  <?php echo __( 'Per day', 'zerospam' ); ?>
38
  <b><?php echo number_format( $per_day, 0 ); ?></b>
39
  </div>
40
  <?php endif; ?>
41
+ <?php if ( $all_spam['unique_spammers'] ) : ?>
42
  <div class="zero-spam__stat">
43
  <?php echo __( 'Unique Spammers', 'zerospam' ); ?>
44
  <b><?php echo number_format( $all_spam['unique_spammers'], 0 ); ?></b>
66
  <?php if (
67
  zerospam_plugin_check( 'cf7' ) &&
68
  ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support']
69
+ ) : ?>
70
  <div class="zero-spam__stat">
71
  <?php echo __( 'Contact Form 7', 'zerospam' ); ?>
72
  <b><?php echo number_format( $all_spam['cf7_spam'], 0 ); ?></b>
76
  <?php if (
77
  zerospam_plugin_check( 'gf' ) &&
78
  ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support']
79
+ ) : ?>
80
  <div class="zero-spam__stat">
81
  <?php echo __( 'Gravity Forms', 'zerospam' ); ?>
82
  <b><?php echo number_format( $all_spam['gf_spam'], 0 ); ?></b>
86
  <?php if (
87
  zerospam_plugin_check( 'bp' ) &&
88
  ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support']
89
+ ) : ?>
90
  <div class="zero-spam__stat">
91
  <?php echo __( 'BP Registrations', 'zerospam' ); ?>
92
  <b><?php echo number_format( $all_spam['bp_registration_spam'], 0 ); ?></b>
96
  <?php if (
97
  zerospam_plugin_check( 'nf' ) &&
98
  ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support']
99
+ ) : ?>
100
  <div class="zero-spam__stat">
101
  <?php echo __( 'Ninja Forms', 'zerospam' ); ?>
102
  <b><?php echo number_format( $all_spam['nf_spam'], 0 ); ?></b>
106
  <?php if (
107
  zerospam_plugin_check( 'wpf' ) &&
108
  ! empty( $this->settings['wpf'] ) && $this->settings['wpf_support']
109
+ ) : ?>
110
  <div class="zero-spam__stat">
111
  <?php echo __( 'WPForms', 'zerospam' ); ?>
112
  <b><?php echo number_format( $all_spam['wpf_spam'], 0 ); ?></b>
118
  </div>
119
  </div>
120
 
121
+ <?php if ( $ip_location_support ) : ?>
122
  <div class="zero-spam__widget">
123
  <div class="zero-spam__overlay">
124
  <div class="zero-spam__inner">
199
  </div>
200
  <?php endif; ?>
201
 
202
+ <?php if ( $all_spam['raw'] ) : ?>
203
  <div class="zero-spam__row">
204
  <div class="zero-spam__cell">
205
  <div class="zero-spam__widget">
215
  </tr>
216
  </thead>
217
  <tbody>
218
+ <?php foreach ( $all_spam['by_day'] as $day => $count ) : ?>
219
  <tr>
220
  <td><b><?php echo $day; ?></b></td>
221
  <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
231
  Morris.Donut({
232
  element: 'donut',
233
  data: [
234
+ <?php foreach ( $all_spam['by_day'] as $day => $count ) : ?>
235
  {value: <?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>, label: '<?php echo $day; ?>', formatted: '<?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>%'},
236
  <?php endforeach; ?>
237
  ],
252
  <thead>
253
  <tr>
254
  <th width="100"><?php echo __( 'IP', 'zerospam' ); ?></th>
255
+ <?php if ( $ip_location_support ) : ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
256
  <th class="zero-spam__text-right">#</th>
257
  <th><?php echo __( 'Status', 'zerospam' ); ?></th>
258
  <th>&nbsp;</th>
263
  arsort( $all_spam['by_spam_count'] );
264
  $cnt = 0;
265
 
266
+ foreach ( $all_spam['by_spam_count'] as $ip => $count ) :
267
+ $cnt++;
268
+ if ( $cnt > 6 ) {
269
+ break;
270
+ }
271
  ?>
272
  <tr data-ip="<?php echo $ip; ?>">
273
  <td><a href="http://ip-lookup.net/index.php?ip=<?php echo $ip; ?>" target="_blank">
274
  <?php echo $ip; ?> <i class="fa fa-external-link-square"></i></a></td>
275
+ <?php if ( $ip_location_support ) : ?>
276
  <td>
277
  <div data-ip-location="<?php echo $ip; ?>"><i class="fa fa-search"></i></div>
278
  </td>
279
  <?php endif; ?>
280
  <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
281
  <td class="zero-spam__status">
282
+ <?php if ( zerospam_is_blocked( $ip ) ) : ?>
283
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
284
+ <?php else : ?>
285
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
286
  <?php endif; ?>
287
  </td>
303
 
304
  <div class="zero-spam__widget">
305
  <div class="zero-spam__inner">
306
+ <?php if ( count( $all_spam['by_date'] ) ) : ?>
307
  <a href="javascript: clearLog();" class="zero-spam__fright button"><?php echo __( 'Reset Log', 'zerospam' ); ?></a>
308
  <h3><?php echo __( 'All Time', 'zerospam' ); ?></h3>
309
  <div id="graph"></div>
314
  element: 'graph',
315
  behaveLikeLine: true,
316
  data: [
317
+ <?php foreach ( $all_spam['by_date'] as $date => $ary ) : ?>
318
  {
319
  'date': '<?php echo $date; ?>',
320
+ <?php foreach ( $ary as $key => $val ) :
321
+ switch ( $key ) :
322
  case 'comment_spam': ?>
323
  'spam_comments' : <?php echo $val; ?>,
324
  <?php break;
326
  'spam_registrations' : <?php echo $val; ?>,
327
  <?php break;
328
  case 'cf7_spam':
329
+ if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ) : ?>
330
  'spam_cf7' : <?php echo $val; ?>,
331
  <?php endif; break;
332
  case 'gf_spam':
333
+ if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) : ?>
334
  'spam_gf' : <?php echo $val; ?>,
335
  <?php endif; break;
336
  case 'bp_registration_spam':
337
+ if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ) : ?>
338
  'bp_registrations' : <?php echo $val; ?>,
339
  <?php endif; break;
340
  case 'nf_spam':
341
+ if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ) : ?>
342
  'nf_spam' : <?php echo $val; ?>,
343
  <?php endif; break;
344
  case 'wpf_spam':
345
+ if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ) : ?>
346
  'wpf_spam' : <?php echo $val; ?>,
347
  <?php endif; break;
348
+ default: if ( $key != 'data' ) : ?>
349
  '<?php echo $key; ?>': <?php echo $val; ?>,
350
  <?php endif; endswitch;
351
  endforeach; ?>
354
  ],
355
  xkey: 'date',
356
  ykeys: [
357
+ <?php foreach ( $ary as $key => $val ) :
358
+ switch ( $key ) :
359
  case 'comment_spam': ?>
360
  'spam_comments',
361
  <?php break;
362
  case 'registration_spam': ?>
363
  'spam_registrations',
364
  <?php break;
365
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ) : ?>
366
  'spam_cf7',
367
  <?php endif; break;
368
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) : ?>
369
  'spam_gf',
370
  <?php endif; break;
371
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ) : ?>
372
  'bp_registrations',
373
  <?php endif; break;
374
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ) : ?>
375
  'nf_spam',
376
  <?php endif; break;
377
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ) : ?>
378
  'wpf_spam',
379
  <?php endif; break;
380
+ default: if ( $key != 'data' ) : ?>
381
  '<?php echo $key; ?>',
382
  <?php endif; endswitch;
383
  endforeach; ?>
384
  ],
385
  labels: [
386
+ <?php foreach ( $ary as $key => $val ) :
387
+ switch ( $key ) :
388
  case 'comment_spam': ?>
389
  '<?php echo __( 'Spam Comments', 'zerospam' ); ?>',
390
  <?php break;
394
  case 'registration_spam': ?>
395
  '<?php echo __( 'Spam Registrations', 'zerospam' ); ?>',
396
  <?php break;
397
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ) : ?>
398
  '<?php echo __( 'Contact Form 7', 'zerospam' ); ?>',
399
  <?php endif; break;
400
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) : ?>
401
  '<?php echo __( 'Gravity Forms', 'zerospam' ); ?>',
402
  <?php endif; break;
403
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ) : ?>
404
  '<?php echo __( 'BuddyPress', 'zerospam' ); ?>',
405
  <?php endif; break;
406
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ) : ?>
407
  '<?php echo __( 'Ninja Forms', 'zerospam' ); ?>',
408
  <?php endif; break;
409
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ) : ?>
410
  '<?php echo __( 'WPForms', 'zerospam' ); ?>',
411
  <?php endif; break;
412
+ default: if ( $key != 'data' ) : ?>
413
  '<?php echo $key; ?>',
414
  <?php endif; endswitch;
415
  endforeach; ?>
416
  ],
417
  xLabels: 'day',
418
  lineColors: [
419
+ <?php foreach ( $ary as $key => $val ) :
420
+ switch ( $key ) :
421
  case 'comment_spam': ?>
422
  '#00639e',
423
  <?php break;
424
  case 'registration_spam': ?>
425
  '#ff183a',
426
  <?php break;
427
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ) : ?>
428
  '#fddb5a',
429
  <?php endif; break;
430
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) : ?>
431
  '#222d3a'
432
  <?php endif; break;
433
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ) : ?>
434
  '#a0d5f4'
435
  <?php endif; break;
436
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ) : ?>
437
  '#ef4748',
438
  <?php endif; break;
439
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ) : ?>
440
  '#e27730',
441
  <?php endif; break;
442
+ default: if ( $key != 'data' ) : ?>
443
  '#c2c2c2',
444
  <?php endif; endswitch;
445
  endforeach; ?>
452
  <tr>
453
  <th><?php echo __( 'Date', 'zerospam' ); ?></th>
454
  <th width="90"><?php echo __( 'Type', 'zerospam' ); ?></th>
455
+ <?php if ( $ip_location_support ) : ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
456
  <th width="106"><?php echo __( 'IP', 'zerospam' ); ?></th>
457
  <th><?php echo __( 'Page', 'zerospam' ); ?></th>
458
  <th><?php echo __( 'Status', 'zerospam' ); ?></th>
461
  </thead>
462
  <tbody>
463
  <?php
464
+ foreach ( $spam['raw'] as $key => $obj ) :
465
  switch ( $obj->type ) {
466
  case 1:
467
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--primary">' . __( 'Registration', 'zerospam' ) . '</span>';
468
  break;
469
  case 2:
470
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--secondary">' . __( 'Comment', 'zerospam' ) . '</span>';
471
  break;
472
  case 3:
473
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--trinary">' . __( 'Contact Form 7', 'zerospam' ) . '</span>';
474
  break;
475
  case 4:
476
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--gf">' . __( 'Gravity Forms', 'zerospam' ) . '</span>';
477
  break;
478
  case 5:
479
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--bpr">' . __( 'BP Registration', 'zerospam' ) . '</span>';
480
  break;
481
  case 6:
482
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--nf">' . __( 'Ninja Forms', 'zerospam' ) . '</span>';
483
  break;
484
  case 7:
485
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--wpf">' . __( 'WPForms', 'zerospam' ) . '</span>';
486
  break;
487
  default:
488
+ $zerospam_type = '<span class="zero-spam__label zero-spam__bg--misc">' . __( $obj->type, 'zerospam' ) . '</span>';
489
  }
490
  ?>
491
  <tr data-ip="<?php echo $obj->ip; ?>" id="row-<?php echo $obj->zerospam_id; ?>">
497
  );
498
  ?>
499
  </td>
500
+ <td><?php echo isset( $zerospam_type ) ? $zerospam_type : '&mdash;'; ?></td>
501
+ <?php if ( $ip_location_support ) : ?>
502
  <td>
503
  <div data-ip-location="<?php echo $obj->ip; ?>"><i class="fa fa-search"></i></div>
504
  </td>
508
  <?php echo $obj->ip; ?> <i class="fa fa-external-link-square"></i></a>
509
  </td>
510
  <td>
511
+ <?php if ( isset( $obj->page ) ) : ?>
512
  <a href="<?php echo esc_url( $obj->page ); ?>" target="_blank"><?php echo $obj->page; ?> <i class="fa fa-external-link-square"></i></a>
513
+ <?php else : ?>
514
  <?php echo __( 'Unknown', 'zerospam' ); ?>
515
  <?php endif; ?>
516
  </td>
517
  <td class="zero-spam__status">
518
+ <?php if ( zerospam_is_blocked( $obj->ip ) ) : ?>
519
  <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
520
+ <?php else : ?>
521
  <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
522
  <?php endif; ?>
523
  </td>
532
  </tbody>
533
  </table>
534
  <?php zerospam_pager( $limit, zerospam_get_spam_count(), $page, $tab ); ?>
535
+ <?php else : ?>
536
+ <?php echo __( 'No spammers detected yet!', 'zerospam' ); ?>
537
  <?php endif; ?>
538
  </div>
539
  </div>
uninstall.php CHANGED
@@ -30,56 +30,14 @@
30
  * @since 1.5.0
31
  */
32
 
33
- // If this file is called directly, abort.
34
- if ( ! defined( 'WPINC' ) ) {
35
- exit;
36
  }
37
 
38
- // If uninstall not called from WordPress, then exit.
39
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
40
- exit;
41
- }
42
-
43
- // Important: Check if the file is the one
44
- // that was registered during the uninstall hook.
45
- if ( basename(__DIR__) . '/zero-spam.php' !== WP_UNINSTALL_PLUGIN ) {
46
- exit;
47
- }
48
-
49
- // Check if the $_REQUEST content actually is the plugin name
50
- if ( isset( $_REQUEST['checked'] ) && ! in_array( basename(__DIR__) . '/zero-spam.php', $_REQUEST['checked'] ) ) {
51
- exit;
52
- }
53
-
54
- if ( ! in_array( $_REQUEST['action'], array( 'delete-plugin', 'delete-selected' ) ) ) {
55
- exit;
56
- }
57
-
58
- // Check user roles.
59
- if ( ! current_user_can( 'activate_plugins' ) ) {
60
- exit;
61
- }
62
-
63
- // Run an admin referrer check to make sure it goes through authentication
64
- if ( defined('DOING_AJAX') && DOING_AJAX ) {
65
- check_ajax_referer( 'updates' );
66
- } else {
67
- check_admin_referer( 'bulk-plugins' );
68
- }
69
-
70
- // Safe to carry on
71
- if ( false != get_option( 'zerospam_general_settings' ) || '' == get_option( 'zerospam_general_settings' ) ) {
72
- delete_site_option( 'zerospam_general_settings' );
73
- delete_option( 'zerospam_general_settings' );
74
- }
75
-
76
- if ( false != get_option( 'zerospam_key' ) || '' == get_option( 'zerospam_key' ) ) {
77
- delete_option( 'zerospam_key' );
78
- }
79
-
80
- if ( false != get_option( 'zerospam_db_version' ) || '' == get_option( 'zerospam_db_version' ) ) {
81
- delete_option( 'zerospam_db_version' );
82
- }
83
 
84
  // Delete database tables
85
  global $wpdb;
30
  * @since 1.5.0
31
  */
32
 
33
+ if ( ! current_user_can( 'activate_plugins' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
34
+ exit();
 
35
  }
36
 
37
+ delete_site_option( 'zerospam_general_settings' );
38
+ delete_option( 'zerospam_general_settings' );
39
+ delete_option( 'zerospam_key' );
40
+ delete_option( 'zerospam_db_version' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  // Delete database tables
43
  global $wpdb;
zero-spam.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WordPress Zero Spam
4
  * Plugin URI: https://benmarshall.me/wordpress-zero-spam
5
  * Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
6
- * Version: 3.1.0
7
  * Author: Ben Marshall
8
  * Author URI: https://benmarshall.me
9
  * License: GPL2
@@ -44,12 +44,12 @@ if( ! defined( 'ZEROSPAM_PLUGIN ' ) )
44
  /**
45
  * Include the plugin helpers.
46
  */
47
- require_once( ZEROSPAM_ROOT . 'inc' . DIRECTORY_SEPARATOR . 'helpers.php' );
48
 
49
  /**
50
  * Used to detect installed plugins.
51
  */
52
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
53
 
54
  spl_autoload_register( 'zerospam_autoloader' );
55
 
3
  * Plugin Name: WordPress Zero Spam
4
  * Plugin URI: https://benmarshall.me/wordpress-zero-spam
5
  * Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
6
+ * Version: 3.1.1
7
  * Author: Ben Marshall
8
  * Author URI: https://benmarshall.me
9
  * License: GPL2
44
  /**
45
  * Include the plugin helpers.
46
  */
47
+ require_once ZEROSPAM_ROOT . 'inc/helpers.php';
48
 
49
  /**
50
  * Used to detect installed plugins.
51
  */
52
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
53
 
54
  spl_autoload_register( 'zerospam_autoloader' );
55