public static function validate($ip, $ip_range)
    {
        // first lets get the lists of ip address or ranges separated by commas
        $ip_ranges = explode(',', $ip_range);
        foreach ($ip_ranges as $ip_range) {
            $ip_range = explode('-', $ip_range);
            if (sizeof($ip_range) > 1) {
                $target_ip = ip2long($ip);
                // If exactly 2, then treat the values as the upper and lower bounds of a range for checking
                // AND the target_ip is valid
                if (count($ip_range) == 2 && $target_ip) {
                    // convert dotted quad notation to long for numeric comparison
                    $lower_bound = ip2long($ip_range[0]);
                    $upper_bound = ip2long($ip_range[1]);
                    // If the target_ip is valid
                    if ($target_ip >= $lower_bound && $target_ip <= $upper_bound) {
                        return true;
                    }

                }

            } else {
                if (self::ip_match($ip, $ip_range[0])) {
                    return true;
                }
            }
        }
        return false;
    }