我正在编写一个脚本,我正在考虑提供某种工具,在客户端请求时更新脚本。
项目是简单的逻辑。
-
客户端服务器向母服务器发送一个请求(将更新后的脚本存储在ZIP文件中),并从服务器下载.ZIP文件。
-
客户端服务器接收.ZIP文件并对其进行解包,从而覆盖过时的脚本文件。
有人能给我一个基本的指导吗?或者我需要做什么来实现这样的功能?
我可以使用pclzip创建/提取档案,但我不知道从哪里开始。
谢谢你的帮助,谢谢。
您需要使用ftp(使用php)上传
例如,在joomla中,我们可以执行以下操作:
jimport('joomla.client.ftp');
$ftp = JFTP::getInstance($server['ip'], 21, null, $server['user'], $server['password']);
try {
foreach($files as $file) {
$fullpath = JPATH_SITE . $file;
$this->createdirs($ftp, $rootdir . $file);
if($ftp->store($fullpath, $rootdir . $file) == false) {
throw new Exception("Cannot transfer file " . $file);
}
}
foreach($adminfiles as $file) {
$fullpath = JPATH_SITE . $file;
$this->createdirs($ftp, $rootdir . $file);
if($ftp->store($fullpath, $rootdir . $file) == false) {
throw new Exception("Cannot transfer file " . $file);
}
}
}
catch(Exception $e) {
$ftp->quit();
die($e->getMessage());
}
$ftp->quit();