亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在php中動態創建子域(cpanel和hosting24)

在php中動態創建子域(cpanel和hosting24)

PHP
翻閱古今 2021-04-04 12:15:48
我正在嘗試使用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 關注
  • 208 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號