* @link http://aidanlister.com/repos/v/function.copyr.php * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyr($source, $dest) { $dest2=cleanID($dest); echo $source."->".$dest." ->$dest2
"; // Simple copy for a file if (is_file($source)) { return copy($source, $dest2); } // Make destination directory if (!is_dir($dest)) { mkdir($dest2); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if ($dest !== "$source/$entry") { copyr("$source/$entry", "$dest/$entry"); } } // Clean up $dir->close(); return true; } copyr("/var/www/su.urx.wiki/data/","/var/www/su.urx.wiki/datanew/"); // пути к папкам на сервере (исходный и конечный) function cleanID($id,$ascii=false){ $id = trim(urldecode($id)); $id = utf8_strtolower($id); $id = utf8_romanize($id); utf8_deaccent($id,-1); $id = preg_replace('#\'+#','_',$id); return($id); } ?>