code: public static function isIpInRange($ip, $range)
      {
          if (($pos = strpos($range, '-')) !== false) {
              $from = ip2long(substr($range, 0, $pos));
              $to = ip2long(substr($range, $pos + 1));
              $ipInt = ip2long($ip);
  
              return ($from < $to and $ipInt >= $from and $ipInt <= $to);
          }
  
          if (strpos($range, '*') !== false) {
              $range = self::ipWildcardToCIDR($range);
          }
  
          @list($net, $bits) = explode('/', $range);
          $bits = null !== $bits ? $bits : 32;
          $bitMask = -2 ** (32 - $bits) & 0x00000000FFFFFFFF;
          $netMask = ip2long($net) & $bitMask;
          $ip_bits = ip2long($ip) & $bitMask;
  
          return (($netMask ^ $ip_bits) === 0);
      }
docs: Test if IP address is in specified range. Range can be specified using IP1-IP2, wildcard 172.16.*.* or CIDR netmask 172.16.0.0/16
  
  @param string $ip Tested IP address
  @param string $range Range
  
  @return bool Is IP in range
  @static