}
}
+/**
+ * @todo FUCKING DOCUMENT THIS FUCKING FUNCTION
+ */
function wfGetLastIPfromXFF( $xff ) {
if ( $xff ) {
// Avoid annoyingly long xff hacks
if ( strrpos !== false ) {
$last = trim( substr( $xff, $n + 1 ) );
// Make sure it is an IP
- $m = preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $last, $last_ip4);
- $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);
+ $m = preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $last);
+ $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);
if ( $m > 0 )
- $xff_ip = $last_ip4;
+ $xff_ip = $last;
else if ( $n > 0 )
- $xff_ip = $last_ip6;
+ $xff_ip = $last;
else
$xff_ip = null;
} else {