Exemplo n.º 1
0
function grabFiles($parentPath)
{
    $directory = array_diff(scandir($parentPath), array('..', '.'));
    $leftNode[] = NULL;
    foreach ($directory as $child) {
        if (!is_dir($parentPath . $child)) {
            generateInsert($parentPath . $child);
        } else {
            generateDirInsert($parentPath . $child . '/');
            array_push($leftNode, $child);
        }
    }
    foreach ($leftNode as $dir) {
        if ($dir != NULL) {
            grabFiles($parentPath . $dir . '/');
        }
    }
}
Exemplo n.º 2
0
function grabFiles($url)
{
    $dh = fsockopen($url, 80);
    while ($fileName = readdir($dh)) {
        if (is_dir($url . $fileName)) {
            grabFiles($url . $fileName);
        }
        $fh = sugar_fopen($url . $fileName, "r");
        $fileContent = fread($fh, filesize($url . $fileName));
        $writeFile = "./{$fileName}";
        $fhLocal = sugar_fopen($writeFile, "w");
        fwrite($writeFile, $fileContent);
    }
}