licensetokill Posted July 25, 2008 Share Posted July 25, 2008 Im looking for a way to let following script or other script check if a domein name is available every for example 5 minutes. Does such script already exist or how to make one. <?php ob_start(); ?> <html> <head> <title>Whois</title> <style> body, td, input { font-family: verdana; font-size: 11px; } form { margin: 0px; } a { color: black; text-decoration: none; } </style> </head> <body> <?php $whois = array(); $whois['be'] = array("whois.dns.be", 43, "{domein}", "FREE"); function whois($whois) { list ($server, $poort, $domein, $vrij) = $whois; $domein = str_replace("{domein}", $_GET['domein'], $domein); $fp = fsockopen($server, $poort); if($fp) { fputs($fp, $domein."\r\n"); while(!feof($fp)) { $data .= fread($fp, 1000); } fclose($fp); } else { $data = "error"; } return $data; } if ($_REQUEST['submit']) { header("location:?domein=".$_POST['domein']); } elseif (!empty($_GET['domein'])) { if (!empty($_GET['ext'])) { echo "<pre>".whois($whois[$_GET['ext']])."</pre>". "<br>". "» <a href=\"?domein=".$_GET['domein']."\">Terug</a>"; } else { echo "<table>". "<tr>". "<td><u>Domeincheck:</u></td>". "<td> </td>". "</tr>"; foreach ($whois as $ext => $value) { list ($server, $poort, $domein, $vrij) = $value; $data = whois($value); if (!ereg($vrij, $data)) { $status = "<a href=\"?domein=".$_GET['domein']."&ext=".$ext."\"><font color=\"red\">bezet</font></a>"; } elseif ($data == "error") { $status = "<font color=\"red\">error</font>"; } else { $status = "<font color=\"darkgreen\">vrij</font>"; } echo "<tr>". "<td>".$_GET['domein'].".".$ext."</td>". "<td align=\"right\">".$status."</td>". "</tr>"; } echo "</table>". "<br>". "» <a href=\"/domeincheck/index.php\">Terug</a>"; } } else { ?> <form method="post"> <table> <tr> <td>Domeinnaam zonder extensie:</td> <td><input type="text" name="domein"></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Controleer!"></td> </tr> </table> </form> <?php } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/116562-multiple-whois-script-that-checks-availability-every-given-in-minutes/ Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 You are best running from a server cron job and get it to email you when the domain is available. The above script works from a form input on a web page so this is not needed for an automated process. You better check that the whois server you are using allows the number of requests you are going to make or they will just block you. Loads of domain reg companies offer drop catching services to make sure you get the domain name you are after if it has not yet expired. Quote Link to comment https://forums.phpfreaks.com/topic/116562-multiple-whois-script-that-checks-availability-every-given-in-minutes/#findComment-599370 Share on other sites More sharing options...
licensetokill Posted July 25, 2008 Author Share Posted July 25, 2008 Could you explain me on how to do it, im using plesk. Thx Quote Link to comment https://forums.phpfreaks.com/topic/116562-multiple-whois-script-that-checks-availability-every-given-in-minutes/#findComment-599490 Share on other sites More sharing options...
JonnoTheDev Posted July 25, 2008 Share Posted July 25, 2008 First you need to find a whois service that isnt going to ban you making all these requests. Here is an example of a whois lookup: http://whois.domaintools.com/mydomain.com Do not use this service in your script as they will certainly ban you! mydomain.com can be any domain name. The bottom of the page contains the WHOIS data. You need to write the script so it can extract this data from the page. Use PHPs CURL to make the request. If there is WHOIS info then you know the domain is registered. If not you may see something like NO MATCH FOR domainname.com which indicates it is expired or unregistered. If this is the case get the script to notify you by email. Set the script off on a cron to run every x mins/hours, etc.(you will need to ask you hosting provider if you can do this in your plesk control panel) Quote Link to comment https://forums.phpfreaks.com/topic/116562-multiple-whois-script-that-checks-availability-every-given-in-minutes/#findComment-599520 Share on other sites More sharing options...
jonsjava Posted July 25, 2008 Share Posted July 25, 2008 and just because I'm bored (figured this might help someone out), here's a domain checker script. <?php $domain = $_GET['domain']; /* USAGE Search to see if a domain is free. CREATED BY: Jon Harris (http://jonsjava.com jonsjava@gmail.com) EXAMPLE: $domain = "example.com"; if (dc_search($domain)){ print "domain free!"; } else{ print "domain taken"; } */ if (dc_search($domain)){ print "domain free!"; } else{ print "domain taken"; } function dc_search($domain){ if (strstr($domain, ";")){ $return_res = false; } else{ $ds = explode(".", $domain); $final = count($ds); while ($final != 1){ $domain_ext = array_pop($ds).".".$domain_ext; $final--; } $domain_ext = substr_replace($domain_ext, "", -1); $extension = strtolower($domain_ext); $allowed_ext = array("com", "co.uk", "org", "com", "net", "info", "com.au"); if (!in_array($extension, $allowed_ext)){ $return_res = false; } else{ $dc_data['com'] = "No match for domain"; $dc_data['net'] = "No match for domain"; $dc_data['org'] = "NOT FOUND"; $dc_data['info'] = "NOT FOUND"; $dc_data['co.uk'] = "This domain name has not been registered."; $dc_data['com.au'] = "No Data Found"; $domain_check = shell_exec("whois $domain"); if (strstr($domain_check, $dc_data[$extension])){ $return_res = true; } else{ $return_res = false; } } } return $return_res; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/116562-multiple-whois-script-that-checks-availability-every-given-in-minutes/#findComment-599527 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.