Ejemplo n.º 1
0
     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'));
     }
     $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)) {
Ejemplo n.º 2
0
$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) . '"');
$result = $fs->dynamicFileName($file);
logSection(basename($file), sprintf('dynamic file name "%s"', basename($result)));
$file = $fixtures . '/test_file_(3)';
$fs->touch($file);
$result = $fs->dynamicFileName($file);
logSection(basename($file), sprintf('dynamic file name "%s"', basename($result)));
$files[] = $file;
$fs->mirror($fixtures, $fixtures . '/mirror', array('image' => array('width' => 300, 'height' => 300, 'type' => 'width', 'crop' => 'left-top')));
logSection(is_dir($fixtures . '/mirror'), 'mirror fixtures directory');
echo "remove created dir? (yes/no)\n";
$result = fgets(STDIN);
$result = trim($result);
if (is_dir($fixtures . '/mirror') && $result == 'yes') {
    $fs->remove($fs->readDir($fixtures . '/mirror', 'r', array('sort' => true)));