$fm->send('files.zip'); $_SYSTEM['jsRequest']->reset(); break; case 'perms': if (!$has_files) { throw new sjException($_SYSTEM['i18n']->__('Unable to process request')); } $fileperms = empty($_REQUEST['fileperms']) ? false : trim($_REQUEST['fileperms']); if (is_numeric($fileperms)) { if (strlen($fileperms) < 3) { while (strlen($fileperms) != 3) { $fileperms .= '0'; } } $fileperms = substr($fileperms, 0, 3); $fs->chmod($files, eval("return(0{$fileperms});")); } break; case 'stat': $filename = $path; if ($has_files) { $filename = reset($files); } $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')); }
<?php $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);