Пример #1
0
 public function elfinder_connector($needInfo = false)
 {
     $needInfo = !$needInfo ? getRequest('param0') : $needInfo;
     if ($needInfo == "getSystemInfo") {
         $arData = array('maxFilesCount' => ini_get("max_file_uploads") ? ini_get("max_file_uploads") : 20);
         return def_module::flush(json_encode($arData), "text/javascript");
     }
     $elfClasses = CURRENT_WORKING_DIR . "/styles/common/other/elfinder/php/";
     require_once $elfClasses . 'elFinderConnector.class.php';
     //require_once $elfClasses . 'elFinder.class.php';
     require_once $elfClasses . 'elFinder.umi.class.php';
     require_once $elfClasses . 'elFinderVolumeDriver.class.php';
     require_once $elfClasses . 'elFinderVolumeLocalFileSystem.class.php';
     require_once $elfClasses . 'elFinderVolumeUmiLocalFileSystem.class.php';
     // full access mode for filemanager module (?full-access=1)
     $isFullAccess = (bool) getRequest('full-access');
     function elfinder_full_access($attr, $path, $data, $volume)
     {
         return strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : $attr == 'read' || $attr == 'write';
     }
     function elfinder_access($attr, $path, $data, $volume)
     {
         if (strpos(basename($path), '.') === 0) {
             return !($attr == 'read' || $attr == 'write');
         } else {
             if (defined("CURRENT_VERSION_LINE") && CURRENT_VERSION_LINE == "demo") {
                 return !($attr == 'write' || $attr == 'hidden');
             }
             return $attr == 'read' || $attr == 'write';
         }
     }
     $opts = array('debug' => true, 'roots' => array());
     $permissions = permissionsCollection::getInstance();
     $userId = $permissions->getUserId();
     $user = umiObjectsCollection::getInstance()->getObject($userId);
     $allowedDirectories = array();
     if (!(defined("CURRENT_VERSION_LINE") && CURRENT_VERSION_LINE == "demo") && ($filemanagerDirectory = $user->getValue('filemanager_directory'))) {
         $i = 1;
         $directories = explode(",", $filemanagerDirectory);
         foreach ($directories as $directory) {
             $directory = trim($directory);
             if (!strlen($directory)) {
                 continue;
             }
             $directory = trim($directory, "/");
             $directoryPath = realpath(CURRENT_WORKING_DIR . "/" . $directory);
             if (strpos($directoryPath, CURRENT_WORKING_DIR . '/files') === false && strpos($directoryPath, CURRENT_WORKING_DIR . '/images') === false || !is_dir($directoryPath)) {
                 continue;
             }
             $allowedDirectories[] = $directory;
         }
     }
     if (count($allowedDirectories)) {
         $i = 1;
         foreach ($allowedDirectories as $directory) {
             $opts['roots'][] = array('id' => 'files' . $i, 'driver' => 'UmiLocalFileSystem', 'path' => CURRENT_WORKING_DIR . "/" . $directory, 'URL' => "/" . $directory, 'accessControl' => 'elfinder_access');
             $i++;
         }
     } else {
         $opts['roots'][] = array('id' => 'files', 'driver' => 'UmiLocalFileSystem', 'path' => CURRENT_WORKING_DIR . '/files/', 'URL' => '/files/', 'accessControl' => $isFullAccess ? 'elfinder_full_access' : 'elfinder_access');
         $opts['roots'][] = array('id' => 'images', 'driver' => 'UmiLocalFileSystem', 'path' => CURRENT_WORKING_DIR . '/images/', 'startPath' => CURRENT_WORKING_DIR . '/images/cms/data', 'URL' => '/images/', 'accessControl' => $isFullAccess ? 'elfinder_full_access' : 'elfinder_access');
     }
     // run elFinder
     $connector = new elFinderConnector(new elFinder($opts));
     $connector->run();
 }