note 51244 added to function.dns-get-record

From: Date: Thu, 24 Mar 2005 13:44:53 +0000
Subject: note 51244 added to function.dns-get-record
Groups: php.notes 
Request: Send a blank email to php-notes+get-86885@lists.php.net to get a copy of this message
I recently needed to do some name server and IP discovery on the fly. Server and domain monitoring system. If you've got a system with dig the below seems to work fine for discovering name server and a addresses. Shouldn't be hard for you to modify it for the other records if needed. $_REQUEST[url] = "http://www.example.com/"; $url_parts = parse_url($_REQUEST[url]); $dns = Dig($url_parts[host]); print_r($dns[name_servers]); print_r($dns[ips]); function Dig ($domain) { $dig = dig $domain; preg_match_all("/in\s+ns\s+(.+?)\s+/is" ,$dig,$name_servers,PREG_PATTERN_ORDER); preg_match_all("/$domain.\s+[0-9]+\s+in\s+a\s+([0-9.]+)\s+/is" ,$dig,$ips,PREG_PATTERN_ORDER); $dns[name_servers] = $name_servers[1]; $dns[ips] = $ips[1]; return($dns); } ---- Manual Page -- http://www.php.net/manual/en/function.dns-get-record.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51244 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51244&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51244&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51244&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51244&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51244&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51244&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86885) next »