0

this is the servers array that I keep top level domain names and extensions

protected $servers = array(

    "com.tr" => "whois.nic.tr",
    "gen.tr" => "whois.nic.tr",
    "web.tr" => "whois.nic.tr",
    "k12.tr" => "whois.nic.tr",
    "org.tr" => "whois.nic.tr"
);

I am required to get whois info so I wrote this function

function whois($domain,$ext)
{
           $server=$this->servers[$ext];
           $domain=$domain.".".$ext;

    if (function_exists('curl_version')) {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $server);
        curl_setopt($curl, CURLOPT_PORT, 43);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 5);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain."\r\n");
        $result = curl_exec($curl);
        curl_close($curl);

                echo '<pre>';
                echo print_r($result);
                echo '</pre>';
    } else {
        trigger_error('cURL is not found!');
        exit();
    }




}

I am using this way whois("google","com");

This function works for google.com and It gives me the correct domain information But when I execute for google.org.tr then (this is the intersting part) sometimes retuns

No match found for "google.org.tr"(whis is expected)

 and  somethimes return "1"

@update

    curl_setopt($curl, CURLOPT_URL, $server);
    curl_setopt($curl, CURLOPT_URL, "telnet://whois.web.tr:43");
    curl_setopt($curl, CURLOPT_PORT, 43);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain."\r\n");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($curl, CURLOPT_NOPROGRESS, TRUE);
    curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_TELNET);

0 Answers0