ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\FileDelivery\Delivery Class Reference

Class Delivery. More...

+ Collaboration diagram for ILIAS\FileDelivery\Delivery:

Public Member Functions

 __construct (string $path_to_file, Services $http)
 
 stream ()
 
 deliver ()
 
 setGeneralHeaders ()
 
 setCachingHeaders ()
 
 generateEtag ()
 
 close ()
 
 getDeliveryType ()
 
 setDeliveryType (string $delivery_type)
 
 getMimeType ()
 
 setMimeType (string $mime_type)
 
 getPathToFile ()
 
 setPathToFile (string $path_to_file)
 
 getDownloadFileName ()
 
 setDownloadFileName (string $download_file_name)
 
 getDisposition ()
 
 setDisposition (string $disposition)
 
 isSendMimeType ()
 
 setSendMimeType (bool $send_mime_type)
 
 isExitAfter ()
 
 setExitAfter (bool $exit_after)
 
 isConvertFileNameToAsci ()
 
 setConvertFileNameToAsci (bool $convert_file_name_to_asci)
 
 getEtag ()
 
 setEtag (string $etag)
 
 getShowLastModified ()
 
 setShowLastModified (bool $show_last_modified)
 
 isHasContext ()
 
 setHasContext (bool $has_context)
 
 hasCache ()
 
 setCache (bool $cache)
 
 hasHashFilename ()
 
 setHashFilename (bool $hash_filename)
 
 checkCache ()
 
 clearBuffer ()
 
 isDeleteFile ()
 
 setDeleteFile (bool $delete_file)
 

Static Public Member Functions

static isDEBUG ()
 
static setDEBUG (bool $DEBUG)
 
static returnASCIIFileName (string $original_filename)
 Converts a UTF-8 filename to ASCII. More...
 

Data Fields

const DIRECT_PHP_OUTPUT = 'php://output'
 
const DISP_ATTACHMENT = 'attachment'
 
const DISP_INLINE = 'inline'
 
const EXPIRES_IN = '+5 days'
 

Private Member Functions

 delivery ()
 
 determineMimeType ()
 
 determineDownloadFileName ()
 
 detemineDeliveryType ()
 
 sendEtagHeader ()
 
 sendLastModified ()
 
 checkExisting ()
 
 cleanDownloadFileName ()
 Converts the filename to ASCII. More...
 
 setDispositionHeaders ()
 

Private Attributes

string $delivery_type = DeliveryMethod::PHP
 
string $mime_type = ''
 
string $path_to_file = ''
 
string $download_file_name = ''
 
string $disposition = self::DISP_ATTACHMENT
 
bool $send_mime_type = true
 
bool $exit_after = true
 
bool $convert_file_name_to_asci = true
 
string $etag = ''
 
bool $show_last_modified = true
 
bool $has_context = true
 
bool $cache = false
 
bool $hash_filename = false
 
bool $delete_file = false
 
Services $http
 
FileDeliveryTypeFactory $factory
 

Static Private Attributes

static string $delivery_type_static = null
 
static bool $DEBUG = false
 

Detailed Description

Class Delivery.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
2.0.0
Since
5.3

Definition at line 37 of file Delivery.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileDelivery\Delivery::__construct ( string  $path_to_file,
Services  $http 
)
Parameters
string$path_to_file
Services$http

Definition at line 67 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$http, ILIAS\FileDelivery\Delivery\detemineDeliveryType(), ILIAS\FileDelivery\Delivery\determineDownloadFileName(), ILIAS\FileDelivery\Delivery\determineMimeType(), ilContext\getType(), ILIAS\FileDelivery\http(), ILIAS\FileDelivery\Delivery\setHasContext(), and ILIAS\FileDelivery\Delivery\setPathToFile().

68  {
69  $this->http = $http;
70  if ($path_to_file === self::DIRECT_PHP_OUTPUT) {
71  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
72  } else {
74  $this->detemineDeliveryType();
75  $this->determineMimeType();
77  }
78  $this->setHasContext(\ilContext::getType() !== null);
79  $this->factory = new FileDeliveryTypeFactory($http);
80  }
setHasContext(bool $has_context)
Definition: Delivery.php:368
static http()
Fetches the global http state from ILIAS.
static getType()
Get context type.
setPathToFile(string $path_to_file)
Definition: Delivery.php:272
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )

Definition at line 431 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\generateEtag(), ILIAS\FileDelivery\Delivery\hasCache(), ILIAS\FileDelivery\Delivery\sendEtagHeader(), ILIAS\FileDelivery\Delivery\setCachingHeaders(), and ILIAS\FileDelivery\Delivery\setShowLastModified().

Referenced by ILIAS\FileDelivery\Delivery\deliver().

431  : void
432  {
433  if ($this->hasCache()) {
434  $this->generateEtag();
435  $this->sendEtagHeader();
436  $this->setShowLastModified(true);
437  $this->setCachingHeaders();
438  }
439  }
setShowLastModified(bool $show_last_modified)
Definition: Delivery.php:356
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExisting()

ILIAS\FileDelivery\Delivery::checkExisting ( )
private

Definition at line 461 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\close(), and ILIAS\FileDelivery\Delivery\getPathToFile().

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

461  : void
462  {
463  if ($this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
464  && !file_exists($this->getPathToFile())
465  ) {
466  $this->close();
467  }
468  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanDownloadFileName()

ILIAS\FileDelivery\Delivery::cleanDownloadFileName ( )
private

Converts the filename to ASCII.

Definition at line 474 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDownloadFileName(), and ILIAS\FileDelivery\Delivery\setDownloadFileName().

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

474  : void
475  {
476  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
478  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:284
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearBuffer()

ILIAS\FileDelivery\Delivery::clearBuffer ( )
Returns
bool

Definition at line 445 of file Delivery.php.

Referenced by ILIAS\FileDelivery\Delivery\deliver().

445  : bool
446  {
447  try {
448  $ob_get_contents = ob_get_contents();
449  if ($ob_get_contents) {
450  // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
451  // . $ob_get_contents);
452  }
453  ob_end_clean(); // fixed 0016469, 0016467, 0016468
454  return true;
455  } catch (\Throwable $t) {
456  return false;
457  }
458  }
+ Here is the caller graph for this function:

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 169 of file Delivery.php.

References ILIAS\FileDelivery\http().

Referenced by ILIAS\FileDelivery\Delivery\checkExisting(), and ILIAS\FileDelivery\Delivery\deliver().

169  : void
170  {
171  $this->http->close();
172  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliver()

ILIAS\FileDelivery\Delivery::deliver ( )

Definition at line 98 of file Delivery.php.

References $response, ILIAS\FileDelivery\Delivery\checkCache(), ILIAS\FileDelivery\Delivery\clearBuffer(), ILIAS\FileDelivery\Delivery\close(), ILIAS\FileDelivery\Delivery\delivery(), ILIAS\FileDelivery\Delivery\getDeliveryType(), ILIAS\FileDelivery\Delivery\getPathToFile(), ILIAS\FileDelivery\http(), ILIAS\FileDelivery\Delivery\isDeleteFile(), ILIAS\FileDelivery\Delivery\isExitAfter(), and ILIAS\FileDelivery\Delivery\setGeneralHeaders().

Referenced by ilFileDelivery\deliverFileLegacy(), and ILIAS\FileDelivery\Delivery\stream().

98  : void
99  {
100  $response = $this->http->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
101  if (
102  !$this->delivery()->doesFileExists($this->path_to_file)
103  && $this->path_to_file !== self::DIRECT_PHP_OUTPUT
104  ) {
105  $response = $this->http->response()->withStatus(404);
106  $this->http->saveResponse($response);
107  $this->http->sendResponse();
108  $this->close();
109  }
110  $this->http->saveResponse($response);
111 
112  $this->clearBuffer();
113  $this->checkCache();
114  $this->setGeneralHeaders();
115  $this->delivery()->prepare($this->getPathToFile());
116  $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
117  if ($this->isDeleteFile()) {
118  $this->delivery()->handleFileDeletion($this->getPathToFile());
119  }
120  if ($this->isExitAfter()) {
121  $this->close();
122  }
123  }
static http()
Fetches the global http state from ILIAS.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delivery()

ILIAS\FileDelivery\Delivery::delivery ( )
private

Definition at line 92 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDeliveryType().

Referenced by ILIAS\FileDelivery\Delivery\deliver(), and ILIAS\FileDelivery\Delivery\stream().

92  : ilFileDeliveryType
93  {
94  return $this->factory->getInstance($this->getDeliveryType());
95  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detemineDeliveryType()

ILIAS\FileDelivery\Delivery::detemineDeliveryType ( )
private

Definition at line 203 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDeliveryType(), ilRuntime\getInstance(), ILIAS\FileDelivery\Delivery\getPathToFile(), ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\PHP, ILIAS\FileDelivery\Delivery\setDeliveryType(), ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\XACCEL, and ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\XSENDFILE.

Referenced by ILIAS\FileDelivery\Delivery\__construct().

203  : void
204  {
205  if (self::$delivery_type_static) {
206  $this->setDeliveryType(self::$delivery_type_static);
207 
208  return;
209  }
210 
211  if (function_exists('apache_get_modules')
212  && in_array('mod_xsendfile', apache_get_modules(), true)
213  ) {
215  }
216 
217  if (is_file('./Services/FileDelivery/classes/override.php')) {
218  $override_delivery_type = false;
220  require_once('./Services/FileDelivery/classes/override.php');
221  if ($override_delivery_type) {
222  $this->setDeliveryType($override_delivery_type);
223  }
224  }
225  $ilRuntime = \ilRuntime::getInstance();
226  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
228  ) {
230  }
231 
232  if ($this->getDeliveryType() === DeliveryMethod::XACCEL
233  && strpos($this->getPathToFile(), './data') !== 0
234  ) {
236  }
237 
238  self::$delivery_type_static = $this->getDeliveryType();
239  }
static getInstance()
setDeliveryType(string $delivery_type)
Definition: Delivery.php:248
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineDownloadFileName()

ILIAS\FileDelivery\Delivery::determineDownloadFileName ( )
private

Definition at line 194 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDownloadFileName(), ILIAS\FileDelivery\Delivery\getPathToFile(), and ILIAS\FileDelivery\Delivery\setDownloadFileName().

Referenced by ILIAS\FileDelivery\Delivery\__construct().

194  : void
195  {
196  if (!$this->getDownloadFileName()) {
197  $download_file_name = basename($this->getPathToFile());
199  }
200  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:284
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineMimeType()

ILIAS\FileDelivery\Delivery::determineMimeType ( )
private

Definition at line 175 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getPathToFile(), ILIAS\FileUpload\MimeType\lookupMimeType(), and ILIAS\FileDelivery\Delivery\setMimeType().

Referenced by ILIAS\FileDelivery\Delivery\__construct().

175  : void
176  {
177  $info = \ILIAS\FileUpload\MimeType::lookupMimeType($this->getPathToFile(), \ILIAS\FileUpload\MimeType::APPLICATION__OCTET_STREAM);
178  if ($info) {
179  $this->setMimeType($info);
180 
181  return;
182  }
183  $finfo = finfo_open(FILEINFO_MIME_TYPE);
184  $info = finfo_file($finfo, $this->getPathToFile());
185  finfo_close($finfo);
186  if ($info) {
187  $this->setMimeType($info);
188 
189  return;
190  }
191  }
setMimeType(string $mime_type)
Definition: Delivery.php:260
Class ChatMainBarProvider .
static lookupMimeType(string $path_to_file, string $fallback=self::APPLICATION__OCTET_STREAM, bool $a_external=false)
Definition: MimeType.php:542
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ILIAS\FileDelivery\Delivery::generateEtag ( )

Definition at line 163 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getPathToFile(), and ILIAS\FileDelivery\Delivery\setEtag().

Referenced by ILIAS\FileDelivery\Delivery\checkCache().

163  : void
164  {
165  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
166  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeliveryType()

ILIAS\FileDelivery\Delivery::getDeliveryType ( )

◆ getDisposition()

ILIAS\FileDelivery\Delivery::getDisposition ( )

Definition at line 290 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

Referenced by ILIAS\FileDelivery\Delivery\setDispositionHeaders().

290  : string
291  {
292  return $this->disposition;
293  }
+ Here is the caller graph for this function:

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )

Definition at line 338 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

Referenced by ILIAS\FileDelivery\Delivery\sendEtagHeader().

338  : string
339  {
340  return $this->etag;
341  }
+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )

Definition at line 254 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

254  : string
255  {
256  return $this->mime_type;
257  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )

Definition at line 350 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

Referenced by ILIAS\FileDelivery\Delivery\sendLastModified().

350  : bool
351  {
353  }
+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )

Definition at line 374 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

Referenced by ILIAS\FileDelivery\Delivery\checkCache().

374  : bool
375  {
376  return $this->cache;
377  }
+ Here is the caller graph for this function:

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )

Definition at line 386 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

386  : bool
387  {
388  return $this->hash_filename;
389  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )

Definition at line 326 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

326  : bool
327  {
329  }
+ Here is the caller graph for this function:

◆ isDEBUG()

static ILIAS\FileDelivery\Delivery::isDEBUG ( )
static

Definition at line 419 of file Delivery.php.

419  : bool
420  {
421  return self::$DEBUG;
422  }

◆ isDeleteFile()

ILIAS\FileDelivery\Delivery::isDeleteFile ( )

Definition at line 517 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

Referenced by ILIAS\FileDelivery\Delivery\deliver().

517  : bool
518  {
519  return $this->delete_file;
520  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )

Definition at line 314 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

Referenced by ILIAS\FileDelivery\Delivery\deliver().

314  : bool
315  {
316  return $this->exit_after;
317  }
+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )

Definition at line 362 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

362  : bool
363  {
364  return $this->has_context;
365  }

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )

Definition at line 302 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

302  : bool
303  {
304  return $this->send_mime_type;
305  }
+ Here is the caller graph for this function:

◆ returnASCIIFileName()

static ILIAS\FileDelivery\Delivery::returnASCIIFileName ( string  $original_filename)
static

Converts a UTF-8 filename to ASCII.

Parameters
$original_filenamestring UFT8-Filename
Returns
string ASCII-Filename

Definition at line 488 of file Delivery.php.

References $ascii_filename.

488  : string
489  {
490  $umlaut_mapping = [
491  "Ä" => "Ae",
492  "Ö" => "Oe",
493  "Ü" => "Ue",
494  "ä" => "ae",
495  "ö" => "oe",
496  "ü" => "ue",
497  "ß" => "ss"
498  ];
499  foreach ($umlaut_mapping as $src => $tgt) {
500  $original_filename = str_replace($src, $tgt, $original_filename);
501  }
502 
503  $ascii_filename = htmlentities($original_filename, ENT_NOQUOTES, 'UTF-8');
504  $ascii_filename = preg_replace('/\&(.)[^;]*;/', '\\1', $ascii_filename);
505  $ascii_filename = preg_replace('/[\x7f-\xff]/', '_', $ascii_filename);
506 
507  // OS do not allow the following characters in filenames: \/:*?"<>|
508  $ascii_filename = preg_replace(
509  '/[:\x5c\/\*\?\"<>\|]/',
510  '_',
512  );
513  return $ascii_filename;
514  }
$ascii_filename
Definition: metadata.php:378

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

Definition at line 398 of file Delivery.php.

References $response, ILIAS\FileDelivery\Delivery\getEtag(), and ILIAS\FileDelivery\http().

Referenced by ILIAS\FileDelivery\Delivery\checkCache(), and ILIAS\FileDelivery\Delivery\setCachingHeaders().

398  : void
399  {
400  if ($this->getEtag()) {
401  $response = $this->http->response()->withHeader('ETag', $this->getEtag());
402  $this->http->saveResponse($response);
403  }
404  }
static http()
Fetches the global http state from ILIAS.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendLastModified()

ILIAS\FileDelivery\Delivery::sendLastModified ( )
private

Definition at line 407 of file Delivery.php.

References $response, ILIAS\FileDelivery\Delivery\getPathToFile(), ILIAS\FileDelivery\Delivery\getShowLastModified(), and ILIAS\FileDelivery\http().

Referenced by ILIAS\FileDelivery\Delivery\setCachingHeaders().

407  : void
408  {
409  if ($this->getShowLastModified()) {
410  $response = $this->http->response()->withHeader(
411  'Last-Modified',
412  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
413  . " GMT"
414  );
415  $this->http->saveResponse($response);
416  }
417  }
static http()
Fetches the global http state from ILIAS.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCache()

ILIAS\FileDelivery\Delivery::setCache ( bool  $cache)

Definition at line 380 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

Referenced by ilWebAccessCheckerDelivery\deliver().

380  : void
381  {
382  $this->cache = $cache;
383  }
+ Here is the caller graph for this function:

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 153 of file Delivery.php.

References $response, ILIAS\HTTP\Response\ResponseHeader\CACHE_CONTROL, ILIAS\HTTP\Response\ResponseHeader\EXPIRES, ILIAS\FileDelivery\http(), ILIAS\HTTP\Response\ResponseHeader\PRAGMA, ILIAS\FileDelivery\Delivery\sendEtagHeader(), and ILIAS\FileDelivery\Delivery\sendLastModified().

Referenced by ILIAS\FileDelivery\Delivery\checkCache().

153  : void
154  {
155  $response = $this->http->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
156 
157  $this->http->saveResponse($response->withHeader(ResponseHeader::EXPIRES, date("D, j M Y H:i:s", strtotime(self::EXPIRES_IN)) . " GMT"));
158  $this->sendEtagHeader();
159  $this->sendLastModified();
160  }
static http()
Fetches the global http state from ILIAS.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::setConvertFileNameToAsci ( bool  $convert_file_name_to_asci)

Definition at line 332 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

Referenced by ilFileDelivery\deliverFileLegacy().

332  : void
333  {
334  $this->convert_file_name_to_asci = $convert_file_name_to_asci;
335  }
+ Here is the caller graph for this function:

◆ setDEBUG()

static ILIAS\FileDelivery\Delivery::setDEBUG ( bool  $DEBUG)
static

Definition at line 425 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

425  : void
426  {
427  self::$DEBUG = $DEBUG;
428  }

◆ setDeleteFile()

ILIAS\FileDelivery\Delivery::setDeleteFile ( bool  $delete_file)

Definition at line 523 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

Referenced by ilFileDelivery\deliverFileLegacy().

523  : void
524  {
525  $this->delete_file = $delete_file;
526  }
+ Here is the caller graph for this function:

◆ setDeliveryType()

ILIAS\FileDelivery\Delivery::setDeliveryType ( string  $delivery_type)

Definition at line 248 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

Referenced by ILIAS\FileDelivery\Delivery\detemineDeliveryType(), and ILIAS\FileDelivery\Delivery\stream().

248  : void
249  {
250  $this->delivery_type = $delivery_type;
251  }
+ Here is the caller graph for this function:

◆ setDisposition()

ILIAS\FileDelivery\Delivery::setDisposition ( string  $disposition)

Definition at line 296 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

Referenced by ilFileDelivery\deliverFileLegacy().

296  : void
297  {
298  $this->disposition = $disposition;
299  }
+ Here is the caller graph for this function:

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

Definition at line 529 of file Delivery.php.

References $response, ILIAS\HTTP\Response\ResponseHeader\CONTENT_DISPOSITION, ILIAS\FileDelivery\Delivery\getDisposition(), ILIAS\FileDelivery\Delivery\getDownloadFileName(), and ILIAS\FileDelivery\http().

Referenced by ILIAS\FileDelivery\Delivery\setGeneralHeaders().

529  : void
530  {
531  $response = $this->http->response();
532  $response = $response->withHeader(
534  $this->getDisposition()
535  . '; filename="'
536  . $this->getDownloadFileName()
537  . '"'
538  );
539  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
540  $this->http->saveResponse($response);
541  }
static http()
Fetches the global http state from ILIAS.
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDownloadFileName()

ILIAS\FileDelivery\Delivery::setDownloadFileName ( string  $download_file_name)

◆ setEtag()

ILIAS\FileDelivery\Delivery::setEtag ( string  $etag)

Definition at line 344 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

Referenced by ILIAS\FileDelivery\Delivery\generateEtag().

344  : void
345  {
346  $this->etag = $etag;
347  }
+ Here is the caller graph for this function:

◆ setExitAfter()

ILIAS\FileDelivery\Delivery::setExitAfter ( bool  $exit_after)

Definition at line 320 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

Referenced by ilFileDelivery\deliverFileLegacy().

320  : void
321  {
322  $this->exit_after = $exit_after;
323  }
+ Here is the caller graph for this function:

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

Definition at line 126 of file Delivery.php.

References $response, ILIAS\HTTP\Response\ResponseHeader\ACCEPT_RANGES, ILIAS\FileDelivery\Delivery\checkExisting(), ILIAS\FileDelivery\Delivery\cleanDownloadFileName(), ILIAS\HTTP\Response\ResponseHeader\CONNECTION, ILIAS\HTTP\Response\ResponseHeader\CONTENT_LENGTH, ILIAS\HTTP\Response\ResponseHeader\CONTENT_TYPE, ILIAS\FileDelivery\Delivery\getDeliveryType(), ILIAS\FileDelivery\Delivery\getDownloadFileName(), ILIAS\FileDelivery\Delivery\getMimeType(), ILIAS\FileDelivery\Delivery\getPathToFile(), ILIAS\FileDelivery\Delivery\hasHashFilename(), ILIAS\FileDelivery\http(), ILIAS\FileDelivery\Delivery\isConvertFileNameToAsci(), ILIAS\FileDelivery\Delivery\isSendMimeType(), ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\PHP, ILIAS\FileDelivery\Delivery\setDispositionHeaders(), and ILIAS\FileDelivery\Delivery\setDownloadFileName().

Referenced by ILIAS\FileDelivery\Delivery\deliver().

126  : void
127  {
128  $this->checkExisting();
129  if ($this->isSendMimeType()) {
130  $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_TYPE, $this->getMimeType());
131  $this->http->saveResponse($response);
132  }
133  if ($this->isConvertFileNameToAsci()) {
134  $this->cleanDownloadFileName();
135  }
136  if ($this->hasHashFilename()) {
137  $this->setDownloadFileName(md5($this->getDownloadFileName()));
138  }
139  $this->setDispositionHeaders();
140  $response = $this->http->response()->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
141  $this->http->saveResponse($response);
142  if ($this->getDeliveryType() === DeliveryMethod::PHP
143  && $this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
144  ) {
145  $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_LENGTH, (string) filesize($this->getPathToFile()));
146  $this->http->saveResponse($response);
147  }
148  $response = $this->http->response()->withHeader(ResponseHeader::CONNECTION, "close");
149  $this->http->saveResponse($response);
150  }
static http()
Fetches the global http state from ILIAS.
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:474
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:284
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHasContext()

ILIAS\FileDelivery\Delivery::setHasContext ( bool  $has_context)

Definition at line 368 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

Referenced by ILIAS\FileDelivery\Delivery\__construct().

368  : void
369  {
370  $this->has_context = $has_context;
371  }
+ Here is the caller graph for this function:

◆ setHashFilename()

ILIAS\FileDelivery\Delivery::setHashFilename ( bool  $hash_filename)

Definition at line 392 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

392  : void
393  {
394  $this->hash_filename = $hash_filename;
395  }

◆ setMimeType()

ILIAS\FileDelivery\Delivery::setMimeType ( string  $mime_type)

Definition at line 260 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

Referenced by ilUtil\deliverData(), ilFileDelivery\deliverFileLegacy(), and ILIAS\FileDelivery\Delivery\determineMimeType().

260  : void
261  {
262  $this->mime_type = $mime_type;
263  }
+ Here is the caller graph for this function:

◆ setPathToFile()

ILIAS\FileDelivery\Delivery::setPathToFile ( string  $path_to_file)

Definition at line 272 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

Referenced by ILIAS\FileDelivery\Delivery\__construct().

272  : void
273  {
274  $this->path_to_file = $path_to_file;
275  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

ILIAS\FileDelivery\Delivery::setSendMimeType ( bool  $send_mime_type)

Definition at line 308 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

308  : void
309  {
310  $this->send_mime_type = $send_mime_type;
311  }

◆ setShowLastModified()

ILIAS\FileDelivery\Delivery::setShowLastModified ( bool  $show_last_modified)

Definition at line 356 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

Referenced by ILIAS\FileDelivery\Delivery\checkCache().

356  : void
357  {
358  $this->show_last_modified = $show_last_modified;
359  }
+ Here is the caller graph for this function:

◆ stream()

ILIAS\FileDelivery\Delivery::stream ( )

Field Documentation

◆ $cache

bool ILIAS\FileDelivery\Delivery::$cache = false
private

◆ $convert_file_name_to_asci

bool ILIAS\FileDelivery\Delivery::$convert_file_name_to_asci = true
private

◆ $DEBUG

bool ILIAS\FileDelivery\Delivery::$DEBUG = false
staticprivate

Definition at line 58 of file Delivery.php.

Referenced by ILIAS\FileDelivery\Delivery\setDEBUG().

◆ $delete_file

bool ILIAS\FileDelivery\Delivery::$delete_file = false
private

◆ $delivery_type

string ILIAS\FileDelivery\Delivery::$delivery_type = DeliveryMethod::PHP
private

◆ $delivery_type_static

string ILIAS\FileDelivery\Delivery::$delivery_type_static = null
staticprivate

Definition at line 43 of file Delivery.php.

◆ $disposition

string ILIAS\FileDelivery\Delivery::$disposition = self::DISP_ATTACHMENT
private

◆ $download_file_name

string ILIAS\FileDelivery\Delivery::$download_file_name = ''
private

◆ $etag

string ILIAS\FileDelivery\Delivery::$etag = ''
private

◆ $exit_after

bool ILIAS\FileDelivery\Delivery::$exit_after = true
private

◆ $factory

FileDeliveryTypeFactory ILIAS\FileDelivery\Delivery::$factory
private

Definition at line 60 of file Delivery.php.

◆ $has_context

bool ILIAS\FileDelivery\Delivery::$has_context = true
private

◆ $hash_filename

bool ILIAS\FileDelivery\Delivery::$hash_filename = false
private

◆ $http

Services ILIAS\FileDelivery\Delivery::$http
private

Definition at line 59 of file Delivery.php.

Referenced by ILIAS\FileDelivery\Delivery\__construct().

◆ $mime_type

string ILIAS\FileDelivery\Delivery::$mime_type = ''
private

◆ $path_to_file

string ILIAS\FileDelivery\Delivery::$path_to_file = ''
private

◆ $send_mime_type

bool ILIAS\FileDelivery\Delivery::$send_mime_type = true
private

◆ $show_last_modified

bool ILIAS\FileDelivery\Delivery::$show_last_modified = true
private

◆ DIRECT_PHP_OUTPUT

const ILIAS\FileDelivery\Delivery::DIRECT_PHP_OUTPUT = 'php://output'

Definition at line 39 of file Delivery.php.

◆ DISP_ATTACHMENT

const ILIAS\FileDelivery\Delivery::DISP_ATTACHMENT = 'attachment'

Definition at line 40 of file Delivery.php.

◆ DISP_INLINE

const ILIAS\FileDelivery\Delivery::DISP_INLINE = 'inline'

Definition at line 41 of file Delivery.php.

◆ EXPIRES_IN

const ILIAS\FileDelivery\Delivery::EXPIRES_IN = '+5 days'

Definition at line 42 of file Delivery.php.


The documentation for this class was generated from the following file: