Récupérer backup auto dans file manager

This commit is contained in:
Fred Tempez 2021-05-04 19:21:47 +02:00
parent 0bcd1c527c
commit ec91858263
4 changed files with 78 additions and 23 deletions

View File

@ -18,6 +18,7 @@ class config extends common {
public static $actions = [
'backup' => self::GROUP_ADMIN,
'copyBackups'=> self::GROUP_ADMIN,
'configMetaImage' => self::GROUP_ADMIN,
'generateFiles' => self::GROUP_ADMIN,
'index' => self::GROUP_ADMIN,
@ -28,7 +29,8 @@ class config extends common {
'logReset' => self::GROUP_ADMIN,
'logDownload'=> self::GROUP_ADMIN,
'blacklistReset' => self::GROUP_ADMIN,
'blacklistDownload' => self::GROUP_ADMIN
'blacklistDownload' => self::GROUP_ADMIN,
];
public static $timezones = [
@ -746,6 +748,23 @@ class config extends common {
}
}
/**
* Récupération des backups auto dans le gestionnaire de fichiers
*/
public function copyBackups() {
// Créer le répertoire manquant
if (!is_dir(self::FILE_DIR.'source/backup')) {
mkdir(self::FILE_DIR.'source/backup');
}
$this->custom_copy(self::BACKUP_DIR, self::FILE_DIR . 'source/backup' );
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'config/advanced',
'notification' => 'Copie terminée',
'state' => true
]);
}
/**
* Fonction de parcours des données de module
@ -767,4 +786,31 @@ class config extends common {
}
return $newArray;
}
/*
* Copie récursive de dossiers
*
*/
private function custom_copy($src, $dst) {
// open the source directory
$dir = opendir($src);
// Make the destination directory if not exist
if (!is_dir($dst)) {
mkdir($dst);
}
// Loop through the files in source directory
while( $file = readdir($dir) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ){
// Recursively calling custom copy function
// for sub directory
$this -> custom_copy($src . '/' . $file, $dst . '/' . $file);
}
else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
}
}

View File

@ -16,24 +16,34 @@
<div class="col12">
<div class="block">
<h4>Maintenance</h4>
<div class="col4">
<?php echo template::checkbox('configAdvancedMaintenance', true, 'Site en maintenance', [
'checked' => $this->getData(['config', 'maintenance'])
<div class="row">
<div class="col12">
<?php echo template::checkbox('configAdvancedMaintenance', true, 'Site en maintenance', [
'checked' => $this->getData(['config', 'maintenance'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::button('configBackupButton', [
'href' => helper::baseUrl() . 'config/backup',
'value' => 'Sauvegarder',
'ico' => 'download-cloud'
]); ?>
</div>
<div class="col4">
<?php echo template::button('configRestoreButton', [
'href' => helper::baseUrl() . 'config/restore',
'value' => 'Restaurer',
'ico' => 'upload-cloud'
]); ?>
</div>
<div class="col4">
<?php echo template::button('configBackupCopyButton', [
'href' => helper::baseUrl() . 'config/copyBackups',
'value' => 'Backups Auto &#10140; FileManager'
]); ?>
</div>
<div class="col3 offset1">
<?php echo template::button('configManageButton', [
'href' => helper::baseUrl() . 'config/backup',
'value' => 'Sauvegarder',
'ico' => 'download'
]); ?>
</div>
<div class="col3">
<?php echo template::button('configRestoreButton', [
'href' => helper::baseUrl() . 'config/restore',
'value' => 'Restaurer',
'ico' => 'upload'
]); ?>
</div>
</div>
</div>

View File

@ -18,7 +18,7 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètre</h4>
<h4>Paramètres de la sauvegarde</h4>
<div class="row">
<div class="col12">
<?php echo template::checkbox('configBackupOption', true, 'Inclure le contenu du gestionnaire de fichiers', [

View File

@ -17,7 +17,7 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètres</h4>
<h4>Archive à restaurer</h4>
<div class="row">
<div class="col10 offset1">
<div class="row">
@ -40,7 +40,7 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Conversion des URL <?php echo template::help('Conversion des URL des ressources multimédia après le transfert d\'une archive entre deux sites aux adresses différentes.');?></h4>
<h4>Conversion après la restauration<?php echo template::help('Conversion des URL des ressources multimédia entre deux sites aux arborescences différentes.');?></h4>
<div class="row">
<div class="col4 offset1">
<?php
@ -58,15 +58,14 @@
'label' => 'Dossier de l\'archive' ,
'value' => $baseUrlValue,
'readonly' => true,
'help' => 'Dossier de base du site stockée dans la sauvegarde.'
'help' => 'Le dossier de base du site est stockée dans la sauvegarde.'
]); ?>
</div>
<div class="col4">
<?php echo template::text('configRestoreCurrentURL', [
'label' => 'Dossier du site actuel',
'value' => helper::baseUrl(false,false),
'readonly' => true,
'help' => 'Dossier du base site actuel.'
'readonly' => true
]); ?>
</div>
<div class="col2 verticalAlignMiddle">