1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht), WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: backup_droplets.php 1916 2013-06-07 04:06:48Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/backup_droplets.php $
|
14
|
* @lastmodified $Date: 2013-06-07 06:06:48 +0200 (Fri, 07 Jun 2013) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
|
19
|
|
20
|
// tool_edit.php
|
21
|
require_once('../../config.php');
|
22
|
require_once(WB_PATH.'/framework/class.admin.php');
|
23
|
if(!function_exists('insertDropletFile')) { require('droplets.functions.php'); }
|
24
|
|
25
|
require_once(WB_PATH.'/framework/functions.php');
|
26
|
// create admin object depending on platform (admin tools were moved out of settings with WB 2.7)
|
27
|
$admin = new admin('admintools', 'admintools');
|
28
|
$admintool_link = ADMIN_URL .'/admintools/index.php';
|
29
|
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
|
30
|
$sOverviewDroplets = $TEXT['LIST_OPTIONS'];
|
31
|
|
32
|
// protect from CSRF
|
33
|
$id = intval($admin->checkIDKEY('id', false, 'GET'));
|
34
|
if (!$id or $id != 999) {
|
35
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link);
|
36
|
}
|
37
|
|
38
|
?>
|
39
|
<div class="droplets" style="margin-top: 6px;">
|
40
|
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
|
41
|
<a href="<?php echo $admintool_link;?>" title="<?php echo $HEADING['ADMINISTRATION_TOOLS']; ?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
|
42
|
<span> » </span>
|
43
|
<a href="<?php echo $module_edit_link;?>" title="<?php echo $sOverviewDroplets ?>" alt="<?php echo $sOverviewDroplets ?>">Droplet Overview</a>
|
44
|
</h4>
|
45
|
<?php
|
46
|
|
47
|
$OK = ' <span style="color:#006400; font-weight:bold;">OK</span> ';
|
48
|
$FAIL = ' <span style="color:#ff0000; font-weight:bold;">FAILED</span> ';
|
49
|
$sBackupName = strftime('%Y%m%d_%H%M%S', time()+ TIMEZONE ).'_droplets.zip';
|
50
|
$tempDir = '/temp/droplets/';
|
51
|
$tempFile = $tempDir.$sBackupName;
|
52
|
// delete old backup
|
53
|
if(is_writeable(dirname(WB_PATH.$tempDir))) {
|
54
|
rm_full_dir ( WB_PATH.$tempDir );
|
55
|
}
|
56
|
|
57
|
$msg = createFolderProtectFile(rtrim( WB_PATH.$tempDir,'/') );
|
58
|
if(sizeof($msg)) {
|
59
|
print '<h4 class="warning">';
|
60
|
echo implode('<br />',$msg).'<br />'.$MESSAGE['MEDIA_DIR_NOT_MADE'].'<br />';
|
61
|
print '</h4>';
|
62
|
}
|
63
|
$sFilesToZip = backupDropletFromDatabase(WB_PATH.$tempDir);
|
64
|
// remove last comma
|
65
|
$sFilesToZip = rtrim($sFilesToZip,',');
|
66
|
|
67
|
echo '<br />Create archive: <strong>'.$sBackupName.'</strong><br />';
|
68
|
|
69
|
if( !class_exists('PclZip',false) ) { require(WB_PATH.'/include/pclzip/pclzip.lib.php'); }
|
70
|
$archive = new PclZip(WB_PATH.$tempFile);
|
71
|
|
72
|
$archiveList = $archive->create($sFilesToZip , PCLZIP_OPT_REMOVE_ALL_PATH );
|
73
|
|
74
|
if ($archiveList == 0){
|
75
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
76
|
die("Error : ".$archive->errorInfo(true));
|
77
|
}
|
78
|
elseif(is_readable(WB_PATH.$tempFile)) {
|
79
|
echo '<br /><ol>';
|
80
|
foreach($archiveList AS $key=>$aDroplet ) {
|
81
|
echo '<li>Backup <strong> '.$aDroplet['stored_filename'].'</strong></li>';
|
82
|
}
|
83
|
echo '</ol><br /><br />Backup created - <a href="'.WB_URL.$tempFile.'">Download</a>';
|
84
|
}
|
85
|
else {
|
86
|
echo '<br /><br />Backup not created - <a href="'.$module_edit_link.'">'.$TEXT['BACK'].'</a>';
|
87
|
}
|
88
|
echo '</div>';
|
89
|
$admin->print_footer();
|