aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2019-11-01 08:16:10 +0100
committerMarc Alexander <admin@m-a-styles.de>2019-11-01 08:16:10 +0100
commit9887a9d76cb5ab872313a0970594d2a8e6ae8f02 (patch)
treeda740abfcb0f9123091d9d62f64674d57a4e2235 /phpBB/includes
parentb40fe17d930795da22c61be247a84ceb3150bccd (diff)
parent163aac74dbe500eac223ea2ebdbce0a76c1d6ab4 (diff)
downloadforums-9887a9d76cb5ab872313a0970594d2a8e6ae8f02.tar
forums-9887a9d76cb5ab872313a0970594d2a8e6ae8f02.tar.gz
forums-9887a9d76cb5ab872313a0970594d2a8e6ae8f02.tar.bz2
forums-9887a9d76cb5ab872313a0970594d2a8e6ae8f02.tar.xz
forums-9887a9d76cb5ab872313a0970594d2a8e6ae8f02.zip
Merge pull request #5724 from rubencm/ticket/16190
[ticket/16190] Deprecate phpbb's checkdnsrr wrapper
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php166
-rw-r--r--phpBB/includes/functions_compatibility.php22
-rw-r--r--phpBB/includes/functions_user.php2
3 files changed, 23 insertions, 167 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 3227a21e26..30f9734efd 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3141,172 +3141,6 @@ function phpbb_inet_pton($address)
return false;
}
-/**
-* Wrapper for php's checkdnsrr function.
-*
-* @param string $host Fully-Qualified Domain Name
-* @param string $type Resource record type to lookup
-* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
-* Other types may work or may not work
-*
-* @return mixed true if entry found,
-* false if entry not found,
-* null if this function is not supported by this environment
-*
-* Since null can also be returned, you probably want to compare the result
-* with === true or === false,
-*/
-function phpbb_checkdnsrr($host, $type = 'MX')
-{
- // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain)
- if (substr($host, -1) == '.')
- {
- $host_fqdn = $host;
- $host = substr($host, 0, -1);
- }
- else
- {
- $host_fqdn = $host . '.';
- }
- // $host has format some.host.example.com
- // $host_fqdn has format some.host.example.com.
-
- // If we're looking for an A record we can use gethostbyname()
- if ($type == 'A' && function_exists('gethostbyname'))
- {
- return (@gethostbyname($host_fqdn) == $host_fqdn) ? false : true;
- }
-
- if (function_exists('checkdnsrr'))
- {
- return checkdnsrr($host_fqdn, $type);
- }
-
- if (function_exists('dns_get_record'))
- {
- // dns_get_record() expects an integer as second parameter
- // We have to convert the string $type to the corresponding integer constant.
- $type_constant = 'DNS_' . $type;
- $type_param = (defined($type_constant)) ? constant($type_constant) : DNS_ANY;
-
- // dns_get_record() might throw E_WARNING and return false for records that do not exist
- $resultset = @dns_get_record($host_fqdn, $type_param);
-
- if (empty($resultset) || !is_array($resultset))
- {
- return false;
- }
- else if ($type_param == DNS_ANY)
- {
- // $resultset is a non-empty array
- return true;
- }
-
- foreach ($resultset as $result)
- {
- if (
- isset($result['host']) && $result['host'] == $host &&
- isset($result['type']) && $result['type'] == $type
- )
- {
- return true;
- }
- }
-
- return false;
- }
-
- // If we're on Windows we can still try to call nslookup via exec() as a last resort
- if (DIRECTORY_SEPARATOR == '\\' && function_exists('exec'))
- {
- @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host_fqdn), $output);
-
- // If output is empty, the nslookup failed
- if (empty($output))
- {
- return NULL;
- }
-
- foreach ($output as $line)
- {
- $line = trim($line);
-
- if (empty($line))
- {
- continue;
- }
-
- // Squash tabs and multiple whitespaces to a single whitespace.
- $line = preg_replace('/\s+/', ' ', $line);
-
- switch ($type)
- {
- case 'MX':
- if (stripos($line, "$host MX") === 0)
- {
- return true;
- }
- break;
-
- case 'NS':
- if (stripos($line, "$host nameserver") === 0)
- {
- return true;
- }
- break;
-
- case 'TXT':
- if (stripos($line, "$host text") === 0)
- {
- return true;
- }
- break;
-
- case 'CNAME':
- if (stripos($line, "$host canonical name") === 0)
- {
- return true;
- }
- break;
-
- default:
- case 'AAAA':
- // AAAA records returned by nslookup on Windows XP/2003 have this format.
- // Later Windows versions use the A record format below for AAAA records.
- if (stripos($line, "$host AAAA IPv6 address") === 0)
- {
- return true;
- }
- // No break
-
- case 'A':
- if (!empty($host_matches))
- {
- // Second line
- if (stripos($line, "Address: ") === 0)
- {
- return true;
- }
- else
- {
- $host_matches = false;
- }
- }
- else if (stripos($line, "Name: $host") === 0)
- {
- // First line
- $host_matches = true;
- }
- break;
- }
- }
-
- return false;
- }
-
- return NULL;
-}
-
// Handler, header and footer
/**
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index b5b60e118e..1f9131c9c0 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -601,3 +601,25 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
return $file;
}
+
+/**
+* Wrapper for php's checkdnsrr function.
+*
+* @param string $host Fully-Qualified Domain Name
+* @param string $type Resource record type to lookup
+* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
+* Other types may work or may not work
+*
+* @return mixed true if entry found,
+* false if entry not found,
+* null if this function is not supported by this environment
+*
+* Since null can also be returned, you probably want to compare the result
+* with === true or === false,
+*
+* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
+*/
+function phpbb_checkdnsrr($host, $type = 'MX')
+{
+ return checkdnsrr($host, $type);
+}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index e0b6a9d0c6..7dd850111e 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1910,7 +1910,7 @@ function phpbb_validate_email($email, $config = null)
{
list(, $domain) = explode('@', $email);
- if (phpbb_checkdnsrr($domain, 'A') === false && phpbb_checkdnsrr($domain, 'MX') === false)
+ if (checkdnsrr($domain, 'A') === false && checkdnsrr($domain, 'MX') === false)
{
return 'DOMAIN_NO_MX_RECORD';
}