rvdb86 Posted January 25, 2009 Share Posted January 25, 2009 hey I have the following script that is meant to check domain availibility: <?php // List of whois servers $serverList[0]['top'] = 'com'; $serverList[0]['server'] = 'whois.crsnic.net'; $serverList[0]['response'] = 'No match for'; $serverList[0]['check'] = true; $serverList[1]['top'] = 'net'; $serverList[1]['server'] = 'whois.crsnic.net'; $serverList[1]['response'] = 'No match for'; $serverList[1]['check'] = false; $serverList[2]['top'] = 'org'; $serverList[2]['server'] = 'whois.publicinterestregistry.net'; $serverList[2]['response'] = 'NOT FOUND'; $serverList[2]['check'] = false; $serverList[3]['top'] = 'co.il'; $serverList[3]['server'] = 'whois.isoc.org.il'; $serverList[3]['response'] = 'NOT FOUND'; $serverList[3]['check'] = false; function checkDomain($domain,$server,$findText){ // Open a socket connection to the whois server $con = fsockopen($server, 43); if (!$con) return false; // Send the requested doman name fputs($con, $domain."\r\n"); // Read and store the server response $response = ' :'; while(!feof($con)) { $response .= fgets($con,128); } // Close the connection fclose($con); // Check the response stream whether the domain is available if (strpos($response, $findText)){ return true; } else { return false; } } function showDomainResult($domain,$server,$findText){ if (checkDomain($domain,$server,$findText)){ echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>"; } else echo "<tr><td>$domain</td><td>TAKEN</td></tr>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Mini Domain Checker</title> </head> <body> <?php if (!isset($_POST['submitBtn'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain"> Domain name: <table> <tr><td><input class="text" name="domainname" type="text" size="36"/></td></tr> <tr> <td> <input type="checkbox" name="all" />All <?php foreach ($serverList as $value) { if ($value['check'] == true) $checked=" checked "; else $checked = " "; echo '<input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top']; } ?> </td></tr> <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr> </table> </form> <?php } else { $domainName = (isset($_POST['domainname'])) ? $_POST['domainname'] : ''; if (isset($_POST['all'])) { // As all was selected so set all top level domains to be checked. for ($i = 0; $i < sizeof($serverList); $i++) { $serverList[$i]['check'] = true; } } else{ for ($i = 0; $i < sizeof($serverList); $i++) { $actTop = "top_".$serverList[$i]['top']; $serverList[$i]['check'] = isset($_POST[$actTop]) ? true : false; } } // Check domains only if the base name is big enough if (strlen($domainName)>2){ echo '<table>'; for ($i = 0; $i < sizeof($serverList); $i++) { if ($serverList[$i]['check']){ showDomainResult($domainName.".".$serverList[$i]['top'],$serverList[$i]['server'],$serverList[$i]['response']); } } echo '</table>'; } } ?> </body> The problem is with .co.il domains. i check that whois.isoc.org.il is the whois server but it returns all the domains as existant. I know this is a long shot but i really hope theres some one who can help me or point me in the right direction! TIA!! Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/ Share on other sites More sharing options...
cainfool Posted January 25, 2009 Share Posted January 25, 2009 Delete that server. Use: <?php // List of whois servers $serverList[0]['top'] = 'com'; $serverList[0]['server'] = 'whois.crsnic.net'; $serverList[0]['response'] = 'No match for'; $serverList[0]['check'] = true; $serverList[1]['top'] = 'net'; $serverList[1]['server'] = 'whois.crsnic.net'; $serverList[1]['response'] = 'No match for'; $serverList[1]['check'] = false; $serverList[2]['top'] = 'org'; $serverList[2]['server'] = 'whois.publicinterestregistry.net'; $serverList[2]['response'] = 'NOT FOUND'; $serverList[2]['check'] = false; function checkDomain($domain,$server,$findText){ // Open a socket connection to the whois server $con = fsockopen($server, 43); if (!$con) return false; // Send the requested doman name fputs($con, $domain."\r\n"); // Read and store the server response $response = ' :'; while(!feof($con)) { $response .= fgets($con,128); } // Close the connection fclose($con); // Check the response stream whether the domain is available if (strpos($response, $findText)){ return true; } else { return false; } } function showDomainResult($domain,$server,$findText){ if (checkDomain($domain,$server,$findText)){ echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>"; } else echo "<tr><td>$domain</td><td>TAKEN</td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/#findComment-746093 Share on other sites More sharing options...
rvdb86 Posted January 26, 2009 Author Share Posted January 26, 2009 thanks for the suggestion but how would i check .co.il domains now? Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/#findComment-746300 Share on other sites More sharing options...
cooldude832 Posted January 26, 2009 Share Posted January 26, 2009 I would use the cURL library to curl into a good domain checker out there and use one of those. They check more info than if its up or not like you are. Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/#findComment-746301 Share on other sites More sharing options...
ilikemath2002 Posted January 26, 2009 Share Posted January 26, 2009 I don't think that .co.il is a TLD in the first place. Someone just bought co.il and org.il and then said they were TLDs. Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/#findComment-746321 Share on other sites More sharing options...
rvdb86 Posted January 26, 2009 Author Share Posted January 26, 2009 hey cooldude832, could you maybe explain the cURL library in a bit more detail as i have never used this before. thanks for everyones co-operation in trying to help me! Link to comment https://forums.phpfreaks.com/topic/142374-checking-domain-availibility/#findComment-746340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.