1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category module
|
5
|
* @package droplet
|
6
|
* @author Ruud Eisinga (Ruud) John (PCWacht)
|
7
|
* @author WebsiteBaker Project
|
8
|
* @copyright 2004-2009, Ryan Djurovich
|
9
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
10
|
* @link http://www.websitebaker2.org/
|
11
|
* @license http://www.gnu.org/licenses/gpl.html
|
12
|
* @platform WebsiteBaker 2.8.x
|
13
|
* @requirements PHP 5.2.2 and higher
|
14
|
* @version $Id: backup_droplets.php 1349 2010-12-19 19:04:59Z Luisehahne $
|
15
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/backup_droplets.php $
|
16
|
* @lastmodified $Date: 2010-12-19 20:04:59 +0100 (Sun, 19 Dec 2010) $
|
17
|
*
|
18
|
*/
|
19
|
|
20
|
// tool_edit.php
|
21
|
require_once('../../config.php');
|
22
|
require_once(WB_PATH.'/framework/class.admin.php');
|
23
|
require_once(WB_PATH.'/framework/functions.php');
|
24
|
// create admin object depending on platform (admin tools were moved out of settings with WB 2.7)
|
25
|
$admin = new admin('admintools', 'admintools');
|
26
|
$admintool_link = ADMIN_URL .'/admintools/index.php';
|
27
|
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
|
28
|
$template_edit_link = ADMIN_URL .'/admintools/tool.php?tool=templateedit';
|
29
|
|
30
|
|
31
|
?>
|
32
|
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
|
33
|
<a href="<?php echo $admintool_link;?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
|
34
|
->
|
35
|
<a href="<?php echo $module_edit_link;?>">Droplets</a>
|
36
|
</h4>
|
37
|
<?php
|
38
|
|
39
|
$temp_dir = WB_PATH.'/temp/droplets/';
|
40
|
$temp_file = '/modules/droplets/backup-droplets.zip';
|
41
|
// make the temporary working directory
|
42
|
mkdir($temp_dir);
|
43
|
$query_droplets = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_droplets ORDER BY modified_when DESC");
|
44
|
while($droplet = $query_droplets->fetchRow()) {
|
45
|
echo 'Saving: '.$droplet["name"].'.php<br />';
|
46
|
$sFile = $temp_dir.$droplet["name"].'.php';
|
47
|
$fh = fopen($sFile, 'w') ;
|
48
|
fwrite($fh, '//:'.$droplet['description']."\n");
|
49
|
fwrite($fh, '//:'.str_replace("\n"," ",$droplet['comments'])."\n");
|
50
|
fwrite($fh, $droplet['code']);
|
51
|
fclose($fh);
|
52
|
}
|
53
|
echo '<br />Create archive: backup-droplets.zip<br />';
|
54
|
|
55
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
56
|
$archive = new PclZip(WB_PATH.$temp_file);
|
57
|
$file_list = $archive->create($temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
|
58
|
if ($file_list == 0){
|
59
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
60
|
die("Error : ".$archive->errorInfo(true));
|
61
|
}
|
62
|
else {
|
63
|
echo '<br /><br />Backup created - <a href="'.WB_URL.$temp_file.'">Download</a>';
|
64
|
}
|
65
|
delete_directory ( $temp_dir );
|
66
|
$admin->print_footer();
|
67
|
|
68
|
|
69
|
function delete_directory($dirname) {
|
70
|
if (is_dir($dirname))
|
71
|
$dir_handle = opendir($dirname);
|
72
|
if (!$dir_handle)
|
73
|
return false;
|
74
|
while($file = readdir($dir_handle)) {
|
75
|
if ($file != "." && $file != "..") {
|
76
|
if (!is_dir($dirname."/".$file))
|
77
|
unlink($dirname."/".$file);
|
78
|
else
|
79
|
delete_directory($dirname.'/'.$file);
|
80
|
}
|
81
|
}
|
82
|
closedir($dir_handle);
|
83
|
rmdir($dirname);
|
84
|
return true;
|
85
|
}
|
86
|
?>
|