note 23588 added to function.checkdnsrr
| From: | php-general at lists dot php dot net | Date: | Tue, 23 Jul 2002 10:45:53 +0000 |
| Subject: | note 23588 added to function.checkdnsrr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33413@lists.php.net to get a copy of this message | ||
<?php
/******************************************************
These functions can be used on WindowsNT to replace
their built-in counterparts that do not work as
expected.
checkdnsrr_winNT() works just the same, returning true
or false
getmxrr_winNT() returns true or false and provides a
list of MX hosts in order of preference.
*******************************************************/
function checkdnsrr_winNT( $host, $type = '' )
{
if( !empty( $host ) )
{
# Set Default Type:
if( $type == '' ) $type = "MX";
@exec( "nslookup -type=$type $host", $output );
while( list( $k, $line ) = each( $output ) )
{
# Valid records begin with host name:
if( eregi( "^$host", $line ) )
{
# record found:
return true;
}
}
return false;
}
}
function getmxrr_winNT( $hostname, &$mxhosts )
{
if( !is_array( $mxhosts ) ) $mxhosts = array();
if( !empty( $hostname ) )
{
@exec( "nslookup -type=MX $hostname", $output, $ret );
while( list( $k, $line ) = each( $output ) )
{
# Valid records begin with hostname:
if( ereg( "^$hostname\tMX preference = ([0-9]+), mail exchanger = (.*)$",
$line, $parts ) )
{
$mxhosts[ $parts[1] ] = $parts[2];
}
}
if( count( $mxhosts ) )
{
reset( $mxhosts );
ksort( $mxhosts );
$i = 0;
while( list( $pref, $host ) = each( $mxhosts ) )
{
$mxhosts2[$i] = $host;
$i++;
}
$mxhosts = $mxhosts2;
return true;
}
else
{
return false;
}
}
}
if ( getmxrr_winNT( "microsoft.com", $hosts ) )
{
echo count($hosts)."<br>";
for ($i=0; $i<=count($hosts); $i++){
echo $hosts[$i];}
}
?>
--
http://www.php.net/manual/en/function.checkdnsrr.php
http://master.php.net/manage/user-notes.php?action=edit+23588
http://master.php.net/manage/user-notes.php?action=delete+23588
http://master.php.net/manage/user-notes.php?action=reject+23588