subdomain creation problem dynamically in php [duplicate]
Possible Duplicate:
problems in dynamic craetion of subdomains in php
Hi, I have below cod开发者_如何学运维e which was working fine on testing server but when i transfer it to iPage server my subdomain is not being create. I m not finding where is coming from .Plz take a look.
function subd($host,$port,$ownername,$passw,$request) {
//$sock = fsockopen('localhost',2082);
$sock = fsockopen("www.mydomain.com", 80, $errno, $errstr, 30);
echo $sock;
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;
}
$domain='mydomain.com';
$subd="f1f1f1f1";
$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd";
Password and userid is with my code. I m not getting any error.When i m echoing this is printing "Resource id #1 " nearby socket printing ($sock).
1) why are you trying to roll your own HTTP client when curl already does it much better
2) what do you think the HTTP request actually sends? (hint you don't initialize the $request variable until after you've closed the socket).
3) is the URL you are publishing to designed to use a published API for adding vhosts?
4) do you think its a good idea to use basic http authentication over a non-secure connection?
5) there is no error checking nor comments in your code
6) "When i m echoing this is printing "Resource id #1 " nearby socket printing" - there is just so many things wrong with this statement, I don't know where to start
You need to find a better place to cut and paste your code from - or learn how to write it yourself.
精彩评论