Ticket #14601: comments_ip_agent.patch

File comments_ip_agent.patch, 1.3 KB (added by mrutz, 3 years ago)
  • comment.php

     
    12611261        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; 
    12621262        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; 
    12631263 
    1264         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
    1265         $commentdata['comment_agent']     = substr($_SERVER['HTTP_USER_AGENT'], 0, 254); 
     1264        if(!isset($commentdata['comment_author_IP'])){ // If IP is not passed in take the clients IP   
     1265                $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; 
     1266        } 
     1267        $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] ); 
     1268         
     1269        if(!isset($commentdata['comment_agent'])){ // If user agent is not passed in take the clients user agent 
     1270                $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; 
     1271        } 
     1272        $commentdata['comment_agent']     = substr($commentdata['comment_agent'], 0, 254); 
    12661273 
    12671274        $commentdata['comment_date']     = current_time('mysql'); 
    12681275        $commentdata['comment_date_gmt'] = current_time('mysql', 1);