WP fail2ban - Version 4.2.3

Version Description

  • Workaround for some versions of PHP 7.x that would cause define()s to be ignored.
  • Add config note to settings tabs.
  • Fix documentation links.
Download this release

Release Info

Developer invisnet
Plugin Icon 128x128 WP fail2ban
Version 4.2.3
Comparing to
See all releases

Code changes from version 4.2.2 to 4.2.3

admin/config.php CHANGED
@@ -61,6 +61,7 @@ function settings()
61
  <?php
62
  settings_fields( 'wp-fail2ban' );
63
  $active_tab->render();
 
64
  ?>
65
  </form>
66
  </div>
61
  <?php
62
  settings_fields( 'wp-fail2ban' );
63
  $active_tab->render();
64
+ echo '<hr><p>' . __( '<strong>Note:</strong> The Free version of <em>WP fail2ban</em> is configured by defining constants in <tt>wp-config.php</tt>; these tabs display those values.<br>Upgrade to the Premium version to enable this interface.' ) . '</p>' ;
65
  ?>
66
  </form>
67
  </div>
admin/config/logging.php CHANGED
@@ -216,7 +216,7 @@ ___HTML___;
216
  __( 'Draft post' ),
217
  $this->commentExtraChecked( WPF2B_EVENT_COMMENT_PASSWORD ),
218
  __( 'Password-protected post' ),
219
- parent::doc_link( 'WP_FAIL2BAN_COMMENTS_EXTRA_LOG', __( 'Use facility:' ) ),
220
  $this->getLogFacilities( 'WP_FAIL2BAN_COMMENT_EXTRA_LOG', false )
221
  );
222
  }
216
  __( 'Draft post' ),
217
  $this->commentExtraChecked( WPF2B_EVENT_COMMENT_PASSWORD ),
218
  __( 'Password-protected post' ),
219
+ parent::doc_link( 'WP_FAIL2BAN_COMMENT_EXTRA_LOG', __( 'Use facility:' ) ),
220
  $this->getLogFacilities( 'WP_FAIL2BAN_COMMENT_EXTRA_LOG', false )
221
  );
222
  }
admin/config/remote-ips.php CHANGED
@@ -95,33 +95,6 @@ class TabRemoteIPs extends Tab
95
  }
96
  printf( '<fieldset><textarea class="code" cols="20" rows="10" disabled="disabled">%s</textarea></fieldset>', esc_html( $value ) );
97
  }
98
-
99
- /**
100
- * Section blurb.
101
- *
102
- * @since 4.0.0
103
- */
104
- public function sectionGeo()
105
- {
106
- }
107
-
108
- /**
109
- * MaxMind database.
110
- *
111
- * @since 4.0.0
112
- */
113
- public function database()
114
- {
115
- $settings = get_option( 'wp-fail2ban' );
116
- $exists = file_exists( @$settings['remote-ip']['maxmind']['path'] );
117
- $fmt = <<<__FMT__
118
- <fieldset>
119
- <label><input type="checkbox" name="wp-fail2ban[remote-ip][maxmind]" %s> Download now</label>
120
- <p class="description">%s</p>
121
- </fieldset>
122
- __FMT__;
123
- printf( $fmt, checked( $exists, false, false ), ( $exists ? __( 'Last modified: ' ) . gmdate( DATE_RFC1123, $settings['remote-ip']['maxmind']['modified'] ) : __( 'No database found.' ) ) );
124
- }
125
 
126
  }
127
  new TabRemoteIPs();
95
  }
96
  printf( '<fieldset><textarea class="code" cols="20" rows="10" disabled="disabled">%s</textarea></fieldset>', esc_html( $value ) );
97
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  }
100
  new TabRemoteIPs();
admin/config/syslog.php CHANGED
@@ -56,7 +56,7 @@ class TabSyslog extends Tab
56
  );
57
  add_settings_field(
58
  'logging-workarounds',
59
- parent::doc_link( 'workarounds', __( 'Options' ) ),
60
  [ $this, 'workarounds' ],
61
  'wp-fail2ban-syslog',
62
  'wp-fail2ban-workarounds'
56
  );
57
  add_settings_field(
58
  'logging-workarounds',
59
+ parent::doc_link( '../syslog', __( 'Options' ) ),
60
  [ $this, 'workarounds' ],
61
  'wp-fail2ban-syslog',
62
  'wp-fail2ban-workarounds'
admin/lib/about.php CHANGED
@@ -41,9 +41,29 @@ function about( $hide_title = false )
41
  <div id="post-body-content">
42
  <div class="meta-box-sortables ui-sortable">
43
  <div class="postbox">
44
- <h2>Version <?php
45
- echo WP_FAIL2BAN_VER ;
46
- ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  <div class="inside">
48
  <ul>
49
  <li><p>Completed support for <tt><a href="https://docs.wp-fail2ban.com/en/4.2/defines/WP_FAIL2BAN_COMMENT_EXTRA_LOG.html" target="docs.wp-fail2ban.com">WP_FAIL2BAN_COMMENT_EXTRA_LOG</a></tt>.</p></li>
@@ -81,9 +101,11 @@ function about( $hide_title = false )
81
  <div class="inside">
82
  <ul>
83
  <?php
84
- ?>
 
85
  <li><a href="https://wordpress.org/support/plugin/wp-fail2ban/" target="_blank">WordPress.org Forum</a></li>
86
  <?php
 
87
  ?>
88
  </div>
89
  </div>
41
  <div id="post-body-content">
42
  <div class="meta-box-sortables ui-sortable">
43
  <div class="postbox">
44
+ <h2>Version 4.2.3</h2>
45
+ <div class="inside">
46
+ <ul>
47
+ <li><p>Workaround for some versions of PHP 7.x that would cause <tt>define()</tt>s to be ignored.</p></li>
48
+ <li><p>Add config note to settings tabs.</p></li>
49
+ <li><p>Fix documentation links.</p></li>
50
+ </ul>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ <div class="meta-box-sortables ui-sortable">
55
+ <div class="postbox">
56
+ <h2>Version 4.2.2</h2>
57
+ <div class="inside">
58
+ <ul>
59
+ <li><p>Fix 5.3 compatibility.</p></li>
60
+ </ul>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ <div class="meta-box-sortables ui-sortable">
65
+ <div class="postbox">
66
+ <h2>Version 4.2.1</h2>
67
  <div class="inside">
68
  <ul>
69
  <li><p>Completed support for <tt><a href="https://docs.wp-fail2ban.com/en/4.2/defines/WP_FAIL2BAN_COMMENT_EXTRA_LOG.html" target="docs.wp-fail2ban.com">WP_FAIL2BAN_COMMENT_EXTRA_LOG</a></tt>.</p></li>
101
  <div class="inside">
102
  <ul>
103
  <?php
104
+ if ( wf_fs()->is_free_plan() ) {
105
+ ?>
106
  <li><a href="https://wordpress.org/support/plugin/wp-fail2ban/" target="_blank">WordPress.org Forum</a></li>
107
  <?php
108
+ }
109
  ?>
110
  </div>
111
  </div>
admin/lib/tab.php CHANGED
@@ -164,7 +164,7 @@ abstract class Tab
164
  $wp_f2b_ver = substr( WP_FAIL2BAN_VER, 0, strrpos( WP_FAIL2BAN_VER, '.' ) );
165
  }
166
  return sprintf(
167
- '<a href="https://wp-fail2ban.readthedocs.io/en/%s/defines/%s.html" style="text-decoration: none;" target="_blank" title="Documentation"><span class="dashicons dashicons-external" style="vertical-align: text-bottom"></span></a> %s',
168
  $wp_f2b_ver,
169
  $define,
170
  $name
@@ -237,7 +237,7 @@ abstract class Tab
237
  array $toggle = array()
238
  )
239
  {
240
- $enabled = defined( $define_name ) && true === constant( $define_name ) && constant( "{$define_log}_NDEF" );
241
  $fmt = <<<___FMT___
242
  <label><input type="checkbox" disabled="disabled" %s> Enable logging</label>,
243
  <label>use facility: %s</label>
@@ -246,7 +246,7 @@ ___FMT___;
246
  $html = sprintf(
247
  $fmt,
248
  checked( $enabled, true, false ),
249
- $this->getLogFacilities( $define_log, $enabled ),
250
  $description
251
  );
252
  echo apply_filters(
164
  $wp_f2b_ver = substr( WP_FAIL2BAN_VER, 0, strrpos( WP_FAIL2BAN_VER, '.' ) );
165
  }
166
  return sprintf(
167
+ '<a href="https://docs.wp-fail2ban.com/en/%s/defines/constants/%s.html" style="text-decoration: none;" target="_blank" title="Documentation"><span class="dashicons dashicons-external" style="vertical-align: text-bottom"></span></a> %s',
168
  $wp_f2b_ver,
169
  $define,
170
  $name
237
  array $toggle = array()
238
  )
239
  {
240
+ $enabled = defined( $define_name ) && true === constant( $define_name );
241
  $fmt = <<<___FMT___
242
  <label><input type="checkbox" disabled="disabled" %s> Enable logging</label>,
243
  <label>use facility: %s</label>
246
  $html = sprintf(
247
  $fmt,
248
  checked( $enabled, true, false ),
249
+ $this->getLogFacilities( $define_log ),
250
  $description
251
  );
252
  echo apply_filters(
filters.d/wordpress-extra.conf CHANGED
@@ -1,5 +1,5 @@
1
  # Fail2Ban filter for WordPress extra failures
2
- # Auto-generated: 2019-04-20T12:44:39+00:00
3
  #
4
 
5
  [INCLUDES]
1
  # Fail2Ban filter for WordPress extra failures
2
+ # Auto-generated: 2019-05-16T11:33:34+00:00
3
  #
4
 
5
  [INCLUDES]
filters.d/wordpress-hard.conf CHANGED
@@ -1,5 +1,5 @@
1
  # Fail2Ban filter for WordPress hard failures
2
- # Auto-generated: 2019-04-20T12:44:39+00:00
3
  #
4
 
5
  [INCLUDES]
1
  # Fail2Ban filter for WordPress hard failures
2
+ # Auto-generated: 2019-05-16T11:33:34+00:00
3
  #
4
 
5
  [INCLUDES]
filters.d/wordpress-soft.conf CHANGED
@@ -1,5 +1,5 @@
1
  # Fail2Ban filter for WordPress soft failures
2
- # Auto-generated: 2019-04-20T12:44:39+00:00
3
  #
4
 
5
  [INCLUDES]
1
  # Fail2Ban filter for WordPress soft failures
2
+ # Auto-generated: 2019-05-16T11:33:34+00:00
3
  #
4
 
5
  [INCLUDES]
lib/constants.php CHANGED
@@ -106,6 +106,7 @@ define('WPF2B_EVENT_AUTH_BLOCK_USER_ENUM', WPF2B_EVENT_CLASS_AUTH | 0x0008)
106
  /**
107
  * Comment
108
  */
 
109
  define('WPF2B_EVENT_COMMENT_SPAM', WPF2B_EVENT_CLASS_COMMENT | WPF2B_EVENT_CLASS_SPAM | 0x0001); // 0x00220001
110
  // comment extra
111
  define('WPF2B_EVENT_COMMENT_NOT_FOUND', WPF2B_EVENT_CLASS_COMMENT | 0x0002); // 0x00020002
106
  /**
107
  * Comment
108
  */
109
+ define('WPF2B_EVENT_COMMENT', WPF2B_EVENT_CLASS_COMMENT | 0x0001); // 0x00020001
110
  define('WPF2B_EVENT_COMMENT_SPAM', WPF2B_EVENT_CLASS_COMMENT | WPF2B_EVENT_CLASS_SPAM | 0x0001); // 0x00220001
111
  // comment extra
112
  define('WPF2B_EVENT_COMMENT_NOT_FOUND', WPF2B_EVENT_CLASS_COMMENT | 0x0002); // 0x00020002
lib/loader.php CHANGED
@@ -31,8 +31,14 @@ function _load(
31
  array $field
32
  )
33
  {
34
- define( "{$define}_NDEF", !defined( $define ) );
35
- if ( constant( "{$define}_NDEF" ) ) {
 
 
 
 
 
 
36
 
37
  if ( defined( "DEFAULT_{$define}" ) ) {
38
  // we've got a default
31
  array $field
32
  )
33
  {
34
+ global $wp_fail2ban ;
35
+ $wp_fail2ban['config'][$define] = [
36
+ 'validate' => $cast,
37
+ 'unset' => $unset,
38
+ 'field' => $field,
39
+ 'ndef' => !defined( $define ),
40
+ ];
41
+ if ( !defined( $define ) ) {
42
 
43
  if ( defined( "DEFAULT_{$define}" ) ) {
44
  // we've got a default
readme.txt CHANGED
@@ -5,8 +5,8 @@ Author URI: https://charles.lecklider.org/
5
  Plugin URI: https://wp-fail2ban.com/
6
  Tags: fail2ban, login, security, syslog
7
  Requires at least: 4.2
8
- Tested up to: 5.1
9
- Stable tag: 4.2.2
10
  Requires PHP: 5.3
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -63,6 +63,11 @@ Write a myriad of WordPress events to syslog for integration with fail2ban.
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
66
  = 4.2.2 =
67
  * Fix 5.3 compatibility.
68
 
@@ -191,6 +196,12 @@ Write a myriad of WordPress events to syslog for integration with fail2ban.
191
 
192
  == Upgrade Notice ==
193
 
 
 
 
 
 
 
194
  = 4.2.1 =
195
  You do not need to update your filters from 4.1.0.
196
 
5
  Plugin URI: https://wp-fail2ban.com/
6
  Tags: fail2ban, login, security, syslog
7
  Requires at least: 4.2
8
+ Tested up to: 5.2
9
+ Stable tag: 4.2.3
10
  Requires PHP: 5.3
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
63
 
64
  == Changelog ==
65
 
66
+ = 4.2.3 =
67
+ * Workaround for some versions of PHP 7.x that would cause `define()`s to be ignored.
68
+ * Add config note to settings tabs.
69
+ * Fix documentation links.
70
+
71
  = 4.2.2 =
72
  * Fix 5.3 compatibility.
73
 
196
 
197
  == Upgrade Notice ==
198
 
199
+ = 4.2.3 =
200
+ This is a bugfix release. You do not need to update your filters from 4.1.0.
201
+
202
+ = 4.2.2 =
203
+ You do not need to update your filters from 4.1.0.
204
+
205
  = 4.2.1 =
206
  You do not need to update your filters from 4.1.0.
207
 
wp-fail2ban-main.php CHANGED
@@ -104,15 +104,6 @@ if ( is_admin() ) {
104
  function wp_login( $user_login, $user )
105
  {
106
  global $wp_xmlrpc_server ;
107
-
108
- if ( defined( 'REST_REQUEST' ) ) {
109
- $event = 'WPF2B_EVENT_REST_AUTH_OK';
110
- } elseif ( $wp_xmlrpc_server ) {
111
- $event = 'WPF2B_EVENT_XMLRPC_AUTH_OK';
112
- } else {
113
- $event = 'WPF2B_EVENT_AUTH_OK';
114
- }
115
-
116
  openlog();
117
  syslog( LOG_INFO, "Accepted password for {$user_login}" );
118
  closelog();
@@ -154,13 +145,10 @@ if ( is_admin() ) {
154
  global $wp_xmlrpc_server ;
155
 
156
  if ( defined( 'REST_REQUEST' ) ) {
157
- $event = 'WPF2B_EVENT_REST_AUTH_FAIL';
158
  $msg = 'REST a';
159
  } elseif ( $wp_xmlrpc_server ) {
160
- $event = 'WPF2B_EVENT_XMLRPC_AUTH_FAIL';
161
  $msg = 'XML-RPC a';
162
  } else {
163
- $event = 'WPF2B_EVENT_AUTH_FAIL';
164
  $msg = 'A';
165
  }
166
 
104
  function wp_login( $user_login, $user )
105
  {
106
  global $wp_xmlrpc_server ;
 
 
 
 
 
 
 
 
 
107
  openlog();
108
  syslog( LOG_INFO, "Accepted password for {$user_login}" );
109
  closelog();
145
  global $wp_xmlrpc_server ;
146
 
147
  if ( defined( 'REST_REQUEST' ) ) {
 
148
  $msg = 'REST a';
149
  } elseif ( $wp_xmlrpc_server ) {
 
150
  $msg = 'XML-RPC a';
151
  } else {
 
152
  $msg = 'A';
153
  }
154
 
wp-fail2ban.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: https://wp-fail2ban.com/
6
  * Description: Write a myriad of WordPress events to syslog for integration with fail2ban.
7
  * Text Domain: wp-fail2ban
8
- * Version: 4.2.2
9
  * Author: Charles Lecklider
10
  * Author URI: https://charles.lecklider.org/
11
  * License: GPLv2
@@ -39,7 +39,7 @@ namespace org\lecklider\charles\wordpress\wp_fail2ban;
39
  /**
40
  * @since 4.0.5
41
  */
42
- define( 'WP_FAIL2BAN_VER', '4.2.2' );
43
  define( 'WP_FAIL2BAN_FILE', __FILE__ );
44
  /**
45
  * @since 4.2.0
5
  * Plugin URI: https://wp-fail2ban.com/
6
  * Description: Write a myriad of WordPress events to syslog for integration with fail2ban.
7
  * Text Domain: wp-fail2ban
8
+ * Version: 4.2.3
9
  * Author: Charles Lecklider
10
  * Author URI: https://charles.lecklider.org/
11
  * License: GPLv2
39
  /**
40
  * @since 4.0.5
41
  */
42
+ define( 'WP_FAIL2BAN_VER', '4.2.3' );
43
  define( 'WP_FAIL2BAN_FILE', __FILE__ );
44
  /**
45
  * @since 4.2.0