示例#1
0
 public function action($parent)
 {
     $s = new SessionHandler($parent->app);
     $util = new Utility();
     $c = $parent->config;
     if ($_POST['sub_action'] != 'copy' && $_POST['sub_action'] != 'cut') {
         $this->error('wrong sub-action');
         return;
     }
     if (trim($_POST['path']) == '' || trim($_POST['path_thumb']) == '') {
         $this->error('no path');
         return;
     }
     $path = $c['current_path'] . $_POST['path'];
     if (is_dir($path)) {
         // can't copy/cut dirs
         if ($c['copy_cut_dirs'] === false) {
             $this->error(sprintf('You are not allowed to %s $s.', $_POST['sub_action'] == 'copy' ? 'copy' : 'cut', 'folders'));
             return;
         }
         // size over limit
         if ($c['copy_cut_max_size'] !== false && is_int($c['copy_cut_max_size'])) {
             if ($copy_cut_max_size * 1024 * 1024 < $util->foldersize($path)) {
                 $this->error(sprintf('The selected files/folders are too big to %s. Limit: %d MB/operation', $_POST['sub_action'] == 'copy' ? 'copy' : 'cut', $c['copy_cut_max_size']));
                 return;
             }
         }
         // file count over limit
         if ($copy_cut_max_count !== false && is_int($copy_cut_max_count)) {
             if ($copy_cut_max_count < filescount($path)) {
                 $this->error(sprintf('You selected too many files/folders to %s. Limit: %d files/operation', $_POST['sub_action'] == 'copy' ? 'copy' : 'cut', $c['copy_cut_max_count']));
                 return;
             }
         }
     } else {
         // can't copy/cut files
         if ($c['copy_cut_files'] === false) {
             $this->error(sprintf('You are not allowed to %s files.', $_POST['sub_action'] == 'copy' ? 'copy' : 'cut', 'files'));
             exit;
         }
     }
     $s->setClipboardPath($_POST['path']);
     $s->setClipboardPathThumb($_POST['path_thumb']);
     $s->setClipboardAction($_POST['sub_action']);
 }
示例#2
0
文件: utils.php 项目: Vatia13/funtime
function filescount($path)
{
    $total_count = 0;
    $files = scandir($path);
    $cleanPath = rtrim($path, '/') . '/';
    foreach ($files as $t) {
        if ($t != "." && $t != "..") {
            $currentFile = $cleanPath . $t;
            if (is_dir($currentFile)) {
                $size = filescount($currentFile);
                $total_count += $size;
            } else {
                $total_count += 1;
            }
        }
    }
    return $total_count;
}
示例#3
0
     if (is_dir($path)) {
         // can't copy/cut dirs
         if ($copy_cut_dirs === false) {
             response(sprintf(trans('Copy_Cut_Not_Allowed'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), trans('Folders')), 403)->send();
             exit;
         }
         // size over limit
         if ($copy_cut_max_size !== false && is_int($copy_cut_max_size)) {
             if ($copy_cut_max_size * 1024 * 1024 < foldersize($path)) {
                 response(sprintf(trans('Copy_Cut_Size_Limit'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), $copy_cut_max_size), 400)->send();
                 exit;
             }
         }
         // file count over limit
         if ($copy_cut_max_count !== false && is_int($copy_cut_max_count)) {
             if ($copy_cut_max_count < filescount($path)) {
                 response(sprintf(trans('Copy_Cut_Count_Limit'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), $copy_cut_max_count), 400)->send();
                 exit;
             }
         }
     } else {
         // can't copy/cut files
         if ($copy_cut_files === false) {
             response(sprintf(trans('Copy_Cut_Not_Allowed'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), trans('Files')), 403)->send();
             exit;
         }
     }
     $_SESSION['RF']['clipboard']['path'] = $_POST['path'];
     $_SESSION['RF']['clipboard_action'] = $_POST['sub_action'];
     break;
 case 'clear_clipboard':
示例#4
0
文件: utils.php 项目: crabstudio/app
/**
* Get number of files in a directory
*
* @param  string  $path
*
* @return  int
*/
function filescount($path, $count_hidden = true)
{
    global $hidden_folders, $hidden_files;
    $total_count = 0;
    $files = scandir($path);
    $cleanPath = rtrim($path, '/') . '/';
    foreach ($files as $t) {
        if ($t != "." && $t != "..") {
            if ($count_hidden or !(in_array($t, $hidden_folders) or in_array($t, $hidden_files))) {
                $currentFile = $cleanPath . $t;
                if (is_dir($currentFile)) {
                    $size = filescount($currentFile);
                    $total_count += $size;
                } else {
                    $total_count += 1;
                }
            }
        }
    }
    return $total_count;
}