From 840e60bdf927cf16d2e21ce81635aa0c4f2bfb50 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 18 Oct 2024 09:36:53 -0300 Subject: [PATCH 1/3] Drop IP warning from settings --- classes/controllers/FrmAppController.php | 36 ------------------------ 1 file changed, 36 deletions(-) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 879a25a942..330291c866 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -649,8 +649,6 @@ public static function admin_init() { FrmInbox::maybe_disable_screen_options(); } - - self::maybe_add_ip_warning(); } /** @@ -676,40 +674,6 @@ private static function trigger_page_load_hooks() { } } - /** - * Show a warning for the IP address setting if it hasn't been set. - * - * @since 6.1 - * - * @return void - */ - private static function maybe_add_ip_warning() { - $settings = FrmAppHelper::get_settings(); - if ( false !== $settings->custom_header_ip ) { - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message. - return; - } - - if ( ! self::is_behind_proxy() ) { - // This message is only applicable when using a reverse proxy. - return; - } - - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) { - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings. - return; - } - - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip'; - $message = sprintf( - // Translators: 1: Global Settings Link - __( 'IP addresses in form submissions may no longer be accurate! If you are experiencing issues, we recommend going to %1$s and enabling the "Use custom headers when retrieving IPs with form submissions." setting.', 'formidable' ), - '' . __( 'Global Settings', 'formidable' ) . '' - ); - $option_name = 'frm_dismiss_ip_address_notice'; - FrmAppHelper::add_dismissable_warning_message( $message, $option_name ); - } - /** * Check if any reverse proxy headers are set. * From 74f9ef2aa89b885854c9b07fb84055ddf1cff8c8 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 18 Oct 2024 09:39:50 -0300 Subject: [PATCH 2/3] Drop another function that is no longer referenced --- classes/controllers/FrmAppController.php | 25 ------------------------ 1 file changed, 25 deletions(-) diff --git a/classes/controllers/FrmAppController.php b/classes/controllers/FrmAppController.php index 330291c866..3f9673fbc8 100644 --- a/classes/controllers/FrmAppController.php +++ b/classes/controllers/FrmAppController.php @@ -674,31 +674,6 @@ private static function trigger_page_load_hooks() { } } - /** - * Check if any reverse proxy headers are set. - * - * @since 6.1 - * - * @return bool - */ - private static function is_behind_proxy() { - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip(); - foreach ( $custom_headers as $header ) { - if ( 'REMOTE_ADDR' === $header ) { - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers. - continue; - } - - $ip = trim( FrmAppHelper::get_server_value( $header ) ); - // Return true for anything that isn't empty but ignoring values like ::1. - if ( $ip && 0 !== strpos( $ip, '::' ) ) { - return true; - } - } - - return false; - } - /** * @return void */ From 35120eef259fba3af51fd199cae1b5027e7ea5b7 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Fri, 18 Oct 2024 09:45:10 -0300 Subject: [PATCH 3/3] Update the default value as well --- classes/models/FrmSettings.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/classes/models/FrmSettings.php b/classes/models/FrmSettings.php index 1362f748ae..77d2c4e311 100644 --- a/classes/models/FrmSettings.php +++ b/classes/models/FrmSettings.php @@ -159,8 +159,7 @@ public function default_options() { 'email_to' => '[admin_email]', 'no_ips' => 0, - // Use false by default. We show a warning when this is unset. Once global settings have been saved, this gets saved. - 'custom_header_ip' => false, + 'custom_header_ip' => 0, 'tracking' => FrmAppHelper::pro_is_installed(), // Only enable this by default for the main site. 'summary_emails' => get_current_blog_id() === get_main_site_id(),