1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7
|
* @author WebsiteBaker Project
|
8
|
* @copyright Ryan Djurovich
|
9
|
* @copyright WebsiteBaker Org. e.V.
|
10
|
* @link http://websitebaker.org/
|
11
|
* @license http://www.gnu.org/licenses/gpl.html
|
12
|
* @platform WebsiteBaker 2.8.3
|
13
|
* @requirements PHP 5.3.6 and higher
|
14
|
* @version $Id: backup_droplets.php 2 2017-07-02 15:14:29Z Manuela $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/droplets/commands/backup_droplets.php $
|
16
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
17
|
*
|
18
|
|
19
|
print '<pre class="mod-pre rounded">function <span>'.__FUNCTION__.'( '.''.' );</span> filename: <span>'.basename(__FILE__).'</span> line: '.__LINE__.' -> <br />';
|
20
|
print_r( $aFilesInDir ); print '</pre>'; flush (); // ob_flush();;sleep(10); die();
|
21
|
*/
|
22
|
/* -------------------------------------------------------- */
|
23
|
// Must include code to stop this file being accessed directly
|
24
|
if(defined('WB_PATH') == false) { die('Cannot access '.basename(__DIR__).'/'.basename(__FILE__).' directly'); }
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
$sOverviewDroplets = $oTrans->TEXT_LIST_OPTIONS;
|
28
|
|
29
|
// suppress to print the header, so no new FTAN will be set
|
30
|
//$oApp = new admin('Addons', 'templates_uninstall', false);
|
31
|
if( !$oApp->checkFTAN() ){
|
32
|
$oApp->print_error($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $ToolUrl );
|
33
|
exit();
|
34
|
}
|
35
|
// After check print the header
|
36
|
|
37
|
if (!function_exists( 'make_dir' ) ) { require($oReg->AppPath.'/framework/functions.php'); }
|
38
|
if (!function_exists('insertDropletFile')) { require($sAddonPath.'/droplets.functions.php'); }
|
39
|
//$oApp->print_header();
|
40
|
// create backup filename with pre index
|
41
|
$sBackupDir = $sAddonRel.'/data/archiv/';
|
42
|
make_dir( $oReg->AppPath.$sBackupDir );
|
43
|
|
44
|
$sDropletTmpDir = $sAddonRel.'/data/tmp/';
|
45
|
$sDropletTmpDir = 'temp/modules/'.$sAddonName.'/tmp/';
|
46
|
rm_full_dir($oReg->AppPath.$sDropletTmpDir, true);
|
47
|
make_dir( $oReg->AppPath.$sDropletTmpDir );
|
48
|
|
49
|
$sTimeStamp = '_'.strftime('%Y%m%d_%H%M%S', time() + $oReg->Timezone ).'.zip';
|
50
|
|
51
|
$FilesInDB = '*';
|
52
|
$aFullList = glob($sAddonPath.'/data/archiv/*.zip', GLOB_NOSORT);
|
53
|
|
54
|
if( isset( $aRequestVars['cb'] ) && sizeof( $aRequestVars['cb']) == 1 ) {
|
55
|
$FilesInDB = '';
|
56
|
foreach( $aRequestVars['cb'] as $FileName ) {
|
57
|
$sSearchFor = $FileName;
|
58
|
$FilesInDB .= '\''.$FileName.'\'';
|
59
|
}
|
60
|
$sBackupName = 'Droplet_'.$FileName.$sTimeStamp;
|
61
|
} elseif( isset( $aRequestVars['cb'] ) && sizeof( $aRequestVars['cb'] > 1 ) ) {
|
62
|
$FilesInDB = '';
|
63
|
foreach( $aRequestVars['cb'] as $FileName ) {
|
64
|
$sSearchFor = $FileName;
|
65
|
$FilesInDB .= '\''.$FileName.'\',';
|
66
|
}
|
67
|
$sBackupName = 'DropletsBackup'.$sTimeStamp;
|
68
|
} else {
|
69
|
$sSearchFor = 'DropletsFullBackup';
|
70
|
$sBackupName = 'DropletsFullBackup'.$sTimeStamp;
|
71
|
}
|
72
|
|
73
|
$aFilesInDir = array();
|
74
|
foreach ($aFullList as $index =>$sItem) {
|
75
|
if (preg_match('/[0-9]+_('.$sSearchFor.'_[^\.]*?)\.zip/si', $sItem, $aMatch)) {
|
76
|
$aFilesInDir[$index+1] = $aMatch[1];
|
77
|
}
|
78
|
}
|
79
|
|
80
|
unset($aFullList);
|
81
|
|
82
|
$sZipFile = $sBackupDir.$sBackupName;
|
83
|
if( !class_exists('PclZip',false) ) { require( $oReg->AppPath.'/include/pclzip/pclzip.lib.php'); }
|
84
|
$aFilesToZip = backupDropletFromDatabase( $oReg->AppPath.$sDropletTmpDir, $FilesInDB, $oDb );
|
85
|
|
86
|
$oArchive = new PclZip( $oReg->AppPath.$sZipFile );
|
87
|
$archiveList = $oArchive->create(
|
88
|
$aFilesToZip
|
89
|
,PCLZIP_OPT_REMOVE_ALL_PATH
|
90
|
);
|
91
|
if ($archiveList == 0){
|
92
|
echo 'Packaging error: '.$oArchive->errorInfo(true);
|
93
|
msgQueue::add("Error : ".$oArchive->errorInfo(true));
|
94
|
} elseif(is_readable($oReg->AppPath.$sBackupDir)) {
|
95
|
?>
|
96
|
|
97
|
<header class="droplets"><h4 >Create archive: <?php echo basename($sZipFile); ?></h4></header>
|
98
|
|
99
|
<section class="droplets drop-outer">
|
100
|
<ol>
|
101
|
<?php
|
102
|
foreach($archiveList AS $key=>$aDroplet ) {
|
103
|
?>
|
104
|
<li>Backup <strong> <?php echo $aDroplet['stored_filename']; ?></strong></li>
|
105
|
<?php } ?>
|
106
|
|
107
|
</ol>
|
108
|
<div class="drop-backup">
|
109
|
<h2>Backup created - <a class="btn" href="<?php echo $oReg->AppUrl.$sBackupDir.$sBackupName; ?>"><?php echo $Droplet_Message['GENERIC_LOCAL_DOWNLOAD']; ?></a>
|
110
|
<button style="padding: 0.2825em 0.8525em; " name="cancel" class="btn" type="button" onclick="window.location='<?php echo $ToolUrl; ?>';"><?php echo $TEXT['CANCEL']; ?></button>
|
111
|
|
112
|
</h2>
|
113
|
</div>
|
114
|
</section>
|
115
|
<?php } else {
|
116
|
msgQueue::add('Backup not created - '.$oTrans->TEXT_BACK.'');
|
117
|
}
|
118
|
|