PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
← All changes | classes/Permissions.php +4 -15 3.1.53.1.6 View file →
@@ -507,26 +507,15 @@
507 507
508 508 /**
509 509 * Get the current user's IP address
510 510 *
511 + * Uses REMOTE_ADDR only to prevent IP spoofing via X-Forwarded-For headers.
512 + *
511 513 * @return string|null IP address or null if not available
512 514 */
513 515 private function get_user_ip() {
514 - // Check for forwarded IP first (behind proxy/load balancer)
515 - $headers = [ 'HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'REMOTE_ADDR' ];
516 - foreach( $headers as $header ) {
517 - if( ! empty( $_SERVER[ $header ] ) ) {
518 - $ip = $_SERVER[ $header ];
519 - // HTTP_X_FORWARDED_FOR can contain multiple IPs, get the first one
520 - if( strpos( $ip, ',' ) !== false ) {
521 - $ip = trim( explode( ',', $ip )[0] );
522 - }
523 - if( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
524 - return $ip;
525 - }
526 - }
527 - }
528 - return null;
516 + $ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '' ) );
517 + return filter_var( $ip, FILTER_VALIDATE_IP ) ? $ip : null;
529 518 }
530 519
531 520 /**
532 521 * Get post count for a user since a specific time