You are here

public function HttpblEvaluator::getIpLocalStatus in http:BL 8

Get status of IP in httpbl_host table of stored hosts.

(legacy name was "_httpbl_cache_get".)

Overrides HttpblEvaluatorInterface::getIpLocalStatus

1 call to HttpblEvaluator::getIpLocalStatus()
HttpblEvaluator::evaluateVisitor in src/HttpblEvaluator.php
Manages remote and local lookups on visiting host IPs, evaluates their remote status as safe or suspicious and determines a locally stored status (safe / white-listed, grey-listed, or blacklisted) which is used (by other functions) to determine an…

File

src/HttpblEvaluator.php, line 399

Class

HttpblEvaluator
HttpblEvaluator evaluates visitor/host page requests.

Namespace

Drupal\httpbl

Code

public function getIpLocalStatus($ip) {

  // Gather all hosts with this IP.
  $hosts = HostQuery::loadHostsByIp($ip);

  // If we have some, count them.
  if (isset($hosts) && !empty($hosts)) {
    $count = count($hosts);

    // As long as there's more than one...
    while ($count > 1) {

      // Sort them in order by index.
      ksort($hosts);

      // Get that host and delete it.
      $id = key($hosts);
      $host = Host::load($id);
      $host
        ->delete();

      // Reverse sort the array and remove the last one.
      arsort($hosts);
      array_pop($hosts);

      // Rinse and repeat.
      $count--;
    }

    // Get the status of the last IP found.
    $id = key($hosts);
    $host = Host::load($id);
    $status = $host
      ->getHostStatus();
  }
  else {
    $status = NULL;
  }
  return $status;
}