public static function getFirstIpFromList($csv, $excludedIps = null)
    {
        $p = strrpos($csv, ',');
        if ($p !== false) {
            $elements = explode(',', $csv);
            foreach ($elements as $ipString) {
                $element = trim(Common::sanitizeInputValue($ipString));
                if(empty($element)) {
                    continue;
                }
                $ip = \Piwik\Network\IP::fromStringIP(IPUtils::sanitizeIp($element));
                if (empty($excludedIps) || (!in_array($element, $excludedIps) && !$ip->isInRanges($excludedIps))) {
                    return $element;
                }
            }

            return '';
        }
        return trim(Common::sanitizeInputValue($csv));
    }
public static function getFirstIpFromList($csv, $excludedIps = null)
    {
        $p = strrpos($csv, ',');
        if ($p !== false) {
            $elements = explode(',', $csv);
            foreach ($elements as $ipString) {
                $element = trim(Common::sanitizeInputValue($ipString));
                if(empty($element)) {
                    continue;
                }
                $ip = \Piwik\Network\IP::fromStringIP(IPUtils::sanitizeIp($element));
                if (empty($excludedIps) || (!in_array($element, $excludedIps) && !$ip->isInRanges($excludedIps))) {
                    return $element;
                }
            }

            return '';
        }
        return trim(Common::sanitizeInputValue($csv));
    }
public static function getFirstIpFromList ( $ csv , $ excludedIps = null ) { $ p = strrpos ( $ csv , ',' ) ; if ( $ p !== false ) { $ elements = explode ( ',' , $ csv ) ; foreach ( $ elements as $ ipString ) { $ element = trim ( Common :: sanitizeInputValue ( $ ipString ) ) ; if ( empty ( $ element ) ) { continue ; } $ ip = \ Piwik \ Network \ IP :: fromStringIP ( IPUtils :: sanitizeIp ( $ element ) ) ; if ( empty ( $ excludedIps ) || ( ! in_array ( $ element , $ excludedIps ) && ! $ ip -> isInRanges ( $ excludedIps ) ) ) { return $ element ; } } return '' ; } return trim ( Common :: sanitizeInputValue ( $ csv ) ) ; }
Returns the last IP address in a comma separated list, subject to an optional exclusion list.

@param string $csv Comma separated list of elements.
@param array $excludedIps Optional list of excluded IP addresses (or IP address ranges).
@return string Last (non-excluded) IP address in the list or an empty string if all given IPs are excluded.
Returns the last IP address in a comma separated list subject to an optional exclusion list .