/** * Gets file, located on server FS * * @param $val file path * @return array $val */ function fn_get_server_data($val) { if (defined('IS_WINDOWS')) { $val = str_replace('\\', '/', $val); } $allowed_paths = array(fn_get_files_dir_path(), fn_get_public_files_path()); $val = fn_normalize_path($val); if (Registry::get('runtime.allow_upload_external_paths') && strpos($val, Registry::get('config.dir.root')) === 0) { $allowed_paths = array($val); } setlocale(LC_ALL, 'en_US.UTF8'); foreach ($allowed_paths as $root_path) { if (strpos($val, $root_path) === 0) { $path = $val; } else { $path = fn_normalize_path($root_path . $val); } if (strpos($path, $root_path) === 0 && file_exists($path)) { $result = array('name' => fn_basename($path), 'path' => $path); $tempfile = fn_create_temp_file(); fn_copy($result['path'], $tempfile); $result['path'] = $tempfile; $result['size'] = filesize($result['path']); $cache = Registry::get('temp_fs_data'); if (!isset($cache[$result['path']])) { // cache file to allow multiple usage $cache[$result['path']] = $tempfile; Registry::set('temp_fs_data', $cache); } return $result; } } return false; }
use Tygh\ElFinder\Core; if (!defined('BOOTSTRAP')) { die('Access denied'); } if (Registry::get('config.demo_mode')) { // ElFinder should not work in demo mode $message = json_encode(array('error' => __('error_demo_mode'))); exit($message); } if (AREA == 'C') { if (!Registry::get('runtime.customization_mode.live_editor')) { die('Access denied'); } } $private_files_path = fn_get_files_dir_path(); $public_files_path = fn_get_public_files_path(); fn_mkdir($private_files_path); fn_mkdir($public_files_path); $start_path = ''; if (!empty($_REQUEST['init']) && !empty($_REQUEST['start_path'])) { unset($_GET['target']); $start_path = fn_normalize_path($private_files_path . $_REQUEST['start_path']); if (strpos($start_path, $private_files_path) !== 0) { $start_path = ''; } } $extra_path = str_replace(Storage::instance('images')->getAbsolutePath(''), '', $public_files_path); $opts = array('roots' => array(array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('private_files'), 'tmbPath' => '', 'path' => $private_files_path, 'startPath' => $start_path, 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png'), array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('public_files'), 'tmbPath' => '', 'path' => $public_files_path, 'URL' => Storage::instance('images')->getUrl($extra_path), 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png'))); if ($mode == 'images') { unset($opts['roots'][0]); }