You are here

public static function Helper::dns__resolve in Anti Spam by CleanTalk 9.1.x

Same name and namespace in other branches
  1. 8.4 src/lib/Cleantalk/Common/Helper.php \Cleantalk\Common\Helper::dns__resolve()

* Resolve DNS to IP * *

Parameters

$host: * @param bool $out * * @return bool

1 call to Helper::dns__resolve()
FirewallUpdater::writeDbExclusions in src/lib/Cleantalk/Common/Firewall/FirewallUpdater.php
Writing to the DB self IPs

File

src/lib/Cleantalk/Common/Helper.php, line 500

Class

Helper
CleanTalk Helper class. Compatible with any CMS.

Namespace

Cleantalk\Common

Code

public static function dns__resolve($host, $out = false) {

  // Get DNS records about URL
  if (function_exists('dns_get_record')) {
    $records = dns_get_record($host, DNS_A);
    if ($records !== false) {
      $out = $records[0]['ip'];
    }
  }

  // Another try if first failed
  if (!$out && function_exists('gethostbynamel')) {
    $records = gethostbynamel($host);
    if ($records !== false) {
      $out = $records[0];
    }
  }
  return $out;
}