If ip is for local network.

@param string $ip

@return bool
493558
public static function isLocal(string $ip = null)
    {
        if (is_null($ip)) {
            $ip = self::get();
        }

        if (stripos($ip, '127.') !== false) {
            return true;
        }

        return !(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) == $ip);
    }
621085
public function set($ip)
    {
        if (is_long($ip)) {
            $ip = long2ip($ip);
        }

        Assertion::ip($ip);

        $this->callMethod('setip', compact('ip'));

        return true;
    }
207436
private function isIpv4InUnroutableRange(IPv4 $ip): bool
    {
        foreach ($this->unrouteableRanges as $ipRange) {
            if ($ip->matches(new Subnet($ipRange))) {
                return true;
            }
        }

        return false;
    }
538320
public function ipIsBlocked($clientIp)
    {
        $blockTime = Wasabi::setting('Core.Auth.block_time');
        $blockEnd = (new \DateTime())->modify('-' . $blockTime . ' minutes');

        return (bool)$this->find()
            ->where([
                'blocked' => true,
                'client_ip' => $clientIp
            ])
            ->andWhere(function (QueryExpression $exp) use ($blockEnd) {
                return $exp->gt('created', $blockEnd->format('Y-m-d H:i:s'));
            })
            ->count();
    }
138213
protected function allowIp($ip)
	{
		if(empty($this->ipFilters))
			return true;
		foreach($this->ipFilters as $filter)
		{
			if($filter==='*' || $filter===$ip || (($pos=strpos($filter,'*'))!==false && !strncmp($ip,$filter,$pos)))
				return true;
		}
		return false;
	}
577876
public function isWorking()
    {
        if (empty($_SERVER[self::TEST_SERVER_VAR])
            && empty($_SERVER[self::TEST_SERVER_VAR_ALT])
            && empty($_SERVER[self::TEST_SERVER_VAR_ALT_IPV6])
        ) {
            return Piwik::translate("UserCountry_CannotFindGeoIPServerVar", self::TEST_SERVER_VAR . ' $_SERVER');
        }

        return true; // can't check for another IP
    }
393802
protected static function getIpVersion($ip)
    {
        // Test for IPv4
        if (ip2long($ip) !== false)
        {
            return "IPv4";
        }
         
        // Test for IPv6
        if (substr_count($ip, ":" ) < 2) return false; // ::1 or 2001::0db8
        if (substr_count($ip, "::") > 1) return false; // one allowed
        
        $groups = explode(':', $ip);
        $num_groups = count($groups);
        if (($num_groups > 8) || ($num_groups < 3)) return false;

        $empty_groups = 0;
        foreach ($groups as $group)
        {
            $group = trim($group);
            if (!empty($group) && !(is_numeric($group) && ($group == 0)))
            {
                if (!preg_match('#([a-fA-F0-9]{0,4})#', $group)) return false;
            }
            else
            {
                ++$empty_groups;
            }
        }
		if ($empty_groups < $num_groups)
		{
			return "IPv6";
		}
		return false; // no (valid) IP Address
	}
689128
public function validateIp($ip)
    {
        $ipnums = explode(".", $ip);
        if (count($ipnums) != 4) {
            return false;
        }
        foreach($ipnums as $ipnum) {
            if (!is_numeric($ipnum) || ($ipnum > 255)) {
                return false;
            }
        }
        return $ip;
    }
319171
public static function validate_ip($ip = '')
    {

        if (empty($ip)) return false;

        return (ip2long($ip) !== false) ? true : false;
    }
649635
public function getInfo($ip = null)
    {
        if ($ip == null) {
            $ip = $this->getIpAdress();
        }

        $url = str_replace('{IP}', $ip, $this->api_adress);
        $hex = $this->ipToHex($ip);
        $me = $this;

        // Check if the IP is in the cache
        if (Cache::has($hex)) {
            $this->isCached = true;
        }
        // Use the IP info stored in cache or store it
        $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) {
            return $me->fetchInfo($url);
        });

        $ipInfo->geoplugin_cached = $this->isCached;

        return $ipInfo;
    }
1122064
public static function inRange(string $ip, string $range): bool
	{
		if(strpos($range, '/') === false)
		{
			$netmask = 32;
		}
		else
		{
			[$range, $netmask] = explode('/', $range, 2);

			if($netmask < 0 || $netmask > 32)
			{
				return false;
			}
		}

		if(($ip2Long = ip2long($ip)) === false || ($range2Long = ip2long($range)) === false)
		{
			return false;
		}

		$netmaskDecimal = ~ ((2 ** (32 - $netmask)) - 1);

		return ($ip2Long & $netmaskDecimal) === ($range2Long & $netmaskDecimal);
	}
1365053
protected function validateIp($ip)
    {
        $filter = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
        return filter_var($ip, FILTER_VALIDATE_IP, $filter);
    }
1158821
def hasIP(self, ip):
        """"""

        for f in self.features:
            if (f.prop.startswith("net_interface.") and
                    f.prop.endswith(".ip") and f.value == ip):
                return True
        return False
467693
public static function compressIp($ip)
    {
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return current(unpack('A4', inet_pton($ip)));
        }
        elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
            return current(unpack('A16', inet_pton($ip)));
        }
        return false;
    }
1364614
public function verifyIp($ip) {
        $data = $this->ip();
        return $data === false || in_array($ip, $data);
    }
842730
public function getIpVersion($ip)
    {
        if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
            return self::IPv6;
        }

        else if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return self::IPv4;
        }
        // invalid ip
        return false;
    }
12823
protected function checkIPv4($UserIP = false)
	{
		// Check if IP present
		if ($UserIP === false)
		{
			return false; // No IP, no search.
		}
		// search for user bot IP-filter definitions in localconfig.php
		if (isset($GLOBALS['DLSTATS']['BOT_IPV4']))
		{
			foreach ($GLOBALS['DLSTATS']['BOT_IPV4'] as $lineleft)
			{
				$network = explode("/", trim($lineleft));
				if (! isset($network[1]))
				{
					$network[1] = 32;
				}
				if ($this->dlstatsIPv4InNetwork($UserIP, $network[0], $network[1]))
				{
					return true; // IP found
				}
			}
		}
		return false;
	}