function rec_copy($to_path, $from_path) { //Sanitize input so ../ isn't allowed (Bug #933) $to_path = str_replace('../', '', $to_path); //Continue with the copying! mkdir($to_path, 0777); $this_path = getcwd(); if (is_dir($from_path)) { chdir($from_path); $handle = opendir('.'); while (($file = readdir($handle)) !== false) { if ($file != "." && $file != "..") { if (is_dir($file)) { rec_copy($to_path . $file . "/", $from_path . $file . "/"); chdir($from_path); } if (is_file($file)) { copy($from_path . $file, $to_path . $file); } } } closedir($handle); } }
function rec_copy($from_path, $to_path) { if ($from_path == '') { trigger_error('Cannot move file', 'from_path not set', E_USER_WARNING); } if ($to_path == '') { trigger_error('Cannot move file', 'to_path not set', E_USER_WARNING); } $mk = mkdir($to_path, 0700); if (!$mk) { trigger_error('Failed creating directory: {$to_path}', E_USER_WARNING); } $this_path = getcwd(); if (is_dir($from_path)) { chdir($from_path); $handle = opendir('.'); while (($file = readdir($handle)) !== false) { if ($file != "." && $file != "..") { if (is_dir($file)) { rec_copy($from_path . $file . "/", $to_path . $file . "/"); chdir($from_path); } if (is_file($file)) { if (!(substr(rtrim($file), strlen(rtrim($file)) - 8, 4) == 'mail' || substr(rtrim($file), strlen(rtrim($file)) - 10, 5) == 'part1' || substr(rtrim($file), strlen(rtrim($file)) - 8, 4) == '.vcf')) { copy($from_path . $file, $to_path . $file); } } } } closedir($handle); } }