|
11 | 11 | * Plugin Name: Fail2WP |
12 | 12 | * Plugin URI: https://code.webbplatsen.net/wordpress/fail2wp/ |
13 | 13 | * Description: Security plugin for WordPress with support for Fail2ban and Cloudflare |
14 | | - * Version: 1.2.1 |
| 14 | + * Version: 1.2.2 |
15 | 15 | * Author: WebbPlatsen, Joaquim Homrighausen <joho@webbplatsen.se> |
16 | 16 | * Author URI: https://webbplatsen.se/ |
17 | 17 | * License: GPL-2.0+ |
|
20 | 20 | * Domain Path: /languages |
21 | 21 | * |
22 | 22 | * fail2wp.php |
23 | | - * Copyright (C) 2021,2022,2023,2024 Joaquim Homrighausen; all rights reserved. |
| 23 | + * Copyright (C) 2020-2024 Joaquim Homrighausen; all rights reserved. |
24 | 24 | * Development sponsored by WebbPlatsen i Sverige AB, www.webbplatsen.se |
25 | 25 | * |
26 | 26 | * This file is part of Fail2WP. Fail2WP is free software. |
|
51 | 51 | } |
52 | 52 |
|
53 | 53 | define( 'FAIL2WP_WORDPRESS_PLUGIN', true ); |
54 | | -define( 'FAIL2WP_VERSION', '1.2.1' ); |
| 54 | +define( 'FAIL2WP_VERSION', '1.2.2' ); |
55 | 55 | define( 'FAIL2WP_REV', 1 ); |
56 | 56 | define( 'FAIL2WP_PLUGINNAME_HUMAN', 'Fail2WP' ); |
57 | 57 | define( 'FAIL2WP_PLUGINNAME_SLUG', 'fail2wp' ); |
|
77 | 77 | define( 'VALIDATE_IPHOSTCIDR_HOSTNAME', 4 ); |
78 | 78 | define( 'VALIDATE_IPHOSTCIDR_HOSTNAME_WC', 5 ); |
79 | 79 |
|
80 | | -define( 'FAIL2WP_DEBUG', false ); |
| 80 | +define( 'FAIL2WP_DEBUG', false ); |
81 | 81 | if ( defined( 'FAIL2WP_DEBUG' ) && FAIL2WP_DEBUG ) { |
82 | | - define( 'FAIL2WP_REST_DEBUG', true ); |
| 82 | + define( 'FAIL2WP_REST_DEBUG', false ); |
83 | 83 | define( 'FAIL2WP_GENERAL_DEBUG', true ); |
84 | 84 | define( 'FAIL2WP_FLOW_DEBUG', true ); |
85 | | - define( 'FAIL2WP_CACHE_DEBUG', true ); |
| 85 | + define( 'FAIL2WP_CACHE_DEBUG', false ); |
86 | 86 | define( 'FAIL2WP_SETTINGS_DEBUG', true ); |
87 | 87 | define( 'FAIL2WP_DUMP_SETTINGS', true ); |
88 | | - define( 'FAIL2WP_XMLRPC_DEBUG', true ); |
| 88 | + define( 'FAIL2WP_XMLRPC_DEBUG', false ); |
89 | 89 | } |
90 | 90 |
|
91 | 91 |
|
@@ -324,13 +324,18 @@ public function __construct( bool $is_for_xmlrpc = false ) { |
324 | 324 | 'types', |
325 | 325 | 'users', |
326 | 326 | ); |
327 | | - |
328 | 327 | // Dump all of our settings, for development |
329 | 328 | if ( defined( 'FAIL2WP_DUMP_SETTINGS' ) && FAIL2WP_DUMP_SETTINGS ) { |
330 | 329 | 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 ); |
332 | 337 | if ( is_array( $settings ) ) { |
333 | | - error_log( var_export( $settings, true ) ); |
| 338 | + error_log( print_r( $settings, true ) ); |
334 | 339 | } else { |
335 | 340 | error_log ( basename( __FILE__ ) . ': Unable to fetch settings' ); |
336 | 341 | } |
@@ -459,12 +464,12 @@ public function __construct( bool $is_for_xmlrpc = false ) { |
459 | 464 | $this->fail2wp_rest_filter_block_routes = array(); |
460 | 465 | update_option( 'fail2wp-rest-filter-block-routes', json_encode( $this->fail2wp_rest_filter_block_routes ) ); |
461 | 466 | } |
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 ); |
463 | 468 | if ( ! is_array( $this->fail2wp_rest_filter_ipv4_bypass ) ) { |
464 | 469 | $this->fail2wp_rest_filter_ipv4_bypass = array(); |
465 | 470 | update_option( 'fail2wp-rest-filter-ipv4-bypass', json_encode( $this->fail2wp_rest_filter_ipv4_bypass ) ); |
466 | 471 | } |
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 ); |
468 | 473 | if ( ! is_array( $this->fail2wp_rest_filter_ipv6_bypass ) ) { |
469 | 474 | $this->fail2wp_rest_filter_ipv6_bypass = array(); |
470 | 475 | 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 ) { |
508 | 513 | } else { |
509 | 514 | $this->fail2wp_cloudflare_check = true; |
510 | 515 | } |
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 ); |
512 | 517 | if ( ! is_array( $this->fail2wp_cloudflare_ipv4 ) ) { |
513 | 518 | $this->fail2wp_cloudflare_ipv4 = array(); |
514 | 519 | update_option( 'fail2wp-cloudflare-ipv4', json_encode( $this->fail2wp_cloudflare_ipv4 ) ); |
515 | 520 | } |
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 ); |
517 | 522 | if ( ! is_array( $this->fail2wp_cloudflare_ipv6 ) ) { |
518 | 523 | $this->fail2wp_cloudflare_ipv6 = array(); |
519 | 524 | update_option( 'fail2wp-cloudflare-ipv6', json_encode( $this->fail2wp_cloudflare_ipv6 ) ); |
520 | 525 | } |
521 | 526 | // ..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 ); |
524 | 529 | $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 ); |
526 | 531 | if ( $this->fail2wp_loginip_dnscache < 0 ) { |
527 | 532 | $this->fail2wp_loginip_dnscache = 60; |
528 | 533 | } elseif ( $this->fail2wp_loginip_dnscache > 10080 ) { |
@@ -1036,7 +1041,8 @@ public function fail2wp_admin_check_new_user( \WP_Error $errors, string $user_lo |
1036 | 1041 | $errors->add( 'fail2wp_username_ban', esc_html__( 'Invalid username, please try again.', 'fail2wp' ) ); |
1037 | 1042 | } |
1038 | 1043 | } |
1039 | | - if ( ! $have_error ) { |
| 1044 | + // Check e-mail |
| 1045 | + if ( ! $have_error && ! empty( $this->fail2wp_reguser_useremail_require ) ) { |
1040 | 1046 | $invalid_email = true; |
1041 | 1047 | if ( ! empty ( $user_email ) ) { |
1042 | 1048 | $invalid_email = true; |
@@ -1667,12 +1673,17 @@ public function fail2wp_about_page() { |
1667 | 1673 | '</p>' . |
1668 | 1674 | '<p style="margin-top:20px;">' . |
1669 | 1675 | '<h3>' . esc_html__( 'Other plugins', 'fail2wp' ) . '</h3>' . |
1670 | | - '<p class="cb2fa-row">' . |
| 1676 | + '<p class="fail2wp-row">' . |
1671 | 1677 | '<a href="https://wordpress.org/plugins/cloudbridge-mattermost" target="_blank" class="fail2wp-ext-link">Cloudbridge Mattermost</a>' . |
1672 | 1678 | '<br/>' . |
1673 | 1679 | esc_html__( 'Plugin that provides integration with Mattermost, including notifications and OAuth2 authentication', 'fail2wp' ) . '.' . |
1674 | 1680 | '</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">' . |
1676 | 1687 | '<a href="https://wordpress.org/plugins/easymap" target="_blank" class="fail2wp-ext-link">EasyMap</a>' . |
1677 | 1688 | '<br/>' . |
1678 | 1689 | esc_html__( 'Plugin that provides uncomplicated map functionality', 'fail2wp' ) . '.' . |
@@ -2689,7 +2700,7 @@ protected function fail2wp_role_is_active( array $roles, array $notify_roles ) : |
2689 | 2700 | // too, but we're likely to have less configured roles/caps than what |
2690 | 2701 | // is available. So maybe this will save an iteration or two :-) |
2691 | 2702 | foreach( $notify_roles as $role ) { |
2692 | | - if ( in_array( $role, $roles ) && $roles[$role] ) { |
| 2703 | + if ( array_key_exists( $role, $roles ) && $roles[$role] ) { |
2693 | 2704 | return( true ); |
2694 | 2705 | } |
2695 | 2706 | } |
@@ -2718,7 +2729,7 @@ protected function fail2wp_roles_merge( array $roles, string $notify_roles ) : s |
2718 | 2729 | // too, but we're likely to have less configured roles/caps than what |
2719 | 2730 | // is available. So maybe this will save an iteration or two :-) |
2720 | 2731 | foreach( $notify_array as $role ) { |
2721 | | - if ( in_array( $role, $roles ) && $roles[$role] ) { |
| 2732 | + if ( array_key_exists( $role, $roles ) && $roles[$role] ) { |
2722 | 2733 | $new_roles[] = $role; |
2723 | 2734 | } |
2724 | 2735 | } |
|
0 commit comments