diff --git a/bl-plugins/backup/js/backup.js b/bl-plugins/backup/js/backup.js deleted file mode 100644 index 94862bab..00000000 --- a/bl-plugins/backup/js/backup.js +++ /dev/null @@ -1,35 +0,0 @@ -jQuery(document).ready(function($) { - $('#backupFile').change(function() { - var file = this.files.length >= 1? this.files[0]: null; - if (file === null) { - return false; - } - - // Build Form Data - var url = $('#jsform').attr("action") || window.location.href; - var form = new FormData(); - form.append("tokenCSRF", $('[name="tokenCSRF"]').val()); - form.append("backupFile", file); - - // Apply Form - $.ajax({ - url: url, - data: form, - type: "POST", - dataType: "json", - mimeType: "multipart/form-data", - contentType: false, - processData: false, - error: function (jqXHR, status, error) { - var data = jqXHR.responseJSON; - var alert = $("
").addClass("alert alert-danger").text(data.message); - - $("#jsform .alert:not(.alert-primary)").remove(); - $("#jstokenCSRF").after(alert); - }, - success: function (data, status, jqXHR) { - window.location.reload(); - } - }); - }); -}); diff --git a/bl-plugins/backup/languages/da.json b/bl-plugins/backup/languages/da.json deleted file mode 100644 index c286b145..00000000 --- a/bl-plugins/backup/languages/da.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "create-backup": "Opret sikkerhedskopi", - "delete-backup": "Slet sikkerhedskopi", - "download": "Download", - "plugin-data": { - "description": "Den enkle måde at tage backup af din Bludit installation på.", - "name": "Backup" - }, - "restore-backup": "Gendan sikkerhedskopi", - "there-are-no-backups-for-the-moment": "Der er ingen sikkerhedskopier i øjeblikket" -} diff --git a/bl-plugins/backup/languages/de_AT.json b/bl-plugins/backup/languages/de_AT.json deleted file mode 100644 index 131fe034..00000000 --- a/bl-plugins/backup/languages/de_AT.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Einfach Backups erstellen und wieder einspielen." - }, - "create-backup": "Backup erstellen", - "upload-backup": "Backup hochladen", - "download": "Backup herunterladen", - "restore-backup": "Backup wiederherstellen", - "delete-backup": "Backup löschen", - "there-are-no-backups-for-the-moment": "Es gibt keine Backups.", - "you-do-not-have-sufficient-permissions": "Du hast nicht die notwendigen Berechtigungen", - "the-backup-was-created-successfully": "Das Backup wurde erfolgreich erstellt.", - "the-backup-file-could-not-be-created": "Das Backup konnte nicht erstellt werden.", - "the-backup-'%s'-could-be-restored-successfully": "Das Backup '%s' konnte erfolgreich wiederhergestellt werden.", - "the-backup-'%s'-could-not-be-restored": "Das Backup '%s' konnte nicht wiederhergestellt werden.", - "the-backup-'%s'-could-be-deleted-successfully": "Das Backup '%s' konnte erfolgreich gelöscht werden.", - "the-backup-'%s'-could-not-be-deleted": "Das Backup '%s' konnte nicht gelöscht werden.", - "the-passed-file-is-not-a-valid-zip-archive": "Die angegebene Datei ist kein gültiges ZIP Archiv.", - "the-passed-file-does-not-end-with-zip": "Die angegebene Datei endet nicht mit .zip.", - "the-passed-file-could-not-be-validated": "Die angegebene Datei konnte nicht geprüft werden.", - "the-passed-file-is-not-a-valid-backup-archive": "Die angegebene Datei ist kein gültiges Backup Archiv.", - "the-backup-file-could-be-uploaded-successfully": "Die Backup Datei konnte erfolgreich hochgeladen werden." -} diff --git a/bl-plugins/backup/languages/de_CH.json b/bl-plugins/backup/languages/de_CH.json deleted file mode 100644 index 131fe034..00000000 --- a/bl-plugins/backup/languages/de_CH.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Einfach Backups erstellen und wieder einspielen." - }, - "create-backup": "Backup erstellen", - "upload-backup": "Backup hochladen", - "download": "Backup herunterladen", - "restore-backup": "Backup wiederherstellen", - "delete-backup": "Backup löschen", - "there-are-no-backups-for-the-moment": "Es gibt keine Backups.", - "you-do-not-have-sufficient-permissions": "Du hast nicht die notwendigen Berechtigungen", - "the-backup-was-created-successfully": "Das Backup wurde erfolgreich erstellt.", - "the-backup-file-could-not-be-created": "Das Backup konnte nicht erstellt werden.", - "the-backup-'%s'-could-be-restored-successfully": "Das Backup '%s' konnte erfolgreich wiederhergestellt werden.", - "the-backup-'%s'-could-not-be-restored": "Das Backup '%s' konnte nicht wiederhergestellt werden.", - "the-backup-'%s'-could-be-deleted-successfully": "Das Backup '%s' konnte erfolgreich gelöscht werden.", - "the-backup-'%s'-could-not-be-deleted": "Das Backup '%s' konnte nicht gelöscht werden.", - "the-passed-file-is-not-a-valid-zip-archive": "Die angegebene Datei ist kein gültiges ZIP Archiv.", - "the-passed-file-does-not-end-with-zip": "Die angegebene Datei endet nicht mit .zip.", - "the-passed-file-could-not-be-validated": "Die angegebene Datei konnte nicht geprüft werden.", - "the-passed-file-is-not-a-valid-backup-archive": "Die angegebene Datei ist kein gültiges Backup Archiv.", - "the-backup-file-could-be-uploaded-successfully": "Die Backup Datei konnte erfolgreich hochgeladen werden." -} diff --git a/bl-plugins/backup/languages/de_DE.json b/bl-plugins/backup/languages/de_DE.json deleted file mode 100644 index 131fe034..00000000 --- a/bl-plugins/backup/languages/de_DE.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Einfach Backups erstellen und wieder einspielen." - }, - "create-backup": "Backup erstellen", - "upload-backup": "Backup hochladen", - "download": "Backup herunterladen", - "restore-backup": "Backup wiederherstellen", - "delete-backup": "Backup löschen", - "there-are-no-backups-for-the-moment": "Es gibt keine Backups.", - "you-do-not-have-sufficient-permissions": "Du hast nicht die notwendigen Berechtigungen", - "the-backup-was-created-successfully": "Das Backup wurde erfolgreich erstellt.", - "the-backup-file-could-not-be-created": "Das Backup konnte nicht erstellt werden.", - "the-backup-'%s'-could-be-restored-successfully": "Das Backup '%s' konnte erfolgreich wiederhergestellt werden.", - "the-backup-'%s'-could-not-be-restored": "Das Backup '%s' konnte nicht wiederhergestellt werden.", - "the-backup-'%s'-could-be-deleted-successfully": "Das Backup '%s' konnte erfolgreich gelöscht werden.", - "the-backup-'%s'-could-not-be-deleted": "Das Backup '%s' konnte nicht gelöscht werden.", - "the-passed-file-is-not-a-valid-zip-archive": "Die angegebene Datei ist kein gültiges ZIP Archiv.", - "the-passed-file-does-not-end-with-zip": "Die angegebene Datei endet nicht mit .zip.", - "the-passed-file-could-not-be-validated": "Die angegebene Datei konnte nicht geprüft werden.", - "the-passed-file-is-not-a-valid-backup-archive": "Die angegebene Datei ist kein gültiges Backup Archiv.", - "the-backup-file-could-be-uploaded-successfully": "Die Backup Datei konnte erfolgreich hochgeladen werden." -} diff --git a/bl-plugins/backup/languages/en.json b/bl-plugins/backup/languages/en.json deleted file mode 100644 index 066efa24..00000000 --- a/bl-plugins/backup/languages/en.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "The simple way to backup your Bludit." - }, - "create-backup": "Create Backup", - "upload-backup": "Upload Backup", - "download": "Download", - "restore-backup": "Restore Backup", - "delete-backup": "Delete Backup", - "there-are-no-backups-for-the-moment": "There are no backups for the moment", - "you-do-not-have-sufficient-permissions": "You do not have sufficient permissions", - "the-backup-was-created-successfully": "The Backup was created successfully.", - "the-backup-file-could-not-be-created": "The Backup file could not be created.", - "the-backup-'%s'-could-be-restored-successfully": "The Backup '%s' could be restored successfully.", - "the-backup-'%s'-could-not-be-restored": "The Backup '%s' could not be restored.", - "the-backup-'%s'-could-be-deleted-successfully": "The Backup '%s' could be deleted successfully.", - "the-backup-'%s'-could-not-be-deleted": "The Backup '%s' could not be deleted.", - "the-passed-file-is-not-a-valid-zip-archive": "The passed file is not a valid ZIP Archive.", - "the-passed-file-does-not-end-with-zip": "The passed file does not ent with .zip.", - "the-passed-file-could-not-be-validated": "The passed file could not be validated.", - "the-passed-file-is-not-a-valid-backup-archive": "The passed file is not a valid backup archive.", - "the-backup-file-could-be-uploaded-successfully": "The backup file could be uploaded successfully." -} diff --git a/bl-plugins/backup/languages/es.json b/bl-plugins/backup/languages/es.json deleted file mode 100644 index 6d5a3b31..00000000 --- a/bl-plugins/backup/languages/es.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "La forma mas fácil de hacer un backup." - }, - "create-backup": "Crear Backup", - "download": "Descargar", - "restore-backup": "Recuperar Backup", - "delete-backup": "Eliminar Backup", - "there-are-no-backups-for-the-moment": "There are no backups for the moment" -} \ No newline at end of file diff --git a/bl-plugins/backup/languages/fa_IR.json b/bl-plugins/backup/languages/fa_IR.json deleted file mode 100644 index 7942e220..00000000 --- a/bl-plugins/backup/languages/fa_IR.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "پشتیبان گیری", - "description": "یک روش ساده برای پشتیبانگیری از بلودیت شما." - }, - "create-backup": "ایجاد پشتیبانی", - "upload-backup": "بارگذاری پشتیبانی", - "download": "دانلود", - "restore-backup": "بازگردانی فایل پشتیبانی", - "delete-backup": "حذف فایل پشتیبانی", - "there-are-no-backups-for-the-moment": "در این لحظه هیچ نسخه پشتیبانی وجود ندارد", - "you-do-not-have-sufficient-permissions": "شما مجوزهای لازم را ندارید", - "the-backup-was-created-successfully": "نسخه پشتیبان با موفقیت ایجاد شد.", - "the-backup-file-could-not-be-created": "امکان ایجاد فایل پشتیبان وجود ندارد.", - "the-backup-'%s'-could-be-restored-successfully": "فایل پشتیبانی '%s' با موفقیت بازیابی شد.", - "the-backup-'%s'-could-not-be-restored": "فایل پشتیبانی '%s' نمی تواند بازیابی شود.", - "the-backup-'%s'-could-be-deleted-successfully": "فایل پشتیبانی '%s' با موفقیت حذف شد.", - "the-backup-'%s'-could-not-be-deleted": "فایل پشتیبانی '%s' نمی تواند حذف شود.", - "the-passed-file-is-not-a-valid-zip-archive": "فایل انتخاب شده یک فایل ZIP معتبری نمیباشد.", - "the-passed-file-does-not-end-with-zip": "فایل انتخاب شده با پسوند zip تمام نمی شود.", - "the-passed-file-could-not-be-validated": "فایل انتخاب شده را نمی توان اعتبارسنجی کرد.", - "the-passed-file-is-not-a-valid-backup-archive": "فایل انتخاب شده یک فایل معتبر نسخه پشتیبان نمی باشد.", - "the-backup-file-could-be-uploaded-successfully": "فایل پشتیبانی با موفقیت آپلود شد." -} diff --git a/bl-plugins/backup/languages/fr_FR.json b/bl-plugins/backup/languages/fr_FR.json deleted file mode 100755 index 7a2708a4..00000000 --- a/bl-plugins/backup/languages/fr_FR.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugin-data": - { - "name": "Sauvegarde", - "description": "Un moyen simple de sauvegarder votre Bludit." - }, - "create-backup": "Créer une sauvegarde", - "upload-backup": "Charger une sauvegarde", - "download": "Télécharger", - "restore-backup": "Restaurer la sauvegarde", - "delete-backup": "Supprimer la sauvegarde", - "there-are-no-backups-for-the-moment": "Il n'y a pas de sauvegardes pour le moment", - "you-do-not-have-sufficient-permissions": "Vous n'avez pas les autorisations suffisantes", - "the-backup-was-created-successfully": "La sauvegarde a été créée avec succès.", - "the-backup-file-could-not-be-created": "Le fichier de sauvegarde n'a pas pu être créé.", - "the-backup-'%s'-could-be-restored-successfully": "La sauvegarde '%s' a pu être restaurée avec succès.", - "the-backup-'%s'-could-not-be-restored": "La sauvegarde '%s' n'a pas pu être restaurée.", - "the-backup-'%s'-could-be-deleted-successfully": "La sauvegarde '%s' a été supprimée avec succès.", - "the-backup-'%s'-could-not-be-deleted": "La sauvegarde '%s' n'a pas pu être supprimée.", - "the-passed-file-is-not-a-valid-zip-archive": "Le fichier transmis n'est pas une archive ZIP valide.", - "the-passed-file-does-not-end-with-zip": "Le fichier transmis ne comporte pas de .zip.", - "the-passed-file-could-not-be-validated": "Le fichier transmis n'a pas pu être validé.", - "the-passed-file-is-not-a-valid-backup-archive": "Le fichier transmis n'est pas une archive de sauvegarde valide.", - "the-backup-file-could-be-uploaded-successfully": "Le fichier de sauvegarde a pu être téléchargé avec succès." -} \ No newline at end of file diff --git a/bl-plugins/backup/languages/it.json b/bl-plugins/backup/languages/it.json deleted file mode 100644 index 7d4f8ab8..00000000 --- a/bl-plugins/backup/languages/it.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Il modo semplice per fare il backup di Bludit." - }, - "create-backup": "Crea Backup", - "download": "Scarica", - "restore-backup": "Ripristina Backup", - "delete-backup": "Elimina Backup", - "there-are-no-backups-for-the-moment": "Non ci sono backup al momento" -} diff --git a/bl-plugins/backup/languages/ja_JP.json b/bl-plugins/backup/languages/ja_JP.json deleted file mode 100644 index 41603f9f..00000000 --- a/bl-plugins/backup/languages/ja_JP.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Bluditを簡単にバックアップします。" - }, - "create-backup": "バックアップを作成", - "download": "ダウンロード", - "restore-backup": "バックアップをリストア", - "delete-backup": "バックアップを削除", - "there-are-no-backups-for-the-moment": "現在、バックアップはありません" -} \ No newline at end of file diff --git a/bl-plugins/backup/languages/nl_NL.json b/bl-plugins/backup/languages/nl_NL.json deleted file mode 100644 index afcb4111..00000000 --- a/bl-plugins/backup/languages/nl_NL.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Backup", - "description": "Eenvoudige manier om backups van Bludit-gegevens te maken." - }, - "create-backup": "Backup maken", - "download": "Downloaden", - "restore-backup": "Herstellen", - "delete-backup": "Verwijderen", - "there-are-no-backups-for-the-moment": "Er zijn geen backups." -} \ No newline at end of file diff --git a/bl-plugins/backup/languages/ru_RU.json b/bl-plugins/backup/languages/ru_RU.json deleted file mode 100644 index 43bfaaab..00000000 --- a/bl-plugins/backup/languages/ru_RU.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Резервные копии", - "description": "Самый простой способ создать резервную копию вашего сайта." - }, - "create-backup": "Создать резервную копию", - "download": "Загрузить", - "restore-backup": "Восстановление из резервной копии", - "delete-backup": "Удалить резервную копию", - "there-are-no-backups-for-the-moment": "На данный момент резервных копий нет" -} \ No newline at end of file diff --git a/bl-plugins/backup/languages/tr_TR.json b/bl-plugins/backup/languages/tr_TR.json deleted file mode 100644 index ff8c3b4a..00000000 --- a/bl-plugins/backup/languages/tr_TR.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugin-data": - { - "name": "Yedekleme", - "description": "Yedek oluşturmak için en kolay yol." - }, - "create-backup": "Yedek oluştur", - "download": "İndir", - "restore-backup": "Geri yükle", - "delete-backup": "Yedeklemeyi sil", - "there-are-no-backups-for-the-moment": "Şu an için yedek yok" -} diff --git a/bl-plugins/backup/metadata.json b/bl-plugins/backup/metadata.json deleted file mode 100644 index 397be841..00000000 --- a/bl-plugins/backup/metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "author": "Bludit", - "email": "", - "website": "https://plugins.bludit.com", - "version": "3.14.0", - "releaseDate": "2022-08-05", - "license": "MIT", - "compatible": "3.14.0", - "notes": "" -} \ No newline at end of file diff --git a/bl-plugins/backup/plugin.php b/bl-plugins/backup/plugin.php deleted file mode 100644 index c7e8d0c2..00000000 --- a/bl-plugins/backup/plugin.php +++ /dev/null @@ -1,344 +0,0 @@ -formButtons = false; - - // Check for zip extension installed - $this->zip = extension_loaded('zip'); - - // Get Last Message - if (empty($_POST) && !empty(Session::get("BACKUP-MESSAGE"))) { - $this->lastStatus = Session::get("BACKUP-STATUS"); - $this->lastMessage = Session::get("BACKUP-MESSAGE"); - unset($_SESSION["s_BACKUP-STATUS"]); - unset($_SESSION["s_BACKUP-MESSAGE"]); - } - } - - protected function response($status, $message) - { - // Return JSON object for AJAX requests - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], "xmlhttprequest") === 0) { - $http = array( - 200 => "200 OK", - 400 => "400 Bad Request", - 415 => "415 Unsupported Media Type" - ); - header("HTTP/1.1 " . $http[$status]); - print(json_encode(array( - "status" => $status < 400, - "message" => $message - ))); - die(); - } - - // Store in Session - Session::set("BACKUP-STATUS", $status < 400); - Session::set("BACKUP-MESSAGE", $message); - return $status < 400; - } - - public function post() - { - if (isset($_POST['createBackup'])) { - return $this->createBackup(); - } elseif (isset($_POST['restoreBackup'])) { - return $this->restoreBackup($_POST['restoreBackup']); - } elseif (isset($_POST['deleteBackup'])) { - return $this->deleteBackup($_POST['deleteBackup']); - } - - if (isset($_FILES['backupFile'])) { - return $this->uploadBackup($_FILES['backupFile']); - } - - return false; - } - - public function adminHead() - { - global $url; - - if ($url->slug() !== "configure-plugin/pluginBackup") { - return false; - } - - $html = $this->includeJS('backup.js'); - - return $html; - } - - public function adminSidebar() - { - global $login; - if ($login->role() === 'admin') { - $backups = $this->backupList(); - return 'Backups '.count($backups).''; - } else { - return ''; - } - } - - public function form() - { - global $L; - - $backups = $this->backupList(); - - $html = ''; - if (empty($backups)) { - $html .= ''; - } - - if($this->lastStatus !== null) { - $html .= ''; - } - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - if ($this->zip) { - $html .= ''; - $html .= ''; - } - $html .= '
'; - $html .= '
'; - $html .= '
'; - - foreach ($backups as $backup) { - $filename = pathinfo($backup,PATHINFO_FILENAME); - $basename = pathinfo($backup,PATHINFO_BASENAME); - - // Format Title - list($name, $count) = array_pad(explode(".", $filename, 2), 2, 0); - if (($temp = Date::format($name, BACKUP_DATE_FORMAT, 'F j, Y, g:i a')) !== false) { - $name = $temp; - } - - $html .= '
'; - $html .= '

'.$name.($count > 0? " ($count)": "").'

'; - // Allow download if a zip file - if ($this->zip) { - $html .= ' '.$L->get('download').''; - } - $html .= ''; - $html .= ''; - $html .= '
'; - $html .= '
'; - } - return $html; - } - - /** - * Downloading Backups is not allowed by default server config - * This webhook is to allow downloads for admins - * Webhook: plugin-backup-download?file={backup-name.zip} - */ - public function beforeAll() - { - global $L; - $webhook = 'plugin-backup-download'; - if ($this->webhook($webhook)) { - if (!empty($_GET['file'])) { - $login = new Login(); - if ($login->role() === 'admin') { - $existingBackups = array_map('basename', glob(PATH_WORKSPACES.'backup/*.zip')); - if (in_array($_GET['file'], $existingBackups)) { - downloadRestrictedFile(PATH_WORKSPACES.'backup/'.$_GET['file']); - } - } else { - Alert::set($L->g('You do not have sufficient permissions')); - Redirect::page('dashboard'); - } - } - exit(0); - } - } - - public function backupList() - { - if ($this->zip) { - $backups = Filesystem::listFiles($this->workspace(), '*', 'zip', true); - } else { - $backups = Filesystem::listDirectories($this->workspace(), '*', true); - } - return $backups; - } - - public function createBackup() - { - global $L; - - // Current backup directory - $currentDate = Date::current(BACKUP_DATE_FORMAT); - $backupDir = $this->workspace().$currentDate; - - // Copy directories to backup directory - // $directoriesToBackup is a private variable of this class - foreach ($this->directoriesToBackup as $dir) { - $destination = $backupDir.DS.basename($dir); - Filesystem::copyRecursive($dir, $destination); - } - - // Compress backup directory - if ($this->zip) { - if (Filesystem::zip($backupDir, $backupDir.'.zip')) { - Filesystem::deleteRecursive($backupDir); - } - - // Add validation file - $zip = new ZipArchive(); - $zip->open($backupDir.'.zip'); - $zip->addFromString('.BLUDIT_BACKUP', md5_file($backupDir.'.zip')); - $zip->close(); - } - - if (file_exists($backupDir.'.zip')) { - return $this->response(200, $L->get("The Backup was created successfully.")); - } - - return $this->response(400, $L->get("The Backup file could not be created.")); - } - - public function validateBackup($filename) - { - $tmp = PATH_TMP.'backup-'.time().'.zip'; - copy($filename, $tmp); - - // Check Archive - $zip = new ZipArchive(); - if($zip->open($tmp) !== true) { - unlink($tmp); - return false; - } - - // Check Basic Folders - if ($zip->addEmptyDir("databases") || $zip->addEmptyDir("pages") || $zip->addEmptyDir("uploads")) { - $zip->close(); - unlink($tmp); - return false; - } - - // Check Checksum - if (($checksum = $zip->getFromName(".BLUDIT_BACKUP")) === false) { - $zip->close(); - unlink($tmp); - return false; - } - $zip->deleteName(".BLUDIT_BACKUP"); - $zip->close(); - $check = $checksum === md5_file($tmp); - - // Return - unlink($tmp); - return $check; - } - - public function restoreBackup($filename) - { - global $L; - - // Remove current files - foreach ($this->directoriesToBackup as $dir) { - Filesystem::deleteRecursive($dir); - } - - // Recover backuped files - if ($this->zip) { - // Zip format - $tmp = $this->workspace().$filename.'.zip'; - $status = Filesystem::unzip($tmp, PATH_CONTENT); - } else { - // Directory format - $tmp = $this->workspace().$filename; - $status = Filesystem::copyRecursive($tmp, PATH_CONTENT); - } - - if ($status) { - return $this->response(200, sprintf($L->get("The Backup '%s' could be restored successfully."), $filename)); - } - return $this->response(400, sprintf($L->get("The Backup '%s' could not be restored."), $filename)); - } - - public function deleteBackup($filename) - { - global $L; - - if ($this->zip) { - // Zip format - $tmp = $this->workspace().$filename.'.zip'; - $status = Filesystem::rmfile($tmp); - } else { - // Directory format - $tmp = $this->workspace().$filename; - $status = Filesystem::deleteRecursive($tmp); - } - - if ($status) { - return $this->response(200, sprintf($L->get("The Backup '%s' could be deleted successfully."), $filename)); - } - return $this->response(400, sprintf($L->get("The Backup '%s' could not be deleted."), $filename)); - } - - public function uploadBackup($backup) - { - global $L; - - // Check File Type - if ($backup["type"] !== "application/zip" && $backup["type"] !== "application/x-zip-compressed") { - return $this->response(415, $L->get("The passed file is not a valid ZIP Archive.")); - } - - // Check File Extension - if (stripos($backup["name"], ".zip") !== (strlen($backup["name"]) - 4)) { - return $this->response(415, $L->get("The passed file does not end with .zip.")); - } - - // Check ZIP extension - if(!$this->zip) { - return $this->response(400, $L->get("The passed file could not be validated.")); - } - - // Validate Backup ZIP - if (!$this->validateBackup($backup["tmp_name"])) { - return $this->response(415, $L->get("The passed file is not a valid backup archive.")); - } - - // File Name - $name = $backup["name"]; - $count = 0; - while (file_exists($this->workspace() . $name)) { - $name = substr($backup["name"], 0, -4) . "." . ++$count . ".zip"; - } - - // Move File to Backup Directory - Filesystem::mv($backup["tmp_name"], $this->workspace() . $name); - return $this->response(200, $L->get("The backup file could be uploaded successfully.")); - } -}