我正在嘗試使用php動態(tài)創(chuàng)建子域,以便每次有人創(chuàng)建用戶時(shí),他們也會創(chuàng)建一個子域。我似乎能找到的所有答案都是一樣的,只是行不通。即,這是最建議的代碼:function createDomain($domain) { // your cPanel username $cpanel_user = 'username'; $cpanel_pass = 'pass'; $cpanel_skin = 'paper_lantern'; $cpanel_host = 'mydomainname.com'; $subdomain = $domain; // directory - defaults to public_html/subdomain_name $dir = 'public_html/user_site'; // create the subdomain $sock = fsockopen($cpanel_host,2082); if(!$sock) { print('Socket error'); exit(); } $pass = base64_encode("$cpanel_user:$cpanel_pass"); $in = "GET /frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$cpanel_host&domain=$subdomain&dir=$dir\r\n"; $in .= "HTTP/1.0\r\n"; $in .= "Host:$cpanel_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;}createDomain('testing');當(dāng)我嘗試直接在瀏覽器中使用鏈接查看發(fā)生了什么時(shí),cpanel告訴我安全令牌有問題,我得到了一個登錄表單。因此,我嘗試撥打電話以生成安全令牌:function createSession() { // Example details $ip = "example.com"; $cp_user = "username"; $cp_pwd = "password"; $url = "https://example.com:2083/login"; $cookies = "/path/to/storage/for/cookies.txt";它成功創(chuàng)建了令牌。然后,我嘗試將安全令牌發(fā)送到另一個調(diào)用,因此將是這樣的:$token . "/frontend/paper_lantern/subdomain/doadddomain.html?rootdomain=" . $main_domain . "&domain=" . $sub_domain_name . "&dir=public_html/subdomains/" . $sub_domain_name但沒有任何反應(yīng),沒有錯誤,沒有創(chuàng)建子域。我該如何進(jìn)行這項(xiàng)工作?
- 1 回答
- 0 關(guān)注
- 205 瀏覽
添加回答
舉報(bào)
0/150
提交
取消