我正在尝试使用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 回答
- 1 回答
- 0 关注
- 196 浏览
添加回答
举报
0/150
提交
取消