php ROOT home ss function backup from to dirs scandir from foreach dir

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$ROOT = 'Z:/home/ss';
function backup($from , $to){
$dirs = scandir($from);
foreach($dirs as &$dir){
if($dir == '.' || $dir == '..')
continue;
$file = $from . '/' . $dir;
if( is_dir($file)){
@mkdir($to . '/' . $dir);
backup($file, $to . '/' . $dir);
continue;
} else {
copy($file, $to . '/' . $dir);
}
}
}
$BKDIR = $ROOT . '/BK';
if(!is_dir( $BKDIR )) @mkdir( $BKDIR );
$BKDIR = $BKDIR . '/' . date('d M Y');
if(!is_dir( $BKDIR )) @mkdir( $BKDIR );
@mkdir(($DEST = $BKDIR . '/' . date('H.i.s') . ($_GET['q'] ? ' (' . $_GET['q'] . ')' : '')));
backup($ROOT . '/www', $DEST);