<?php
$domainName = 'example.com';
$subDomainName = 'demo';
$subDomain = $subDomainName;
$cPanelUser = 'cpanel_user_name';
$cPanelPass = 'cpanel_pass';
$rootDomain = $domainName;
$buildRequest = "/frontend/paper_lantern/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/$domainName/$subDomain";
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."
";
$buildHeaders .= "HTTP/1.0
";
$buildHeaders .= "Host:localhost
";
$buildHeaders .= "Authorization: Basic " . $authPass . "
";
$buildHeaders .= "
";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
echo $newDomain = "http://" . $subDomain . "." . $rootDomain . "/";
?>