1 |
989
|
aldus
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
* @version 1.0
|
4 |
|
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
5 |
|
|
* @date June 2009
|
6 |
|
|
*
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
// tool_edit.php
|
10 |
|
|
require_once('../../config.php');
|
11 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
12 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
13 |
|
|
// create admin object depending on platform (admin tools were moved out of settings with WB 2.7)
|
14 |
|
|
$admin = new admin('admintools', 'admintools');
|
15 |
|
|
$admintool_link = ADMIN_URL .'/admintools/index.php';
|
16 |
|
|
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
|
17 |
|
|
$template_edit_link = ADMIN_URL .'/admintools/tool.php?tool=templateedit';
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
?>
|
21 |
|
|
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
|
22 |
|
|
<a href="<?php echo $admintool_link;?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
|
23 |
|
|
->
|
24 |
|
|
<a href="<?php echo $module_edit_link;?>">Droplets</a>
|
25 |
|
|
</h4>
|
26 |
|
|
<?php
|
27 |
|
|
|
28 |
|
|
$temp_dir = WB_PATH.'/temp/droplets/';
|
29 |
|
|
$temp_file = '/modules/droplets/backup-droplets.zip';
|
30 |
|
|
// make the temporary working directory
|
31 |
|
|
mkdir($temp_dir);
|
32 |
|
|
$query_droplets = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_droplets ORDER BY modified_when DESC");
|
33 |
|
|
while($droplet = $query_droplets->fetchRow()) {
|
34 |
|
|
echo 'Saving: '.$droplet["name"].'.php<br />';
|
35 |
|
|
$sFile = $temp_dir.$droplet["name"].'.php';
|
36 |
|
|
$fh = fopen($sFile, 'w') ;
|
37 |
|
|
fwrite($fh, '//:'.$droplet['description']."\n");
|
38 |
|
|
fwrite($fh, '//:'.str_replace("\n"," ",$droplet['comments'])."\n");
|
39 |
|
|
fwrite($fh, $droplet['code']);
|
40 |
|
|
fclose($fh);
|
41 |
|
|
}
|
42 |
|
|
echo '<br />Create archive: backup-droplets.zip<br />';
|
43 |
|
|
|
44 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
45 |
|
|
$archive = new PclZip(WB_PATH.$temp_file);
|
46 |
|
|
$file_list = $archive->create($temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
|
47 |
|
|
if ($file_list == 0){
|
48 |
|
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
49 |
|
|
die("Error : ".$archive->errorInfo(true));
|
50 |
|
|
}
|
51 |
|
|
else {
|
52 |
|
|
echo '<br /><br />Backup created - <a href="'.WB_URL.$temp_file.'">Download</a>';
|
53 |
|
|
}
|
54 |
|
|
delete_directory ( $temp_dir );
|
55 |
|
|
$admin->print_footer();
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
function delete_directory($dirname) {
|
59 |
|
|
if (is_dir($dirname))
|
60 |
|
|
$dir_handle = opendir($dirname);
|
61 |
|
|
if (!$dir_handle)
|
62 |
|
|
return false;
|
63 |
|
|
while($file = readdir($dir_handle)) {
|
64 |
|
|
if ($file != "." && $file != "..") {
|
65 |
|
|
if (!is_dir($dirname."/".$file))
|
66 |
|
|
unlink($dirname."/".$file);
|
67 |
|
|
else
|
68 |
|
|
delete_directory($dirname.'/'.$file);
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
closedir($dir_handle);
|
72 |
|
|
rmdir($dirname);
|
73 |
|
|
return true;
|
74 |
|
|
}
|
75 |
|
|
?>
|