public function getFile() { if ($this->hasRequestParameter('uri')) { $uri = urldecode($this->getRequestParameter('uri')); $mediaSource = new MediaSource(array()); $filepath = $mediaSource->download($uri); if ($this->hasRequestParameter('xml')) { $this->returnJson(htmlentities(file_get_contents($filepath))); } else { \tao_helpers_Http::returnFile($filepath, false); } } else { throw new \common_exception_Error('invalid media identifier'); } }
/** * Download a file to the item directory* * @throws common_exception_MissingParameter */ public function download() { if (!$this->hasRequestParameter('uri') || !$this->hasRequestParameter('path') || !$this->hasRequestParameter('lang')) { throw new common_exception_MissingParameter(); } $item = new core_kernel_classes_Resource($this->getRequestParameter('uri')); $itemLang = $this->getRequestParameter('lang'); $resolver = new ItemMediaResolver($item, $itemLang); $asset = $resolver->resolve($this->getRequestParameter('path')); $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier()); return \tao_helpers_Http::returnFile($filePath); }
public function accessFile() { list($extension, $module, $action, $code, $filePath) = explode('/', tao_helpers_Request::getRelativeUrl(), 5); list($key, $subPath) = explode(' ', base64_decode($code), 2); $source = WebsourceManager::singleton()->getWebsource($key); if ($source instanceof ActionWebSource) { $path = $source->getFileSystem()->getPath() . $subPath . (empty($filePath) ? '' : DIRECTORY_SEPARATOR . $filePath); tao_helpers_Http::returnFile($path); } }
if (count($parts) < 2) { header('HTTP/1.0 403 Forbidden'); die; } list($subPath, $file) = $parts; $configPath = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'tao' . DIRECTORY_SEPARATOR . 'websource_' . $ap . '.conf.php'; if (!file_exists($configPath)) { header('HTTP/1.0 403 Forbidden'); die; } $config = (include $configPath); $compiledPath = $config['options']['path']; $secretPassphrase = $config['options']['secret']; $ttl = $config['options']['ttl']; $correctToken = md5($timestamp . $subPath . $secretPassphrase); if (time() - $timestamp > $ttl || $token != $correctToken) { header('HTTP/1.0 403 Forbidden'); die; } $path = array(); foreach (explode('/', $subPath . $file) as $ele) { $path[] = rawurldecode($ele); } $filename = $compiledPath . implode(DIRECTORY_SEPARATOR, $path); if (strpos($filename, '?')) { // A query string is provided with the file to be retrieved - clean up! $parts = explode('?', $filename); $filename = $parts[0]; } tao_helpers_Http::returnFile($filename); exit;
private function renderFile($item, $path, $lang) { if (tao_helpers_File::securityCheck($path, true)) { $resolver = new ItemMediaResolver($item, $lang); $asset = $resolver->resolve($path); $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier()); \tao_helpers_Http::returnFile($filePath); } else { throw new common_exception_Error('invalid item preview file path'); } }
/** * (non-PHPdoc) * @see \oat\tao\model\media\MediaBrowser::download */ public function download($filename) { $sysPath = $this->getSysPath($filename); tao_helpers_Http::returnFile($sysPath); }
/** * render an item as a Qti zip package * @author christophe GARCIA <*****@*****.**> */ public function export() { try { if ($this->getRequestMethod() != Request::HTTP_GET) { throw new \common_exception_NotImplemented('Only GET method is accepted to export QIT Item.'); } if (!$this->hasRequestParameter('id')) { $this->returnFailure(new \common_exception_MissingParameter('required parameter `id` is missing')); } $id = $this->getRequestParameter('id'); $item = new \core_kernel_classes_Resource($id); $itemService = \taoItems_models_classes_ItemsService::singleton(); if ($itemService->hasItemModel($item, array(ItemModel::MODEL_URI))) { $path = \tao_helpers_Export::getExportFile(); $tmpZip = new \ZipArchive(); $tmpZip->open($path, \ZipArchive::CREATE); $exporter = new QTIPackedItemExporter($item, $tmpZip); $exporter->export(array('apip' => false)); $exporter->getZip()->close(); header('Content-Type: application/zip'); \tao_helpers_Http::returnFile($path, false); return; } else { $this->returnFailure(new \common_exception_NotFound('item can\'t be found')); } } catch (\Exception $e) { $this->returnFailure($e); } }
/** * Invokes download of pregenerated delivery * @throws \common_exception_Error * @throws \tao_models_classes_MissingRequestParameterException */ public function download() { $instance = $this->getCurrentInstance(); $fileResource = $instance->getOnePropertyValue(new core_kernel_classes_Property(BookletClassService::PROPERTY_FILE_CONTENT)); if ($fileResource instanceof core_kernel_classes_Resource) { $file = new core_kernel_versioning_File($fileResource); header('Content-Disposition: attachment; filename="' . basename($file->getAbsolutePath()) . '"'); \tao_helpers_Http::returnFile($file->getAbsolutePath()); } }
/** * Download a file to the item directory* * @throws common_exception_MissingParameter * @throws common_exception_Error * @throws tao_models_classes_FileNotFoundException */ public function download() { $svgzSupport = false; if (!$this->hasRequestParameter('uri') || !$this->hasRequestParameter('path') || !$this->hasRequestParameter('lang')) { throw new common_exception_MissingParameter(); } if ($this->hasRequestParameter('svgzsupport')) { $svgzSupport = true; } $item = new core_kernel_classes_Resource($this->getRequestParameter('uri')); $itemLang = $this->getRequestParameter('lang'); $resolver = new ItemMediaResolver($item, $itemLang); $rawParams = $this->getRequest()->getRawParameters(); //have to use raw value to respect special characters in names $asset = $resolver->resolve($rawParams['path']); $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier()); $info = $asset->getMediaSource()->getFileInfo($asset->getMediaIdentifier()); if ($info['mime'] != 'application/qti+xml') { header('Content-Type: ' . $info['mime']); } \tao_helpers_Http::returnFile($filePath, false, $svgzSupport); }
/** * Download a file to the item directory* * @throws common_exception_MissingParameter */ public function download() { if (!$this->hasRequestParameter('uri')) { throw new common_exception_MissingParameter('uri', __METHOD__); } $testUri = $this->getRequestParameter('uri'); $test = new core_kernel_classes_Resource($testUri); if (!$this->hasRequestParameter('path')) { throw new common_exception_MissingParameter('path', __METHOD__); } $baseDir = taoQtiTest_helpers_ResourceManager::getBaseDir($test); $path = $baseDir . ltrim($this->getRequestParameter('path'), '/'); tao_helpers_Http::returnFile($path); }
private function renderResource($item, $path) { $lang = common_session_SessionManager::getSession()->getDataLanguage(); $resolver = new ItemMediaResolver($item, $lang); $asset = $resolver->resolve($path); $filePath = $asset->getMediaSource()->download($asset->getMediaIdentifier()); \tao_helpers_Http::returnFile($filePath); }
private function renderResource($item, $path) { $identifier = ''; $subPath = $path; if (strpos($path, '://') !== false) { $identifier = substr($path, 0, strpos($path, '://')); $subPath = substr($path, strpos($path, '://') + 3); } //@todo : allow preview in a language other than the one in the session $lang = common_session_SessionManager::getSession()->getDataLanguage(); $folder = taoItems_models_classes_ItemsService::singleton()->getItemFolder($item, $lang); if (tao_helpers_File::securityCheck($path, true)) { if ($identifier === 'taomgr') { $fileManager = FileManager::getFileManagementModel(); $filename = $fileManager->retrieveFile($subPath); } else { $filename = $folder . $path; } tao_helpers_Http::returnFile($filename); } else { throw new common_exception_Error('invalid item preview file path'); } }