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 { |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 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. |
| 218 | 214 | * |
| 219 | 215 | * $_SERVER['REMOTE_ADDR'] cannot be used in all cases, such as when the user |
| 220 | 216 | * is making their request through a proxy, or when the web server is behind |
| … |
… |
class WP_Community_Events { |
| 222 | 218 | * than the user's actual address. |
| 223 | 219 | * |
| 224 | 220 | * Modified from http://stackoverflow.com/a/2031935/450127, MIT license. |
| 225 | | * Modified from https://github.com/geertw/php-ip-anonymizer, MIT license. |
| 226 | 221 | * |
| 227 | 222 | * SECURITY WARNING: This function is _NOT_ intended to be used in |
| 228 | 223 | * circumstances where the authenticity of the IP address matters. This does |
| … |
… |
class WP_Community_Events { |
| 232 | 227 | * @access protected |
| 233 | 228 | * @since 4.8.0 |
| 234 | 229 | * |
| 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. |
| 237 | 231 | */ |
| 238 | 232 | public static function get_unsafe_client_ip() { |
| 239 | 233 | $client_ip = false; |
| … |
… |
class WP_Community_Events { |
| 263 | 257 | } |
| 264 | 258 | } |
| 265 | 259 | |
| 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 | | |
| 277 | 260 | return $client_ip; |
| 278 | 261 | } |
| 279 | 262 | |