diff --git a/includes/Admin/SettingsPage.php b/includes/Admin/SettingsPage.php index 37f8c58..2d03681 100644 --- a/includes/Admin/SettingsPage.php +++ b/includes/Admin/SettingsPage.php @@ -56,7 +56,9 @@ final class SettingsPage { foreach ( \StreamGoals\Core\ClientIp::MODES as $k => $l ) { echo ''; } - echo '

Donation forms limit how fast one visitor can start payments (to stop abuse). If your site is behind Cloudflare or another proxy, choose it here so each visitor is counted separately; otherwise everyone looks like the same visitor and a busy moment, like a raid, could block donations. Only choose a proxy option if all traffic to your site really goes through it.

'; + echo '

Donation forms limit how fast one visitor can start payments (to stop abuse). If your site is behind Cloudflare or another proxy, choose it here so each visitor is counted separately; otherwise everyone looks like the same visitor and a busy moment, like a raid, could block donations. Only choose a proxy option if all traffic to your site really goes through it.

'; + self::ipDiagnostics( (string) $s['visitor_ip_header'] ); + echo ''; echo '

PayPal fee estimate

'; echo '

When a donor chooses "cover the fees", the form adds the estimated PayPal fee so you receive the amount they intended. The defaults (3.49% + $0.49) are US domestic estimates. Fees for international (cross-border) payments and currency conversion are higher and are not included, so you may receive slightly less than expected in those cases. Check PayPal\'s current fee page for your country and adjust.

'; @@ -66,6 +68,23 @@ final class SettingsPage { Admin::close(); } + /** Shows the owner what their server passes to the plugin right now, to help pick the right option. */ + private static function ipDiagnostics( string $mode ): void { + $keys = array( 'REMOTE_ADDR' => 'Connection address', 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For' ); + $server = array(); + foreach ( $keys as $k => $_ ) { + if ( isset( $_SERVER[ $k ] ) && is_string( $_SERVER[ $k ] ) ) { + $server[ $k ] = sanitize_text_field( wp_unslash( $_SERVER[ $k ] ) ); + } + } + echo '
What does my server see right now?'; + foreach ( $keys as $k => $label ) { + echo ''; + } + echo ''; + echo '
' . esc_html( $label ) . '' . ( isset( $server[ $k ] ) ? esc_html( $server[ $k ] ) : '(not sent)' ) . '
Visitor address used with the saved option' . esc_html( \StreamGoals\Core\ClientIp::resolve( $server, $mode ) ) . '

This is your own visit. If the connection address belongs to your proxy or CDN (not to you) and your proxy\'s header shows your real address, choose that proxy option above and save. Then the "used" row should show your real address.

'; + } + public static function handleSave(): void { Admin::guard( 'sg_settings_save' ); $post = Admin::post_raw();