Solved Domain availability script part

Richard G

Verified User
Joined
Jul 6, 2008
Messages
12,775
Location
Maastricht
I have some script for a long time, got that from a friend, but now it does not work accurate anymore for .org and .info domains.
Maybe somebody has something even better. I don't need a complete page, just what I have to put here.

At this moment I've got this for example:
Code:
$whois = array();
$whois['nl']   = array("whois.domain-registry.nl", 43, "is {domein}.nl", "is free");
$whois['be']   = array("das.dns.be", 4343, "{domein}.be", "Status:      AVAILABLE");
$whois['com']  = array("whois.nsiregistry.net", 43, "{domein}.com", "No match for");
$whois['net']  = array("whois.nsiregistry.net", 43, "{domein}.net", "No match for");
$whois['org']  = array("whois.publicinterestregistry.net", 43, "{domein}.org", "NOT FOUND");
$whois['info'] = array("whois.afilias.info", 43, "{domein}.info", "NOT FOUND");
$whois['biz']  = array("whois.biz", 43, "{domein}.biz", "No Data Found");

Most of them work, not real fast. But at least the .org and .info is not giving the correct values anymore. Not 100% sure about the rest.
But I'm totally not in to scripting, so no clue as to what I have to change here.

Can anybody help me with this or provide me with something better which I can fill in here?
 
But at least the .org and .info is not giving the correct values anymore.

What you mean? You got no result at all? Or result from whois is completely wrong?

I guess that results of queries are not trusted, because you might get FREE/AVAILABLE FOR REGISTRATION status for already registered domains. If this is the case, then either the used WHOIS servers changed format of their replies and your script will need to be updated then.

OR...

Your script does not get a reply from them because of a network issue. A network issue might be either your server's IP is blocked by them, or their IP is blocked on your server. Or port is blocked for IPV6, etc...

p.s. The lines you've posted do not do any action, those are arrays of data, which are processed somewhere else (not shown part here).
 
What you mean? You got no result at all? Or result from whois is completely wrong?
I mean the result is wrong. It gives "bezet" which is "occupied" while it should "vrij" (available).

As for the script, I think you mean this? I found that a bit lower:
Code:
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  (!empty($_GET['domein']))
{
    if (!empty($_GET['ext']))
    {
        echo "<pre>".whois($whois[$_GET['ext']])."</pre>".
        "<br />".
        "&raquo; <a href=\"?domein=".$_GET['domein']."\">Terug</a>";
    }
    else
    {
        echo "<table>".
        "<tr>".
        "<td><u>Domeincheck:</u></td>".
        "<td>&nbsp;</td>".
        "</tr>";

        foreach ($whois as $ext => $value)
        {
            list ($server, $poort, $domein, $vrij) = $value;

            $data = whois($value);

            if(!preg_match("/$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 <a href='./order.php'>bestel</a></font>";
            }
 
You might need to change the line:

PHP:
if(!preg_match("/$vrij/",$data))

to

PHP:
if(!preg_match("/$vrij/i",$data))

The script expects to find "NOT FOUND" in the uppercase, but a whois server gives it in a lower-case:

Code:
Domain not found.
 
Unfortunately it does not work for .nl domains.
Maybe you can mail him to add support for it. It's a big script. Seems to work with the whois from the OS.
There is a .txt file with all google.tld in it. Maybe if you add google.nl in there the .nl domains also work, I don't know.

I'm not a scripter.
 
It's no big issue. And I have reported it in the past. I think the Dutch registry sidn.nl does not provide this information publicly.
 
There is no support for .NL domains. They might need to be informed about it, so that they would add a support for .NL domains.
You might open an issue here https://github.com/click0/domain-check-2/issues

I opened a request at github. It seems whois servers hide a lot of data for .nl and .de, including the expiration time of the domain due to EU rules.
So any suggestions for whois servers with data for .nl and .de are welcome.
https://github.com/click0/domain-check-2/issues/35
 
So any suggestions for whois servers with data for .nl and .de are welcome.
Since SIDN is -the- authority for .nl domains, I doubt if you will find any which can prevale the information, same for Germany as Germany is very strict with privacy rules, even stronger than the Netherlands.

Having that said, things for bringing it to attention on Github. I didn't do that because I'm not interested in experiation dates, only in availability of a domain so a customer can see if he can register it or not.
 
Back
Top