Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,6 @@ public static function admin_init() {

FrmInbox::maybe_disable_screen_options();
}

self::maybe_add_ip_warning();
}

/**
Expand All @@ -676,65 +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' ),
'<a href="' . esc_url( $global_settings_link ) . '">' . __( 'Global Settings', 'formidable' ) . '</a>'
);
$option_name = 'frm_dismiss_ip_address_notice';
FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
}

/**
* 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
*/
Expand Down
3 changes: 1 addition & 2 deletions classes/models/FrmSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down