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');