2
0
Эх сурвалжийг харах

Maj possibilité de supprimer un Backup

stany.ferer 2 жил өмнө
parent
commit
3df322cf78

+ 12 - 0
core/class/backup.class.php

@@ -82,4 +82,16 @@ class backup
         }
         return $tempArray;
     }
+
+    public static function delete(string $_nameBackup)
+    {
+        if(file_exists(DIR_BACKUP . "/" . $_nameBackup)){
+            unlink(DIR_BACKUP . "/" . $_nameBackup);
+            alert::recSuccess("BackUp :. Suppression de " . $_nameBackup);
+            return TRUE;
+        } else {
+            alert::recError("BackUp :. Erreur lors de la suppression de " . $_nameBackup);
+            return FALSE;
+        }
+    }
 }

+ 11 - 0
core/submit/cms.parametres-delete-backup-zip.php

@@ -0,0 +1,11 @@
+<?php
+
+if (core::ifPost("from")) {
+    backup::delete(core::getPost("file"));
+    header("Location: /parametres.html");
+    exit();
+
+} else {
+    header('HTTP/1.0 401 Unauthorized');
+    exit();
+}

+ 15 - 1
core/views/pages/cms.parametres-restore.php

@@ -19,7 +19,8 @@
                     <th data-formatter="downloadFile" data-sortable="true" data-field="file" data-filter-control="input" data-align="left">Nom</th>
                     <th data-sortable="true" data-field="size" data-filter-control="input" data-width="100">Taille</th>
                     <th data-sortable="true" data-field="date" data-filter-control="input" data-width="170">Date de création</th>
-                    <th data-formatter="restoreBackup" data-width="130"></th>
+                    <th data-formatter="restoreBackup" data-width="110"></th>
+                    <th data-formatter="deleteBackup" data-width="10"></th>
                 </tr>
             </thead>
         </table>
@@ -48,4 +49,17 @@
         }
         
     }
+
+    function deleteBackup(value, row, index) {
+        if(index != 0){
+            return '<form method="post" action="/submit.php">\n\
+            <input type="hidden" name="from" value="parametres-restore-backup-zip">\n\
+            <input type="hidden" name="file" value="' + row.file + '">\n\
+            <button type="submit" onclick="return confirm(\'Etes-vous certain de vouloir supprimer ce backup?\')" class="btn btn-outline-warning btn-sm">Supprimer</button>\n\
+            </form>';
+        } else {
+            return '';
+        }
+        
+    }
 </script>