JovanJ Posted May 23, 2013 Share Posted May 23, 2013 (edited) 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, Edited May 23, 2013 by JovanJ Quote Link to comment https://forums.phpfreaks.com/topic/278338-result-problem/ Share on other sites More sharing options...
xenLiam Posted May 24, 2013 Share Posted May 24, 2013 For the "Cannot modify header information" error, you can't put a header() anywhere in the code after text has been printed out. You can try to resolve that by adding ob_start() to the top of the script to buffer the output (after the first <?php). As for the rest of the code, you seem to be using 2083, which is the SSL port for cPanel, when you call the function, but I don't see that being used anywhere inside the function (you connect to 2082, the standard HTTP port). Not saying it's the problem, just pointing it out. Quote Link to comment https://forums.phpfreaks.com/topic/278338-result-problem/#findComment-1431995 Share on other sites More sharing options...
JovanJ Posted May 24, 2013 Author Share Posted May 24, 2013 I've tried to add ob_start(); and same error in error_log. Also i tried to change 2083 to 2082 and again same. Do you've any other idea what i can do? Is there some other way in php how i can redirect page after some code lines are finished? Quote Link to comment https://forums.phpfreaks.com/topic/278338-result-problem/#findComment-1432021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.