note 51244 deleted from function.dns-get-record by googleguy

From: Date: Tue, 22 Oct 2013 10:17:10 +0000
Subject: note 51244 deleted from function.dns-get-record by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196975@lists.php.net to get a copy of this message
Note Submitter: ed at noxserver dot com ---- 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); }

« previous php.notes (#196975) next »