1 |
1457
|
Luisehahne
|
<?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$
|
15 |
|
|
* @filesource $HeadURL$
|
16 |
|
|
* @lastmodified $Date$
|
17 |
|
|
*
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
|
|
// 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 |
|
|
$template_edit_link = ADMIN_URL .'/admintools/tool.php?tool=templateedit';
|
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 |
|
|
<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 |
1457
|
Luisehahne
|
->
|
42 |
1503
|
Luisehahne
|
<a href="<?php echo $module_edit_link;?>" title="<?php echo $sOverviewDroplets ?>" alt="<?php echo $sOverviewDroplets ?>">Droplet Edit</a>
|
43 |
1457
|
Luisehahne
|
</h4>
|
44 |
|
|
<?php
|
45 |
|
|
|
46 |
|
|
$temp_dir = WB_PATH.'/temp/droplets/';
|
47 |
|
|
$temp_file = '/modules/droplets/backup-droplets.zip';
|
48 |
|
|
// make the temporary working directory
|
49 |
|
|
mkdir($temp_dir);
|
50 |
1503
|
Luisehahne
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
|
51 |
|
|
$sql .= 'ORDER BY `modified_when` DESC';
|
52 |
|
|
$query_droplets = $database->query($sql);
|
53 |
1457
|
Luisehahne
|
while($droplet = $query_droplets->fetchRow()) {
|
54 |
|
|
echo 'Saving: '.$droplet["name"].'.php<br />';
|
55 |
|
|
$sFile = $temp_dir.$droplet["name"].'.php';
|
56 |
|
|
$fh = fopen($sFile, 'w') ;
|
57 |
|
|
fwrite($fh, '//:'.$droplet['description']."\n");
|
58 |
|
|
fwrite($fh, '//:'.str_replace("\n"," ",$droplet['comments'])."\n");
|
59 |
|
|
fwrite($fh, $droplet['code']);
|
60 |
|
|
fclose($fh);
|
61 |
|
|
}
|
62 |
|
|
echo '<br />Create archive: backup-droplets.zip<br />';
|
63 |
|
|
|
64 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
65 |
|
|
$archive = new PclZip(WB_PATH.$temp_file);
|
66 |
|
|
$file_list = $archive->create($temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
|
67 |
|
|
if ($file_list == 0){
|
68 |
|
|
echo "Packaging error: '.$archive->errorInfo(true).'";
|
69 |
|
|
die("Error : ".$archive->errorInfo(true));
|
70 |
|
|
}
|
71 |
|
|
else {
|
72 |
|
|
echo '<br /><br />Backup created - <a href="'.WB_URL.$temp_file.'">Download</a>';
|
73 |
|
|
}
|
74 |
1503
|
Luisehahne
|
|
75 |
1457
|
Luisehahne
|
delete_directory ( $temp_dir );
|
76 |
|
|
|
77 |
|
|
function delete_directory($dirname) {
|
78 |
|
|
if (is_dir($dirname))
|
79 |
|
|
$dir_handle = opendir($dirname);
|
80 |
|
|
if (!$dir_handle)
|
81 |
|
|
return false;
|
82 |
|
|
while($file = readdir($dir_handle)) {
|
83 |
|
|
if ($file != "." && $file != "..") {
|
84 |
|
|
if (!is_dir($dirname."/".$file))
|
85 |
|
|
unlink($dirname."/".$file);
|
86 |
|
|
else
|
87 |
|
|
delete_directory($dirname.'/'.$file);
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
closedir($dir_handle);
|
91 |
|
|
rmdir($dirname);
|
92 |
|
|
return true;
|
93 |
|
|
}
|
94 |
1503
|
Luisehahne
|
|
95 |
|
|
$admin->print_footer();
|