Check subnet

@param  string $input

@return bool
498907
protected function belongsToSubnet($input): bool
    {
        $range = $this->networkRange;
        $min = sprintf('%032b', ip2long($range['min']));
        $input = sprintf('%032b', ip2long($input));

        return ($input & $range['mask']) === ($min & $range['mask']);
    }
1169527
public static function receive($input = null)
    {
        if (is_null($input)) {
            if (self::$receivedWebhook !== null) {
                $input = self::$receivedWebhook;
            } else {
                $input = file_get_contents("php://input");
            }
        }

        if (!is_null($input) && $input != '') {
            return self::processWebhook($input);
        }

        return false;
    }
358113
public function validate($input)
    {
        $checkDigit = explode(',', '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,h,j,k,l,m,n,p,r,s,t,u,v,w,x,y');

        // Get the check digit
        $check = strtolower(substr($input, -1, 1));

        // Remove dash, plus or A
        if (strlen($input) == 11) {
            $input = substr($input, 0, 6) . substr($input, 7, 3);
        } else {
            $input = substr($input, 0, 9);
        }

        if (!preg_match('/^\d+$/', $input)) {
            return false;
        }

        // Do the math
        $result = $input % 31;

        return $checkDigit[$result] == $check;
    }
508906
protected function checkIPv6($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_IPV6']))
		{
			foreach ($GLOBALS['DLSTATS']['BOT_IPV6'] as $lineleft)
			{
				$network = explode("/", trim($lineleft));
				if (! isset($network[1]))
				{
					$network[1] = 128;
				}
				if ($this->dlstatsIPv6InNetwork($UserIP, $network[0], $network[1]))
				{
					return true; // IP found
				}
			}
		}
		return false;
	}
1172194
public function isDirty($input)
    {
        return is_array($input) ? $this->isADirtyArray($input) : $this->isADirtyString($input);
    }
166261
public function validate($input): bool
    {
        if ($input instanceof DateTime) {
            return true;
        }

        if (!\is_string($input)) {
            return false;
        }

        if (null === $this->format) {
            return false !== strtotime($input);
        }

        $dateFromFormat = DateTime::createFromFormat($this->format, $input);

        return $dateFromFormat
            && $input === date($this->format, $dateFromFormat->getTimestamp());
    }
1368854
public function verifySalt($input)
    {
        $valid = false;
        $matches = array ();
        if (1 === preg_match('/^\$pbkdf2(?:-(?P<digest>sha256|sha512))?\$(?P<rounds>\d+)\$(?P<salt>[\.\/0-9A-Za-z]{0,1366})\$?/', $input, $matches)) {
            $digest = $matches['digest'] ?: self::DIGEST_SHA1;
            $rounds = $matches['rounds'];
            $salt = $matches['salt'];

            $digestValid = false;
            if (in_array($digest, array (self::DIGEST_SHA1, self::DIGEST_SHA256, self::DIGEST_SHA512))) {
                $digestValid = true;
            }

            $roundsValid = false;
            if ($rounds[0] != '0' && $rounds >= 1 && $rounds <= 4294967296) {
                $roundsValid = true;
            }

            if ($digestValid && $roundsValid) {
                $valid = true;
            }
        }

        return $valid;
    }
80886
public function validate($input): bool
    {
        if (\is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL)) {
            [, $domain] = explode('@', $input, 2);
            if ($this->checkDns) {
                return checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A');
            }
            return true;
        }
        return false;
    }
563538
public function getLength($input)
    {
        if (is_scalar($input)) {
            if ($this->countByChars) {
                return mb_strlen($input, $this->charset);
            } else {
                return strlen($input);
            }
        } elseif (is_array($input) || $input instanceof \Countable) {
            return count($input);
        } else {
            return false;
        }
    }
560045
protected function isUpdate($input)
    {
        return (isset($input[$this->id_name]) && ! empty($input[$this->id_name]) );
    }
1126986
public function validate($input): bool
    {
        return $this->less($this->minValue, $input)
            && $this->less($input, $this->maxValue);
    }
1291660
protected function checkIsNull($input) {
		$isNull = $this->isNull;
		if($isNull)
			return $isNull($input);
		else
			return $input === null || $input === '';
	}
196438
public static function parseIPv4($input)
    {
        $parts = explode('.', $input);
        if ($parts[count($parts) - 1] === '') {
            array_pop($parts);
        }
        
        if ($parts === []) {
            $ipv4 = '';
        } elseif (count($parts) > 4) {
            $ipv4 = (string)$input;
        } else {
            $numbers = [];
            foreach ($parts as $i => $part) {
                if ($part === '') {
                    $ipv4 = (string)$input;
                    break;
                }
                $n = self::parseIPv4Number($part);
                if ($n === false) {
                    $ipv4 = (string)$input;
                    break;
                }
                if ($n > 255 && $i !== count($parts) - 1) {
                    $ipv4 = false;
                }
                $numbers[] = $n;
            }
            
            if (!isset($ipv4)) {
                $ipv4 = array_pop($numbers);
                if ($ipv4 >= pow(256, 4 - count($numbers))) {
                    $ipv4 = false;
                } else {
                    foreach ($numbers as $counter => $n) {
                        $ipv4 += $n * pow(256, 3 - $counter);
                    }
                }
            }
        }
        
        return $ipv4;
    }
1227885
protected function collectionIsIterable($input)
    {
        if (isset($input) && is_array($input)) {
            return true;
        }

        if ($input instanceof \ArrayAccess || $input instanceof \Iterator || $input instanceof \Traversable) {
            return true;
        }

        return false;
    }
1202072
protected function scan( $input )
	{
		static $regex;
		if ( !isset( $regex ) )
		{
			$regex = sprintf( '/(%s)|%s/%s', implode( ')|(', $this->getCatchablePatterns() ), implode( '|', $this->getNonCatchablePatterns() ), $this->getModifiers() );
		}
		$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
		$matches = preg_split( $regex, $input, -1, $flags );
		foreach ( $matches as $match )
		{
			// Must remain before 'value' assignment since it can change content
			$type = $this->getType( $match[0] );
			$this->tokens[] = [
				'value' => $match[0],
				'type' => $type,
				'position' => $match[1],
			];
		}
	}
683195
public function has($input): NodeList {
        if ($input instanceof NodeList || $input instanceof \DOMNode) {
            $inputNodes = $this->inputAsNodeList($input, false);

            $fn = function($node) use ($inputNodes) {
                $descendantNodes = $node->find('*', 'descendant::');

                // Determine if we have a descendant match.
                return $inputNodes->reduce(function($carry, $inputNode) use ($descendantNodes) {
                    // Match descendant nodes against input nodes.
                    if ($descendantNodes->exists($inputNode)) {
                        return true;
                    }

                    return $carry;
                }, false);
            };

        } elseif (is_string($input)) {
            $fn = function($node) use ($input) {
                return $node->find($input, 'descendant::')->count() != 0;
            };

        } elseif (is_callable($input)) {
            $fn = $input;

        } else {
            throw new \InvalidArgumentException('Unexpected input value of type "' . gettype($input) . '"');
        }

        return $this->getNodesMatchingInput($fn);
    }
1036802
public static function isBool($input) {
        if(is_bool($input)) {
            return $input; //Already a boolean
        }
        if(is_int($input) || is_float($input)) {
            return $input != 0;
        }
        $input = strtolower(self::isString($input));
        return in_array($input, array('active', 'true', 'yes', '1', 'on', 'y'), TRUE);
    }