WordPress.org

Make WordPress Core

Ticket #4198: get-user-real-ip-api.2.diff

File get-user-real-ip-api.2.diff, 1.6 KB (added by technosailor, 11 years ago)

Replacement

  • wp-includes/comment.php

     
    328328        extract($commentdata);
    329329
    330330        if ( ! isset($comment_author_IP) )
    331                 $comment_author_IP = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] );
     331                $comment_author_IP = preg_replace( '/[^0-9., ]/', '',get_user_real_ip() );
    332332        if ( ! isset($comment_date) )
    333333                $comment_date = current_time('mysql');
    334334        if ( ! isset($comment_date_gmt) )
     
    383383        $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    384384        $commentdata['user_ID']         = (int) $commentdata['user_ID'];
    385385
    386         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] );
     386        $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',get_user_real_ip() );
    387387        $commentdata['comment_agent']     = $_SERVER['HTTP_USER_AGENT'];
    388388
    389389        $commentdata['comment_date']     = current_time('mysql');
     
    789789                $client->query('weblogUpdates.ping', get_option('blogname'), $home);
    790790}
    791791
    792 ?>
    793  No newline at end of file
     792?>
  • wp-includes/pluggable.php

     
    569569}
    570570endif;
    571571
     572if ( !function_exists('get_user_real_ip') )
     573{
     574        function get_user_real_ip()
     575        {
     576                $userip = ( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
     577                return $userip;
     578        }
     579}
    572580?>