From 3f3fde21e9737e012c79e4fecb65890323c55e2b Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Thu, 2 Nov 2017 23:43:13 +0100 Subject: [PATCH] Bludit v2.0.2 --- bl-kernel/boot/init.php | 6 +- bl-plugins/backup/languages/en.json | 7 --- bl-plugins/backup/languages/es.json | 7 --- bl-plugins/backup/metadata.json | 10 --- bl-plugins/backup/plugin.php | 97 ----------------------------- 5 files changed, 3 insertions(+), 124 deletions(-) delete mode 100644 bl-plugins/backup/languages/en.json delete mode 100644 bl-plugins/backup/languages/es.json delete mode 100644 bl-plugins/backup/metadata.json delete mode 100644 bl-plugins/backup/plugin.php diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 73528138..e798d5e2 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -1,10 +1,10 @@ formButtons = false; - } - - // Install the plugin and create the workspace directory - public function install($position=0) - { - parent::install($position); - $workspace = $this->workspace(); - return mkdir($workspace, 0755, true); - } - - // Uninstall the plugin and delete the workspace directory - public function uninstall() - { - parent::uninstall(); - $workspace = $this->workspace(); - return Filesystem::deleteRecursive($workspace); - } - - // Redefine workspace - public function workspace() - { - return PATH_CONTENT.'backup'.DS; - } - - public function form() - { - $this->createBackup(); - } - - public function createBackup() - { - $currentDate = Date::current(BACKUP_DATE_FORMAT); - - // Create backup directory with the current date - $tmp = $this->workspace().'backup-'.$currentDate; - - // Copy pages directory - $destination = $tmp.DS.'pages'; - mkdir($destination, 0755, true); - $source = rtrim(PATH_PAGES, '/'); - Filesystem::copyRecursive($source, $destination); - - // Copy databases directory - $destination = $tmp.DS.'databases'; - mkdir($destination, 0755, true); - $source = rtrim(PATH_DATABASES, '/'); - Filesystem::copyRecursive($source, $destination); - - // Copy uploads directory - $destination = $tmp.DS.'uploads'; - mkdir($destination, 0755, true); - $source = rtrim(PATH_UPLOADS, '/'); - Filesystem::copyRecursive($source, $destination); - - // Compress backup directory - if (Filesystem::zip($tmp, $tmp.'.zip')) { - Filesystem::deleteRecursive($tmp); - } - } - - // Copy the content from the backup to /bl-content/ - private function replaceContent($idExecution) - { - $source = $this->workspace().$idExecution; - $dest = rtrim(PATH_CONTENT, '/'); - return Filesystem::copyRecursive($source, $dest); - } - - // Delete old backups until the $idExecution - private function cleanUp($idExecution) - { - $backups = $this->getBackupsDirectories(); - foreach ($backups as $dir) { - $backupIDExecution = basename($dir); - Filesystem::deleteRecursive($dir); - if($backupIDExecution==$idExecution) { - return true; - } - } - return true; - } - - // Returns array with all backups directories sorted by date newer first - private function getBackupsDirectories() - { - $workspace = $this->workspace(); - return Filesystem::listDirectories($workspace, $regex='*', $sortByDate=true); - } -} \ No newline at end of file