创建插件域的子域

时间:2019-07-19 05:16:09

标签: php subdomain programmatically-created addon-domain

如何通过编程方式使用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);

0 个答案:

没有答案