Wrong ip address is being reported after new update due to port in ip address
-
The latest update for the plugin is breaking ip address reporting.
My IP address is coming back with a port number like this from HTTP_X_FORWARDED_FOR:
45.454.633.433:34444
Before the update this was accounted for in the code in the file wp-content\plugins\all-in-one-wp-security-and-firewall\classes\wp-security-utility-ip-address.php here://Now remove port portion if applicable if(strpos($visitor_ip, '.') !== FALSE && strpos($visitor_ip, ':') !== FALSE){ //likely ipv4 address with port $visitor_ip = preg_replace('/:\d+$/', '', $visitor_ip); //Strip off port }
Because this code is missing in the update, line 23 of the update is causing the ip address to be blank because the port is not recognized as an IP address and then it is trying to get the external ip address instead.
The external address it returns is the server address and not the person’s internet ip address.
Line 23:
$user_ip = (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
In order to fix this I had to put these lines into in wp-config.
`$_SERVER[‘REMOTE_ADDR’] = current(explode(‘,’, current(explode(‘:’, $_SERVER[‘HTTP_X_FORWARDED_FOR’]))));
$_SERVER[‘HTTP_X_FORWARDED_FOR’] = current(explode(‘,’, current(explode(‘:’, $_SERVER[‘HTTP_X_FORWARDED_FOR’]))));Is there any way to make a fix for ports?
- The topic ‘Wrong ip address is being reported after new update due to port in ip address’ is closed to new replies.