Skip to content

Commit ae9465d

Browse files
committed
Validated with WordPress 6.6.x
1 parent ce4da46 commit ae9465d

File tree

5 files changed

+59
-36
lines changed

5 files changed

+59
-36
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Software License](https://img.shields.io/badge/License-GPL%20v2-green.svg?style=flat-square)](LICENSE) [![PHP 7.2\+](https://img.shields.io/badge/PHP-7.2-blue?style=flat-square)](https://php.net) [![PHP 7.4\+](https://img.shields.io/badge/PHP-7.4-blue?style=flat-square)](https://php.net) [![PHP 8.1](https://img.shields.io/badge/PHP-8.1-blue?style=flat-square)](https://php.net) [![WordPress 5](https://img.shields.io/badge/WordPress-5.8-orange?style=flat-square)](https://wordpress.org) [![WordPress 6](https://img.shields.io/badge/WordPress-6.1-orange?style=flat-square)](https://wordpress.org)
1+
[![Software License](https://img.shields.io/badge/License-GPL%20v2-green.svg?style=flat-square)](LICENSE) [![PHP 7.2\+](https://img.shields.io/badge/PHP-7.2-blue?style=flat-square)](https://php.net) [![PHP 7.4\+](https://img.shields.io/badge/PHP-7.4-blue?style=flat-square)](https://php.net) [![PHP 8.1](https://img.shields.io/badge/PHP-8.1-blue?style=flat-square)](https://php.net) [![WordPress 5](https://img.shields.io/badge/WordPress-5.8-orange?style=flat-square)](https://wordpress.org) [![WordPress 6](https://img.shields.io/badge/WordPress-6.6-orange?style=flat-square)](https://wordpress.org)
22

33
# Fail2WP
44

@@ -33,8 +33,8 @@ The plugin also plays nicely with Fail2ban, which is an advanced way of blocking
3333
### Other notes
3434

3535
* This plugin `may` work with earlier versions of WordPress
36-
* This plugin has been tested with `WordPress 5.5+ and 6.5.x` at the time of this writing
37-
* This plugin has been tested with `PHP 7.2, 7.4, and 8.1.20` at the time of this writing
36+
* This plugin has been tested with `WordPress 5.5.x and 6.x` at the time of this writing
37+
* This plugin has been tested with `PHP 7.2, 7.4, and 8.1.x` at the time of this writing
3838
* This plugin optionally makes use of `mb_` PHP functions
3939
* This plugin may create entries in your PHP error log (if active)
4040
* This plugin contains no Javascript
@@ -69,6 +69,12 @@ This is a hard question to answer. There are no known incompatibilities.
6969

7070
## Changelog
7171

72+
### 1.2.2
73+
* Verified with WordPress 6.6
74+
* Improved code for role notification settings, [PR#2](https://github.com/joho1968/Fail2WP/pull/2)
75+
* Improved code for e-mail checking for new user registrations [PR#1](https://github.com/joho1968/Fail2WP/pull/1)
76+
* Thanks to [philscott-rg](https://github.com/philscott-rg) and [Edward Casbon ](https://github.com/edwardcasbon)
77+
7278
### 1.2.1
7379
* Verified with WordPress 6.5.2
7480
* Updated "About" information
@@ -120,7 +126,7 @@ This is a hard question to answer. There are no known incompatibilities.
120126

121127
Please see [LICENSE](LICENSE) for a full copy of GPLv2
122128

123-
Copyright (C) 2020, 2021, 2022, 2023, 2024 [Joaquim Homrighausen](https://github.com/joho1968); all rights reserved.
129+
Copyright (C) 2020-2024 [Joaquim Homrighausen](https://github.com/joho1968); all rights reserved.
124130

125131
This file is part of Fail2WP. Fail2WP is free software.
126132

@@ -140,9 +146,9 @@ Boston, MA 02110-1301, USA.
140146

141147
The Fail2WP WordPress Plugin was written by Joaquim Homrighausen while converting :coffee: into code.
142148

143-
Fail2WP is sponsored by [WebbPlatsen i Sverige AB](https://webbplatsen.se), Stockholm, :sweden:
149+
Fail2WP is sponsored by [WebbPlatsen i Sverige AB](https://webbplatsen.se) :sweden:
144150

145-
Commercial support and customizations for this plugin is available from WebbPlatsen i Sverige AB in Stockholm, :sweden:
151+
Commercial support and customizations for this plugin is available from WebbPlatsen i Sverige AB in :sweden:
146152

147153
If you find this plugin useful, the author is happy to receive a donation, good review, or just a kind word.
148154

fail2wp/css/fail2wp.css

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88
padding-right: 5px;
99
}
1010
.fail2wp-config-header {
11-
padding: 20px 10px;
12-
border-top: 5px solid #35537a;
13-
background: #fff;
11+
padding: 20px 10px;
12+
border-top: 5px solid #35537a;
13+
background: #fff;
1414
}
1515
.fail2wp-config-section {
16-
margin-top: 15px;
17-
padding: 25px 10px;
18-
color: #000;
19-
background: #fff;
16+
margin-top: 15px;
17+
padding: 25px 10px;
18+
color: #000;
19+
background: #fff;
2020
}
2121
.fail2wp-ext-link {
2222
color: #007bff;
2323
text-decoration: none;
2424
}
25+
.fail2wp-row {
26+
margin-top: 5px;
27+
}
2528
img.fail2wp-wps-logo {
2629
display: inline;
2730
float: left;

fail2wp/fail2wp.php

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Fail2WP
1212
* Plugin URI: https://code.webbplatsen.net/wordpress/fail2wp/
1313
* Description: Security plugin for WordPress with support for Fail2ban and Cloudflare
14-
* Version: 1.2.1
14+
* Version: 1.2.2
1515
* Author: WebbPlatsen, Joaquim Homrighausen <joho@webbplatsen.se>
1616
* Author URI: https://webbplatsen.se/
1717
* License: GPL-2.0+
@@ -20,7 +20,7 @@
2020
* Domain Path: /languages
2121
*
2222
* fail2wp.php
23-
* Copyright (C) 2021,2022,2023,2024 Joaquim Homrighausen; all rights reserved.
23+
* Copyright (C) 2020-2024 Joaquim Homrighausen; all rights reserved.
2424
* Development sponsored by WebbPlatsen i Sverige AB, www.webbplatsen.se
2525
*
2626
* This file is part of Fail2WP. Fail2WP is free software.
@@ -51,7 +51,7 @@
5151
}
5252

5353
define( 'FAIL2WP_WORDPRESS_PLUGIN', true );
54-
define( 'FAIL2WP_VERSION', '1.2.1' );
54+
define( 'FAIL2WP_VERSION', '1.2.2' );
5555
define( 'FAIL2WP_REV', 1 );
5656
define( 'FAIL2WP_PLUGINNAME_HUMAN', 'Fail2WP' );
5757
define( 'FAIL2WP_PLUGINNAME_SLUG', 'fail2wp' );
@@ -77,15 +77,15 @@
7777
define( 'VALIDATE_IPHOSTCIDR_HOSTNAME', 4 );
7878
define( 'VALIDATE_IPHOSTCIDR_HOSTNAME_WC', 5 );
7979

80-
define( 'FAIL2WP_DEBUG', false );
80+
define( 'FAIL2WP_DEBUG', false );
8181
if ( defined( 'FAIL2WP_DEBUG' ) && FAIL2WP_DEBUG ) {
82-
define( 'FAIL2WP_REST_DEBUG', true );
82+
define( 'FAIL2WP_REST_DEBUG', false );
8383
define( 'FAIL2WP_GENERAL_DEBUG', true );
8484
define( 'FAIL2WP_FLOW_DEBUG', true );
85-
define( 'FAIL2WP_CACHE_DEBUG', true );
85+
define( 'FAIL2WP_CACHE_DEBUG', false );
8686
define( 'FAIL2WP_SETTINGS_DEBUG', true );
8787
define( 'FAIL2WP_DUMP_SETTINGS', true );
88-
define( 'FAIL2WP_XMLRPC_DEBUG', true );
88+
define( 'FAIL2WP_XMLRPC_DEBUG', false );
8989
}
9090

9191

@@ -324,13 +324,18 @@ public function __construct( bool $is_for_xmlrpc = false ) {
324324
'types',
325325
'users',
326326
);
327-
328327
// Dump all of our settings, for development
329328
if ( defined( 'FAIL2WP_DUMP_SETTINGS' ) && FAIL2WP_DUMP_SETTINGS ) {
330329
global $wpdb;
331-
$settings = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'fail2wp%'" ), ARRAY_A );
330+
/*
331+
$settings = $wpdb->get_results(
332+
$wpdb->prepare( "SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'fail2wp%'" ),
333+
ARRAY_A
334+
);
335+
*/
336+
$settings = $wpdb->get_results( "SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'fail2wp%'", ARRAY_A );
332337
if ( is_array( $settings ) ) {
333-
error_log( var_export( $settings, true ) );
338+
error_log( print_r( $settings, true ) );
334339
} else {
335340
error_log ( basename( __FILE__ ) . ': Unable to fetch settings' );
336341
}
@@ -459,12 +464,12 @@ public function __construct( bool $is_for_xmlrpc = false ) {
459464
$this->fail2wp_rest_filter_block_routes = array();
460465
update_option( 'fail2wp-rest-filter-block-routes', json_encode( $this->fail2wp_rest_filter_block_routes ) );
461466
}
462-
$this->fail2wp_rest_filter_ipv4_bypass = @ json_decode( get_option ( 'fail2wp-rest-filter-ipv4-bypass', null ), true, 2 );
467+
$this->fail2wp_rest_filter_ipv4_bypass = @ json_decode( get_option( 'fail2wp-rest-filter-ipv4-bypass', null ), true, 2 );
463468
if ( ! is_array( $this->fail2wp_rest_filter_ipv4_bypass ) ) {
464469
$this->fail2wp_rest_filter_ipv4_bypass = array();
465470
update_option( 'fail2wp-rest-filter-ipv4-bypass', json_encode( $this->fail2wp_rest_filter_ipv4_bypass ) );
466471
}
467-
$this->fail2wp_rest_filter_ipv6_bypass = @ json_decode( get_option ( 'fail2wp-rest-filter-ipv6-bypass', null ), true, 2 );
472+
$this->fail2wp_rest_filter_ipv6_bypass = @ json_decode( get_option( 'fail2wp-rest-filter-ipv6-bypass', null ), true, 2 );
468473
if ( ! is_array( $this->fail2wp_rest_filter_ipv6_bypass ) ) {
469474
$this->fail2wp_rest_filter_ipv6_bypass = array();
470475
update_option( 'fail2wp-rest-filter-ipv6-bypass', json_encode( $this->fail2wp_rest_filter_ipv6_bypass ) );
@@ -508,21 +513,21 @@ public function __construct( bool $is_for_xmlrpc = false ) {
508513
} else {
509514
$this->fail2wp_cloudflare_check = true;
510515
}
511-
$this->fail2wp_cloudflare_ipv4 = @ json_decode( get_option ( 'fail2wp-cloudflare-ipv4', null ), true, 2 );
516+
$this->fail2wp_cloudflare_ipv4 = @ json_decode( get_option( 'fail2wp-cloudflare-ipv4', null ), true, 2 );
512517
if ( ! is_array( $this->fail2wp_cloudflare_ipv4 ) ) {
513518
$this->fail2wp_cloudflare_ipv4 = array();
514519
update_option( 'fail2wp-cloudflare-ipv4', json_encode( $this->fail2wp_cloudflare_ipv4 ) );
515520
}
516-
$this->fail2wp_cloudflare_ipv6 = @ json_decode( get_option ( 'fail2wp-cloudflare-ipv6', null ), true, 2 );
521+
$this->fail2wp_cloudflare_ipv6 = @ json_decode( get_option( 'fail2wp-cloudflare-ipv6', null ), true, 2 );
517522
if ( ! is_array( $this->fail2wp_cloudflare_ipv6 ) ) {
518523
$this->fail2wp_cloudflare_ipv6 = array();
519524
update_option( 'fail2wp-cloudflare-ipv6', json_encode( $this->fail2wp_cloudflare_ipv6 ) );
520525
}
521526
// ..Login IP checking @since 1.2.0
522-
$this->fail2wp_loginip_enable = get_option ( 'fail2wp-loginip-enable', false );
523-
$this->fail2wp_loginip_testmode = get_option ( 'fail2wp-loginip-testmode', true );
527+
$this->fail2wp_loginip_enable = get_option( 'fail2wp-loginip-enable', false );
528+
$this->fail2wp_loginip_testmode = get_option( 'fail2wp-loginip-testmode', true );
524529
$this->fail2wp_loginip_inform_fail2ban = get_option( 'fail2wp-loginip-inform-fail2ban', false );
525-
$this->fail2wp_loginip_dnscache = get_option ( 'fail2wp-loginip-dnscache', -1 );
530+
$this->fail2wp_loginip_dnscache = get_option( 'fail2wp-loginip-dnscache', -1 );
526531
if ( $this->fail2wp_loginip_dnscache < 0 ) {
527532
$this->fail2wp_loginip_dnscache = 60;
528533
} elseif ( $this->fail2wp_loginip_dnscache > 10080 ) {
@@ -1036,7 +1041,8 @@ public function fail2wp_admin_check_new_user( \WP_Error $errors, string $user_lo
10361041
$errors->add( 'fail2wp_username_ban', esc_html__( 'Invalid username, please try again.', 'fail2wp' ) );
10371042
}
10381043
}
1039-
if ( ! $have_error ) {
1044+
// Check e-mail
1045+
if ( ! $have_error && ! empty( $this->fail2wp_reguser_useremail_require ) ) {
10401046
$invalid_email = true;
10411047
if ( ! empty ( $user_email ) ) {
10421048
$invalid_email = true;
@@ -1667,12 +1673,17 @@ public function fail2wp_about_page() {
16671673
'</p>' .
16681674
'<p style="margin-top:20px;">' .
16691675
'<h3>' . esc_html__( 'Other plugins', 'fail2wp' ) . '</h3>' .
1670-
'<p class="cb2fa-row">' .
1676+
'<p class="fail2wp-row">' .
16711677
'<a href="https://wordpress.org/plugins/cloudbridge-mattermost" target="_blank" class="fail2wp-ext-link">Cloudbridge Mattermost</a>' .
16721678
'<br/>' .
16731679
esc_html__( 'Plugin that provides integration with Mattermost, including notifications and OAuth2 authentication', 'fail2wp' ) . '.' .
16741680
'</p>' .
1675-
'<p class="cb2fa-row">' .
1681+
'<p class="fail2wp-row">' .
1682+
'<a href="https://wordpress.org/plugins/cloudbridge-2fa" target="_blank" class="fail2wp-ext-link">Cloudbridge Mattermost</a>' .
1683+
'<br/>' .
1684+
esc_html__( 'Plugin that provides uncomplicated 2FA protection', 'fail2wp' ) . '.' .
1685+
'</p>' .
1686+
'<p class="fail2wp-row">' .
16761687
'<a href="https://wordpress.org/plugins/easymap" target="_blank" class="fail2wp-ext-link">EasyMap</a>' .
16771688
'<br/>' .
16781689
esc_html__( 'Plugin that provides uncomplicated map functionality', 'fail2wp' ) . '.' .
@@ -2689,7 +2700,7 @@ protected function fail2wp_role_is_active( array $roles, array $notify_roles ) :
26892700
// too, but we're likely to have less configured roles/caps than what
26902701
// is available. So maybe this will save an iteration or two :-)
26912702
foreach( $notify_roles as $role ) {
2692-
if ( in_array( $role, $roles ) && $roles[$role] ) {
2703+
if ( array_key_exists( $role, $roles ) && $roles[$role] ) {
26932704
return( true );
26942705
}
26952706
}
@@ -2718,7 +2729,7 @@ protected function fail2wp_roles_merge( array $roles, string $notify_roles ) : s
27182729
// too, but we're likely to have less configured roles/caps than what
27192730
// is available. So maybe this will save an iteration or two :-)
27202731
foreach( $notify_array as $role ) {
2721-
if ( in_array( $role, $roles ) && $roles[$role] ) {
2732+
if ( array_key_exists( $role, $roles ) && $roles[$role] ) {
27222733
$new_roles[] = $role;
27232734
}
27242735
}

fail2wp/languages/fail2wp-sv_SE.mo

131 Bytes
Binary file not shown.

fail2wp/languages/fail2wp-sv_SE.po

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,10 @@ msgid ""
450450
msgstr ""
451451
"Ett tillägg som integrerar WordPress med Mattermost, inklusive aviseringar "
452452
"och OAuth2-autentisering"
453-
453+
msgid ""
454+
"Plugin that provides uncomplicated 2FA protection"
455+
msgstr ""
456+
"Ett tillägg som tillhandahåller okomplicerat 2FA-skydd"
454457
#: fail2wp.php:1678
455458
msgid "Plugin that provides uncomplicated map functionality"
456459
msgstr "Ett tillägg som tillhandahåller okomplicerad kartfunktionalitet"

0 commit comments

Comments
 (0)