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?<br /><br />Is this possible?<br /><br />Thanks,<br />James<!--content-->
Check this<br /><a href="http://php.net/checkdnsrr" target="_blank">http://php.net/checkdnsrr</a><br />and this<br /><a href="http://pear.php.net/package/Net_DNS" target="_blank">http://pear.php.net/package/Net_DNS</a><!--content-->
Cheers Raul!<br /><br />Thats exactly what I was after, only thing is I don't know enought PHP to make it work <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
Can anyone help me on this please?<!--content-->
I've previously tried to use PEAR but got stuck and frustrated, so I quit trying... So I'm not of much help, sorry.<!--content-->
PHP5 will make this easier, but that's still beta so...<br /><br />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.<br /><br />Then here's a script that would do what you want:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />if ($d) {<br /> Â Â require_once("Net/DNS.php");<br /> Â Â $res = new Net_DNS_Resolver();<br /> Â Â $res->debug = 0;<br /> Â Â $result = $res->search($d, "NS");<br /> Â Â foreach ($result->answer as $rec)<br /> Â Â Â Â print($rec->nsdname."<br />");<br />} else<br /> Â Â echo "You didn't give me anything to lookup.";<br />?><!--c2--></div><!--ec2--><br /><br />For an example of the output:<br /><!--coloro:blue--><span style="color:blue"><!--/coloro-->http://biggorilla.com/tools/ns.php?d=google.com<!--colorc--></span><!--/colorc--><br /><br />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:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php include("http://yoursite.com/tools/ns.php?d=domain.com"); ?><!--c2--></div><!--ec2--><br /><br />Just do not link to my site for that include (I'll eventually remove my installed script). <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /> <br /><br />I leave any further customization for your needs as an exercise for you. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /><!--content-->
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.<br /><br />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.<br /><br />To get nameservers from Whois information is considerably more complex because different domain types return records in different formats.<!--content-->
Thanks Mike! Thats perfect apart from when I do the included it says <br /><br />" Warning: main(): stream does not support seeking in /home/purplesp/public_html/status/index.php on line 62<br />ns2.totalchoicehosting.com<br />ns1.totalchoicehosting.com"<br /><br />Do you know why this is?<br /><br />Cheers<br />James<!--content-->
Can you post up here, or PM me your exact include statement?<!--content-->
I'm just using:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><? @include ("http://www.pswd.biz/status/ns.php?d=purplespider.co.uk");?><!--c2--></div><!--ec2--><!--content-->
Check this<br /><a href="http://php.net/checkdnsrr" target="_blank">http://php.net/checkdnsrr</a><br />and this<br /><a href="http://pear.php.net/package/Net_DNS" target="_blank">http://pear.php.net/package/Net_DNS</a><!--content-->
Cheers Raul!<br /><br />Thats exactly what I was after, only thing is I don't know enought PHP to make it work <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid="" border="0" alt="sad.gif" /><!--content-->
Can anyone help me on this please?<!--content-->
I've previously tried to use PEAR but got stuck and frustrated, so I quit trying... So I'm not of much help, sorry.<!--content-->
PHP5 will make this easier, but that's still beta so...<br /><br />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.<br /><br />Then here's a script that would do what you want:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />if ($d) {<br /> Â Â require_once("Net/DNS.php");<br /> Â Â $res = new Net_DNS_Resolver();<br /> Â Â $res->debug = 0;<br /> Â Â $result = $res->search($d, "NS");<br /> Â Â foreach ($result->answer as $rec)<br /> Â Â Â Â print($rec->nsdname."<br />");<br />} else<br /> Â Â echo "You didn't give me anything to lookup.";<br />?><!--c2--></div><!--ec2--><br /><br />For an example of the output:<br /><!--coloro:blue--><span style="color:blue"><!--/coloro-->http://biggorilla.com/tools/ns.php?d=google.com<!--colorc--></span><!--/colorc--><br /><br />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:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php include("http://yoursite.com/tools/ns.php?d=domain.com"); ?><!--c2--></div><!--ec2--><br /><br />Just do not link to my site for that include (I'll eventually remove my installed script). <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid="" border="0" alt="wink.gif" /> <br /><br />I leave any further customization for your needs as an exercise for you. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /><!--content-->
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.<br /><br />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.<br /><br />To get nameservers from Whois information is considerably more complex because different domain types return records in different formats.<!--content-->
Thanks Mike! Thats perfect apart from when I do the included it says <br /><br />" Warning: main(): stream does not support seeking in /home/purplesp/public_html/status/index.php on line 62<br />ns2.totalchoicehosting.com<br />ns1.totalchoicehosting.com"<br /><br />Do you know why this is?<br /><br />Cheers<br />James<!--content-->
Can you post up here, or PM me your exact include statement?<!--content-->
I'm just using:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><? @include ("http://www.pswd.biz/status/ns.php?d=purplespider.co.uk");?><!--c2--></div><!--ec2--><!--content-->