getServiceLocator(); common_Logger::singleton()->register(); /** @var common_ext_ExtensionsManager $e */ $e = $serviceManager->get(common_ext_ExtensionsManager::SERVICE_ID); $config = $e->getExtensionById('tao')->getConfig('websource_' . $webSourceId); //$config = include $configPath; if (!is_array($config) || !isset($config['className'])) { header('HTTP/1.0 403 Forbidden'); die(); } $className = $config['className']; $options = isset($config['options']) ? $config['options'] : []; $source = new $className($options); if (!$source instanceof FlyTokenWebSource) { header('HTTP/1.0 403 Forbidden'); die(); } $fsService = $serviceManager->get(FileSystemService::SERVICE_ID); $fileSystem = $fsService->getFileSystem($source->getOption($source::OPTION_FILESYSTEM_ID)); $source->setFileSystem($fileSystem); try { $ttl = isset($options['ttl']) && $options['ttl'] ? $options['ttl'] : (30 * 60); //30 min default $path = $source->getFilePathFromUrl($url); $stream = $source->getFileStream($path); header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl)); tao_helpers_Http::returnStream($stream, $source->getMimetype($path)); $stream->detach(); } catch (\tao_models_classes_FileNotFoundException $e) { header("HTTP/1.0 404 Not Found"); } exit();