1 |
1457
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category module
|
5 |
|
|
* @package droplet
|
6 |
1684
|
Luisehahne
|
* @author Ruud Eisinga (Ruud) John (PCWacht), WebsiteBaker Project
|
7 |
1916
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1457
|
Luisehahne
|
* @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$
|
13 |
1916
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1457
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
1684
|
Luisehahne
|
|
19 |
|
|
|
20 |
1457
|
Luisehahne
|
// tool_edit.php
|
21 |
|
|
require_once('../../config.php');
|
22 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
23 |
1916
|
Luisehahne
|
if(!function_exists('insertDropletFile')) { require('droplets.functions.php'); }
|
24 |
1457
|
Luisehahne
|
|
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 |
1503
|
Luisehahne
|
$sOverviewDroplets = $TEXT['LIST_OPTIONS'];
|
31 |
1457
|
Luisehahne
|
|
32 |
|
|
// protect from CSRF
|
33 |
1503
|
Luisehahne
|
$id = intval($admin->checkIDKEY('id', false, 'GET'));
|
34 |
1457
|
Luisehahne
|
if (!$id or $id != 999) {
|
35 |
1473
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link);
|
36 |
1457
|
Luisehahne
|
}
|
37 |
|
|
|
38 |
|
|
?>
|
39 |
1741
|
Luisehahne
|
<div class="droplets" style="margin-top: 6px;">
|
40 |
1457
|
Luisehahne
|
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
|
41 |
1503
|
Luisehahne
|
<a href="<?php echo $admintool_link;?>" title="<?php echo $HEADING['ADMINISTRATION_TOOLS']; ?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
|
42 |
1741
|
Luisehahne
|
<span> » </span>
|
43 |
|
|
<a href="<?php echo $module_edit_link;?>" title="<?php echo $sOverviewDroplets ?>" alt="<?php echo $sOverviewDroplets ?>">Droplet Overview</a>
|
44 |
1457
|
Luisehahne
|
</h4>
|
45 |
|
|
<?php
|
46 |
|
|
|
47 |
1676
|
Luisehahne
|
$OK = ' <span style="color:#006400; font-weight:bold;">OK</span> ';
|
48 |
|
|
$FAIL = ' <span style="color:#ff0000; font-weight:bold;">FAILED</span> ';
|
49 |
1684
|
Luisehahne
|
$sBackupName = strftime('%Y%m%d_%H%M%S', time()+ TIMEZONE ).'_droplets.zip';
|
50 |
1916
|
Luisehahne
|
$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 |
1457
|
Luisehahne
|
}
|
56 |
1676
|
Luisehahne
|
|
57 |
1916
|
Luisehahne
|
$msg = createFolderProtectFile(rtrim( WB_PATH.$tempDir,'/') );
|
58 |
1676
|
Luisehahne
|
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 |
1916
|
Luisehahne
|
$sFilesToZip = backupDropletFromDatabase(WB_PATH.$tempDir);
|
64 |
|
|
// remove last comma
|
65 |
1676
|
Luisehahne
|
$sFilesToZip = rtrim($sFilesToZip,',');
|
66 |
|
|
|
67 |
1684
|
Luisehahne
|
echo '<br />Create archive: <strong>'.$sBackupName.'</strong><br />';
|
68 |
1457
|
Luisehahne
|
|
69 |
1916
|
Luisehahne
|
if( !class_exists('PclZip',false) ) { require(WB_PATH.'/include/pclzip/pclzip.lib.php'); }
|
70 |
|
|
$archive = new PclZip(WB_PATH.$tempFile);
|
71 |
1676
|
Luisehahne
|
|
72 |
1916
|
Luisehahne
|
$archiveList = $archive->create($sFilesToZip , PCLZIP_OPT_REMOVE_ALL_PATH );
|
73 |
|
|
|
74 |
|
|
if ($archiveList == 0){
|
75 |
1457
|
Luisehahne
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
76 |
|
|
die("Error : ".$archive->errorInfo(true));
|
77 |
|
|
}
|
78 |
1916
|
Luisehahne
|
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 |
1457
|
Luisehahne
|
}
|
85 |
1676
|
Luisehahne
|
else {
|
86 |
|
|
echo '<br /><br />Backup not created - <a href="'.$module_edit_link.'">'.$TEXT['BACK'].'</a>';
|
87 |
1457
|
Luisehahne
|
}
|
88 |
1741
|
Luisehahne
|
echo '</div>';
|
89 |
1503
|
Luisehahne
|
$admin->print_footer();
|