brooksh Posted March 8, 2007 Share Posted March 8, 2007 I am trying to write a script that verifies that a domain resolves to my server. It works fine for .com and .net but anything else it doesn't find the name servers. If anyone has any ideas on how to fix it, or if someone knows a better script, please share it with me. Thanks. $homepage = "test.org"; if($homepage != "") { $end2 = substr("$homepage",-2); $end3 = substr("$homepage",-3); $end4 = substr("$homepage",-4); if($end4==info) {$type=info;} if($end3==biz) {$type=biz;} if($end2==us) {$type=us;} if($end2==ws) {$type=ws;} if($end4==name) {$type=name;} if($end3==com) {$type=com; $lookup="whois.crsnic.net";} if($end3==net) {$type=net; $lookup="whois.crsnic.net";} if($end3==org) {$type=org; $lookup="whois.publicinterestregistry.net";} if($end4==info) {$type=info; $lookup="whois.afilias.info";} $fp = fsockopen( "$lookup", 43, &$errno, &$errstr, 10); fputs($fp, "$homepage\r\n"); while(!feof($fp)) { $buf = fgets($fp,128); if (ereg( "Domain servers", $buf)) { {$dns = fgets($fp,128);} {$dns .= fgets($fp,128);} } if (ereg( "Name Server:", $buf)) { {$dns = fgets($fp,128);} {$dns .= fgets($fp,128);} $dns = str_replace( "Name Server:", "", $buf); $dns = str_replace( "Server:", "", $dns); $dns = trim($dns); } } echo "Name Server: $dns"; if ($dns == "NS1.TESTING.COM") { } else { echo "<table width=100%><tr><td><p align=\"left\"><font color=\"#FF0000\"> <font face=\"Arial\" size=\"2\">You must change the name servers to <b>$homepage</b>. <BR>Go to your current registrar </font><font face=\"Arial\" size=\"1\">(register.com, godaddy.com)</font><font face=\"Arial\" size=\"2\"> and change the name servers to ns1.testing.com and ns2.testing.com</font></font><BR><BR></p></td></tr></table>"; } } Link to comment https://forums.phpfreaks.com/topic/41857-name-server-lookup-for-a-domain-hostname/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.