1 |
1457
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category module
|
5 |
|
|
* @package droplet
|
6 |
1684
|
Luisehahne
|
* @author Ruud Eisinga (Ruud) John (PCWacht), WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2012, 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 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @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 |
|
|
|
24 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
25 |
|
|
// create admin object depending on platform (admin tools were moved out of settings with WB 2.7)
|
26 |
|
|
$admin = new admin('admintools', 'admintools');
|
27 |
|
|
$admintool_link = ADMIN_URL .'/admintools/index.php';
|
28 |
|
|
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
|
29 |
1503
|
Luisehahne
|
$sOverviewDroplets = $TEXT['LIST_OPTIONS'];
|
30 |
1457
|
Luisehahne
|
|
31 |
|
|
// protect from CSRF
|
32 |
1503
|
Luisehahne
|
$id = intval($admin->checkIDKEY('id', false, 'GET'));
|
33 |
1457
|
Luisehahne
|
if (!$id or $id != 999) {
|
34 |
1473
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link);
|
35 |
1457
|
Luisehahne
|
}
|
36 |
|
|
|
37 |
|
|
?>
|
38 |
1741
|
Luisehahne
|
<div class="droplets" style="margin-top: 6px;">
|
39 |
1457
|
Luisehahne
|
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
|
40 |
1503
|
Luisehahne
|
<a href="<?php echo $admintool_link;?>" title="<?php echo $HEADING['ADMINISTRATION_TOOLS']; ?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
|
41 |
1741
|
Luisehahne
|
<span> » </span>
|
42 |
|
|
<a href="<?php echo $module_edit_link;?>" title="<?php echo $sOverviewDroplets ?>" alt="<?php echo $sOverviewDroplets ?>">Droplet Overview</a>
|
43 |
1457
|
Luisehahne
|
</h4>
|
44 |
|
|
<?php
|
45 |
|
|
|
46 |
1676
|
Luisehahne
|
$OK = ' <span style="color:#006400; font-weight:bold;">OK</span> ';
|
47 |
|
|
$FAIL = ' <span style="color:#ff0000; font-weight:bold;">FAILED</span> ';
|
48 |
1684
|
Luisehahne
|
$sBackupName = strftime('%Y%m%d_%H%M%S', time()+ TIMEZONE ).'_droplets.zip';
|
49 |
1676
|
Luisehahne
|
$temp_dir = '/temp/droplets/';
|
50 |
1684
|
Luisehahne
|
$temp_file = $temp_dir.$sBackupName;
|
51 |
1676
|
Luisehahne
|
|
52 |
|
|
if(is_writeable(dirname(WB_PATH.$temp_dir))) {
|
53 |
|
|
rm_full_dir ( WB_PATH.$temp_dir );
|
54 |
1457
|
Luisehahne
|
}
|
55 |
1676
|
Luisehahne
|
|
56 |
1684
|
Luisehahne
|
/*
|
57 |
|
|
// make the temporary working directory
|
58 |
|
|
if(!make_dir(WB_PATH.$temp_dir, octdec('0777') )){
|
59 |
|
|
// $admin->print_error($MESSAGE['MEDIA_DIR_NOT_MADE'], $module_edit_link);
|
60 |
|
|
}
|
61 |
|
|
*/
|
62 |
|
|
|
63 |
1676
|
Luisehahne
|
$msg = createFolderProtectFile(rtrim( WB_PATH.$temp_dir,'/') );
|
64 |
|
|
if(sizeof($msg)) {
|
65 |
|
|
print '<h4 class="warning">';
|
66 |
|
|
echo implode('<br />',$msg).'<br />'.$MESSAGE['MEDIA_DIR_NOT_MADE'].'<br />';
|
67 |
|
|
print '</h4>';
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
$sFilesToZip = '';
|
71 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
72 |
|
|
$sql .= 'ORDER BY `modified_when` DESC';
|
73 |
|
|
|
74 |
|
|
$query_droplets = $database->query($sql);
|
75 |
|
|
while($droplet = $query_droplets->fetchRow()) {
|
76 |
1738
|
Luisehahne
|
echo 'Saving: '.$droplet["name"].'.php';
|
77 |
1676
|
Luisehahne
|
$sFile = $droplet["name"].'.php';
|
78 |
|
|
if($fh = fopen(WB_PATH.$temp_dir.$sFile, 'w'))
|
79 |
|
|
{
|
80 |
|
|
fwrite($fh, '//:'.$droplet['description']."\n");
|
81 |
|
|
fwrite($fh, '//:'.str_replace("\n"," ",$droplet['comments'])."\n");
|
82 |
|
|
fwrite($fh, $droplet['code']);
|
83 |
|
|
fclose($fh);
|
84 |
|
|
echo " $OK<br />";
|
85 |
|
|
} else {
|
86 |
|
|
echo " $FAIL<br />"; }
|
87 |
|
|
$sFilesToZip .= WB_PATH.$temp_dir.$sFile.',';
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
$sFilesToZip = rtrim($sFilesToZip,',');
|
91 |
|
|
|
92 |
1684
|
Luisehahne
|
echo '<br />Create archive: <strong>'.$sBackupName.'</strong><br />';
|
93 |
1457
|
Luisehahne
|
|
94 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
95 |
|
|
$archive = new PclZip(WB_PATH.$temp_file);
|
96 |
1676
|
Luisehahne
|
|
97 |
1738
|
Luisehahne
|
$file_list = $archive->create($sFilesToZip , PCLZIP_OPT_REMOVE_ALL_PATH );
|
98 |
1457
|
Luisehahne
|
if ($file_list == 0){
|
99 |
|
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
100 |
|
|
die("Error : ".$archive->errorInfo(true));
|
101 |
|
|
}
|
102 |
1676
|
Luisehahne
|
elseif(is_readable(WB_PATH.$temp_file)) {
|
103 |
1457
|
Luisehahne
|
echo '<br /><br />Backup created - <a href="'.WB_URL.$temp_file.'">Download</a>';
|
104 |
|
|
}
|
105 |
1676
|
Luisehahne
|
else {
|
106 |
|
|
echo '<br /><br />Backup not created - <a href="'.$module_edit_link.'">'.$TEXT['BACK'].'</a>';
|
107 |
1457
|
Luisehahne
|
}
|
108 |
1741
|
Luisehahne
|
echo '</div>';
|
109 |
1503
|
Luisehahne
|
$admin->print_footer();
|