function recurseFiles(&$d_arr, &$ds_arr, &$f_arr, &$s_arr, &$d, &$f, &$s, &$includedFolders, $path, $mosConfig_absolute_path)
{
    $currentfullpath = $mosConfig_absolute_path . $path;
    # Open possibly available directory
    if (is_dir($currentfullpath)) {
        if ($handle = opendir($currentfullpath)) {
            while (false !== ($file = readdir($handle))) {
                # Make sure we don't push parental directories or dotfiles (unix) into the arrays
                if ($file != "." && $file != "..") {
                    if (is_dir($currentfullpath . "/" . $file)) {
                        # Create array for directories
                        $d_arr[++$d] = $currentfullpath . "/" . $file;
                        recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $includedFolders, $path . "/" . $file, $mosConfig_absolute_path);
                    } else {
                        if (in_array($currentfullpath, $includedFolders)) {
                            # Create array for files
                            $s_arr[$f] = filesize($currentfullpath . '/' . $file);
                            $f_arr[$f++] = str_replace($mosConfig_absolute_path . '/', '', $currentfullpath . '/') . $file;
                            $s += filesize($currentfullpath . '/' . $file);
                        }
                    }
                }
            }
        }
        # Wrap things up if we're in a directory
        if (is_dir($handle)) {
            closedir($handle);
        }
    }
}
Пример #2
0
function recurseFiles(&$d_arr, &$ds_arr, &$f_arr, &$s_arr, &$d, &$f, &$s, &$includedFolders, $path, $excluded = array(), $fperm = '')
{
    // ----------------------------------------------------------
    // Routine to recurse a folder structure and record the files
    // their sizes and parent folders
    // ----------------------------------------------------------
    global $mdir, $_CONFIG;
    $currentfullpath = $_CONFIG['backup_path'] . $path;
    # Open possibly available directory
    if (is_dir($currentfullpath) && !is_link($currentfullpath)) {
        if ($handle = @opendir($currentfullpath)) {
            while (false !== ($file = readdir($handle))) {
                # Make sure we don't push parental directories or dotfiles (unix) into the arrays
                if ($file != "." && $file != "..") {
                    $exc = 0;
                    $cfile = $currentfullpath . "/" . $file;
                    if (sizeof($excluded) != 0) {
                        foreach ($excluded as $key => $value) {
                            if ($value != '' && !$exc) {
                                $cfile = str_replace("//", "/", $cfile);
                                if (strstr($cfile, $value) != '' || strstr($cfile . "/", $value) != '') {
                                    $exc = 1;
                                    break;
                                }
                            }
                        }
                    }
                    if (@is_dir($cfile) && !@is_link($currentfullpath)) {
                        # Create array for directories
                        if ($fperm && !$exc) {
                            $perm = substr(sprintf('%o', fileperms($cfile)), -4);
                            fwrite($fperm, str_replace($_CONFIG['backup_path'], "", $cfile) . "|" . $perm . "\n");
                        }
                        #$d_arr[++$d] = $cfile;
                        if (!$exc) {
                            recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $includedFolders, $path . "/" . $file, $excluded, $fperm);
                        }
                    } else {
                        # Create array for files
                        if ($fperm && !$exc) {
                            $perm = substr(sprintf('%o', @fileperms($cfile)), -4);
                            #$sfile = sprintf("%.2f",get_filesize($cfile)/1024);
                            fwrite($fperm, str_replace($_CONFIG['backup_path'], "", $cfile) . "|" . $perm . "\n");
                        }
                        if (!$exc) {
                            #$s_arr[$f] = @filesize($cfile);
                            if (!$_CONFIG['mem'] && $_CONFIG['backup_refresh'] != 1) {
                                $f_arr[$f++] = $cfile;
                            } else {
                                $f++;
                            }
                            $s += @filesize($cfile);
                        }
                    }
                }
            }
        }
        # Wrap things up if we're in a directory
        #if( is_dir( $currentfullpath ) )
        @closedir($handle);
    }
}