note 88301 added to function.checkdnsrr

From: Date: Mon, 19 Jan 2009 20:12:46 +0000
Subject: note 88301 added to function.checkdnsrr
Groups: php.notes 
Request: Send a blank email to php-notes+get-149478@lists.php.net to get a copy of this message
After successfully handling getmxrr() correctly, I decided to have a bash at this, here's the result: <?php // checkdnsrr() support for Windows by HM2K <php [spat] hm2k.org> function win_checkdnsrr($host, $type='MX') { if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { return; } if (empty($host)) { return; } $types=array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY'); if (!in_array($type,$types)) { user_error("checkdnsrr() Type '$type' not supported", E_USER_WARNING); return; } @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output); foreach($output as $line){ if (preg_match('/^'.$host.'/',$line)) { return true; } } } // Define if (!function_exists('checkdnsrr')) { function checkdnsrr($host, $type='MX') { return win_checkdnsrr($host, $type); } } /* example */ echo "<pre>"; $domains=array('example.com','php.net'); foreach ($domains as $domain) { $result=checkdnsrr($domain); echo $domain.':'; echo $result?"true\n":"false\n"; } ?> ---- Server IP: 92.48.74.199 Probable Submitter: 82.152.138.226 ---- Manual Page -- http://www.php.net/manual/en/function.checkdnsrr.php Edit -- https://master.php.net/note/edit/88301 Del: integrated -- https://master.php.net/note/delete/88301/integrated Del: useless -- https://master.php.net/note/delete/88301/useless Del: bad code -- https://master.php.net/note/delete/88301/bad+code Del: spam -- https://master.php.net/note/delete/88301/spam Del: non-english -- https://master.php.net/note/delete/88301/non-english Del: in docs -- https://master.php.net/note/delete/88301/in+docs Del: other reasons-- https://master.php.net/note/delete/88301 Reject -- https://master.php.net/note/reject/88301 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149478) next »