if (!defined('SJ_IS_ADMIN')) {
    header('Location: http://www.google.com');
    exit;
}
require $sjConfig['lib_dir'] . '/model/image.class.php';
$path = trim($_REQUEST['path']);
$action = $_REQUEST['action'];
$base_work_space = $sjConfig['root'];
$path = $base_work_space . $path;
$path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
try {
    if (!pathIn($path, $base_work_space) || isset($sjConfig['allowed_actions']) && !in_array($action, $sjConfig['allowed_actions'])) {
        throw new sjException($_SYSTEM['i18n']->__('Access denied'));
    }
    $fs = new iFilesystem();
    $fm = iFilemanager::create()->setFilesystem($fs->setI18n($_SYSTEM['i18n']));
    $files = array();
    $has_files = isset($_REQUEST['files']) && is_array($_REQUEST['files']);
    if ($has_files) {
        $files = $_REQUEST['files'];
        // name of files
        if (isset($_REQUEST['baseDir'])) {
            $base_dir = trim($_REQUEST['baseDir']);
            // in the the path have symbol '/'
            $base_dir = $base_work_space . $base_dir;
            if (!pathIn($base_dir, $base_work_space)) {
                throw new sjException($_SYSTEM['i18n']->__('Access denied'));
            }
        } else {
            $base_dir = $path;
        }
 /**
  * Set filemanager class name.
  * The object of this class must be an instance of iFilemanager
  *
  * @param string $class
  * @return bool
  */
 public static function setClass($class)
 {
     $exists = class_exists($class);
     if ($exists) {
         self::$class = $class;
     }
     return $exists;
 }
<?php

$dir = dirname(__FILE__);
$fixtures = $dir . '/../fixtures';
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();
$fm = iFilemanager::create()->setFilesystem($fs);
$fs->mkdirs($fixtures . '/filemanager');
$files = $fs->readDir($fixtures . '/image', 'r');
$fm->import($files)->paste($fixtures . '/filemanager', array('override' => true, 'chmod' => 0644, 'image' => array('width' => 300, 'height' => 200, 'type' => 'height', 'crop' => 'left-top'), 'thumbs' => array('tmb_' => array('width' => 100, 'height' => 100, 'type' => 'height', 'crop' => 'left-top'))))->clear();
logSection(is_dir($fixtures . '/filemanager'), 'paste all files from fixtures to fixtures/filemanager, make thumbs for images');
$fm->import($fs->readDir($fixtures . '/filemanager', 'r'))->compress($fixtures . '/filemanager/copressed.zip');
logSection(is_file($fixtures . '/filemanager/copressed.zip'), 'Compress dir fixtures/filemanger');
echo "remove created files? (yes/no)\n";
$result = fgets(STDIN);
$result = trim($result);
if (is_dir($fixtures . '/filemanager') && $result == 'yes') {
    $fm->exec(array($fs, 'remove'));
    logSection(!is_file($fixtures . '/filemanager/copressed.zip'), 'remove files through exec method');
}