forked from ZwiiCMS-Team/ZwiiCMS
Fonction backup modifiée
This commit is contained in:
parent
e87172682c
commit
fe5302be14
@ -196,7 +196,6 @@ class config extends common {
|
|||||||
unlink('robots.bak');
|
unlink('robots.bak');
|
||||||
return(fclose($filenew));
|
return(fclose($filenew));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sauvegarde des données
|
* Sauvegarde des données
|
||||||
*/
|
*/
|
||||||
@ -204,23 +203,29 @@ class config extends common {
|
|||||||
// Creation du ZIP
|
// Creation du ZIP
|
||||||
$fileName = str_replace('/','',helper::baseUrl(false,false)) . '-'. date('Y-m-d-h-i-s', time()) . '.zip';
|
$fileName = str_replace('/','',helper::baseUrl(false,false)) . '-'. date('Y-m-d-h-i-s', time()) . '.zip';
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
|
|
||||||
$zip->open(self::TEMP_DIR . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
$zip->open(self::TEMP_DIR . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||||
|
$directory = 'site/';
|
||||||
|
$filter = array('backup','tmp');
|
||||||
$files = new RecursiveIteratorIterator(
|
$files = new RecursiveIteratorIterator(
|
||||||
new RecursiveDirectoryIterator(realpath(self::DATA_DIR)),
|
new RecursiveCallbackFilterIterator(
|
||||||
RecursiveIteratorIterator::LEAVES_ONLY
|
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) {
|
foreach ($files as $name => $file) {
|
||||||
if (!$file->isDir()) {
|
if (!$file->isDir()) {
|
||||||
$filePath = $file->getRealPath();
|
$filePath = $file->getRealPath();
|
||||||
$relativePath = substr($filePath, strlen(realpath(self::DATA_DIR)) + 1);
|
$relativePath = substr($filePath, strlen(realpath($directory)) + 1);
|
||||||
$zip->addFile($filePath, $relativePath);
|
$zip->addFile($filePath, $relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
// Enregistre la date de backup manuel
|
|
||||||
$this->setData(['core', 'lastBackup', mktime(0, 0, 0)]);
|
|
||||||
// Téléchargement du ZIP
|
// Téléchargement du ZIP
|
||||||
header('Content-Type: application/zip');
|
header('Content-Type: application/zip');
|
||||||
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
||||||
|
Loading…
Reference in New Issue
Block a user