Пример #1
0
     $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);
     break;
 case 'upload':
     if (empty($_FILES)) {
         throw new sjException($_SYSTEM['i18n']->__('Unable to process request'));
     }
     $cfgName = empty($_REQUEST['use_cfg']) ? null : $_REQUEST['use_cfg'];
     $cfg = $sjConfig['uploader'];
     if (isset($cfg['named'][$cfgName])) {
Пример #2
0
$dir = dirname(__FILE__);
$fixtures = $dir . '/../fixtures';
$files = array();
require $dir . '/../../lib/php/model/sfFilesystem.class.php';
require $dir . '/../../lib/php/model/iFilemanager.class.php';
require $dir . '/../../lib/php/model/image.class.php';
$fs = new iFilesystem();
logSection($fs->formatSize($fixtures), '->formatSize("' . realpath($fixtures) . '")');
$file = $fixtures . '/test_file_';
$fs->touch($file);
logSection(file_exists($file), 'file touched', 'create');
$files[] = $file;
$fs->chmod($file, 0777);
logSection($fs->getMode($file) == '777', 'change mode to 0777', 'create');
$fileName = 'this is "bad :file|';
$newFileName = $fs->prepareFilename($fileName);
logSection($fileName, 'change filename to "' . $newFileName . '"');
$dir = $fs->readDir($fixtures);
$count = count($dir);
logSection($count, '(not recursive) number of items in fixtures dir = ' . $count);
$dir = $fs->readDir($fixtures, 'r');
$count = count($dir);
logSection($count, '(recursive) number of items in fixtures dir = ' . $count);
$dir = $fs->readDir($fixtures, 'r', array('flags' => 0));
$count = count($dir);
logSection($count, '(recursive) number of files in fixtures dir = ' . $count);
$dir = $fs->readDir($fixtures, 'r', array('skip' => '/jpe?g$/i'));
$count = count($dir);
logSection($count, '(skip jpeg) number of items in fixtures dir = ' . $count);
$result = $fs->stat($file);
logSection(is_array($result), 'stat for file "' . basename($file) . '"');