diff options
Diffstat (limited to 'controller/backup.php')
-rw-r--r-- | controller/backup.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/controller/backup.php b/controller/backup.php index 81d72b9..4fb01ef 100644 --- a/controller/backup.php +++ b/controller/backup.php | |||
@@ -8,20 +8,23 @@ function sauvegarder($from) | |||
8 | 8 | ||
9 | $cheminDestination = "data/"; | 9 | $cheminDestination = "data/"; |
10 | $date = date("d-m-Y", time()); | 10 | $date = date("d-m-Y", time()); |
11 | $nomFichier = "melaineDATA_" . $date . ".zip"; | 11 | $nomFichier = "melaineDATA_" . $date; |
12 | // ne prendre que les dossiers pour exclure les fichiers password.txt, melaineDATA.zip et melainePHP.zip existant | 12 | // ne prendre que les dossiers pour exclure les fichiers password.txt, melaineDATA.zip et melainePHP.zip existant |
13 | $dossiersCibles = [ 'data/archives', 'data/concerts', 'data/liens', 'data/presse', 'data/ateliers', 'data/discographie', 'data/melaine', 'data/peinture' ]; | 13 | $dossiersCibles = [ 'data/archives', 'data/concerts', 'data/liens', 'data/presse', 'data/ateliers', 'data/discographie', 'data/melaine', 'data/peinture' ]; |
14 | //$fichiersALaRacine = []; | 14 | //$fichiersALaRacine = []; |
15 | 15 | ||
16 | createZip($cheminDestination, $nomFichier, $dossiersCibles); | 16 | createZip($cheminDestination, $nomFichier, $dossiersCibles); |
17 | 17 | ||
18 | global $archiveFormat; | ||
19 | $nomFichier = $nomFichier . '.' . $archiveFormat; | ||
20 | |||
18 | require('view/backup.php'); | 21 | require('view/backup.php'); |
19 | } | 22 | } |
20 | 23 | ||
21 | function creerMelainePHP() | 24 | function creerMelainePHP() |
22 | { | 25 | { |
23 | $cheminDestination = 'data/'; | 26 | $cheminDestination = 'data/'; |
24 | $nomFichier = "melainePHP.zip"; | 27 | $nomFichier = "melainePHP"; |
25 | // tous les dossiers sauf data et .git | 28 | // tous les dossiers sauf data et .git |
26 | $dossiersCibles = ['model', 'view', 'controller', 'public', 'lib']; | 29 | $dossiersCibles = ['model', 'view', 'controller', 'public', 'lib']; |
27 | $fichiersALaRacine = ['*.php', '.htaccess', '*.txt']; // robots? | 30 | $fichiersALaRacine = ['*.php', '.htaccess', '*.txt']; // robots? |
@@ -34,6 +37,9 @@ function creerMelainePHP() | |||
34 | // le quatrième est optionnel et concerne les fichiers à la racine | 37 | // le quatrième est optionnel et concerne les fichiers à la racine |
35 | function createZip($destinationPath, $zipFileName, array $targetDirectories, array $allPattern = []) | 38 | function createZip($destinationPath, $zipFileName, array $targetDirectories, array $allPattern = []) |
36 | { | 39 | { |
40 | global $archiveFormat; // choix du format | ||
41 | $zipFileName = $zipFileName . '.' . $archiveFormat; | ||
42 | |||
37 | try | 43 | try |
38 | { | 44 | { |
39 | $Zip = new ZipArchive(); | 45 | $Zip = new ZipArchive(); |
@@ -101,6 +107,8 @@ function restaurer($from) | |||
101 | // recharger la même page en écrivant les données | 107 | // recharger la même page en écrivant les données |
102 | if(isset($_FILES['archive']) && $_FILES['archive']['error'] == 0) | 108 | if(isset($_FILES['archive']) && $_FILES['archive']['error'] == 0) |
103 | { | 109 | { |
110 | // détecter le format (zip ou autre) | ||
111 | |||
104 | // une copie du zip est conservée dans data/ au cas où | 112 | // une copie du zip est conservée dans data/ au cas où |
105 | move_uploaded_file($_FILES['archive']['tmp_name'], 'data/' . $_FILES['archive']['name']); | 113 | move_uploaded_file($_FILES['archive']['tmp_name'], 'data/' . $_FILES['archive']['name']); |
106 | chmod('data/' . $_FILES['archive']['name'], 0666); | 114 | chmod('data/' . $_FILES['archive']['name'], 0666); |
@@ -117,10 +125,6 @@ function restaurer($from) | |||
117 | echo($e); | 125 | echo($e); |
118 | die(); | 126 | die(); |
119 | } | 127 | } |
120 | |||
121 | //var_dump($Zip->open($nomFichier, ZipArchive::RDONLY)); | ||
122 | //var_dump(ZipArchive::ER_NOENT); | ||
123 | |||
124 | if($Zip->open($nomFichier, ZipArchive::RDONLY) === TRUE) | 128 | if($Zip->open($nomFichier, ZipArchive::RDONLY) === TRUE) |
125 | { | 129 | { |
126 | $j = 0; | 130 | $j = 0; |