/** * Freeing memories */ static function spam_dispose() { self::get_blocklist(NULL); SpamPickup::whois_responsibility(NULL); }
/** * Check responsibility-root of the FQDN * 'foo.bar.example.com' => 'example.com' (.com has the last whois for it) * 'foo.bar.example.au' => 'example.au' (.au has the last whois for it) * 'foo.bar.example.edu.au' => 'example.edu.au' (.edu.au has the last whois for it) * 'foo.bar.example.act.edu.au' => 'example.act.edu.au' (.act.edu.au has the last whois for it) * @staticvar type $domain * @param type $fqdn * @param type $parent * @param type $implicit * @return string */ static function whois_responsibility($fqdn = 'foo.bar.example.com', $parent = FALSE, $implicit = TRUE) { static $domain; if ($fqdn === NULL) { $domain = NULL; // Unset return ''; } if (!is_string($fqdn)) { return ''; } if (SpamPickup::is_ip($fqdn)) { return $fqdn; } if (!isset($domain)) { $domain = array(); if (file_exists(DOMAIN_INI_FILE)) { include DOMAIN_INI_FILE; // Set } } $result = array(); $dcursor =& $domain; $array = array_reverse(explode('.', $fqdn)); $i = 0; while (TRUE) { if (!isset($array[$i])) { break; } $acursor = $array[$i]; if (is_array($dcursor) && isset($dcursor[$acursor])) { $result[] =& $array[$i]; $dcursor =& $dcursor[$acursor]; } else { if (!$parent && isset($acursor)) { $result[] =& $array[$i]; // Whois servers must know this subdomain } break; } ++$i; } // Implicit responsibility: Top-Level-Domains must not be yours // 'bar.foo.something' => 'foo.something' if ($implicit && count($result) == 1 && count($array) > 1) { $result[] =& $array[1]; } return $result ? implode('.', array_reverse($result)) : ''; }