如何自动将模板网页传输到子域? [英] How to transfer the template webpages to sub domain automatically?

查看:52
本文介绍了如何自动将模板网页传输到子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请让我先解释一下我的问题。我在服务器上有一些网站模板,我使用php代码创建了我的网站的子域名,如abc.xyz.com。创建子域后,我需要自动将模板文件夹的所有内容(文件和文件夹)复制到我的abc文件夹。目前我手动执行此操作,例如使用fileZilla FTP将模板文件夹的内容上传到abc。如何通过php编码来实现它。



这是我的PHP代码自动生成子域名:



 <?php  

函数create_subdomain($ subDomain,$ cPanelUser,$ cPanelPass,$ rootDomain) ){

// $ buildRequest =/ frontend / x3 / sububmain / doadddomain.html ?rootdomain =。 $ rootDomain。 & domain =。 $ subDomain;

$ buildRequest = / frontend / x3 / subdomain / doadddomain.html?rootdomain = $ rootDomain & domain = $ subDomain & dir = public_html / $ subDomain ;

$ openSocket = fsockopen(' 本地主机',2082);
if(!$ openSocket){
return 套接字错误;
exit();
}

$ authString = $ cPanelUser $ cPanelPass ;
$ authPass = base64_encode($ authString);
$ buildHeaders = GET $ buildRequest \\\\ n< /跨度>;
$ buildHeaders 。= HTTP / 1.0 \r\\\
;
$ buildHeaders 。= 主机:localhost \r\\\
;
$ buildHeaders 。= 授权:基本 $ authPass \\\\ n;
$ buildHeaders 。= \ r \\\
;

fputs($ openSocket,$ buildHeaders);
while(!feof($ openSocket)){
fgets($ openSocket,128);
}
fclose($ openSocket);

$ newDomain = http:// $ subDomain $ rootDomain /;

return 创建的子域$ NEWDOMAIN;


}
?>





这是函数,我传递了必要的参数。

解决方案

subDomain,


cPanelUser ,

cPanelPass,

Please let me explain my problem theoratically first. I have a few website templates on the server and I have created subdomain of my website like abc.xyz.com using php code. I need to copy the template folder's all contents(files and folders) to my abc folder automatically once the subdomain has been created. Currently I am doing this manually like uploading the template folder's contents to abc using fileZilla FTP. How can I achieve it with coding in php.

Here is my php code which makes subdomain automatically:

<?php

function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain) {

//  $buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain;

$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/" . $subDomain;

    $openSocket = fsockopen('localhost',2082);
    if(!$openSocket) {
        return "Socket error";
        exit();
    }

    $authString = $cPanelUser . ":" . $cPanelPass;
    $authPass = base64_encode($authString);
    $buildHeaders  = "GET " . $buildRequest ."\r\n";
    $buildHeaders .= "HTTP/1.0\r\n";
    $buildHeaders .= "Host:localhost\r\n";
    $buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
    $buildHeaders .= "\r\n";

    fputs($openSocket, $buildHeaders);
    while(!feof($openSocket)) {
    fgets($openSocket,128);
    }
    fclose($openSocket);

    $newDomain = "http://" . $subDomain . "." . $rootDomain . "/";

    return "Created subdomain $newDomain";


}
?>



this is the function and I am passing the necessary parameters.

解决方案

subDomain,


cPanelUser,


cPanelPass,


这篇关于如何自动将模板网页传输到子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆