/** * Constructor * * @param array $image image meta data * @param int $statusCode the HTTP status code, defaults to 200 */ public function __construct(array $image, $statusCode = Http::STATUS_OK) { $name = $image['name']; $this->preview = $image['preview']; $this->setStatus($statusCode); $this->addHeader('Content-type', $image['mimetype'] . '; charset=utf-8'); \OCP\Response::setContentDispositionHeader($name, 'attachment'); }
/** * Send the requested content */ public function sendResponse() { \OCP\Response::disableCaching(); if (!$this->fileExists()) { $this->sendNotFound(); } $this->instance->sendResponse(); exit; }
/** * show preview * @return void */ public function showPreview($mimeType = null) { \OCP\Response::enableCaching(3600 * 24); // 24 hours if (is_null($this->preview)) { $this->getPreview(); } $this->preview->show($mimeType); }
/** * Sends the preview, including the headers to client which requested it * * @param null|string $mimeTypeForHeaders the media type to use when sending back the reply * * @throws NotFoundException */ public function showPreview($mimeTypeForHeaders = null) { // Check if file is valid if ($this->isFileValid() === false) { throw new NotFoundException('File not found.'); } if ($cachedPath = $this->isCached($this->info->getId())) { header('Content-Type: ' . $this->info->getMimetype()); $this->userView->readfile($cachedPath); return; } if (is_null($this->preview)) { $this->getPreview(); } if ($this->preview instanceof \OCP\IImage) { if ($this->preview->valid()) { \OCP\Response::enableCaching(3600 * 24); // 24 hours } else { $this->getMimeIcon(); } $this->preview->show($mimeTypeForHeaders); } }
/** * @param null|string $mimeType * @throws NotFoundException */ public function showPreview($mimeType = null) { // Check if file is valid if ($this->isFileValid() === false) { throw new NotFoundException('File not found.'); } \OCP\Response::enableCaching(3600 * 24); // 24 hours if (is_null($this->preview)) { $this->getPreview(); } if ($this->preview instanceof \OC_Image) { $this->preview->show($mimeType); } }
/** * Initiate Shibboleth Logout if neccessary * and then return the user to standard internal * logout URL (it will be in Request URI). If the * user is already logged out of Shibboleth, do nothing. */ private function onLogout() { $suid = $this->userAttrManager->getShibUid(); if ($suid) { $this->logger->info('Initiating Shibboleth logout for: ' . $suid, $this->logCtx); $shibLogout = $this->urlGenerator->linkTo('', 'Shibboleth.sso/Logout', array('return' => $this->request->getRequestUri())); \OCP\Response::redirect($shibLogout); exit; } }
public function show() { if ($this->useOriginal) { $fp = @$this->view->fopen($this->path, 'rb'); $mtime = $this->view->filemtime($this->path); $size = $this->view->filesize($this->path); $mime = $this->view->getMimetype($this->path); } else { $fp = @fopen($this->path, 'rb'); $mtime = filemtime($this->path); $size = filesize($this->path); $mime = \OC_Helper::getMimetype($this->path); } if ($fp) { \OCP\Response::enableCaching(); \OCP\Response::setLastModifiedHeader($mtime); header('Content-Length: ' . $size); header('Content-Type: ' . $mime); fpassthru($fp); } else { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); } }
/** * @brief analyses the parameter for calendar parameter and returns the objects * @param (string) $calendarid - calendarid * @param (int) $start - unixtimestamp of start * @param (int) $end - unixtimestamp of end * @return (array) $events */ public static function getrequestedEvents($calendarid, $start, $end) { $events = array(); if ($calendarid === 'shared_events') { $checkStart = $start->format('U'); $singleevents = \OCP\Share::getItemsSharedWith(self::SHAREEVENT, ShareEvent::FORMAT_EVENT); foreach ($singleevents as $singleevent) { $startCheck_dt = new \DateTime($singleevent['startdate'], new \DateTimeZone('UTC')); $checkStartSE = $startCheck_dt->format('U'); // \OCP\Util::writeLog('calendar','STARTDATE'.$checkStart.' -> '.$checkStartSE, \OCP\Util::DEBUG); if ($checkStartSE > $checkStart) { $singleevent['summary'] .= ' (' . (string) self::$l10n->t('by') . ' ' . Object::getowner($singleevent['id']) . ')'; $events[] = $singleevent; } } } else { if (is_numeric($calendarid)) { $calendar = self::getCalendar($calendarid); \OCP\Response::enableCaching(0); \OCP\Response::setETagHeader($calendar['ctag']); $events = Object::allInPeriod($calendarid, $start, $end, $calendar['userid'] !== \OCP\User::getUser()); } else { \OCP\Util::emitHook('OCA\\CalendarPlus', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events)); } } return $events; }
* ownCloud - Updater plugin * * @author Victor Dubiniuk * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com * * This file is licensed under the Affero General Public License version 3 or * later. */ namespace OCA\Updater; \OCP\JSON::checkAdminUser(); \OCP\JSON::callCheck(); $file = basename(@$_GET["filename"]); // Prevent directory traversal if (strlen($file) < 3) { exit; } $filename = App::getBackupBase() . $file; if (!@file_exists($filename)) { exit; } header('Content-Type:' . \OCP\Files::getMimeType($filename)); if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) { header('Content-Disposition: attachment; filename="' . rawurlencode(basename($filename)) . '"'); } else { header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode(basename($filename)) . '; filename="' . rawurlencode(basename($filename)) . '"'); } \OCP\Response::disableCaching(); header('Content-Length: ' . filesize($filename)); \OC_Util::obEnd(); readfile($filename);
public function redirectTo($ssoURL) { \OCP\Response::redirect($ssoURL); exit; }
break; case 'play': $ftype = \OC\Files\Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = $collection->getSongByPath($arguments['path']); $collection->registerPlay($songId); header('Content-Type:' . $ftype); \OCP\Response::enableCaching(3600 * 24); // 24 hour header('Accept-Ranges: bytes'); header('Content-Length: ' . \OC\Files\Filesystem::filesize($arguments['path'])); $mtime = \OC\Files\Filesystem::filemtime($arguments['path']); \OCP\Response::setLastModifiedHeader($mtime); \OC\Files\Filesystem::readfile($arguments['path']); exit; case 'find_music': $scanner = new Scanner($collection); $music = $scanner->getMusic(); \OCP\JSON::encodedPrint($music); exit; } } class ScanWatcher { /** * @var \OC_EventSource $eventSource; */ private $eventSource;
/** * @brief show preview * @return void */ public function showPreview() { \OCP\Response::enableCaching(3600 * 24); // 24 hours if (is_null($this->preview)) { $this->getPreview(); } $this->preview->show('image/png'); return; }
/** * Get the thumbnail of the image * @param string $thumbImagePath */ public function getThumbnail($thumbImagePath) { $fp = @fopen($thumbImagePath, 'rb'); $mtime = filemtime($thumbImagePath); $size = filesize($thumbImagePath); $mime = \OC_Helper::getMimetype($thumbImagePath); if ($fp) { \OCP\Response::enableCaching(); \OCP\Response::setLastModifiedHeader($mtime); header('Content-Length: ' . $size); header('Content-Type: ' . $mime); fpassthru($fp); } else { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); } }