WordPress Zero Spam - Version 3.0.0

Version Description

  • Lots of updates & fixes! Improved code documentation to help promote contributions.
Download this release

Release Info

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

Code changes from version 2.2.1 to 3.0.0

inc/admin-sidebar.tpl.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * Admin Sidebar Template
4
- *
5
- * Content for the plugin settings page right sidebar.
6
- *
7
- * @since 1.5.0
8
- */
9
-
10
- /**
11
- * Security Note: Blocks direct access to the plugin PHP files.
12
- */
13
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
- ?>
15
- <div class="zero-spam__widget">
16
- <div class="zero-spam__inner">
17
- <h2><a href="<?php echo esc_url( $plugin['PluginURI'] ); ?>" target="_blank"><?php echo __( $plugin['Name'], 'zerospam' ); ?></a></h2>
18
- <p class="zero-spam__description"><b><?php echo __( 'Rate', 'zerospam' ); ?>:</b> <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" target="_blank"><i class="fa fa-star"></i>
19
- <i class="fa fa-star"></i>
20
- <i class="fa fa-star"></i>
21
- <i class="fa fa-star"></i>
22
- <i class="fa fa-star"></i></a> |
23
- <b>Version:</b> <?php echo $plugin['Version']; ?> | <b><?php echo __( 'Author', 'zerospam' ); ?></b> <?php echo $plugin['Author']; ?></p>
24
- <p><?php echo $plugin['Description']; ?></p>
25
- <p><small>If you have suggestions for a new add-on, feel free to email me at <a href="mailto:me@benmarshall.me">me@benmarshall.me</a>. Want regular updates? Follow me on <a href="https://twitter.com/bmarshall0511" target="_blank">Twitter</a> or <a href="https://benmarshall.me/" target="_blank">visit my blog</a>.</small></p>
26
- <p>
27
- <a href="https://www.gittip.com/bmarshall511/" class="zero-spam__button" target="_blank"><?php echo __( 'Show Support &mdash; Donate!', 'zerospam' ); ?></a>
28
- <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" class="zero-spam__button" target="_blank"><?php echo __( 'Spread the Love &mdash; Rate!', 'zerospam' ); ?></a>
29
- </p>
30
- </div>
31
- </div>
32
-
33
- <div class="zero-spam__widget">
34
- <div class="zero-spam__inner">
35
- <h3><?php echo __( 'Are you a WordPress developer?', 'zerospam' ); ?></h3>
36
-
37
- <p><?php echo __( 'Help grow this plugin, integrate into your own or add new features by contributing.', 'zerospam' ); ?></p>
38
- <p><a href="https://github.com/bmarshall511/wordpress-zero-spam" target="_blank" class="button button-large button-primary"><?php echo __( 'Fork it on GitHub!', 'zerospam' ); ?></a></p>
39
- </div>
40
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/block-ip-form.tpl.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /**
3
- * Block IP form template.
4
- *
5
- * @since 1.5.0
6
- */
7
-
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">
15
- <table class="form-table">
16
- <tr>
17
- <th><label for="zerospam-ip">IP:</th>
18
- <td><input type="text" name="zerospam-ip" id="zerospam-ip" value="<?php echo esc_attr( $ip ); ?>" readonly="readonly" class="regular-text"></td>
19
- </tr>
20
- <tr>
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>
101
- jQuery( document ).ready( function( $ ) {
102
- $( "#zero-spam__block-ip-form" ).submit( function( e ) {
103
- e.preventDefault();
104
-
105
- var form = $( this );
106
-
107
- $( "input[type='submit']", form ).attr( "disabled", true );
108
- $( ".zero-spam__msg" ).remove();
109
-
110
- var data = $( "#zero-spam__block-ip-form" ).serialize();
111
- data += '&security=<?php echo $ajax_nonce; ?>';
112
- data += '&action=block_ip';
113
-
114
- $.post( ajaxurl, data, function( d ) {
115
- $( "input[type='submit']", form ).attr( "disabled", false );
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
-
123
- $( "#zerospam-type" ).change( function() {
124
- var val = $( this ).val();
125
- if ( "permanent" == val ) {
126
- $( ".zero-spam__period" ).hide();
127
- } else {
128
- $( ".zero-spam__period" ).show();
129
- }
130
- });
131
- });
132
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{src → inc}/helpers.php RENAMED
@@ -1,4 +1,14 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Security Note: Blocks direct access to the plugin PHP files.
4
  */
@@ -393,45 +403,53 @@ function zerospam_all_spam_ary() {
393
 
394
  $type_map = array(1 => 'registration_spam', 2 => 'comment_spam', 3 => 'cf7_spam', 4 => 'gf_spam', 5 => 'bp_registration_spam', 'nf' => 'nf_spam' );
395
 
396
- // By Weekday
397
- $query = $wpdb->prepare("SELECT DATE_FORMAT(date, '%%a') as day, COUNT(*) counts FROM $table_name WHERE 1=1 GROUP BY day");
398
- if ( $by_day = $wpdb->get_results($query) ) {
399
- foreach ( $by_day as $r ) {
400
- $return['by_day'][$r->day] = $r->counts;
 
 
401
  }
402
  }
403
- // By IP
404
- $query = $wpdb->prepare("SELECT ip, COUNT(*) counts FROM $table_name WHERE 1=1 GROUP BY ip ORDER BY counts DESC LIMIT 10");
405
- if ( $by_count = $wpdb->get_results($query) ) {
406
- foreach ( $by_count as $r ) {
407
- $return['by_spam_count'][$r->ip] = $r->counts;
 
 
 
408
  }
409
  }
410
 
411
- // COUNTS
412
- $query = $wpdb->prepare("SELECT type, COUNT(*) counts FROM $table_name WHERE 1=1 GROUP BY type");
413
- if ( $type_counts = $wpdb->get_results($query) ) {
414
- foreach( $type_counts as $r ) {
415
- $type = isset($type_map[$r->type]) ? $type_map[$r->type] : $r->type;
416
- $return[$type] = $r->counts;
 
 
417
  }
418
  }
419
 
420
  // Unique Spammers
421
- if ( $unique_spammers = $wpdb->get_var("SELECT COUNT(DISTICT ip) FROM $table_name") ) {
 
422
  $return['unique_spammers'] = $unique_spammers;
423
  }
424
 
425
  // By date: LIMIT 100 days for graph
426
- $query = $wpdb->prepare("SELECT type, LEFT(date, 10) day, COUNT(*) counts FROM $table_name WHERE 1=1 GROUP BY day, type ORDER BY date DESC LIMIT 100");
427
- if ( $by_date = $wpdb->get_results($query) ) {
428
-
429
- foreach( $by_date as $r ) {
430
- if ( !isset($type_map[$r->type]) )
431
- continue;
432
-
433
- if ( !isset($return['by_date'][$r->day]) ) {
434
- $return['by_date'][$r->day] = array(
435
  'data' => array(),
436
  'comment_spam' => 0,
437
  'registration_spam' => 0,
@@ -441,7 +459,7 @@ function zerospam_all_spam_ary() {
441
  'nf_spam' => 0
442
  );
443
  }
444
- $return['by_date'][$r->day][$type_map[$r->type]] = $r->counts;
445
  }
446
  }
447
 
@@ -537,18 +555,6 @@ function zerospam_pager( $limit = 10, $total_num, $page, $tab ) {
537
  <?php
538
  }
539
 
540
- function zerospam_admin_url() {
541
- if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
542
- $settings_url = network_admin_url( 'settings.php' );
543
- } else if ( home_url() != site_url() ) {
544
- $settings_url = home_url( '/wp-admin/' . 'options-general.php' );
545
- } else {
546
- $settings_url = admin_url( 'options-general.php' );
547
- }
548
-
549
- return $settings_url;
550
- }
551
-
552
  function zerospam_get_spam_count() {
553
  global $wpdb;
554
  $table_name = $wpdb->prefix . 'zerospam_log';
@@ -662,9 +668,91 @@ function zerospam_get_ip_info( $ip ) {
662
  return false;
663
  }
664
 
665
- function zerospam_get_blocked_ip_count() {
666
- global $wpdb;
667
- $table_name = $wpdb->prefix . 'zerospam_blocked_ips';
668
- $query = $wpdb->get_row( 'SELECT COUNT(*) AS count FROM ' . $table_name );
669
- return $query->count;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  }
1
  <?php
2
+ /**
3
+ * Zero Spam Helpers
4
+ *
5
+ * Contains all of Zero Spam helper functions. Can be used within other themes
6
+ * & plugins.
7
+ *
8
+ * @package WordPress Zero Spam
9
+ * @since 1.0.0
10
+ */
11
+
12
  /**
13
  * Security Note: Blocks direct access to the plugin PHP files.
14
  */
403
 
404
  $type_map = array(1 => 'registration_spam', 2 => 'comment_spam', 3 => 'cf7_spam', 4 => 'gf_spam', 5 => 'bp_registration_spam', 'nf' => 'nf_spam' );
405
 
406
+ // Get spammers by weekday.
407
+ $by_weekday_ary = $wpdb->get_results( "SELECT DATE_FORMAT(date, '%a') as day, COUNT(*) num FROM $table_name GROUP BY day", ARRAY_A );
408
+ if ( $by_weekday_ary )
409
+ {
410
+ foreach ( $by_weekday_ary as $key => $ary )
411
+ {
412
+ $return['by_day'][ $ary['day'] ] = $ary['num'];
413
  }
414
  }
415
+
416
+ // By IP.
417
+ // @TODO - Need to make the limit dynamic.
418
+ $by_ip_ary = $wpdb->get_results( "SELECT ip, COUNT(*) num FROM $table_name GROUP BY ip ORDER BY num DESC LIMIT 100", ARRAY_A );
419
+ if ( $by_ip_ary )
420
+ {
421
+ foreach ( $by_ip_ary as $key => $ary ) {
422
+ $return['by_spam_count'][ $ary['ip'] ] = $ary['num'];
423
  }
424
  }
425
 
426
+ // By type.
427
+ $by_type = $wpdb->get_results( "SELECT type, COUNT(*) num FROM $table_name GROUP BY type", ARRAY_A );
428
+ if ( $by_type )
429
+ {
430
+ foreach( $by_type as $key => $ary )
431
+ {
432
+ $type = ! empty( $type_map[ $ary['type'] ] ) ? $type_map[ $ary['type'] ] : $ary['type'];
433
+ $return[ $type ] = $ary['num'];
434
  }
435
  }
436
 
437
  // Unique Spammers
438
+ if ( $unique_spammers = $wpdb->get_var( "SELECT COUNT(DISTINCT ip) FROM $table_name" ) )
439
+ {
440
  $return['unique_spammers'] = $unique_spammers;
441
  }
442
 
443
  // By date: LIMIT 100 days for graph
444
+ // @TODO - Need to make the limit dynamic.
445
+ $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 );
446
+ if ( $by_date )
447
+ {
448
+ foreach( $by_date as $key => $ary )
449
+ {
450
+ if ( ! empty( $return['by_date'][ $ary['day'] ] ) )
451
+ {
452
+ $return['by_date'][ $ary['day'] ] = array(
453
  'data' => array(),
454
  'comment_spam' => 0,
455
  'registration_spam' => 0,
459
  'nf_spam' => 0
460
  );
461
  }
462
+ $return['by_date'][ $ary['day'] ][ $type_map[ $ary['type'] ] ] = $ary['num'];
463
  }
464
  }
465
 
555
  <?php
556
  }
557
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  function zerospam_get_spam_count() {
559
  global $wpdb;
560
  $table_name = $wpdb->prefix . 'zerospam_log';
668
  return false;
669
  }
670
 
671
+ /**
672
+ * WordPress admin URL.
673
+ *
674
+ * Returns the admin URL based off of whether it's a network enabled.
675
+ *
676
+ * @since 1.0.0
677
+ *
678
+ * @see is_plugin_active_for_network
679
+ * @see network_admin_url
680
+ * @see home_url
681
+ * @see admin_url
682
+ * @global string ZEROSPAM_PLUGIN The plugin root directory.
683
+ *
684
+ * @return string The plugin settings page URL.
685
+ */
686
+ if ( ! function_exists( 'zerospam_admin_url' ) )
687
+ {
688
+ function zerospam_admin_url()
689
+ {
690
+ if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) )
691
+ {
692
+ // Network enabled.
693
+ $settings_url = network_admin_url( 'settings.php' );
694
+ }
695
+ else
696
+ {
697
+ // No network.
698
+ $settings_url = admin_url( 'options-general.php' );
699
+ }
700
+
701
+ return $settings_url;
702
+ }
703
+ }
704
+
705
+ /**
706
+ * Blocked IP count.
707
+ *
708
+ * Returns the number of blocked IPs.
709
+ *
710
+ * @since 1.0.0
711
+ *
712
+ * @see wpdb::get_row
713
+ * @global object $wpdb Contains a set of functions used to interact with a database.
714
+ *
715
+ * @return int The number of blocked IPs.
716
+ */
717
+ if ( ! function_exists( 'zerospam_get_blocked_ip_count' ) )
718
+ {
719
+ function zerospam_get_blocked_ip_count()
720
+ {
721
+ global $wpdb;
722
+
723
+ $table_name = $wpdb->prefix . 'zerospam_blocked_ips';
724
+ $query = $wpdb->get_row( 'SELECT COUNT(*) AS count FROM ' . $table_name );
725
+ return $query->count;
726
+ }
727
+ }
728
+
729
+ /**
730
+ * ZeroSpam library autoloader.
731
+ *
732
+ * The autoloads all available Zero Spam libraries.
733
+ *
734
+ * @since 1.0.0
735
+ *
736
+ * @param string $class_name The name of the ZeroSpam library.
737
+ * @return boolean TRUE if library successfully included, FALSE if not.
738
+ */
739
+ if ( ! function_exists( 'zerospam_autoloader' ) )
740
+ {
741
+ function zerospam_autoloader( $class_name )
742
+ {
743
+ if ( false !== strpos( $class_name, 'ZeroSpam' ) )
744
+ {
745
+ $classes_dir = ZEROSPAM_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
746
+ $class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';
747
+
748
+ /**
749
+ * Include the plugin library.
750
+ */
751
+ require_once $classes_dir . $class_file;
752
+
753
+ return true;
754
+ }
755
+
756
+ return false;
757
+ }
758
  }
inc/ip-block.tpl.php DELETED
@@ -1,75 +0,0 @@
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">
8
- <thead>
9
- <tr>
10
- <th><?php echo __( 'IP', 'zerospam' ); ?></th>
11
- <th><?php echo __( 'Status', 'zerospam' ); ?></th>
12
- <th><?php echo __( 'Start Date', 'zerospam' ); ?></th>
13
- <th><?php echo __( 'End Date', 'zerospam' ); ?></th>
14
- <th><?php echo __( 'Reason', 'zerospam' ); ?></th>
15
- <th>&nbsp;</th>
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
- ?>
53
- </td>
54
- <td class="zero-spam__reason"><?php echo esc_html( $data->reason ); ?></td>
55
- <td class="zero-spam__text-center">
56
- <i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;
57
- <i class="fa fa-edit"></i>&nbsp;
58
- <a href="#" class="button button-small zero-spam__block-ip" data-ip="<?php echo esc_attr( $data->ip ); ?>">
59
- <i class="fa fa-gear"></i>
60
- </a>&nbsp;
61
-
62
- <a href="#" class="button button-small zero-spam__trash" data-ip="<?php echo esc_attr( $data->ip ); ?>"><i class="fa fa-trash"></i></a>
63
- </td>
64
- </tr>
65
- <?php endforeach; ?>
66
- </tbody>
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>
74
- </div>
75
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/spammer-logs.tpl.php DELETED
@@ -1,525 +0,0 @@
1
- <?php
2
- /**
3
- * Spammer Log Template
4
- *
5
- * Content for the plugin spammer log page.
6
- *
7
- * @since 1.5.0
8
- */
9
-
10
- /**
11
- * Security Note: Blocks direct access to the plugin PHP files.
12
- */
13
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
- ?>
15
- <div class="zero-spam__row">
16
- <div class="zero-spam__cell">
17
- <div class="zero-spam__widget zero-spam__bg--primary">
18
- <div class="zero-spam__inner">
19
- <h3><?php echo __( 'Summary', 'zerospam' ); ?></h3>
20
- <div class="zero-spam__row">
21
- <?php if ( isset( $num_days ) ): ?>
22
- <div class="zero-spam__stat">
23
- <?php echo __( 'Protected', 'zerospam' ); ?>
24
- <b><?php echo number_format( $num_days, 0 ); ?> <?php echo __( 'days', 'zerospam' ); ?></b>
25
- </div>
26
- <?php endif; ?>
27
- <div class="zero-spam__stat">
28
- <?php echo __( 'Total Spam', 'zerospam' ); ?>
29
- <b><?php echo number_format( $all_spam['raw'], 0 ); ?></b>
30
- </div>
31
- <?php if ( isset( $per_day ) ): ?>
32
- <div class="zero-spam__stat">
33
- <?php echo __( 'Per day', 'zerospam' ); ?>
34
- <b><?php echo number_format( $per_day, 0 ); ?></b>
35
- </div>
36
- <?php endif; ?>
37
- <div class="zero-spam__stat">
38
- <?php echo __( 'Unique Spammers', 'zerospam' ); ?>
39
- <b><?php echo number_format( $all_spam['unique_spammers'], 0 ); ?></b>
40
- </div>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- <div class="zero-spam__cell">
46
- <div class="zero-spam__widget zero-spam__bg--secondary">
47
- <div class="zero-spam__inner">
48
- <h3><?php echo __( 'Stats', 'zerospam' ); ?></h3>
49
- <div class="zero-spam__row">
50
- <div class="zero-spam__stat">
51
- <?php echo __( 'Comments', 'zerospam' ); ?>
52
- <b><?php echo number_format( $all_spam['comment_spam'], 0 ); ?></b>
53
- </div>
54
- <div class="zero-spam__stat">
55
- <?php echo __( 'Registrations', 'zerospam' ); ?>
56
- <b><?php echo number_format( $all_spam['registration_spam'], 0 ); ?></b>
57
- </div>
58
-
59
- <?php if (
60
- zerospam_plugin_check( 'cf7' ) &&
61
- ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support']
62
- ): ?>
63
- <div class="zero-spam__stat">
64
- <?php echo __( 'Contact Form 7', 'zerospam' ); ?>
65
- <b><?php echo number_format( $all_spam['cf7_spam'], 0 ); ?></b>
66
- </div>
67
- <?php endif; ?>
68
-
69
- <?php if (
70
- zerospam_plugin_check( 'gf' ) &&
71
- ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support']
72
- ): ?>
73
- <div class="zero-spam__stat">
74
- <?php echo __( 'Gravity Forms', 'zerospam' ); ?>
75
- <b><?php echo number_format( $all_spam['gf_spam'], 0 ); ?></b>
76
- </div>
77
- <?php endif; ?>
78
-
79
- <?php if (
80
- zerospam_plugin_check( 'bp' ) &&
81
- ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support']
82
- ): ?>
83
- <div class="zero-spam__stat">
84
- <?php echo __( 'BP Registrations', 'zerospam' ); ?>
85
- <b><?php echo number_format( $all_spam['bp_registration_spam'], 0 ); ?></b>
86
- </div>
87
- <?php endif; ?>
88
-
89
- <?php if (
90
- zerospam_plugin_check( 'nf' ) &&
91
- ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support']
92
- ): ?>
93
- <div class="zero-spam__stat">
94
- <?php echo __( 'Ninja Forms', 'zerospam' ); ?>
95
- <b><?php echo number_format( $all_spam['nf_spam'], 0 ); ?></b>
96
- </div>
97
- <?php endif; ?>
98
-
99
- <?php if (
100
- zerospam_plugin_check( 'wpf' ) &&
101
- ! empty( $this->settings['wpf'] ) && $this->settings['wpf_support']
102
- ): ?>
103
- <div class="zero-spam__stat">
104
- <?php echo __( 'WPForms', 'zerospam' ); ?>
105
- <b><?php echo number_format( $all_spam['wpf_spam'], 0 ); ?></b>
106
- </div>
107
- <?php endif; ?>
108
- </div>
109
- </div>
110
- </div>
111
- </div>
112
- </div>
113
-
114
- <?php if ( $ip_location_support ): ?>
115
- <div class="zero-spam__widget">
116
- <div class="zero-spam__overlay">
117
- <div class="zero-spam__inner">
118
- <i class="fa fa-circle-o-notch fa-spin"></i>
119
- <h4><?php echo __( 'Crunching numbers...', 'zerospam' ); ?></h4>
120
- <p><?php echo __( 'This could take a minute or two, please be patient.' ); ?></p>
121
- </div>
122
- </div>
123
- <div class="zero-spam__row">
124
- <div class="zero-spam__cell">
125
- <div class="zero-spam__inner">
126
- <h3><?php echo __( 'Most Spam By Country', 'zerospam' ); ?></h3>
127
- <table class="zero-spam__table">
128
- <thead>
129
- <tr>
130
- <th><?php echo __( 'Country', 'zerospam' ); ?></th>
131
- <th class="zero-spam__text-right"><?php echo __( 'Count', 'zerospam' ); ?></th>
132
- </tr>
133
- </thead>
134
- <tbody id="zerospam-country-spam">
135
- </tbody>
136
- </table>
137
- </div>
138
- </div>
139
- <div class="zero-spam__cell">
140
- <div id="map" class="zero-spam__map"></div>
141
- <script>
142
-
143
- jQuery(function() {
144
- jQuery.post( ajaxurl, {
145
- action: 'get_ip_spam',
146
- security: '<?php echo $ajax_nonce; ?>',
147
- }, function( data ) {
148
- if ( data ) {
149
- var obj = jQuery.parseJSON( data ),
150
- country_count = {},
151
- cnt = 0;
152
-
153
- if ( obj.by_country ) {
154
- jQuery( ".zero-spam__overlay" ).fadeOut();
155
-
156
-
157
- jQuery.each( obj.by_country, function( abbr, c ) {
158
- cnt++;
159
- if ( cnt > 6 ) return false;
160
- jQuery( "#zerospam-country-spam" ).append( "<tr><td><b>" + c.name + "</b></td><td class='zero-spam__text-right'>" + c.count + "</td></tr>" );
161
- country_count[abbr] = String(c.count);
162
- });
163
-
164
- jQuery('#map').vectorMap({
165
- map: 'world_mill_en',
166
- backgroundColor: '#1b1e24',
167
- series: {
168
- regions: [{
169
- scale: ['#ffe6ea', '#ff183a'],
170
- normalizeFunction: 'linear',
171
- attribute: 'fill',
172
- values: country_count
173
- }]
174
- }
175
-
176
- });
177
-
178
- var map = jQuery('#map').vectorMap('get', 'mapObject');
179
- map.series.regions[0].setValues( country_count );
180
- } else {
181
- jQuery( ".zero-spam__inner", jQuery( ".zero-spam__overlay" ) ).html( "<i class='fa fa-thumbs-up'></i><h4>No spammers yet!</h4>" );
182
- }
183
- } else {
184
- jQuery( ".zero-spam__inner", jQuery( ".zero-spam__overlay" ) ).html( "<i class='fa fa-exclamation-triangle'></i><h4>IP API Usage Limit Reached</h4><p>You've reached you're daily limit to the IP API to gather location information. Please check back in one hour.</p>" );
185
- }
186
- });
187
- });
188
- </script>
189
- </div>
190
- </div>
191
- </div>
192
- <?php endif; ?>
193
-
194
- <?php if ( $all_spam['raw'] ): ?>
195
- <div class="zero-spam__row">
196
- <div class="zero-spam__cell">
197
- <div class="zero-spam__widget">
198
- <div class="zero-spam__inner">
199
- <div class="zero-spam__row">
200
- <div class="zero-spam__cell">
201
- <h3><?php echo __( 'Percentage of Spam by Day', 'zerospam' ); ?></h3>
202
- <table class="zero-spam__table">
203
- <thead>
204
- <tr>
205
- <th><?php echo __( 'Day', 'zerospam' ); ?></th>
206
- <th class="zero-spam__text-right"><?php echo __( 'Count', 'zerospam' ); ?></th>
207
- </tr>
208
- </thead>
209
- <tbody>
210
- <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
211
- <tr>
212
- <td><b><?php echo $day; ?></b></td>
213
- <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
214
- </tr>
215
- <?php endforeach; ?>
216
- </tbody>
217
- </table>
218
- </div>
219
- <div class="zero-spam__cell">
220
- <div id="donut"></div>
221
- <script>
222
- jQuery(function() {
223
- Morris.Donut({
224
- element: 'donut',
225
- data: [
226
- <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
227
- {value: <?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>, label: '<?php echo $day; ?>', formatted: '<?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>%'},
228
- <?php endforeach; ?>
229
- ],
230
- formatter: function (x, data) { return data.formatted; }
231
- });
232
- });
233
- </script>
234
- </div>
235
- </div>
236
- </div>
237
- </div>
238
- </div>
239
- <div class="zero-spam__cell">
240
- <div class="zero-spam__widget">
241
- <div class="zero-spam__inner">
242
- <h3><?php echo __( 'Most Frequent Spammers', 'zerospam' ); ?></h3>
243
- <table class="zero-spam__table">
244
- <thead>
245
- <tr>
246
- <th width="100"><?php echo __( 'IP', 'zerospam' ); ?></th>
247
- <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
248
- <th class="zero-spam__text-right">#</th>
249
- <th><?php echo __( 'Status', 'zerospam' ); ?></th>
250
- <th>&nbsp;</th>
251
- </tr>
252
- </thead>
253
- <tbody>
254
- <?php
255
- arsort( $all_spam['by_spam_count'] );
256
- $cnt = 0;
257
-
258
- foreach( $all_spam['by_spam_count'] as $ip => $count ):
259
- $cnt++; if ( $cnt > 6) break;
260
- ?>
261
- <tr data-ip="<?php echo $ip; ?>">
262
- <td><a href="http://ip-lookup.net/index.php?ip=<?php echo $ip; ?>" target="_blank">
263
- <?php echo $ip; ?> <i class="fa fa-external-link-square"></i></a></td>
264
- <?php if ( $ip_location_support ): ?>
265
- <td>
266
- <div data-ip-location="<?php echo $ip; ?>"><i class="fa fa-search"></i></div>
267
- </td>
268
- <?php endif; ?>
269
- <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
270
- <td class="zero-spam__status">
271
- <?php if( zerospam_is_blocked( $ip ) ): ?>
272
- <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
273
- <?php else: ?>
274
- <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
275
- <?php endif; ?>
276
- </td>
277
- <td class="zero-spam__text-center">
278
- <i class="fa fa-circle-o-notch fa-spin"></i>
279
- <i class="fa fa-edit"></i>
280
- <a href="#" class="button button-small zero-spam__block-ip"
281
- data-ip="<?php echo $ip; ?>"><i class="fa fa-gear"></i></a>
282
- </td>
283
- </tr>
284
- <?php endforeach; ?>
285
- </tbody>
286
- </table>
287
- </div>
288
- </div>
289
- </div>
290
- </div>
291
- <?php endif; ?>
292
-
293
- <div class="zero-spam__widget">
294
- <div class="zero-spam__inner">
295
- <?php if ( count( $all_spam['by_date'] ) ): ?>
296
- <a href="javascript: clearLog();" class="zero-spam__fright button"><?php echo __( 'Reset Log', 'zerospam' ); ?></a>
297
- <h3><?php echo __( 'All Time', 'zerospam' ); ?></h3>
298
- <div id="graph"></div>
299
- <script>
300
- jQuery(function() {
301
- // Use Morris.Area instead of Morris.Line
302
- Morris.Area({
303
- element: 'graph',
304
- behaveLikeLine: true,
305
- data: [
306
- <?php foreach( $all_spam['by_date'] as $date => $ary ): ?>
307
- {
308
- 'date': '<?php echo $date; ?>',
309
- <?php foreach ( $ary as $key => $val ):
310
- switch ( $key ):
311
- case 'comment_spam': ?>
312
- 'spam_comments' : <?php echo $val; ?>,
313
- <?php break;
314
- case 'registration_spam': ?>
315
- 'spam_registrations' : <?php echo $val; ?>,
316
- <?php break;
317
- case 'cf7_spam':
318
- if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
319
- 'spam_cf7' : <?php echo $val; ?>,
320
- <?php endif; break;
321
- case 'gf_spam':
322
- if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
323
- 'spam_gf' : <?php echo $val; ?>,
324
- <?php endif; break;
325
- case 'bp_registration_spam':
326
- if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
327
- 'bp_registrations' : <?php echo $val; ?>,
328
- <?php endif; break;
329
- case 'nf_spam':
330
- if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
331
- 'nf_spam' : <?php echo $val; ?>,
332
- <?php endif; break;
333
- case 'wpf_spam':
334
- if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
335
- 'wpf_spam' : <?php echo $val; ?>,
336
- <?php endif; break;
337
- default: if ( $key != 'data' ): ?>
338
- '<?php echo $key; ?>': <?php echo $val; ?>,
339
- <?php endif; endswitch;
340
- endforeach; ?>
341
- },
342
- <?php endforeach; ?>
343
- ],
344
- xkey: 'date',
345
- ykeys: [
346
- <?php foreach ( $ary as $key => $val ):
347
- switch ( $key ):
348
- case 'comment_spam': ?>
349
- 'spam_comments',
350
- <?php break;
351
- case 'registration_spam': ?>
352
- 'spam_registrations',
353
- <?php break;
354
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
355
- 'spam_cf7',
356
- <?php endif; break;
357
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
358
- 'spam_gf',
359
- <?php endif; break;
360
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
361
- 'bp_registrations',
362
- <?php endif; break;
363
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
364
- 'nf_spam',
365
- <?php endif; break;
366
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
367
- 'wpf_spam',
368
- <?php endif; break;
369
- default: if ( $key != 'data' ): ?>
370
- '<?php echo $key; ?>',
371
- <?php endif; endswitch;
372
- endforeach; ?>
373
- ],
374
- labels: [
375
- <?php foreach ( $ary as $key => $val ):
376
- switch ( $key ):
377
- case 'comment_spam': ?>
378
- '<?php echo __( 'Spam Comments', 'zerospam' ); ?>',
379
- <?php break;
380
- case 'registration_spam': ?>
381
- '<?php echo __( 'Spam Registrations', 'zerospam' ); ?>',
382
- <?php break;
383
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
384
- '<?php echo __( 'Contact Form 7', 'zerospam' ); ?>',
385
- <?php endif; break;
386
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
387
- '<?php echo __( 'Gravity Forms', 'zerospam' ); ?>',
388
- <?php endif; break;
389
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
390
- '<?php echo __( 'BuddyPress', 'zerospam' ); ?>',
391
- <?php endif; break;
392
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
393
- '<?php echo __( 'Ninja Forms', 'zerospam' ); ?>',
394
- <?php endif; break;
395
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
396
- '<?php echo __( 'WPForms', 'zerospam' ); ?>',
397
- <?php endif; break;
398
- default: if ( $key != 'data' ): ?>
399
- '<?php echo $key; ?>',
400
- <?php endif; endswitch;
401
- endforeach; ?>
402
- ],
403
- xLabels: 'day',
404
- lineColors: [
405
- <?php foreach ( $ary as $key => $val ):
406
- switch ( $key ):
407
- case 'comment_spam': ?>
408
- '#00639e',
409
- <?php break;
410
- case 'registration_spam': ?>
411
- '#ff183a',
412
- <?php break;
413
- case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
414
- '#fddb5a',
415
- <?php endif; break;
416
- case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
417
- '#222d3a'
418
- <?php endif; break;
419
- case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
420
- '#a0d5f4'
421
- <?php endif; break;
422
- case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
423
- '#ef4748',
424
- <?php endif; break;
425
- case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
426
- '#e27730',
427
- <?php endif; break;
428
- default: if ( $key != 'data' ): ?>
429
- '#c2c2c2',
430
- <?php endif; endswitch;
431
- endforeach; ?>
432
- ]
433
- });
434
- });
435
- </script>
436
- <table class="zero-spam__table">
437
- <thead>
438
- <tr>
439
- <th><?php echo __( 'Date', 'zerospam' ); ?></th>
440
- <th width="90"><?php echo __( 'Type', 'zerospam' ); ?></th>
441
- <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
442
- <th width="106"><?php echo __( 'IP', 'zerospam' ); ?></th>
443
- <th><?php echo __( 'Page', 'zerospam' ); ?></th>
444
- <th><?php echo __( 'Status', 'zerospam' ); ?></th>
445
- <th>&nbsp;</th>
446
- </tr>
447
- </thead>
448
- <tbody>
449
- <?php
450
- foreach ( $spam['raw'] as $key => $obj ):
451
- switch ( $obj->type ) {
452
- case 1:
453
- $type = '<span class="zero-spam__label zero-spam__bg--primary">' . __( 'Registration', 'zerospam' ) . '</span>';
454
- break;
455
- case 2:
456
- $type = '<span class="zero-spam__label zero-spam__bg--secondary">' . __( 'Comment', 'zerospam' ) . '</span>';
457
- break;
458
- case 3:
459
- $type = '<span class="zero-spam__label zero-spam__bg--trinary">' . __( 'Contact Form 7', 'zerospam' ) . '</span>';
460
- break;
461
- case 4:
462
- $type = '<span class="zero-spam__label zero-spam__bg--gf">' . __( 'Gravity Forms', 'zerospam' ) . '</span>';
463
- break;
464
- case 5:
465
- $type = '<span class="zero-spam__label zero-spam__bg--bpr">' . __( 'BP Registration', 'zerospam' ) . '</span>';
466
- break;
467
- case 6:
468
- $type = '<span class="zero-spam__label zero-spam__bg--nf">' . __( 'Ninja Forms', 'zerospam' ) . '</span>';
469
- break;
470
- case 7:
471
- $type = '<span class="zero-spam__label zero-spam__bg--wpf">' . __( 'WPForms', 'zerospam' ) . '</span>';
472
- break;
473
- default:
474
- $type = '<span class="zero-spam__label zero-spam__bg--misc">' . __( $obj->type, 'zerospam' ) . '</span>';
475
- }
476
- ?>
477
- <tr data-ip="<?php echo $obj->ip; ?>" id="row-<?php echo $obj->zerospam_id; ?>">
478
- <td>
479
- <?php
480
- echo date_i18n(
481
- 'l, F jS, Y g:ia',
482
- strtotime( $obj->date )
483
- );
484
- ?>
485
- </td>
486
- <td><?php echo isset( $type ) ? $type : '&mdash;'; ?></td>
487
- <?php if ( $ip_location_support ): ?>
488
- <td>
489
- <div data-ip-location="<?php echo $obj->ip; ?>"><i class="fa fa-search"></i></div>
490
- </td>
491
- <?php endif; ?>
492
- <td>
493
- <a href="http://ip-lookup.net/index.php?ip=<?php echo $obj->ip; ?>" target="_blank">
494
- <?php echo $obj->ip; ?> <i class="fa fa-external-link-square"></i></a>
495
- </td>
496
- <td>
497
- <?php if ( isset( $obj->page ) ): ?>
498
- <a href="<?php echo esc_url( $obj->page ); ?>" target="_blank"><?php echo $obj->page; ?> <i class="fa fa-external-link-square"></i></a>
499
- <?php else: ?>
500
- <?php echo __( 'Unknown', 'zerospam' ); ?>
501
- <?php endif; ?>
502
- </td>
503
- <td class="zero-spam__status">
504
- <?php if( zerospam_is_blocked( $obj->ip ) ): ?>
505
- <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
506
- <?php else: ?>
507
- <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
508
- <?php endif; ?>
509
- </td>
510
- <td class="zero-spam__text-center">
511
- <i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;
512
- <i class="fa fa-edit"></i>&nbsp;
513
- <a href="#" class="button button-small zero-spam__block-ip"
514
- data-ip="<?php echo $obj->ip; ?>"><i class="fa fa-gear"></i></a>
515
- </td>
516
- </tr>
517
- <?php endforeach; ?>
518
- </tbody>
519
- </table>
520
- <?php zerospam_pager( $limit, zerospam_get_spam_count(), $page, $tab ); ?>
521
- <?php else: ?>
522
- <?php echo __( 'No spammers detected yet!', 'zerospam'); ?>
523
- <?php endif; ?>
524
- </div>
525
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{src → lib}/ZeroSpam/Access.php RENAMED
File without changes
{src → lib}/ZeroSpam/Admin.php RENAMED
@@ -127,7 +127,7 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
127
  // Gravity Forms support.
128
  if ( zerospam_plugin_check( 'gf' ) ) {
129
  add_settings_field( 'gf_support', __( 'Gravity Forms Support', 'zerospam' ), array( $this, 'field_gf_support' ), 'zerospam_general_settings', 'section_general' );
130
-
131
  if ( ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) {
132
  add_settings_field( 'spammer_msg_gf', __( 'Gravity Forms Spam Message', 'zerospam' ), array( $this, 'field_spammer_msg_gf' ), 'zerospam_general_settings', 'section_messages' );
133
  }
@@ -546,7 +546,12 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
546
  <?php $this->option_tabs(); ?>
547
  <div class="zerospam__row">
548
  <div class="zerospam__right">
549
- <?php require_once ZEROSPAM_ROOT . 'inc/admin-sidebar.tpl.php'; ?>
 
 
 
 
 
550
  </div>
551
  <div class="zerospam__left">
552
  <?php
@@ -580,7 +585,10 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
580
  $ip_location_support = false;
581
  }
582
 
583
- require_once ZEROSPAM_ROOT . 'inc/spammer-logs.tpl.php';
 
 
 
584
  } elseif ( $tab == 'zerospam_ip_block' ) {
585
  $limit = 10;
586
  $args = array(
@@ -589,9 +597,16 @@ class ZeroSpam_Admin extends ZeroSpam_Plugin {
589
  );
590
  $ips = zerospam_get_blocked_ips( $args );
591
 
592
- require_once ZEROSPAM_ROOT . 'inc/ip-block.tpl.php';
 
 
 
593
  } else {
594
- require_once ZEROSPAM_ROOT . 'inc/general-settings.tpl.php';
 
 
 
 
595
  } ?>
596
  </div>
597
 
127
  // Gravity Forms support.
128
  if ( zerospam_plugin_check( 'gf' ) ) {
129
  add_settings_field( 'gf_support', __( 'Gravity Forms Support', 'zerospam' ), array( $this, 'field_gf_support' ), 'zerospam_general_settings', 'section_general' );
130
+
131
  if ( ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ) {
132
  add_settings_field( 'spammer_msg_gf', __( 'Gravity Forms Spam Message', 'zerospam' ), array( $this, 'field_spammer_msg_gf' ), 'zerospam_general_settings', 'section_messages' );
133
  }
546
  <?php $this->option_tabs(); ?>
547
  <div class="zerospam__row">
548
  <div class="zerospam__right">
549
+ <?php
550
+ /**
551
+ * Include the admin sidebar.
552
+ */
553
+ require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'admin-sidebar.php' );
554
+ ?>
555
  </div>
556
  <div class="zerospam__left">
557
  <?php
585
  $ip_location_support = false;
586
  }
587
 
588
+ /**
589
+ * Include the Spammer Logs page.
590
+ */
591
+ require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'spammer-logs.php' );
592
  } elseif ( $tab == 'zerospam_ip_block' ) {
593
  $limit = 10;
594
  $args = array(
597
  );
598
  $ips = zerospam_get_blocked_ips( $args );
599
 
600
+ /**
601
+ * Include the Blocked IPs page.
602
+ */
603
+ require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'ip-block.php' );
604
  } else {
605
+
606
+ /**
607
+ * General settings page template.
608
+ */
609
+ require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'general-settings.php' );
610
  } ?>
611
  </div>
612
 
{src → lib}/ZeroSpam/Ajax.php RENAMED
@@ -106,7 +106,10 @@ class ZeroSpam_Ajax extends ZeroSpam_Plugin {
106
  }
107
  }
108
 
109
- require_once( ZEROSPAM_ROOT . 'inc/block-ip-form.tpl.php' );
 
 
 
110
 
111
  die();
112
  }
106
  }
107
  }
108
 
109
+ /**
110
+ * Include the block IP form.
111
+ */
112
+ require_once( ZEROSPAM_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'block-ip-form.php' );
113
 
114
  die();
115
  }
{src → lib}/ZeroSpam/BuddyPress.php RENAMED
File without changes
{src → lib}/ZeroSpam/Comments.php RENAMED
@@ -1,6 +1,39 @@
1
  <?php
2
- class ZeroSpam_Comments extends ZeroSpam_Plugin {
3
- public function run() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  add_action( 'preprocess_comment', array( $this, 'preprocess_comment' ) );
5
  }
6
 
@@ -14,11 +47,13 @@ class ZeroSpam_Comments extends ZeroSpam_Plugin {
14
  *
15
  * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/preprocess_comment
16
  */
17
- public function preprocess_comment( $commentdata ) {
 
18
  if (
19
  ( is_user_logged_in() && current_user_can( 'moderate_comments' ) ) ||
20
  ( zerospam_is_valid() )
21
  ) {
 
22
  return $commentdata;
23
  }
24
 
@@ -30,4 +65,4 @@ class ZeroSpam_Comments extends ZeroSpam_Plugin {
30
 
31
  die( __( $this->settings['spammer_msg_comment'], 'zerospam' ) );
32
  }
33
- }
1
  <?php
2
+ /**
3
+ * ZeroSpam_Comments library
4
+ *
5
+ * Processes comments for spam.
6
+ *
7
+ * @package WordPress Zero Spam
8
+ * @subpackage ZeroSpam_Comments
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
+ *
20
+ * This library process user comments and checks for spam.
21
+ *
22
+ * @since 1.0.0
23
+ */
24
+ class ZeroSpam_Comments extends ZeroSpam_Plugin
25
+ {
26
+ /**
27
+ * Runs the library.
28
+ *
29
+ * Initializes & runs the ZeroSpam_Comments library.
30
+ *
31
+ * @since 1.0.0
32
+ *
33
+ * @see add_action
34
+ */
35
+ public function run()
36
+ {
37
  add_action( 'preprocess_comment', array( $this, 'preprocess_comment' ) );
38
  }
39
 
47
  *
48
  * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/preprocess_comment
49
  */
50
+ public function preprocess_comment( $commentdata )
51
+ {
52
  if (
53
  ( is_user_logged_in() && current_user_can( 'moderate_comments' ) ) ||
54
  ( zerospam_is_valid() )
55
  ) {
56
+ // Allow moderaters to post comments.
57
  return $commentdata;
58
  }
59
 
65
 
66
  die( __( $this->settings['spammer_msg_comment'], 'zerospam' ) );
67
  }
68
+ }
{src → lib}/ZeroSpam/ContactForm7.php RENAMED
File without changes
{src → lib}/ZeroSpam/GravityForms.php RENAMED
File without changes
lib/ZeroSpam/Install.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ZeroSpam_Install library
4
+ *
5
+ * Runs when the plugin is activated.
6
+ *
7
+ * @package WordPress Zero Spam
8
+ * @subpackage ZeroSpam_Install
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
+ *
20
+ * This library creates all of the required tables and sets the initial
21
+ * settings.
22
+ *
23
+ * @since 1.0.0
24
+ *
25
+ * @see ZeroSpam_Plugin
26
+ */
27
+ class ZeroSpam_Install extends ZeroSpam_Plugin
28
+ {
29
+ const DB_VERSION = '2.0';
30
+
31
+ /**
32
+ * Runs the library.
33
+ *
34
+ * Initializes & runs the ZeroSpam_Install library.
35
+ *
36
+ * @since 1.0.0
37
+ *
38
+ * @see register_activation_hook
39
+ * @see add_action
40
+ * @global string ZEROSPAM_PLUGIN The plugin root directory.
41
+ */
42
+ public function run()
43
+ {
44
+
45
+ // Called when the plugin is activated.
46
+ register_activation_hook( ZEROSPAM_PLUGIN, array( $this, 'activate' ) );
47
+
48
+ // This hook is called once any activated plugins have been loaded.
49
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
50
+ }
51
+
52
+ /**
53
+ * Sets the plugin's default options.
54
+ *
55
+ * When the plugin is activated, this is ran to set/update the plugin default
56
+ * options.
57
+ *
58
+ * @since 1.0.0
59
+ *
60
+ * @see is_plugin_active_for_network
61
+ * @see plugin_basename
62
+ * @see update_site_option
63
+ * @see update_option
64
+ * @global string ZEROSPAM_PLUGIN The plugin root directory.
65
+ */
66
+ private function activate()
67
+ {
68
+ // Install the DB tables.
69
+ $this->install();
70
+
71
+ if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) )
72
+ {
73
+
74
+ // Set the network's site default settings.
75
+ update_site_option( 'zerospam_general_settings', $this->default_settings );
76
+ }
77
+ else
78
+ {
79
+
80
+ // Set the site default settings.
81
+ update_option( 'zerospam_general_settings', $this->default_settings );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Installs plugin tables.
87
+ *
88
+ * Installs all of the required plugin tables.
89
+ *
90
+ * @since 2.0.0
91
+ * @access private
92
+ *
93
+ * @see wpdb::get_row
94
+ * @see dbDelta
95
+ * @see update_option
96
+ * @global string ZEROSPAM_PLUGIN The plugin root directory.
97
+ */
98
+ private function install()
99
+ {
100
+ global $wpdb;
101
+
102
+ // Define the plugin table names.
103
+ $log_table_name = $wpdb->prefix . 'zerospam_log';
104
+ $ip_table_name = $wpdb->prefix . 'zerospam_blocked_ips';
105
+ $ip_data_table_name = $wpdb->prefix . 'zerospam_ip_data';
106
+
107
+ // Get the plugin database version.
108
+ $current_version = get_option( 'zerospam_db_version' );
109
+
110
+ // If no version available, first time install.
111
+ if ( empty( $current_version ) )
112
+ {
113
+ /*
114
+ * We'll set the default character set and collation for this table.
115
+ * If we don't do this, some characters could end up being converted
116
+ * to just ?'s when saved in our table.
117
+ */
118
+ $charset_collate = $wpdb->get_charset_collate();
119
+
120
+ // Prepare the DB queries.
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,
128
+ type varchar(255) NOT NULL DEFAULT 'Undefined Form',
129
+ ip varchar(15) NOT NULL,
130
+ date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
131
+ page varchar(255) DEFAULT NULL,
132
+ PRIMARY KEY (zerospam_id),
133
+ KEY type (type)
134
+ ) $charset_collate;";
135
+ }
136
+
137
+ // Check for the IP table. . If not available, create it.
138
+ if ( $wpdb->get_var( 'SHOW TABLES LIKE \'' . $ip_table_name . '\'' ) != $ip_table_name )
139
+ {
140
+ $sql .= "CREATE TABLE $ip_table_name (
141
+ zerospam_ip_id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
142
+ ip varchar(15) NOT NULL,
143
+ type enum('permanent','temporary') NOT NULL DEFAULT 'temporary',
144
+ start_date datetime DEFAULT NULL,
145
+ end_date datetime DEFAULT NULL,
146
+ reason varchar(255) DEFAULT NULL,
147
+ PRIMARY KEY (zerospam_ip_id),
148
+ UNIQUE KEY ip (ip)
149
+ ) $charset_collate;";
150
+ }
151
+
152
+ // Run the query is set.
153
+ if ( $sql )
154
+ {
155
+ /**
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
+
163
+ // Set the plugin DB version.
164
+ update_option( 'zerospam_db_version', self::DB_VERSION );
165
+ }
166
+
167
+ // Check for available DB updates.
168
+ elseif ( $current_version != self::DB_VERSION )
169
+ {
170
+ // 2.0 Updates.
171
+ if ( version_compare( '2.0', $current_version ) ) {
172
+ $wpdb->query( "ALTER TABLE `$log_table_name` CHANGE `type` `type` VARCHAR(255) NOT NULL DEFAULT 'Undefined Form';" );
173
+ }
174
+
175
+ // Set the updated plugin DB version.
176
+ update_option( 'zerospam_db_version', $this->db_version );
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Checks for outdated DB tables.
182
+ *
183
+ * This hook is called once any activated plugins have been loaded. Is
184
+ * generally used for immediate filter setup, or plugin overrides.
185
+ *
186
+ * @since 2.0.0
187
+ * @access private
188
+ *
189
+ * @see get_option
190
+ * @see dbDelta
191
+ * @see update_option
192
+ * @see ZeroSpam_Install::install
193
+ * @global string ZEROSPAM_PLUGIN The plugin root directory.
194
+ */
195
+ public function plugins_loaded()
196
+ {
197
+ if ( get_option( 'zerospam_db_version' ) != self::DB_VERSION )
198
+ {
199
+
200
+ // If version outdated, upgrade.
201
+ $this->install();
202
+ }
203
+ }
204
+ }
{src → lib}/ZeroSpam/NinjaForms.php RENAMED
File without changes
{src → lib}/ZeroSpam/Plugin.php RENAMED
@@ -1,5 +1,29 @@
1
  <?php
2
- class ZeroSpam_Plugin implements ArrayAccess {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  protected $contents;
4
  public $settings = array();
5
 
@@ -28,6 +52,38 @@ class ZeroSpam_Plugin implements ArrayAccess {
28
  $this->load_settings();
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  /**
32
  * Add setting link to plugin.
33
  *
@@ -71,7 +127,7 @@ class ZeroSpam_Plugin implements ArrayAccess {
71
  public function plugin_row_meta( $links, $file ) {
72
  if ( false !== strpos( $file, 'zero-spam.php' ) ) {
73
  $links = array_merge( $links, array( '<a href="https://benmarshall.me/wordpress-zero-spam-plugin/">Documentation</a>' ) );
74
- $links = array_merge( $links, array( '<a href="https://www.gittip.com/bmarshall511/">Donate</a>' ) );
75
  }
76
  return $links;
77
  }
@@ -94,26 +150,4 @@ class ZeroSpam_Plugin implements ArrayAccess {
94
  }
95
  return isset( $this->contents[$offset] ) ? $this->contents[$offset] : null;
96
  }
97
-
98
- public function run() {
99
- foreach( $this->contents as $key => $content ){ // Loop on contents
100
- if( is_callable($content) ){
101
- $content = $this[$key];
102
- }
103
- if( is_object( $content ) ){
104
- $reflection = new ReflectionClass( $content );
105
- if( $reflection->hasMethod( 'run' ) ){
106
- $content->run(); // Call run method on object
107
- }
108
- }
109
- }
110
-
111
- add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
112
-
113
- if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
114
- add_filter( 'network_admin_plugin_action_links_' . plugin_basename( ZEROSPAM_PLUGIN ), array( $this, 'plugin_action_links' ) );
115
- } else {
116
- add_filter( 'plugin_action_links_' . plugin_basename( ZEROSPAM_PLUGIN ), array( $this, 'plugin_action_links' ) );
117
- }
118
- }
119
- }
1
  <?php
2
+ /**
3
+ * ZeroSpam_Plugin library
4
+ *
5
+ * Sets up the plugin and initializes all ZeroSpam libraries.
6
+ *
7
+ * @package WordPress Zero Spam
8
+ * @subpackage ZeroSpam_Plugin
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
+ *
20
+ * This library creates defines the default settings & initializes all
21
+ * available plugin libraries.
22
+ *
23
+ * @since 1.0.0
24
+ */
25
+ class ZeroSpam_Plugin implements ArrayAccess
26
+ {
27
  protected $contents;
28
  public $settings = array();
29
 
52
  $this->load_settings();
53
  }
54
 
55
+ /**
56
+ * Runs the library.
57
+ *
58
+ * Initializes & runs the ZeroSpam_Plugin library.
59
+ *
60
+ * @since 1.0.0
61
+ *
62
+ * @see register_activation_hook
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
+ }
76
+ }
77
+
78
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
79
+
80
+ if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
81
+ add_filter( 'network_admin_plugin_action_links_' . plugin_basename( ZEROSPAM_PLUGIN ), array( $this, 'plugin_action_links' ) );
82
+ } else {
83
+ add_filter( 'plugin_action_links_' . plugin_basename( ZEROSPAM_PLUGIN ), array( $this, 'plugin_action_links' ) );
84
+ }
85
+ }
86
+
87
  /**
88
  * Add setting link to plugin.
89
  *
127
  public function plugin_row_meta( $links, $file ) {
128
  if ( false !== strpos( $file, 'zero-spam.php' ) ) {
129
  $links = array_merge( $links, array( '<a href="https://benmarshall.me/wordpress-zero-spam-plugin/">Documentation</a>' ) );
130
+ $links = array_merge( $links, array( 'Want to see continued improvements? <a href="https://www.gittip.com/bmarshall511/" target="_blank"><b>Donate!</b></a>' ) );
131
  }
132
  return $links;
133
  }
150
  }
151
  return isset( $this->contents[$offset] ) ? $this->contents[$offset] : null;
152
  }
153
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{src → lib}/ZeroSpam/Registration.php RENAMED
File without changes
lib/ZeroSpam/Scripts.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ZeroSpam_Comments library
4
+ *
5
+ * Processes comments for spam.
6
+ *
7
+ * @package WordPress Zero Spam
8
+ * @subpackage ZeroSpam_Comments
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
+ *
20
+ * Registers plugin CSS & JS scripts.
21
+ *
22
+ * @since 1.0.0
23
+ */
24
+ class ZeroSpam_Scripts
25
+ {
26
+ /**
27
+ * Runs the library.
28
+ *
29
+ * Initializes & runs the ZeroSpam_Scripts library.
30
+ *
31
+ * @since 1.0.0
32
+ *
33
+ * @see add_action
34
+ */
35
+ public function run()
36
+ {
37
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
38
+ add_action( 'login_footer', array( $this, 'wp_enqueue_scripts' ) );
39
+ }
40
+
41
+ public function wp_enqueue_scripts() {
42
+ $this->register_styles();
43
+ $this->register_scripts();
44
+
45
+ $this->enqueue_styles();
46
+ $this->enqueue_scripts();
47
+ }
48
+
49
+ public function register_scripts() {
50
+ wp_register_script( 'zerospam', plugins_url( '/js/zerospam.js' , ZEROSPAM_PLUGIN ), array( 'jquery' ), '3.0.0', true );
51
+ }
52
+
53
+ public function enqueue_scripts() {
54
+ wp_localize_script( 'zerospam', 'zerospam', array( 'key' => zerospam_get_key() ) );
55
+ wp_enqueue_script( 'zerospam' );
56
+ }
57
+ }
{src → lib}/ZeroSpam/WPForms.php RENAMED
File without changes
readme.txt CHANGED
@@ -4,11 +4,11 @@ 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: 4.6.1
7
- Stable tag: 2.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Zero Spam makes blocking spam comments a cinch. Install, activate and enjoy a spam-free site. Supports Gravity Forms, Ninja Forms, BuddyPress & more!
12
 
13
  == Description ==
14
 
@@ -124,6 +124,9 @@ Yes! Install [Sunny](https://wphuman.com/go/sunny/) and follow this [guide](http
124
 
125
  == Changelog ==
126
 
 
 
 
127
  = 2.2.1 =
128
  * Fixed uninstall issue, thanks @thiagolcks (https://github.com/bmarshall511/wordpress-zero-spam/pull/139)
129
 
@@ -229,6 +232,7 @@ Yes! Install [Sunny](https://wphuman.com/go/sunny/) and follow this [guide](http
229
 
230
  == Contributors ==
231
  * [Ben Marshall](https://github.com/bmarshall511)
 
232
  * [Andy Fragen](https://github.com/afragen)
233
  * [Tang Rufus](https://github.com/TangRufus)
234
  * [Lee Willis](https://github.com/leewillis77)
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: 4.6.1
7
+ Stable tag: 3.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Zero Spam makes blocking spam comments a cinch. Install, activate and enjoy a spam-free site. Even supports third-party plugins!
12
 
13
  == Description ==
14
 
124
 
125
  == Changelog ==
126
 
127
+ = 3.0.0 =
128
+ * Lots of updates & fixes! Improved code documentation to help promote contributions.
129
+
130
  = 2.2.1 =
131
  * Fixed uninstall issue, thanks @thiagolcks (https://github.com/bmarshall511/wordpress-zero-spam/pull/139)
132
 
232
 
233
  == Contributors ==
234
  * [Ben Marshall](https://github.com/bmarshall511)
235
+ * [Thiago Locks](https://github.com/thiagolcks)
236
  * [Andy Fragen](https://github.com/afragen)
237
  * [Tang Rufus](https://github.com/TangRufus)
238
  * [Lee Willis](https://github.com/leewillis77)
src/ZeroSpam/Install.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
- class ZeroSpam_Install extends ZeroSpam_Plugin {
3
- public $db_version = '2.0';
4
-
5
- public function run() {
6
- // Called when the plugin is activated.
7
- register_activation_hook( ZEROSPAM_PLUGIN, array( $this, 'activate' ) );
8
-
9
- add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
10
- }
11
-
12
- public function activate() {
13
- $this->install();
14
-
15
- if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
16
- update_site_option( 'zerospam_general_settings', $this->default_settings );
17
- } else {
18
- update_option( 'zerospam_general_settings', $this->default_settings );
19
- }
20
- }
21
-
22
- /**
23
- * Installs the plugins DB tables.
24
- *
25
- * @since 2.0.0
26
- *
27
- * @link http://codex.wordpress.org/Creating_Tables_with_Plugins
28
- */
29
- public function install() {
30
- global $wpdb;
31
-
32
- $log_table_name = $wpdb->prefix . 'zerospam_log';
33
- $ip_table_name = $wpdb->prefix . 'zerospam_blocked_ips';
34
- $ip_data_table_name = $wpdb->prefix . 'zerospam_ip_data';
35
-
36
- $current_version = get_option( 'zerospam_db_version' );
37
-
38
- if ( empty( $current_version ) ) {
39
- /*
40
- * We'll set the default character set and collation for this table.
41
- * If we don't do this, some characters could end up being converted
42
- * to just ?'s when saved in our table.
43
- */
44
- $charset_collate = '';
45
-
46
- if ( ! empty( $wpdb->charset ) ) {
47
- $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
48
- }
49
-
50
- if ( ! empty( $wpdb->collate ) ) {
51
- $charset_collate .= " COLLATE {$wpdb->collate}";
52
- }
53
-
54
- $sql = false;
55
-
56
- // Check for the log table.
57
- if ( $wpdb->get_var( 'SHOW TABLES LIKE \'' . $log_table_name . '\'') != $log_table_name ) {
58
- $sql = "CREATE TABLE $log_table_name (
59
- zerospam_id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
60
- type varchar(255) NOT NULL DEFAULT 'Undefined Form',
61
- ip varchar(15) NOT NULL,
62
- date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
63
- page varchar(255) DEFAULT NULL,
64
- PRIMARY KEY (zerospam_id),
65
- KEY type (type)
66
- ) $charset_collate;";
67
- }
68
-
69
- // Check for the IP table.
70
- if ( $wpdb->get_var( 'SHOW TABLES LIKE \'' . $ip_table_name . '\'' ) != $ip_table_name ) {
71
- $sql .= "CREATE TABLE $ip_table_name (
72
- zerospam_ip_id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
73
- ip varchar(15) NOT NULL,
74
- type enum('permanent','temporary') NOT NULL DEFAULT 'temporary',
75
- start_date datetime DEFAULT NULL,
76
- end_date datetime DEFAULT NULL,
77
- reason varchar(255) DEFAULT NULL,
78
- PRIMARY KEY (zerospam_ip_id),
79
- UNIQUE KEY ip (ip)
80
- ) $charset_collate;";
81
- }
82
-
83
- if ( $sql ) {
84
- require_once ABSPATH . 'wp-admin/includes/upgrade.php';
85
- dbDelta( $sql );
86
- }
87
-
88
- $options = (array) $this->settings;
89
- $options['registration_support'] = 1;
90
- $options['comment_support'] = 1;
91
- $options['log_spammers'] = 1;
92
- $options['wp_generator'] = 1;
93
- $options['cf7_support'] = 1;
94
- $options['gf_support'] = 1;
95
- $options['bp_support'] = 1;
96
- $options['nf_support'] = 1;
97
- $options['wpf_support'] = 1;
98
- $options['ip_location_support'] = 1;
99
-
100
- if ( is_plugin_active_for_network( plugin_basename( ZEROSPAM_PLUGIN ) ) ) {
101
- update_site_option( 'zerospam_general_settings', $options );
102
- } else {
103
- update_option( 'zerospam_general_settings', $options );
104
- }
105
-
106
- update_option( 'zerospam_db_version', $this->db_version );
107
- } elseif ( $current_version != $this->db_version ) {
108
- if ( version_compare( '2.0', $current_version ) ) {
109
- $wpdb->query( "ALTER TABLE `$log_table_name` CHANGE `type` `type` VARCHAR(255) NOT NULL DEFAULT 'Undefined Form';" );
110
- }
111
-
112
- update_option( 'zerospam_db_version', $this->db_version );
113
- }
114
- }
115
-
116
- /**
117
- * Uses plugins_loaded.
118
- *
119
- * This hook is called once any activated plugins have been loaded. Is
120
- * generally used for immediate filter setup, or plugin overrides.
121
- *
122
- * @since 2.0.0
123
- *
124
- * @link http://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
125
- */
126
- public function plugins_loaded() {
127
- if ( get_option( 'zerospam_db_version' ) != $this->db_version ) {
128
- $this->install();
129
- }
130
- }
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/ZeroSpam/Scripts.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- class ZeroSpam_Scripts {
3
- public function run() {
4
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
5
- add_action( 'login_footer', array( $this, 'wp_enqueue_scripts' ) );
6
- }
7
-
8
- public function wp_enqueue_scripts() {
9
- $this->register_styles();
10
- $this->register_scripts();
11
-
12
- $this->enqueue_styles();
13
- $this->enqueue_scripts();
14
- }
15
-
16
- public function register_styles() {
17
- //wp_register_style( 'bam-wedding', get_template_directory_uri() . '/assets/css/style.css' );
18
- }
19
-
20
- public function register_scripts() {
21
- wp_register_script( 'zerospam', plugins_url( '/js/zerospam.js' , ZEROSPAM_PLUGIN ), array( 'jquery' ), '2.0.0', true );
22
- }
23
-
24
- public function enqueue_styles() {
25
- //wp_enqueue_style( 'bam-wedding' );
26
- }
27
-
28
- public function enqueue_scripts() {
29
- wp_localize_script( 'zerospam', 'zerospam', array( 'key' => zerospam_get_key() ) );
30
- wp_enqueue_script( 'zerospam' );
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/index.php DELETED
@@ -1 +0,0 @@
1
- <?php // Silence is golden
 
tpl/admin-sidebar.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Sidebar Template
4
+ *
5
+ * Content for the plugin settings page right sidebar.
6
+ *
7
+ * @since 1.5.0
8
+ */
9
+
10
+ /**
11
+ * Security Note: Blocks direct access to the plugin PHP files.
12
+ */
13
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
+ ?>
15
+ <div class="zero-spam__widget">
16
+ <div class="zero-spam__inner">
17
+ <h2><a href="<?php echo esc_url( $plugin['PluginURI'] ); ?>" target="_blank"><?php echo __( $plugin['Name'], 'zerospam' ); ?></a></h2>
18
+ <p class="zero-spam__description"><b><?php echo __( 'Rate', 'zerospam' ); ?>:</b> <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" target="_blank"><i class="fa fa-star"></i>
19
+ <i class="fa fa-star"></i>
20
+ <i class="fa fa-star"></i>
21
+ <i class="fa fa-star"></i>
22
+ <i class="fa fa-star"></i></a> |
23
+ <b>Version:</b> <?php echo $plugin['Version']; ?> | <b><?php echo __( 'Author', 'zerospam' ); ?></b> <?php echo $plugin['Author']; ?></p>
24
+ <p><?php echo $plugin['Description']; ?></p>
25
+ <p><small>If you have suggestions for a new add-on, feel free to email me at <a href="mailto:me@benmarshall.me">me@benmarshall.me</a>. Want regular updates? Follow me on <a href="https://twitter.com/bmarshall0511" target="_blank">Twitter</a> or <a href="https://benmarshall.me/" target="_blank">visit my blog</a>.</small></p>
26
+ <p>
27
+ <a href="https://www.gittip.com/bmarshall511/" class="zero-spam__button" target="_blank"><?php echo __( 'Show Support &mdash; Donate!', 'zerospam' ); ?></a>
28
+ <a href="https://wordpress.org/support/view/plugin-reviews/zero-spam" class="zero-spam__button" target="_blank"><?php echo __( 'Spread the Love &mdash; Rate!', 'zerospam' ); ?></a>
29
+ </p>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="zero-spam__widget">
34
+ <div class="zero-spam__inner">
35
+ <h3><?php echo __( 'Are you a WordPress developer?', 'zerospam' ); ?></h3>
36
+
37
+ <p><?php echo __( 'Help grow this plugin, integrate into your own or add new features by contributing.', 'zerospam' ); ?></p>
38
+ <p><a href="https://github.com/bmarshall511/wordpress-zero-spam" target="_blank" class="button button-large button-primary"><?php echo __( 'Fork it on GitHub!', 'zerospam' ); ?></a></p>
39
+ </div>
40
+ </div>
tpl/block-ip-form.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block IP form template.
4
+ *
5
+ * @since 1.5.0
6
+ */
7
+
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">
15
+ <table class="form-table">
16
+ <tr>
17
+ <th><label for="zerospam-ip">IP:</th>
18
+ <td><input type="text" name="zerospam-ip" id="zerospam-ip" value="<?php echo esc_attr( $ip ); ?>" readonly="readonly" class="regular-text"></td>
19
+ </tr>
20
+ <tr>
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>
101
+ jQuery( document ).ready( function( $ ) {
102
+ $( "#zero-spam__block-ip-form" ).submit( function( e ) {
103
+ e.preventDefault();
104
+
105
+ var form = $( this );
106
+
107
+ $( "input[type='submit']", form ).attr( "disabled", true );
108
+ $( ".zero-spam__msg" ).remove();
109
+
110
+ var data = $( "#zero-spam__block-ip-form" ).serialize();
111
+ data += '&security=<?php echo $ajax_nonce; ?>';
112
+ data += '&action=block_ip';
113
+
114
+ $.post( ajaxurl, data, function( d ) {
115
+ $( "input[type='submit']", form ).attr( "disabled", false );
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
+
123
+ $( "#zerospam-type" ).change( function() {
124
+ var val = $( this ).val();
125
+ if ( "permanent" == val ) {
126
+ $( ".zero-spam__period" ).hide();
127
+ } else {
128
+ $( ".zero-spam__period" ).show();
129
+ }
130
+ });
131
+ });
132
+ </script>
inc/general-settings.tpl.php → tpl/general-settings.php RENAMED
@@ -12,12 +12,12 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
12
  ?>
13
  <div class="zero-spam__row">
14
  <div class="zero-spam__widget">
15
- <div class="zero-spam__inner">
16
- <form method="post" action="<?php echo $action; ?>">
17
- <?php settings_fields( $tab ); ?>
18
- <?php do_settings_sections( $tab ); ?>
19
- <?php submit_button(); ?>
20
- </form>
21
- </div>
22
  </div>
23
  </div>
12
  ?>
13
  <div class="zero-spam__row">
14
  <div class="zero-spam__widget">
15
+ <div class="zero-spam__inner">
16
+ <form method="post" action="<?php echo $action; ?>">
17
+ <?php settings_fields( $tab ); ?>
18
+ <?php do_settings_sections( $tab ); ?>
19
+ <?php submit_button(); ?>
20
+ </form>
21
+ </div>
22
  </div>
23
  </div>
tpl/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
tpl/ip-block.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
8
+ <thead>
9
+ <tr>
10
+ <th><?php echo __( 'IP', 'zerospam' ); ?></th>
11
+ <th><?php echo __( 'Status', 'zerospam' ); ?></th>
12
+ <th><?php echo __( 'Start Date', 'zerospam' ); ?></th>
13
+ <th><?php echo __( 'End Date', 'zerospam' ); ?></th>
14
+ <th><?php echo __( 'Reason', 'zerospam' ); ?></th>
15
+ <th>&nbsp;</th>
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
+ ?>
53
+ </td>
54
+ <td class="zero-spam__reason"><?php echo esc_html( $data->reason ); ?></td>
55
+ <td class="zero-spam__text-center">
56
+ <i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;
57
+ <i class="fa fa-edit"></i>&nbsp;
58
+ <a href="#" class="button button-small zero-spam__block-ip" data-ip="<?php echo esc_attr( $data->ip ); ?>">
59
+ <i class="fa fa-gear"></i>
60
+ </a>&nbsp;
61
+
62
+ <a href="#" class="button button-small zero-spam__trash" data-ip="<?php echo esc_attr( $data->ip ); ?>"><i class="fa fa-trash"></i></a>
63
+ </td>
64
+ </tr>
65
+ <?php endforeach; ?>
66
+ </tbody>
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>
74
+ </div>
75
+ </div>
tpl/spammer-logs.php ADDED
@@ -0,0 +1,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Spammer Log Template
4
+ *
5
+ * Content for the plugin spammer log page.
6
+ *
7
+ * @since 1.5.0
8
+ */
9
+
10
+ /**
11
+ * Security Note: Blocks direct access to the plugin PHP files.
12
+ */
13
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
+ ?>
15
+ <div class="zero-spam__row">
16
+ <div class="zero-spam__cell">
17
+ <div class="zero-spam__widget zero-spam__bg--primary">
18
+ <div class="zero-spam__inner">
19
+ <h3><?php echo __( 'Summary', 'zerospam' ); ?></h3>
20
+ <div class="zero-spam__row">
21
+ <?php if ( isset( $num_days ) ): ?>
22
+ <div class="zero-spam__stat">
23
+ <?php echo __( 'Protected', 'zerospam' ); ?>
24
+ <b><?php echo number_format( $num_days, 0 ); ?> <?php echo __( 'days', 'zerospam' ); ?></b>
25
+ </div>
26
+ <?php endif; ?>
27
+ <div class="zero-spam__stat">
28
+ <?php echo __( 'Total Spam', 'zerospam' ); ?>
29
+ <b><?php echo number_format( $all_spam['raw'], 0 ); ?></b>
30
+ </div>
31
+ <?php if ( isset( $per_day ) ): ?>
32
+ <div class="zero-spam__stat">
33
+ <?php echo __( 'Per day', 'zerospam' ); ?>
34
+ <b><?php echo number_format( $per_day, 0 ); ?></b>
35
+ </div>
36
+ <?php endif; ?>
37
+ <div class="zero-spam__stat">
38
+ <?php echo __( 'Unique Spammers', 'zerospam' ); ?>
39
+ <b><?php echo number_format( $all_spam['unique_spammers'], 0 ); ?></b>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ <div class="zero-spam__cell">
46
+ <div class="zero-spam__widget zero-spam__bg--secondary">
47
+ <div class="zero-spam__inner">
48
+ <h3><?php echo __( 'Stats', 'zerospam' ); ?></h3>
49
+ <div class="zero-spam__row">
50
+ <div class="zero-spam__stat">
51
+ <?php echo __( 'Comments', 'zerospam' ); ?>
52
+ <b><?php echo number_format( $all_spam['comment_spam'], 0 ); ?></b>
53
+ </div>
54
+ <div class="zero-spam__stat">
55
+ <?php echo __( 'Registrations', 'zerospam' ); ?>
56
+ <b><?php echo number_format( $all_spam['registration_spam'], 0 ); ?></b>
57
+ </div>
58
+
59
+ <?php if (
60
+ zerospam_plugin_check( 'cf7' ) &&
61
+ ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support']
62
+ ): ?>
63
+ <div class="zero-spam__stat">
64
+ <?php echo __( 'Contact Form 7', 'zerospam' ); ?>
65
+ <b><?php echo number_format( $all_spam['cf7_spam'], 0 ); ?></b>
66
+ </div>
67
+ <?php endif; ?>
68
+
69
+ <?php if (
70
+ zerospam_plugin_check( 'gf' ) &&
71
+ ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support']
72
+ ): ?>
73
+ <div class="zero-spam__stat">
74
+ <?php echo __( 'Gravity Forms', 'zerospam' ); ?>
75
+ <b><?php echo number_format( $all_spam['gf_spam'], 0 ); ?></b>
76
+ </div>
77
+ <?php endif; ?>
78
+
79
+ <?php if (
80
+ zerospam_plugin_check( 'bp' ) &&
81
+ ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support']
82
+ ): ?>
83
+ <div class="zero-spam__stat">
84
+ <?php echo __( 'BP Registrations', 'zerospam' ); ?>
85
+ <b><?php echo number_format( $all_spam['bp_registration_spam'], 0 ); ?></b>
86
+ </div>
87
+ <?php endif; ?>
88
+
89
+ <?php if (
90
+ zerospam_plugin_check( 'nf' ) &&
91
+ ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support']
92
+ ): ?>
93
+ <div class="zero-spam__stat">
94
+ <?php echo __( 'Ninja Forms', 'zerospam' ); ?>
95
+ <b><?php echo number_format( $all_spam['nf_spam'], 0 ); ?></b>
96
+ </div>
97
+ <?php endif; ?>
98
+
99
+ <?php if (
100
+ zerospam_plugin_check( 'wpf' ) &&
101
+ ! empty( $this->settings['wpf'] ) && $this->settings['wpf_support']
102
+ ): ?>
103
+ <div class="zero-spam__stat">
104
+ <?php echo __( 'WPForms', 'zerospam' ); ?>
105
+ <b><?php echo number_format( $all_spam['wpf_spam'], 0 ); ?></b>
106
+ </div>
107
+ <?php endif; ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <?php if ( $ip_location_support ): ?>
115
+ <div class="zero-spam__widget">
116
+ <div class="zero-spam__overlay">
117
+ <div class="zero-spam__inner">
118
+ <i class="fa fa-circle-o-notch fa-spin"></i>
119
+ <h4><?php echo __( 'Crunching numbers...', 'zerospam' ); ?></h4>
120
+ <p><?php echo __( 'This could take a minute or two, please be patient.' ); ?></p>
121
+ </div>
122
+ </div>
123
+ <div class="zero-spam__row">
124
+ <div class="zero-spam__cell">
125
+ <div class="zero-spam__inner">
126
+ <h3><?php echo __( 'Most Spam By Country', 'zerospam' ); ?></h3>
127
+ <table class="zero-spam__table">
128
+ <thead>
129
+ <tr>
130
+ <th><?php echo __( 'Country', 'zerospam' ); ?></th>
131
+ <th class="zero-spam__text-right"><?php echo __( 'Count', 'zerospam' ); ?></th>
132
+ </tr>
133
+ </thead>
134
+ <tbody id="zerospam-country-spam">
135
+ </tbody>
136
+ </table>
137
+ </div>
138
+ </div>
139
+ <div class="zero-spam__cell">
140
+ <div id="map" class="zero-spam__map"></div>
141
+ <script>
142
+
143
+ jQuery(function() {
144
+ jQuery.post( ajaxurl, {
145
+ action: 'get_ip_spam',
146
+ security: '<?php echo $ajax_nonce; ?>',
147
+ }, function( data ) {
148
+ if ( data ) {
149
+ var obj = jQuery.parseJSON( data ),
150
+ country_count = {},
151
+ cnt = 0;
152
+
153
+ if ( obj.by_country ) {
154
+ jQuery( ".zero-spam__overlay" ).fadeOut();
155
+
156
+
157
+ jQuery.each( obj.by_country, function( abbr, c ) {
158
+ cnt++;
159
+ if ( cnt > 6 ) return false;
160
+ jQuery( "#zerospam-country-spam" ).append( "<tr><td><b>" + c.name + "</b></td><td class='zero-spam__text-right'>" + c.count + "</td></tr>" );
161
+ country_count[abbr] = String(c.count);
162
+ });
163
+
164
+ jQuery('#map').vectorMap({
165
+ map: 'world_mill_en',
166
+ backgroundColor: '#1b1e24',
167
+ series: {
168
+ regions: [{
169
+ scale: ['#ffe6ea', '#ff183a'],
170
+ normalizeFunction: 'linear',
171
+ attribute: 'fill',
172
+ values: country_count
173
+ }]
174
+ }
175
+
176
+ });
177
+
178
+ var map = jQuery('#map').vectorMap('get', 'mapObject');
179
+ map.series.regions[0].setValues( country_count );
180
+ } else {
181
+ jQuery( ".zero-spam__inner", jQuery( ".zero-spam__overlay" ) ).html( "<i class='fa fa-thumbs-up'></i><h4>No spammers yet!</h4>" );
182
+ }
183
+ } else {
184
+ jQuery( ".zero-spam__inner", jQuery( ".zero-spam__overlay" ) ).html( "<i class='fa fa-exclamation-triangle'></i><h4>IP API Usage Limit Reached</h4><p>You've reached you're daily limit to the IP API to gather location information. Please check back in one hour.</p>" );
185
+ }
186
+ });
187
+ });
188
+ </script>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ <?php endif; ?>
193
+
194
+ <?php if ( $all_spam['raw'] ): ?>
195
+ <div class="zero-spam__row">
196
+ <div class="zero-spam__cell">
197
+ <div class="zero-spam__widget">
198
+ <div class="zero-spam__inner">
199
+ <div class="zero-spam__row">
200
+ <div class="zero-spam__cell">
201
+ <h3><?php echo __( 'Percentage of Spam by Day', 'zerospam' ); ?></h3>
202
+ <table class="zero-spam__table">
203
+ <thead>
204
+ <tr>
205
+ <th><?php echo __( 'Day', 'zerospam' ); ?></th>
206
+ <th class="zero-spam__text-right"><?php echo __( 'Count', 'zerospam' ); ?></th>
207
+ </tr>
208
+ </thead>
209
+ <tbody>
210
+ <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
211
+ <tr>
212
+ <td><b><?php echo $day; ?></b></td>
213
+ <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
214
+ </tr>
215
+ <?php endforeach; ?>
216
+ </tbody>
217
+ </table>
218
+ </div>
219
+ <div class="zero-spam__cell">
220
+ <div id="donut"></div>
221
+ <script>
222
+ jQuery(function() {
223
+ Morris.Donut({
224
+ element: 'donut',
225
+ data: [
226
+ <?php foreach( $all_spam['by_day'] as $day => $count ): ?>
227
+ {value: <?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>, label: '<?php echo $day; ?>', formatted: '<?php echo zerospam_get_percent( $count, $all_spam['raw'] ); ?>%'},
228
+ <?php endforeach; ?>
229
+ ],
230
+ formatter: function (x, data) { return data.formatted; }
231
+ });
232
+ });
233
+ </script>
234
+ </div>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ <div class="zero-spam__cell">
240
+ <div class="zero-spam__widget">
241
+ <div class="zero-spam__inner">
242
+ <h3><?php echo __( 'Most Frequent Spammers', 'zerospam' ); ?></h3>
243
+ <table class="zero-spam__table">
244
+ <thead>
245
+ <tr>
246
+ <th width="100"><?php echo __( 'IP', 'zerospam' ); ?></th>
247
+ <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
248
+ <th class="zero-spam__text-right">#</th>
249
+ <th><?php echo __( 'Status', 'zerospam' ); ?></th>
250
+ <th>&nbsp;</th>
251
+ </tr>
252
+ </thead>
253
+ <tbody>
254
+ <?php
255
+ arsort( $all_spam['by_spam_count'] );
256
+ $cnt = 0;
257
+
258
+ foreach( $all_spam['by_spam_count'] as $ip => $count ):
259
+ $cnt++; if ( $cnt > 6) break;
260
+ ?>
261
+ <tr data-ip="<?php echo $ip; ?>">
262
+ <td><a href="http://ip-lookup.net/index.php?ip=<?php echo $ip; ?>" target="_blank">
263
+ <?php echo $ip; ?> <i class="fa fa-external-link-square"></i></a></td>
264
+ <?php if ( $ip_location_support ): ?>
265
+ <td>
266
+ <div data-ip-location="<?php echo $ip; ?>"><i class="fa fa-search"></i></div>
267
+ </td>
268
+ <?php endif; ?>
269
+ <td class="zero-spam__text-right"><?php echo number_format( $count, 0 ); ?></td>
270
+ <td class="zero-spam__status">
271
+ <?php if( zerospam_is_blocked( $ip ) ): ?>
272
+ <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
273
+ <?php else: ?>
274
+ <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
275
+ <?php endif; ?>
276
+ </td>
277
+ <td class="zero-spam__text-center">
278
+ <i class="fa fa-circle-o-notch fa-spin"></i>
279
+ <i class="fa fa-edit"></i>
280
+ <a href="#" class="button button-small zero-spam__block-ip"
281
+ data-ip="<?php echo $ip; ?>"><i class="fa fa-gear"></i></a>
282
+ </td>
283
+ </tr>
284
+ <?php endforeach; ?>
285
+ </tbody>
286
+ </table>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ </div>
291
+ <?php endif; ?>
292
+
293
+ <div class="zero-spam__widget">
294
+ <div class="zero-spam__inner">
295
+ <?php if ( count( $all_spam['by_date'] ) ): ?>
296
+ <a href="javascript: clearLog();" class="zero-spam__fright button"><?php echo __( 'Reset Log', 'zerospam' ); ?></a>
297
+ <h3><?php echo __( 'All Time', 'zerospam' ); ?></h3>
298
+ <div id="graph"></div>
299
+ <script>
300
+ jQuery(function() {
301
+ // Use Morris.Area instead of Morris.Line
302
+ Morris.Area({
303
+ element: 'graph',
304
+ behaveLikeLine: true,
305
+ data: [
306
+ <?php foreach( $all_spam['by_date'] as $date => $ary ): ?>
307
+ {
308
+ 'date': '<?php echo $date; ?>',
309
+ <?php foreach ( $ary as $key => $val ):
310
+ switch ( $key ):
311
+ case 'comment_spam': ?>
312
+ 'spam_comments' : <?php echo $val; ?>,
313
+ <?php break;
314
+ case 'registration_spam': ?>
315
+ 'spam_registrations' : <?php echo $val; ?>,
316
+ <?php break;
317
+ case 'cf7_spam':
318
+ if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
319
+ 'spam_cf7' : <?php echo $val; ?>,
320
+ <?php endif; break;
321
+ case 'gf_spam':
322
+ if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
323
+ 'spam_gf' : <?php echo $val; ?>,
324
+ <?php endif; break;
325
+ case 'bp_registration_spam':
326
+ if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
327
+ 'bp_registrations' : <?php echo $val; ?>,
328
+ <?php endif; break;
329
+ case 'nf_spam':
330
+ if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
331
+ 'nf_spam' : <?php echo $val; ?>,
332
+ <?php endif; break;
333
+ case 'wpf_spam':
334
+ if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
335
+ 'wpf_spam' : <?php echo $val; ?>,
336
+ <?php endif; break;
337
+ default: if ( $key != 'data' ): ?>
338
+ '<?php echo $key; ?>': <?php echo $val; ?>,
339
+ <?php endif; endswitch;
340
+ endforeach; ?>
341
+ },
342
+ <?php endforeach; ?>
343
+ ],
344
+ xkey: 'date',
345
+ ykeys: [
346
+ <?php foreach ( $ary as $key => $val ):
347
+ switch ( $key ):
348
+ case 'comment_spam': ?>
349
+ 'spam_comments',
350
+ <?php break;
351
+ case 'registration_spam': ?>
352
+ 'spam_registrations',
353
+ <?php break;
354
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
355
+ 'spam_cf7',
356
+ <?php endif; break;
357
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
358
+ 'spam_gf',
359
+ <?php endif; break;
360
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
361
+ 'bp_registrations',
362
+ <?php endif; break;
363
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
364
+ 'nf_spam',
365
+ <?php endif; break;
366
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
367
+ 'wpf_spam',
368
+ <?php endif; break;
369
+ default: if ( $key != 'data' ): ?>
370
+ '<?php echo $key; ?>',
371
+ <?php endif; endswitch;
372
+ endforeach; ?>
373
+ ],
374
+ labels: [
375
+ <?php foreach ( $ary as $key => $val ):
376
+ switch ( $key ):
377
+ case 'comment_spam': ?>
378
+ '<?php echo __( 'Spam Comments', 'zerospam' ); ?>',
379
+ <?php break;
380
+ case 'registration_spam': ?>
381
+ '<?php echo __( 'Spam Registrations', 'zerospam' ); ?>',
382
+ <?php break;
383
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
384
+ '<?php echo __( 'Contact Form 7', 'zerospam' ); ?>',
385
+ <?php endif; break;
386
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
387
+ '<?php echo __( 'Gravity Forms', 'zerospam' ); ?>',
388
+ <?php endif; break;
389
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
390
+ '<?php echo __( 'BuddyPress', 'zerospam' ); ?>',
391
+ <?php endif; break;
392
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
393
+ '<?php echo __( 'Ninja Forms', 'zerospam' ); ?>',
394
+ <?php endif; break;
395
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
396
+ '<?php echo __( 'WPForms', 'zerospam' ); ?>',
397
+ <?php endif; break;
398
+ default: if ( $key != 'data' ): ?>
399
+ '<?php echo $key; ?>',
400
+ <?php endif; endswitch;
401
+ endforeach; ?>
402
+ ],
403
+ xLabels: 'day',
404
+ lineColors: [
405
+ <?php foreach ( $ary as $key => $val ):
406
+ switch ( $key ):
407
+ case 'comment_spam': ?>
408
+ '#00639e',
409
+ <?php break;
410
+ case 'registration_spam': ?>
411
+ '#ff183a',
412
+ <?php break;
413
+ case 'cf7_spam': if ( zerospam_plugin_check( 'cf7' ) && ! empty( $this->settings['cf7_support'] ) && $this->settings['cf7_support'] ): ?>
414
+ '#fddb5a',
415
+ <?php endif; break;
416
+ case 'gf_spam': if ( zerospam_plugin_check( 'gf' ) && ! empty( $this->settings['gf_support'] ) && $this->settings['gf_support'] ): ?>
417
+ '#222d3a'
418
+ <?php endif; break;
419
+ case 'bp_registration_spam': if ( zerospam_plugin_check( 'bp' ) && ! empty( $this->settings['bp_support'] ) && $this->settings['bp_support'] ): ?>
420
+ '#a0d5f4'
421
+ <?php endif; break;
422
+ case 'nf_spam': if ( zerospam_plugin_check( 'nf' ) && ! empty( $this->settings['nf_support'] ) && $this->settings['nf_support'] ): ?>
423
+ '#ef4748',
424
+ <?php endif; break;
425
+ case 'wpf_spam': if ( zerospam_plugin_check( 'wpf' ) && ! empty( $this->settings['wpf_support'] ) && $this->settings['wpf_support'] ): ?>
426
+ '#e27730',
427
+ <?php endif; break;
428
+ default: if ( $key != 'data' ): ?>
429
+ '#c2c2c2',
430
+ <?php endif; endswitch;
431
+ endforeach; ?>
432
+ ]
433
+ });
434
+ });
435
+ </script>
436
+ <table class="zero-spam__table">
437
+ <thead>
438
+ <tr>
439
+ <th><?php echo __( 'Date', 'zerospam' ); ?></th>
440
+ <th width="90"><?php echo __( 'Type', 'zerospam' ); ?></th>
441
+ <?php if ( $ip_location_support ): ?><th><?php echo __( 'Location', 'zerospam' ); ?></th><?php endif; ?>
442
+ <th width="106"><?php echo __( 'IP', 'zerospam' ); ?></th>
443
+ <th><?php echo __( 'Page', 'zerospam' ); ?></th>
444
+ <th><?php echo __( 'Status', 'zerospam' ); ?></th>
445
+ <th>&nbsp;</th>
446
+ </tr>
447
+ </thead>
448
+ <tbody>
449
+ <?php
450
+ foreach ( $spam['raw'] as $key => $obj ):
451
+ switch ( $obj->type ) {
452
+ case 1:
453
+ $type = '<span class="zero-spam__label zero-spam__bg--primary">' . __( 'Registration', 'zerospam' ) . '</span>';
454
+ break;
455
+ case 2:
456
+ $type = '<span class="zero-spam__label zero-spam__bg--secondary">' . __( 'Comment', 'zerospam' ) . '</span>';
457
+ break;
458
+ case 3:
459
+ $type = '<span class="zero-spam__label zero-spam__bg--trinary">' . __( 'Contact Form 7', 'zerospam' ) . '</span>';
460
+ break;
461
+ case 4:
462
+ $type = '<span class="zero-spam__label zero-spam__bg--gf">' . __( 'Gravity Forms', 'zerospam' ) . '</span>';
463
+ break;
464
+ case 5:
465
+ $type = '<span class="zero-spam__label zero-spam__bg--bpr">' . __( 'BP Registration', 'zerospam' ) . '</span>';
466
+ break;
467
+ case 6:
468
+ $type = '<span class="zero-spam__label zero-spam__bg--nf">' . __( 'Ninja Forms', 'zerospam' ) . '</span>';
469
+ break;
470
+ case 7:
471
+ $type = '<span class="zero-spam__label zero-spam__bg--wpf">' . __( 'WPForms', 'zerospam' ) . '</span>';
472
+ break;
473
+ default:
474
+ $type = '<span class="zero-spam__label zero-spam__bg--misc">' . __( $obj->type, 'zerospam' ) . '</span>';
475
+ }
476
+ ?>
477
+ <tr data-ip="<?php echo $obj->ip; ?>" id="row-<?php echo $obj->zerospam_id; ?>">
478
+ <td>
479
+ <?php
480
+ echo date_i18n(
481
+ 'l, F jS, Y g:ia',
482
+ strtotime( $obj->date )
483
+ );
484
+ ?>
485
+ </td>
486
+ <td><?php echo isset( $type ) ? $type : '&mdash;'; ?></td>
487
+ <?php if ( $ip_location_support ): ?>
488
+ <td>
489
+ <div data-ip-location="<?php echo $obj->ip; ?>"><i class="fa fa-search"></i></div>
490
+ </td>
491
+ <?php endif; ?>
492
+ <td>
493
+ <a href="http://ip-lookup.net/index.php?ip=<?php echo $obj->ip; ?>" target="_blank">
494
+ <?php echo $obj->ip; ?> <i class="fa fa-external-link-square"></i></a>
495
+ </td>
496
+ <td>
497
+ <?php if ( isset( $obj->page ) ): ?>
498
+ <a href="<?php echo esc_url( $obj->page ); ?>" target="_blank"><?php echo $obj->page; ?> <i class="fa fa-external-link-square"></i></a>
499
+ <?php else: ?>
500
+ <?php echo __( 'Unknown', 'zerospam' ); ?>
501
+ <?php endif; ?>
502
+ </td>
503
+ <td class="zero-spam__status">
504
+ <?php if( zerospam_is_blocked( $obj->ip ) ): ?>
505
+ <span class="zero-spam__label zero-spam__bg--primary"><?php echo __( 'Blocked', 'zerospam' ); ?></span>
506
+ <?php else: ?>
507
+ <span class="zero-spam__label zero-spam__bg--trinary"><?php echo __( 'Unblocked', 'zerospam' ); ?></span>
508
+ <?php endif; ?>
509
+ </td>
510
+ <td class="zero-spam__text-center">
511
+ <i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;
512
+ <i class="fa fa-edit"></i>&nbsp;
513
+ <a href="#" class="button button-small zero-spam__block-ip"
514
+ data-ip="<?php echo $obj->ip; ?>"><i class="fa fa-gear"></i></a>
515
+ </td>
516
+ </tr>
517
+ <?php endforeach; ?>
518
+ </tbody>
519
+ </table>
520
+ <?php zerospam_pager( $limit, zerospam_get_spam_count(), $page, $tab ); ?>
521
+ <?php else: ?>
522
+ <?php echo __( 'No spammers detected yet!', 'zerospam'); ?>
523
+ <?php endif; ?>
524
+ </div>
525
+ </div>
uninstall.php CHANGED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * Fired when the plugin is uninstalled.
@@ -19,7 +27,7 @@
19
  * For more information, see the following discussion:
20
  * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
21
  *
22
- * @since 1.5.0
23
  */
24
 
25
  // If this file is called directly, abort.
1
  <?php
2
+ /**
3
+ * Uninstall
4
+ *
5
+ * Contains all plugin uninstall functionality.
6
+ *
7
+ * @package WordPress Zero Spam
8
+ * @since 1.0.0
9
+ */
10
 
11
  /**
12
  * Fired when the plugin is uninstalled.
27
  * For more information, see the following discussion:
28
  * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
29
  *
30
+ * @since 1.5.0
31
  */
32
 
33
  // If this file is called directly, abort.
zero-spam.php CHANGED
@@ -3,13 +3,13 @@
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: 2.2.1
7
  * Author: Ben Marshall
8
  * Author URI: https://benmarshall.me
9
  * License: GPL2
10
  */
11
 
12
- /* Copyright 2015 Ben Marshall (email : me@benmarshall.me)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License, version 2, as
@@ -31,34 +31,29 @@
31
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
32
 
33
  // Define constants.
34
- if( ! defined( 'ZEROSPAM_ROOT ' ) ) {
 
35
  define( 'ZEROSPAM_ROOT', plugin_dir_path( __FILE__ ) );
36
  }
37
 
38
- if( ! defined( 'ZEROSPAM_PLUGIN ' ) ) {
 
39
  define( 'ZEROSPAM_PLUGIN', __FILE__ );
40
  }
41
 
42
  /**
43
  * Include the plugin helpers.
44
  */
45
- require_once ZEROSPAM_ROOT . 'src' . DIRECTORY_SEPARATOR . 'helpers.php';
46
 
47
  /**
48
  * Used to detect installed plugins.
49
  */
50
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
51
 
52
  spl_autoload_register( 'zerospam_autoloader' );
53
- function zerospam_autoloader( $class_name ) {
54
- if ( false !== strpos( $class_name, 'ZeroSpam' ) ) {
55
- $classes_dir = ZEROSPAM_ROOT . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
56
- $class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';
57
- require_once $classes_dir . $class_file;
58
- }
59
- }
60
 
61
- // Load the plugin features.
62
  $plugin = new ZeroSpam_Plugin();
63
  $plugin['install'] = new ZeroSpam_Install();
64
  $plugin['access'] = new ZeroSpam_Access();
@@ -67,11 +62,13 @@ $plugin['admin'] = new ZeroSpam_Admin();
67
  $plugin['ajax'] = new ZeroSpam_Ajax();
68
 
69
  // Registration support.
70
- if ( ! empty( $plugin->settings['registration_support'] ) && $plugin->settings['registration_support'] ) {
 
71
  $plugin['registration'] = new ZeroSpam_Registration();
72
  }
73
 
74
  // Comments support.
 
75
  if ( ! empty( $plugin->settings['comment_support'] ) && $plugin->settings['comment_support'] ) {
76
  $plugin['comments'] = new ZeroSpam_Comments();
77
  }
@@ -80,7 +77,8 @@ if ( ! empty( $plugin->settings['comment_support'] ) && $plugin->settings['comme
80
  if (
81
  zerospam_plugin_check( 'cf7' ) &&
82
  ! empty( $plugin->settings['cf7_support'] ) && $plugin->settings['cf7_support']
83
- ) {
 
84
  $plugin['cf7'] = new ZeroSpam_ContactForm7();
85
  }
86
 
@@ -88,7 +86,8 @@ if (
88
  if (
89
  zerospam_plugin_check( 'bp' ) &&
90
  ! empty( $plugin->settings['bp_support'] ) && $plugin->settings['bp_support']
91
- ) {
 
92
  $plugin['bp'] = new ZeroSpam_BuddyPress();
93
  }
94
 
@@ -96,7 +95,8 @@ if (
96
  if (
97
  zerospam_plugin_check( 'nf' ) &&
98
  ! empty( $plugin->settings['nf_support'] ) && $plugin->settings['nf_support']
99
- ) {
 
100
  $plugin['nf'] = new ZeroSpam_NinjaForms();
101
  }
102
 
@@ -104,7 +104,8 @@ if (
104
  if (
105
  zerospam_plugin_check( 'gf' ) &&
106
  ! empty( $plugin->settings['gf_support'] ) && $plugin->settings['gf_support']
107
- ) {
 
108
  $plugin['gf'] = new ZeroSpam_GravityForms();
109
  }
110
 
@@ -112,7 +113,8 @@ if (
112
  if (
113
  zerospam_plugin_check( 'wpf' ) &&
114
  ! empty( $plugin->settings['wpf_support'] ) && $plugin->settings['wpf_support']
115
- ) {
 
116
  $plugin['wpf'] = new ZeroSpam_WPForms();
117
  }
118
 
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.0.0
7
  * Author: Ben Marshall
8
  * Author URI: https://benmarshall.me
9
  * License: GPL2
10
  */
11
 
12
+ /* Copyright 2015 - 2016 Ben Marshall (email : me@benmarshall.me)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License, version 2, as
31
  defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
32
 
33
  // Define constants.
34
+ if( ! defined( 'ZEROSPAM_ROOT ' ) )
35
+ {
36
  define( 'ZEROSPAM_ROOT', plugin_dir_path( __FILE__ ) );
37
  }
38
 
39
+ if( ! defined( 'ZEROSPAM_PLUGIN ' ) )
40
+ {
41
  define( 'ZEROSPAM_PLUGIN', __FILE__ );
42
  }
43
 
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
 
56
+ // Load the plugin libraries.
57
  $plugin = new ZeroSpam_Plugin();
58
  $plugin['install'] = new ZeroSpam_Install();
59
  $plugin['access'] = new ZeroSpam_Access();
62
  $plugin['ajax'] = new ZeroSpam_Ajax();
63
 
64
  // Registration support.
65
+ if ( ! empty( $plugin->settings['registration_support'] ) && $plugin->settings['registration_support'] )
66
+ {
67
  $plugin['registration'] = new ZeroSpam_Registration();
68
  }
69
 
70
  // Comments support.
71
+
72
  if ( ! empty( $plugin->settings['comment_support'] ) && $plugin->settings['comment_support'] ) {
73
  $plugin['comments'] = new ZeroSpam_Comments();
74
  }
77
  if (
78
  zerospam_plugin_check( 'cf7' ) &&
79
  ! empty( $plugin->settings['cf7_support'] ) && $plugin->settings['cf7_support']
80
+ )
81
+ {
82
  $plugin['cf7'] = new ZeroSpam_ContactForm7();
83
  }
84
 
86
  if (
87
  zerospam_plugin_check( 'bp' ) &&
88
  ! empty( $plugin->settings['bp_support'] ) && $plugin->settings['bp_support']
89
+ )
90
+ {
91
  $plugin['bp'] = new ZeroSpam_BuddyPress();
92
  }
93
 
95
  if (
96
  zerospam_plugin_check( 'nf' ) &&
97
  ! empty( $plugin->settings['nf_support'] ) && $plugin->settings['nf_support']
98
+ )
99
+ {
100
  $plugin['nf'] = new ZeroSpam_NinjaForms();
101
  }
102
 
104
  if (
105
  zerospam_plugin_check( 'gf' ) &&
106
  ! empty( $plugin->settings['gf_support'] ) && $plugin->settings['gf_support']
107
+ )
108
+ {
109
  $plugin['gf'] = new ZeroSpam_GravityForms();
110
  }
111
 
113
  if (
114
  zerospam_plugin_check( 'wpf' ) &&
115
  ! empty( $plugin->settings['wpf_support'] ) && $plugin->settings['wpf_support']
116
+ )
117
+ {
118
  $plugin['wpf'] = new ZeroSpam_WPForms();
119
  }
120