WordPress.org

Make WordPress Core

Ticket #11938: patch.txt

File patch.txt, 1.0 KB (added by husky, 5 years ago)
Line 
1Index: akismet.php
2===================================================================
3--- akismet.php (revision 194958)
4+++ akismet.php (working copy)
5@@ -414,8 +414,19 @@
6 
7 function akismet_auto_check_comment( $comment ) {
8        global $akismet_api_host, $akismet_api_port;
9+       
10+       // Some servers might not reveal the real IP from the original commenter in
11+       // the REMOTE_ADDR field, but forward it using the HTTP_X_FORWARDED_HOST
12+       // header. In that case we need to check for that too/
13+       // See this ticket in WP trac: http://core.trac.wordpress.org/ticket/11938
14+       if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
15+          $remote_addr = $_SERVER['HTTP_X_FORWARDED_HOST'];
16+       } else {
17+          // Normal case
18+          $remote_addr = $_SERVER['REMOTE_ADDR'];
19+       }
20 
21-       $comment['user_ip']    = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
22+       $comment['user_ip']    = preg_replace( '/[^0-9., ]/', '', $remote_addr);
23        $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
24        $comment['referrer']   = $_SERVER['HTTP_REFERER'];
25        $comment['blog']       = get_option('home');