function recurse_move($src, $dst, $newuid) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_move($src . '/' . $file,$dst . '/' . $file, $uid);
}
else {
$from = $src . "/" . $file;
$to = $dst . "/" . $file;
$path = $from;
$newpath = $to;
$fileid = basename(readlink($from));
rename($src . '/' . $file,$dst . '/' . $file);
$db = new Db4();
$db->open(null, DB_DIR . "/file.db", "file");
$data = $db->get($fileid);
if (!empty($data)) {
$xml = simplexml_load_string($data);
$infos = $xml->xpath("/infos/info[@path='$path']");
$info = $infos[0];
$info["path"] = $newpath;
$info["uid"] = $newuid;
$db->put($fileid, $xml->asXML());
} else {}
$db->close();
}
}
}
closedir($dir);
rmdir($src);
}
Title:
recursive move dir
Description:
function recurse_move($src, $dst, $newuid) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { ...
...
Rating:
4