php域可用性检查器脚本

时间:2017-08-18 17:21:30

标签: php linux

我已将此脚本作为php domain availability function的答案。任何人都可以告诉我如何使用此脚本回应“域stackoverflow.com已注册/免费”。在这里我可以看到它使用fsockopen方法,这意味着它可以在Windows Server平台上正常工作但是Linux服务器平台呢?这段代码会在那里工作吗?如果没有,我需要做些什么来支持linux服务器呢?请不要使用exec()命令,因为我的主机已屏蔽exec()system()等。

脚本

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

0 个答案:

没有答案
相关问题