0

如何以编程方式使用 PHP 创建插件域的子域?

我的主域是 example.com

插件域是 example2.com

现在我想使用 PHP 创建 test.example2.com。如何创建此子域?

我尝试了以下代码,但它总是创建主域的子域。

function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain) 
    {
        $buildRequest = "/frontend/paper_lantern/subdomain/doadddomain.html?rootdomain=".$rootDomain."&domain=".$subDomain."&dir=example2.com/".$subDomain;

        $openSocket = fsockopen('localhost',2082);
        if(!$openSocket) 
        {
            return "Socket error";
            exit();
        }

        $authString = $cPanelUser.":".$cPanelPass;
        $authPass = base64_encode($authString);
        $buildHeaders  = "GET ".$buildRequest."\r\n";
        $buildHeaders .= "HTTP/1.0\r\n";
        $buildHeaders .= "Host:localhost\r\n";
        $buildHeaders .= "Authorization: Basic ".$authPass."\r\n";
        $buildHeaders .= "\r\n";

        fputs($openSocket, $buildHeaders);
        //echo $openSocket;
        while(!feof($openSocket)) 
        {
            fgets($openSocket,128);
        }
        fclose($openSocket);


    }
$subDomain = 'test.example2.com';
$cPanelUser = 'username';
$cPanelPass = 'password';
$rootDomain = 'http://www.exampe2.com/';

create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain);
4

0 回答 0