Bludit v2.0.2
This commit is contained in:
parent
49c5ceb46e
commit
3f3fde21e9
@ -1,10 +1,10 @@
|
||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// Bludit version
|
||||
define('BLUDIT_VERSION', '2.0.1');
|
||||
define('BLUDIT_VERSION', '2.0.2');
|
||||
define('BLUDIT_CODENAME', 'Morty');
|
||||
define('BLUDIT_RELEASE_DATE', '2017-10-23');
|
||||
define('BLUDIT_BUILD', '20171023');
|
||||
define('BLUDIT_RELEASE_DATE', '2017-11-02');
|
||||
define('BLUDIT_BUILD', '20171102');
|
||||
|
||||
// Debug mode
|
||||
// Change to FALSE, for prevent warning or errors on browser
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Backup",
|
||||
"description": "Backup system"
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"plugin-data":
|
||||
{
|
||||
"name": "Backup",
|
||||
"description": "Backup system"
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"author": "Bludit",
|
||||
"email": "",
|
||||
"website": "https://pro.bludit.com",
|
||||
"version": "2.0",
|
||||
"releaseDate": "2017-05-19",
|
||||
"license": "Bludit PRO",
|
||||
"compatible": "2.0",
|
||||
"notes": "This plugin is delivery with Bludit PRO. Read more about it on https://pro.bludit.com"
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
class pluginBackup extends Plugin {
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Disable default form buttons (Save and Cancel)
|
||||
$this->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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user