Hi,
I am making some subdomain script which creates subdomain and also copy some files to folder of that subdomain but...
I've one problem with $result statement. My code looks like this (part of the code):
function subd($host,$port,$ownername,$passw,$request) {
$sock = fsockopen('localhost',2082);
if(!$sock) {
print('Socket error');
exit();
}
$authstr = "$ownername:$passw";
$pass = base64_encode($authstr);
$in = "GET $request\r\n";
$in .= "HTTP/1.0\r\n";
$in .= "Host:$host\r\n";
$in .= "Authorization: Basic $pass\r\n";
$in .= "\r\n";
fputs($sock, $in);
while (!feof($sock)) {
$result .= fgets ($sock,128);
}
fclose( $sock );
return $result;
}
foreach($doms as $dom) {
$lines = explode(';',$dom);
if (count($lines) == 2) {
$domain = trim($lines[0]);
$subd = trim($lines[1]);
}
else {
$domain = getVar('domain', DOMAIN);
$subd = trim($lines[0]);
}
$dir = 'public_html/' . $subd; // the Document Root folder for subdomain
$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd&dir=$dir";
$cpanelhost = "mysite.com";
$result = subd($cpanelhost,2083,$cpaneluser,$cpanelpass,$request);
$show = strip_tags($result);
echo $show;
$cpanel_skin - is cpanel skin, set as 'x3'
$cpaneluser - username of cpanel login
$cpanelpassword - password of cpanel password
The problem is when I've code as above, subdomain is created fine, but it returns me page 'Server is not responding' and also there is an error in my error_log file "Cannot modify header information - headers already sent by " (There is a redirect header, because of that there is error in error_log).. When i remove :
$result = subd($cpanelhost,2083,$cpaneluser,$cpanelpass,$request);
Error in error_log is still there, but server is not showing me error page and also subdomain is not created. Does any one have some idea how i can avoid server to show me error page and to redirect it somehow?
I forgot to mention, "Cannot modify header information - headers already sent by ", it says outpage happens on line 25, and on that line there is just a open tag for php... <?php ... nothing else
Cheers,