function urename($from_path, $to_path) { ForceDirectories($to_path); $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)) { urename($from_path . $file . "/", $to_path . $file . "/"); chdir($from_path); } if (is_file($file)) { rename($from_path . $file, $to_path . $file); chmod($to_path . $file, isset($config['folder_rights']) ? $config['folder_rights'] : 0644); } } } closedir($handle); } else { rename($from_path, $to_path); } $res = rmdir($from_path); @rmdir(dirname($from_path)); return $res; }
function urename($pathfrom, $pathto) { // определение настроек места $ext = $this->getDirExtension($pathfrom); $pathfrom_dec = my_convert_cyr_string($pathfrom, "w", $ext["encoding"]); return urename($pathfrom_dec, $pathto); }
while (false !== ($file = readdir($handle))) { $extension = pathinfo($file, PATHINFO_EXTENSION); if (!is_dir($mypath_dec . "/" . $file) && $file != "." && $file != ".." && in_array($extension, $includeExtensions)) { $md5 = $config['md5'] ? md5_file($mypath_dec . "/" . $file) : ""; $fs = $storages->getFileSize($mypath_dec . "/" . $file, false); $fpath = $movefile ? $mystorage . $directory . $suffix . "/" . $file : $mypath_dec . "/" . $file; $fpath = $storages->encode_path($fpath); $path_parts = pathinfo($fpath); $name = $path_parts["basename"]; $sql = "INSERT INTO files(FilmID,Name,MD5,Path,Size) VALUES({$filmid},'" . addslashes($name) . "','{$md5}','" . addslashes($fpath) . "',{$fs})"; $result = mysql_query($sql); } } closedir($handle); if ($movefile) { if (!urename($mypath_dec . "/", $mystorage . $directory . $suffix . "/")) { //файлы не скопировались } else { $_RESULT["ok"] = 1; } } else { $_RESULT["ok"] = 1; } } else { mysql_query("UPDATE films SET AsDir={$movefile} WHERE ID={$filmid}"); $multipath = preg_split("/(\r\n|\r|\n)/", $field["Path"]); if ($movefile) { @mkdir($mystorage . $directory . $suffix, 0775); } foreach ($multipath as $mypath) { $mypath_dec = $storages->decode_path($mypath);