Index: trunk/phase3/includes/ProxyTools.php |
— | — | @@ -25,6 +25,9 @@ |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
| 29 | +/** |
| 30 | + * @todo FUCKING DOCUMENT THIS FUCKING FUNCTION |
| 31 | + */ |
29 | 32 | function wfGetLastIPfromXFF( $xff ) { |
30 | 33 | if ( $xff ) { |
31 | 34 | // Avoid annoyingly long xff hacks |
— | — | @@ -34,12 +37,12 @@ |
35 | 38 | if ( strrpos !== false ) { |
36 | 39 | $last = trim( substr( $xff, $n + 1 ) ); |
37 | 40 | // Make sure it is an IP |
38 | | - $m = preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $last, $last_ip4); |
39 | | - $n = preg_match('#:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}#', $last, $last_ip6); |
| 41 | + $m = preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $last); |
| 42 | + $n = preg_match('#^:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}$#', $last); |
40 | 43 | if ( $m > 0 ) |
41 | | - $xff_ip = $last_ip4; |
| 44 | + $xff_ip = $last; |
42 | 45 | else if ( $n > 0 ) |
43 | | - $xff_ip = $last_ip6; |
| 46 | + $xff_ip = $last; |
44 | 47 | else |
45 | 48 | $xff_ip = null; |
46 | 49 | } else { |