purplespider Posted March 14, 2004 Share Posted March 14, 2004 I'm looking for a simple PHP/CGI script to display the nameserver of a set, hard coded, domain. The reason being I would like a page which simply lists all my domains and next to them displays their nameservers? Is this possible? Thanks, James Quote Link to comment Share on other sites More sharing options...
borfast Posted March 14, 2004 Share Posted March 14, 2004 Check this http://php.net/checkdnsrr and this http://pear.php.net/package/Net_DNS Quote Link to comment Share on other sites More sharing options...
purplespider Posted March 14, 2004 Author Share Posted March 14, 2004 Cheers Raul! Thats exactly what I was after, only thing is I don't know enought PHP to make it work Quote Link to comment Share on other sites More sharing options...
purplespider Posted March 16, 2004 Author Share Posted March 16, 2004 Can anyone help me on this please? Quote Link to comment Share on other sites More sharing options...
DarqFlare Posted March 16, 2004 Share Posted March 16, 2004 I've previously tried to use PEAR but got stuck and frustrated, so I quit trying... So I'm not of much help, sorry. Quote Link to comment Share on other sites More sharing options...
MikeJ Posted March 16, 2004 Share Posted March 16, 2004 PHP5 will make this easier, but that's still beta so... If you get the Pear Net_DNS library that Raul recommended above, put it into the directory you want to create a script to use it, then extract the contents using File Manager, and rename the directory it creates to "Net" (the latest package will create a directory called "Net_DNS-1.00b2", that's what you need to rename). You can delete the compressed file after that. Then here's a script that would do what you want: ><?php if ($d) { require_once("Net/DNS.php"); $res = new Net_DNS_Resolver(); $res->debug = 0; $result = $res->search($d, "NS"); foreach ($result->answer as $rec) print($rec->nsdname."<br />"); } else echo "You didn't give me anything to lookup."; ?> For an example of the output: http://biggorilla.com/tools/ns.php?d=google.com My recommendation would be to use the script just like above, and include it wherever you need the results. Just change the value of "d" accordingly. So, if you had the script in the directory "tools" under public_html, then whever you wanted the nameservers to output in a page: ><?php include("http://yoursite.com/tools/ns.php?d=domain.com"); ?> Just do not link to my site for that include (I'll eventually remove my installed script). I leave any further customization for your needs as an exercise for you. Quote Link to comment Share on other sites More sharing options...
MikeJ Posted March 16, 2004 Share Posted March 16, 2004 Oh...btw, I should have mentioned this is done via DNS lookups, not WHOIS lookups. That means it will display information as it's retrieved from the DNS server that it queries. Why that's important is because when a domain account is created on TCH servers, the nameservers will show as TCH's when this script is run on those servers even if your domain really has them somewhere else. To get nameservers from Whois information is considerably more complex because different domain types return records in different formats. Quote Link to comment Share on other sites More sharing options...
purplespider Posted March 17, 2004 Author Share Posted March 17, 2004 Thanks Mike! Thats perfect apart from when I do the included it says " Warning: main(): stream does not support seeking in /home/purplesp/public_html/status/index.php on line 62 ns2.totalchoicehosting.com ns1.totalchoicehosting.com" Do you know why this is? Cheers James Quote Link to comment Share on other sites More sharing options...
MikeJ Posted March 17, 2004 Share Posted March 17, 2004 Can you post up here, or PM me your exact include statement? Quote Link to comment Share on other sites More sharing options...
purplespider Posted March 17, 2004 Author Share Posted March 17, 2004 I'm just using: ><? @include ("http://www.pswd.biz/status/ns.php?d=purplespider.co.uk");?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.