我有一个函数可以为我提供高达 n 级的完整文件结构,
function getDirectory($path = '.', $ignore = '') {
$dirTree = array ();
$dirTreeTemp = array ();
$ignore[] = '.';
$ignore[] = '..';
$dh = @opendir($path);
while (false !== ($file = readdir($dh))) {
if (!in_array($file, $ignore)) {
if (!is_dir("$path/$file")) {
//display of file and directory name with their modification time
$stat = stat("$path/$file");
$statdir = stat("$path");
$dirTree["$path"][] = $file. " === ".
date('Y-m-d H:i:s', $stat['mtime']) . " Directory ==
".$path."===". date('Y-m-d H:i:s', $statdir['mtime']) ;
} else {
$dirTreeTemp = getDirectory("$path/$file", $ignore);
if (is_array($dirTreeTemp))$dirTree =
array_merge($dirTree, $dirTreeTemp);
}
}
}
closedir($dh);
return $dirTree;
}
$ignore = array('.htaccess', 'error_log', 'cgi-bin', 'php.ini', '.ftpquota');
//function call
$dirTree = getDirectory('.', $ignore);
//file structure array print
print_r($dirTree);
现在我的要求是,我有两个站点
- 开发/测试站点 - 我测试所有更改的地方
- 生产站点 - 我最终根据开发站点中的测试发布所有更改
现在,例如,我已经在开发/测试站点测试了图像上传,我发现它适合在生产站点上发布,然后我会将开发/测试数据库详细信息完全转移到生产数据库,但现在我想比较文件结构以及将相应的图像文件传输到生产文件夹。
当我通过编辑图像并以相同的名称上传图像来更新图像时,可能会出现这种情况,现在在这种情况下,图像文件已经存在,这将限制“file_exist”逻辑的使用,所以对于这些类型的情况....如何比较两个文件结构以根据要求完成同步?
已编辑
要求必须是一个脚本,我将需要它作为 joomla 组件功能。请按照此回复。