Ticket #4412: comment.patch.diff

File comment.patch.diff, 1.0 KB (added by RuddO, 5 years ago)

Comment detection of 127.0.0.1

  • comment.php

     
    384384        $commentdata['user_ID']         = (int) $commentdata['user_ID']; 
    385385 
    386386        $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
    387         $commentdata['comment_agent']     = $_SERVER['HTTP_USER_AGENT']; 
     387        if ($commentdata['comment_author_IP'] == "127.0.0.1") { 
     388                foreach ( array( 
     389                        "HTTP_CLIENT_IP", 
     390                        "HTTP_X_FORWARDED_FOR", 
     391                        "HTTP_X_FORWARDED", 
     392                        "HTTP_FORWARDED_FOR", 
     393                        "HTTP_FORWARDED", 
     394                        "REMOTE_ADDR") as $addrtype ) { 
     395                                if (!isset($_SERVER[$addrtype])) { continue; } 
     396                                $commentdata['comment_author_IP'] = preg_replace( '/[^0-9., ]/', '',$_SERVER[$addrtype] ); 
     397                                if ($commentdata['comment_author_IP']) break; 
     398                        } 
     399        } 
     400        $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; 
    388401 
    389402        $commentdata['comment_date']     = current_time('mysql'); 
    390403        $commentdata['comment_date_gmt'] = current_time('mysql', 1);