Ticket #4602: get_ip_address.patch
| File get_ip_address.patch, 2.3 KB (added by hovenko, 6 years ago) |
|---|
-
wp-includes/comment.php
337 337 extract($commentdata, EXTR_SKIP); 338 338 339 339 if ( ! isset($comment_author_IP) ) 340 $comment_author_IP = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);340 $comment_author_IP = preg_replace( '/[^0-9., ]/', '', wp_get_ip_address() ); 341 341 if ( ! isset($comment_date) ) 342 342 $comment_date = current_time('mysql'); 343 343 if ( ! isset($comment_date_gmt) ) … … 392 392 $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; 393 393 $commentdata['user_ID'] = (int) $commentdata['user_ID']; 394 394 395 $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);395 $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '', wp_get_ip_address() ); 396 396 $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; 397 397 398 398 $commentdata['comment_date'] = current_time('mysql'); … … 816 816 wp_cache_add($comment->comment_ID, $comment, 'comment'); 817 817 } 818 818 819 ?> 820 No newline at end of file 819 ?> -
wp-includes/functions.php
860 860 return false; 861 861 } 862 862 863 /** 864 * Finds the IP address of the client. Works behind proxy servers that use 865 * the X-Forwarded-For header to build a chain of client IP addresses. 866 * 867 * @return string 868 */ 869 function wp_get_ip_address() { 870 if ($ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"]) { 871 // IP addresses can be chained, separated with commas, 872 // we want the first one. 873 if (strpos($ip_address, ',') !== false) { 874 $ip_address = explode(',', $ip_address); 875 $ip_address = $ip_address[0]; 876 } 877 } 878 else { 879 $ip_address = $_SERVER["REMOTE_ADDR"]; 880 } 881 882 $ip_address = apply_filters('remote_ip_address', $ip_address); 883 884 return $ip_address; 885 } 886 863 887 function wp_mkdir_p($target) { 864 888 // from php.net/mkdir user contributed notes 865 889 if (file_exists($target)) {
