diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php new file mode 100644 index 0000000..b8f89c2 --- /dev/null +++ b/core/module/config/tool/autobackup.php @@ -0,0 +1,26 @@ +open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); +$directory = '../../../../site'; +$files = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator( + $directory, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } + ) +); +foreach ($files as $name => $file) { + if (!$file->isDir()) { + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen(realpath($directory)) + 1); + $zip->addFile($filePath, $relativePath); + } +} +$zip->close(); \ No newline at end of file