Skip to content

Commit 9d3891c

Browse files
authored
folder get removed first then add backup files
1 parent 3cdb7e9 commit 9d3891c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

ces_module_backup.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@
22
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
33
class Copy {
44

5+
function rrmdir($dir)
6+
{
7+
if (is_dir($dir))
8+
{
9+
$objects = scandir($dir);
10+
11+
foreach ($objects as $object)
12+
{
13+
if ($object != '.' && $object != '..')
14+
{
15+
if (filetype($dir.'/'.$object) == 'dir') {$this->rrmdir($dir.'/'.$object);}
16+
else {unlink($dir.'/'.$object);}
17+
}
18+
}
19+
20+
reset($objects);
21+
rmdir($dir);
22+
}
23+
}
24+
525
function recursive_copy($src, $dst) {
626
if(is_dir($src)) {
727
$dir = opendir($src);
8-
928
mkdir($dst, 0777, true);
1029

1130
while(( $file = readdir($dir)) ) {
@@ -51,8 +70,10 @@ function recursive_copy($src, $dst) {
5170

5271
$fix_dst = isset($json['default_copy_path']) ? $current_path . $json['default_copy_path'] . '/' : $current_path;
5372

54-
include_once $current_path . $json['default_path'] . '/admin/config.php';
55-
include_once $current_path . $json['default_path'] . '/config.php';
73+
@$copy->rrmdir($fix_dst . $folder);
74+
75+
@require_once $current_path . $json['default_path'] . '/admin/config.php';
76+
@require_once $current_path . $json['default_path'] . '/config.php';
5677

5778
foreach ($json['all_files'] as $key => $folder) {
5879
$copy->recursive_copy($current_path . $json['default_path'] . '/' . $folder, $fix_dst . $folder);

0 commit comments

Comments
 (0)