我正在嘗試使用php動態創建子域,以便每次有人創建用戶時,他們也會創建一個子域。我似乎能找到的所有答案都是一樣的,只是行不通。即,這是最建議的代碼: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');當我嘗試直接在瀏覽器中使用鏈接查看發生了什么時,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";它成功創建了令牌。然后,我嘗試將安全令牌發送到另一個調用,因此將是這樣的:$token . "/frontend/paper_lantern/subdomain/doadddomain.html?rootdomain=" . $main_domain . "&domain=" . $sub_domain_name . "&dir=public_html/subdomains/" . $sub_domain_name但沒有任何反應,沒有錯誤,沒有創建子域。我該如何進行這項工作?
- 1 回答
- 0 關注
- 208 瀏覽
添加回答
舉報
0/150
提交
取消