[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_ext/bad-behavior/bad-behavior/ -> roundtripdns.inc.php (source)

   1  <?php if (!defined('BB2_CORE')) die("I said no cheating!");
   2  
   3  # Round trip DNS verification
   4  
   5  # Returns TRUE if DNS matches; FALSE on mismatch
   6  # Returns $ip if an error occurs
   7  # TODO: Not IPv6 safe
   8  # FIXME: Returns false on DNS server failure; PHP provides no distinction
   9  # between no records and error condition
  10  function bb2_roundtripdns($ip,$domain)
  11  {
  12      if (@is_ipv6($ip)) return $ip;
  13  
  14      $host = gethostbyaddr($ip);
  15      $host_result = strpos(strrev($host), strrev($domain));
  16      if ($host_result === false || $host_result > 0) return false;
  17      $addrs = gethostbynamel($host);
  18      if (in_array($ip, $addrs)) return true;
  19      return false;
  20  }
  21  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7