Ejemplo n.º 1
0
     $stat = $fs->stat($filename);
     $stat['size'] = $fs->formatSize($filename) . 'b';
     $_RESULT['file_info'] = $stat;
     break;
 case 'create_dir':
     if (!isset($_REQUEST['dirname']) || !$_REQUEST['dirname']) {
         throw new sjException($_SYSTEM['i18n']->__('Unable to process request'));
     }
     $dirname = trim($_REQUEST['dirname']);
     if (preg_match('/[\\/:*?<>|\'"]+/', $dirname)) {
         throw new sjException($_SYSTEM['i18n']->__('File name can not contains following symmbols: \\/:*?<>|"\''));
     }
     if (is_dir($path . $dirname)) {
         throw new sjException($_SYSTEM['i18n']->__('Unable to create folder. Folder with this name already exists'));
     }
     if (!$fs->mkdirs($path . $dirname)) {
         throw new sjException($_SYSTEM['i18n']->__('Unable to create folder. Permissions denied'));
     }
     break;
 case 'rename':
     if (!$has_files || !isset($_REQUEST['fileNames']) || empty($_REQUEST['fileNames'])) {
         throw new sjException($_SYSTEM['i18n']->__('Unable to process request'));
     }
     $newFileName = $fs->prepareFilename(reset($_REQUEST['fileNames']));
     $newFileExt = $fs->getPathInfo($newFileName, PATHINFO_EXTENSION);
     if ($newFileExt && !empty($sjConfig['uploader']['allowed_types']) && !in_array($newFileExt, $sjConfig['uploader']['allowed_types'])) {
         throw new sjException($_SYSTEM['i18n']->__('Files with extension "%s" does not allowed', $newFileExt));
     }
     $oldFile = reset($files);
     $dirname = dirname($oldFile);
     $fs->rename($oldFile, $dirname . DIRECTORY_SEPARATOR . $newFileName);