Make WordPress Core

Ticket #40871: 40871.diff

File 40871.diff, 2.0 KB (added by iandunn, 8 years ago)
  • src/wp-admin/includes/class-wp-community-events.php

    diff --git src/wp-admin/includes/class-wp-community-events.php src/wp-admin/includes/class-wp-community-events.php
    index 9a41459740..5f642af203 100644
    class WP_Community_Events { 
    210210        }
    211211
    212212        /**
    213          * Determines the user's actual IP address and attempts to partially
    214          * anonymize an IP address by converting it to a network ID.
    215          *
    216          * Geolocating the network ID usually returns a similar location as the
    217          * actual IP, but provides some privacy for the user.
     213         * Determines the user's actual IP address.
    218214         *
    219215         * $_SERVER['REMOTE_ADDR'] cannot be used in all cases, such as when the user
    220216         * is making their request through a proxy, or when the web server is behind
    class WP_Community_Events { 
    222218         * than the user's actual address.
    223219         *
    224220         * Modified from http://stackoverflow.com/a/2031935/450127, MIT license.
    225          * Modified from https://github.com/geertw/php-ip-anonymizer, MIT license.
    226221         *
    227222         * SECURITY WARNING: This function is _NOT_ intended to be used in
    228223         * circumstances where the authenticity of the IP address matters. This does
    class WP_Community_Events { 
    232227         * @access protected
    233228         * @since 4.8.0
    234229         *
    235          * @return false|string The anonymized address on success; the given address
    236          *                      or false on failure.
     230         * @return false|string The IP address on success, or false on failure.
    237231         */
    238232        public static function get_unsafe_client_ip() {
    239233                $client_ip = false;
    class WP_Community_Events { 
    263257                        }
    264258                }
    265259
    266                 // These functions are not available on Windows until PHP 5.3.
    267                 if ( function_exists( 'inet_pton' ) && function_exists( 'inet_ntop' ) ) {
    268                         if ( 4 === strlen( inet_pton( $client_ip ) ) ) {
    269                                 $netmask = '255.255.255.0'; // ipv4.
    270                         } else {
    271                                 $netmask = 'ffff:ffff:ffff:ffff:0000:0000:0000:0000'; // ipv6.
    272                         }
    273 
    274                         $client_ip = inet_ntop( inet_pton( $client_ip ) & inet_pton( $netmask ) );
    275                 }
    276 
    277260                return $client_ip;
    278261        }
    279262