Exemplo n.º 1
0
function movedir($srcdir, $dstdir){
	if(file_exists($srcdir)){
	mkdir($dstdir);
	$ds = opendir($srcdir);

	while($file = readdir($ds)){
		$path = $srcdir.'/'.$file;
		$dstpath = $dstdir.'/'.$file;
		if($file !='.' && $file != '..'){

			if(is_dir($path)){
				movedir($path, $dstpath);
			}else{
				copy($path, $dstpath);
				unlink($path);

			}

		}

	}
}else{
	echo '<h3 style="color:red">文件目录不存在哦!</h3>';
}

	closedir($ds);
	return rmdir($srcdir);

}
Exemplo n.º 2
0
function moves($entrys, $dir, $path)
{
    foreach ($entrys as $e) {
        $pa = $dir . '/' . $e;
        if (isPathNotPermission(processDirectory($path . '/' . $e))) {
            /* Entry not permission */
        } else {
            if (@is_file($pa)) {
                if (!@copy($pa, $path . '/' . $e)) {
                    return false;
                }
                @unlink($pa);
            } else {
                if (@is_dir($pa)) {
                    if (!movedir($pa, $path)) {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        }
    }
    return true;
}
Exemplo n.º 3
0
/**
 * 移动文件夹
 * @param  string  $oldDir		原文件夹
 * @param  string  $targetDir	移动后的文件夹名
 * @param  boolean $overWrite	是否覆盖已有文件夹(true:覆盖已有文件夹,false:不覆盖已有文件夹)默认覆盖
 * @return boolean				移动成功返回true,否则返回false
 */
function movedir($oldDir, $targetDir, $overWrite = true)
{
    $oldDir = path_absolute($oldDir);
    $targetDir = path_absolute($targetDir);
    @clearstatcache();
    $targetDir = substr($targetDir, -1) == '/' ? $targetDir : $targetDir . '/';
    $oldDir = substr($oldDir, -1) == '/' ? $oldDir : $oldDir . '/';
    if (!is_dir($oldDir)) {
        return false;
    }
    if (!file_exists($targetDir)) {
        makedir($targetDir);
    }
    $resource = opendir($oldDir);
    if (!$resource) {
        return false;
    }
    while (($file = readdir($resource)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (!is_dir($oldDir . $file)) {
            movefile($oldDir . $file, $targetDir . $file, $overWrite);
        } else {
            movedir($oldDir . $file, $targetDir . $file, $overWrite);
        }
    }
    closedir($resource);
    @clearstatcache();
    return rmdir($oldDir);
}
Exemplo n.º 4
0
     if (empty($_POST['path'])) {
         echo 'Chưa nhập đầy đủ thông tin';
     } else {
         if ($dir == processDirectory($_POST['path'])) {
             echo 'Đường dẫn mới phải khác đường dẫn hiện tại';
         } else {
             if (!is_dir($_POST['path'])) {
                 echo 'Đường dẫn mới không tồn tại';
             } else {
                 if (isPathNotPermission(processDirectory($_POST['path']))) {
                     echo 'Bạn không thể di chuyển thư mục tới đường dẫn của File Manager';
                 } else {
                     if (isPathNotPermission(processDirectory($_POST['path'] . '/' . $name))) {
                         echo 'Bạn không thể di chuyển thư mục giống tên tới thư mục chứa thư mục của File Manager';
                     } else {
                         if (!movedir($dir . '/' . $name, processDirectory($_POST['path']))) {
                             echo 'Di chuyển thư mục thất bại';
                         } else {
                             goURL('index.php?dir=' . $dirEncode . $pages['paramater_1']);
                         }
                     }
                 }
             }
         }
     }
     echo '</div>';
 }
 echo '<div class="list">
         <span class="bull">&bull;</span><span>' . printPath($dir . '/' . $name, true) . '</span><hr/>
         <form action="folder_move.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '" method="post">
             <span class="bull">&bull;</span>Đường dẫn thư mục mới:<br/>