note 35311 added to function.checkdnsrr

From: Date: Wed, 27 Aug 2003 09:15:28 +0000
Subject: note 35311 added to function.checkdnsrr
Groups: php.notes 
Request: Send a blank email to php-notes+get-55164@lists.php.net to get a copy of this message
maybe usefull, a blacklist (DNSBL) check function: function is_blacklisted($ip) { $dnsbl_check=array("bl.spamcop.net", "relays.osirusoft.com", "list.dsbl.org", "sbl.spamhaus.org"); if ($ip) { $quads=explode(".",$ip); $rip=$quads[3].".".$quads[2].".".$quads[1].".".$quads[0]; for ($i=0; $i<count($dnsbl_check); $i++) { if (checkdnsrr($rip.".".$dnsbl_check[$i],"A")) { $listed.=$dnsbl_check[$i]." "; } } if ($listed) { return $listed; } else { return FALSE; } foreach ($result as $line) (if(eregi("^$hostName",$line)) { return true; } } }} kriek at jonkriek dot com 26-Mar-2003 10:08 The checkdnsrr function is not implemented on the Windows platform. The way to get around this problem is to write your own version of checkdnsrr. Example: myCheckDNSRR function myCheckDNSRR($hostName, $recType = '') { if(!empty($hostName)) { if( $recType == '' ) $recType = "MX"; exec("nslookup -type=$recType $hostName", $result); // check each line to find the one that starts with the host // name. If it exists then the function succeeded. foreach ($result as $line) { if(eregi("^$hostName",$line)) { return true; } } // otherwise there was no mail handler for the domain return false; } foreach ($result as $line) (if(eregi("^$hostName",$line)) { return true; if ($ip) { $quads=explode(".",$ip); $rip=$quads[3].".".$quads[2].".".$quads[1].".".$quads[0]; for ($i=0; $i<count($dnsbl_check); $i++) { if (checkdnsrr($rip.".".$dnsbl_check[$i],"A")) { $listed.=$dnsbl_check[$i]." "; } ---- Manual Page -- http://www.php.net/manual/en/function.checkdnsrr.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35311 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35311&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35311&report=yes

« previous php.notes (#55164) next »