note 98944 deleted from function.checkdnsrr by danbrown

From: Date: Fri, 16 Jul 2010 19:12:45 +0000
Subject: note 98944 deleted from function.checkdnsrr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170926@lists.php.net to get a copy of this message
Note Submitter: ldw[DOT]trading[DOT]uk[A.T]gmail[DOT]com ---- Re: alex at xela dot co dot uk With Bind the domains in the zone records are followed by a ., and not appending this to the end of the domain names will cause the check to fail (so for Bind users it appears to be absolutely necessary to append a . to the domain names). Also, using a variable with checkdnsrr, eg: checkdnsrr($domain,"A"), and definitely when dealing with more than one domain, will return false results, eg: <?php $host = $_SERVER["HTTP_HOST"]; $no_tld = (preg_replace('/\..+/', '', $host)); $tld_us = '.us.'; $tld_biz = '.biz.'; $tld_com = '.com.'; $tld_net = '.net.'; $tld_org = '.org.'; $tld_info = '.info.'; $tld_couk = '.co.uk.'; $check_us = $no_tld . $tld_us; $valid_us = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.us.'),"A"); $check_biz = $no_tld . $tld_biz; $valid_biz = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.biz.'),"A"); $check_com = $no_tld . $tld_com; $valid_com = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.com.'),"A"); $check_net = $no_tld . $tld_net; $valid_net = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.net.'),"A"); $check_org = $no_tld . $tld_org; $valid_org = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.org.'),"A"); $check_info = $no_tld . $tld_info; $valid_info = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.info.'),"A"); $check_couk = $no_tld . $tld_couk; $valid_couk = checkdnsrr(((preg_replace('/\..+/', '', $host)) . '.co.uk.'),"A"); print '<div style="padding: 0 25px 0 25px; line-height: 150%; color: black; text-align: justify; font-size: larger;"> <p style="font-size: xx-large; font-weight: bold; color: black; line-height: 200%;">'; { if ($valid_com) print (preg_replace('/\.com\./', '.com', $check_com)); print '</p> <p style="font-size: xx-large; font-weight: bold; color: black; line-height: 200%;">'; { if ($valid_couk) print (preg_replace('/\.co\.uk\./', '.co.uk', $check_couk)); ?> ...which, when tested against an existing .co.uk domain with zone file on the server, would return results for both .com and .co.uk (or, incorrectly) just the .com of whichever domain the script was tested with, even in the absence of a zone file on the server for the .com TLD of the same domain. The same applies when used in a much more simplistic way, too: <?php $host = $_SERVER["HTTP_HOST"]; $no_tld = (preg_replace('/\..+/', '', $host)); $tld_com = '.com.'; $tld_couk = '.co.uk.'; $check_com = $no_tld . $tld_com; $check_couk = $no_tld . $tld_couk; if (checkdnsrr($check_com,"A")) { print 'LINE1'; } elseif (checkdnsrr($check_couk,"A")) print 'LINE2'; ?> That, too, would return true for both .com and .co.uk (or, again, and incorrectly, just the .com) of a given domain regardless of whether zone files for both were on the server or not. Naturally I have tested this in a number of variations, but the results are always the same: if you use an actual domain name the results will be correct, but variables will break the functionality and cause false results to be given. I don't believe that this is a bug, - more the way the function was intended to work; but it is annoying, none-the-less, because it renders the function completely useless for the reliable production of dynamic scripts like (in my case) a script to detect a requested domain name and to then present a page complete with a listing of all other domains of the same name on the server, regardless of TLD, and without having to resort to listing all the available domains in a database or array (bearing in mind that any given user could potentially have thousands of domains and inputting them all could be a needlessly long and arduous process when all the TLDs of any one of the domain names could be displayed automatically by a simple script).

« previous php.notes (#170926) next »