You are here

class IPRangesManager in IP Ranges 8

Hierarchy

Expanded class hierarchy of IPRangesManager

1 file declares its use of IPRangesManager
IPRangesEventSubscriber.php in lib/Drupal/ip_ranges/EventSubscriber/IPRangesEventSubscriber.php
1 string reference to 'IPRangesManager'
ip_ranges.services.yml in ./ip_ranges.services.yml
ip_ranges.services.yml
1 service uses IPRangesManager
ip_ranges.manager in ./ip_ranges.services.yml
Drupal\ip_ranges\IPRangesManager

File

lib/Drupal/ip_ranges/IPRangesManager.php, line 7

Namespace

Drupal\ip_ranges
View source
class IPRangesManager {
  public function __construct(Connection $connection) {
    $this->connection = $connection;
  }
  public function ipIsBanned($ip) {
    $args = array(
      ':ip' => ip2long($ip),
    );
    $sql = "SELECT * FROM {ip_ranges} WHERE type = :type AND ip_lower <= :ip AND ip_higher >= :ip";
    $banned = $this->connection
      ->queryRange($sql, 0, 1, $args + array(
      ':type' => 0,
    ))
      ->fetchField() && !$this->connection
      ->queryRange($sql, 0, 1, $args + array(
      ':type' => 1,
    ))
      ->fetchField();
    return $banned;
  }

}

Members