Beispiel #1
0
$configService = $driver->connect('config', array('dir' => $root . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR, 'humanReadable' => true));
$serviceManager = new ServiceManager($configService);
$configPath = $root . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'tao' . DIRECTORY_SEPARATOR . 'websource_' . $webSourceId . '.conf.php';
if (!file_exists($configPath)) {
    header('HTTP/1.0 403 Forbidden');
    die;
}
$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'] : array();
$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 {
    $path = $source->getFilePathFromUrl($url);
    $stream = $source->getFileStream($path);
    tao_helpers_Http::returnStream($stream, $source->getMimetype($path));
    $stream->detach();
} catch (\tao_models_classes_FileNotFoundException $e) {
    header("HTTP/1.0 404 Not Found");
}
exit;