0

I have got this script as an answer on php domain availability function. Can anyone please tell me how I can use this script to echo "Domain stackoverflow.com is already registered/free". And here I can see that its using fsockopen method which means this will work fine on Windows Server platform but what about Linux server platform? Will this code work there? If not, what are the changes I need to make to support linux servers? Please without using exec() command as my host has blocked exec(), system() etc.

Script

<?php
    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;   
        }
    }
?>

$status = checkDomain("stackoverflow.com",'whois.crsnic.net','No match for');
Itchydon
  • 2,572
  • 6
  • 19
  • 33
  • didn't you post this already? https://stackoverflow.com/questions/45759290/php-domain-availability-script-exec-function-alternative – Funk Forty Niner Aug 18 '17 at 17:25
  • no that's a completely different question regarding another code/another script... here I am trying something new.. please read that question once properly and see if you can answer.. –  Aug 18 '17 at 17:27
  • There's a lot of methods that look the same to me; what am I not grasping here? – Funk Forty Niner Aug 18 '17 at 17:27
  • scripts in both the questions are different... here you can see I have mentioned the link where I have got this code from and here I want to know how to echo out the response.. yes one thing is common in both and that is how to run the code in linux platform server.. in previous question an exec() command was used which is disabled by my host and I wanted to figure out a solution to make it work.. here, I want information on how to run this code on linux.. not totaly same.. somewhat different.. –  Aug 18 '17 at 17:31

0 Answers0