ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\FileDelivery\Delivery Class Reference

Class Delivery. More...

+ Collaboration diagram for ILIAS\FileDelivery\Delivery:

Data Structures

class  BaseDelivery
 
class  LegacyDelivery
 

Public Types

enum  Disposition : string { INLINE = 'inline' }
 

Public Member Functions

 __construct ($input, 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
 
FileStream $resource = null
 

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 38 of file Delivery.php.

Member Enumeration Documentation

◆ Disposition

enum ILIAS::FileDelivery::Delivery::Disposition : string
Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s
Enumerator
INLINE 

Definition at line 26 of file Disposition.php.

26  : string
27 {
28  case ATTACHMENT = 'attachment';
29  case INLINE = 'inline';
30 }

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 69 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().

70  {
71  $this->http = $http;
72  if ($input instanceof FileStream) {
73  $this->resource = $input;
74  $this->path_to_file = $input->getMetadata('uri');
75  } elseif ($input === self::DIRECT_PHP_OUTPUT) {
76  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
77  } else {
78  $this->setPathToFile($input);
79  }
80 
81  $this->detemineDeliveryType();
82  $this->determineMimeType();
84 
85  $this->setHasContext(\ilContext::getType() !== null);
86  $this->factory = new FileDeliveryTypeFactory($http);
87  }
setHasContext(bool $has_context)
Definition: Delivery.php:378
static http()
Fetches the global http state from ILIAS.
static getType()
Get context type.
setPathToFile(string $path_to_file)
Definition: Delivery.php:282
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )

Definition at line 441 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().

441  : void
442  {
443  if ($this->hasCache()) {
444  $this->generateEtag();
445  $this->sendEtagHeader();
446  $this->setShowLastModified(true);
447  $this->setCachingHeaders();
448  }
449  }
setShowLastModified(bool $show_last_modified)
Definition: Delivery.php:366
+ 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 471 of file Delivery.php.

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

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

471  : void
472  {
473  if ($this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
474  && !file_exists($this->getPathToFile())
475  ) {
476  $this->close();
477  }
478  }
+ 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 484 of file Delivery.php.

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

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

484  : void
485  {
486  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
488  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:294
+ 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 455 of file Delivery.php.

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

455  : bool
456  {
457  try {
458  $ob_get_contents = ob_get_contents();
459  if ($ob_get_contents) {
460  // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
461  // . $ob_get_contents);
462  }
463  ob_end_clean(); // fixed 0016469, 0016467, 0016468
464  return true;
465  } catch (\Throwable $t) {
466  return false;
467  }
468  }
+ Here is the caller graph for this function:

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 179 of file Delivery.php.

References ILIAS\FileDelivery\http().

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

179  : void
180  {
181  $this->http->close();
182  }
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 108 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().

108  : void
109  {
110  $response = $this->http->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
111  if (
112  !$this->delivery()->doesFileExists($this->path_to_file)
113  && $this->path_to_file !== self::DIRECT_PHP_OUTPUT
114  ) {
115  $response = $this->http->response()->withStatus(404);
116  $this->http->saveResponse($response);
117  $this->http->sendResponse();
118  $this->close();
119  }
120  $this->http->saveResponse($response);
121 
122  $this->clearBuffer();
123  $this->checkCache();
124  $this->setGeneralHeaders();
125  $this->delivery()->prepare($this->getPathToFile(), $this->resource);
126  $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
127  if ($this->isDeleteFile()) {
128  $this->delivery()->handleFileDeletion($this->getPathToFile());
129  }
130  if ($this->isExitAfter()) {
131  $this->close();
132  }
133  }
$response
Definition: xapitoken.php:93
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:

◆ delivery()

ILIAS\FileDelivery\Delivery::delivery ( )
private

Definition at line 98 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDeliveryType(), ILIAS\FileDelivery\Delivery\isDeleteFile(), and ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\PHP.

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

98  : ilFileDeliveryType
99  {
100  if ($this->isDeleteFile()) {
101  return $this->factory->getInstance(DeliveryMethod::PHP);
102  }
103 
104  return $this->factory->getInstance($this->getDeliveryType());
105  }
+ 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 213 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().

213  : void
214  {
215  if (self::$delivery_type_static) {
216  $this->setDeliveryType(self::$delivery_type_static);
217 
218  return;
219  }
220 
221  if (function_exists('apache_get_modules')
222  && in_array('mod_xsendfile', apache_get_modules(), true)
223  ) {
225  }
226 
227  if (is_file('./Services/FileDelivery/classes/override.php')) {
228  $override_delivery_type = false;
230  require_once('./Services/FileDelivery/classes/override.php');
231  if ($override_delivery_type) {
232  $this->setDeliveryType($override_delivery_type);
233  }
234  }
235  $ilRuntime = \ilRuntime::getInstance();
236  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
238  ) {
240  }
241 
242  if ($this->getDeliveryType() === DeliveryMethod::XACCEL
243  && strpos($this->getPathToFile(), './data') !== 0
244  ) {
246  }
247 
248  self::$delivery_type_static = $this->getDeliveryType();
249  }
static getInstance()
setDeliveryType(string $delivery_type)
Definition: Delivery.php:258
+ 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 204 of file Delivery.php.

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

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

204  : void
205  {
206  if (!$this->getDownloadFileName()) {
207  $download_file_name = basename($this->getPathToFile());
209  }
210  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:294
+ 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 185 of file Delivery.php.

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

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

185  : void
186  {
187  $info = \ILIAS\FileUpload\MimeType::lookupMimeType($this->getPathToFile(), \ILIAS\FileUpload\MimeType::APPLICATION__OCTET_STREAM);
188  if ($info) {
189  $this->setMimeType($info);
190 
191  return;
192  }
193  $finfo = finfo_open(FILEINFO_MIME_TYPE);
194  $info = finfo_file($finfo, $this->getPathToFile());
195  finfo_close($finfo);
196  if ($info) {
197  $this->setMimeType($info);
198 
199  return;
200  }
201  }
setMimeType(string $mime_type)
Definition: Delivery.php:270
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 173 of file Delivery.php.

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

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

173  : void
174  {
175  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
176  }
+ 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 300 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

300  : string
301  {
302  return $this->disposition;
303  }
+ Here is the caller graph for this function:

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )

Definition at line 348 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

348  : string
349  {
350  return $this->etag;
351  }
+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )

Definition at line 264 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

264  : string
265  {
266  return $this->mime_type;
267  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )

Definition at line 360 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

360  : bool
361  {
363  }
+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )

Definition at line 384 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

384  : bool
385  {
386  return $this->cache;
387  }
+ Here is the caller graph for this function:

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )

Definition at line 396 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

396  : bool
397  {
398  return $this->hash_filename;
399  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )

Definition at line 336 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

336  : bool
337  {
339  }
+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 429 of file Delivery.php.

429  : bool
430  {
431  return self::$DEBUG;
432  }

◆ isDeleteFile()

ILIAS\FileDelivery\Delivery::isDeleteFile ( )

Definition at line 527 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

527  : bool
528  {
529  return $this->delete_file;
530  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )

Definition at line 324 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

324  : bool
325  {
326  return $this->exit_after;
327  }
+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )

Definition at line 372 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

372  : bool
373  {
374  return $this->has_context;
375  }

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )

Definition at line 312 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

312  : bool
313  {
314  return $this->send_mime_type;
315  }
+ 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 498 of file Delivery.php.

Referenced by ilFileDataForumDraftsRCImplementation\deliverZipFile(), and ilFileDataForumRCImplementation\deliverZipFile().

498  : string
499  {
500  $umlaut_mapping = [
501  "Ä" => "Ae",
502  "Ö" => "Oe",
503  "Ü" => "Ue",
504  "ä" => "ae",
505  "ö" => "oe",
506  "ü" => "ue",
507  "ß" => "ss"
508  ];
509  foreach ($umlaut_mapping as $src => $tgt) {
510  $original_filename = str_replace($src, $tgt, $original_filename);
511  }
512 
513  $ascii_filename = htmlentities($original_filename, ENT_NOQUOTES, 'UTF-8');
514  $ascii_filename = preg_replace('/\&(.)[^;]*;/', '\\1', $ascii_filename);
515  $ascii_filename = preg_replace('/[\x7f-\xff]/', '_', $ascii_filename);
516 
517  // OS do not allow the following characters in filenames: \/:*?"<>|
518  $ascii_filename = preg_replace(
519  '/[:\x5c\/\*\?\"<>\|]/',
520  '_',
521  $ascii_filename
522  );
523  return $ascii_filename;
524  }
+ Here is the caller graph for this function:

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

Definition at line 408 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().

408  : void
409  {
410  if ($this->getEtag()) {
411  $response = $this->http->response()->withHeader('ETag', $this->getEtag());
412  $this->http->saveResponse($response);
413  }
414  }
$response
Definition: xapitoken.php:93
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:

◆ sendLastModified()

ILIAS\FileDelivery\Delivery::sendLastModified ( )
private

Definition at line 417 of file Delivery.php.

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

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

417  : void
418  {
419  if ($this->getShowLastModified()) {
420  $response = $this->http->response()->withHeader(
421  'Last-Modified',
422  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
423  . " GMT"
424  );
425  $this->http->saveResponse($response);
426  }
427  }
$response
Definition: xapitoken.php:93
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:

◆ setCache()

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

Definition at line 390 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

390  : void
391  {
392  $this->cache = $cache;
393  }

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 163 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().

163  : void
164  {
165  $response = $this->http->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
166 
167  $this->http->saveResponse($response->withHeader(ResponseHeader::EXPIRES, date("D, j M Y H:i:s", strtotime(self::EXPIRES_IN)) . " GMT"));
168  $this->sendEtagHeader();
169  $this->sendLastModified();
170  }
$response
Definition: xapitoken.php:93
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:

◆ setConvertFileNameToAsci()

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

Definition at line 342 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

Referenced by ilFileDelivery\deliverFileLegacy().

342  : void
343  {
344  $this->convert_file_name_to_asci = $convert_file_name_to_asci;
345  }
+ Here is the caller graph for this function:

◆ setDEBUG()

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

Definition at line 435 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

435  : void
436  {
437  self::$DEBUG = $DEBUG;
438  }

◆ setDeleteFile()

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

Definition at line 533 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

Referenced by ilFileDelivery\deliverFileLegacy().

533  : void
534  {
535  $this->delete_file = $delete_file;
536  }
+ Here is the caller graph for this function:

◆ setDeliveryType()

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

Definition at line 258 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

258  : void
259  {
260  $this->delivery_type = $delivery_type;
261  }
+ Here is the caller graph for this function:

◆ setDisposition()

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

Definition at line 306 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

Referenced by ilFileDelivery\deliverFileLegacy().

306  : void
307  {
308  $this->disposition = $disposition;
309  }
+ Here is the caller graph for this function:

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

Definition at line 539 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().

539  : void
540  {
541  $response = $this->http->response();
542  $response = $response->withHeader(
544  $this->getDisposition()
545  . '; filename="'
546  . $this->getDownloadFileName()
547  . '"'
548  );
549  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
550  $this->http->saveResponse($response);
551  }
$response
Definition: xapitoken.php:93
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:

◆ setDownloadFileName()

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

◆ setEtag()

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

Definition at line 354 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

354  : void
355  {
356  $this->etag = $etag;
357  }
+ Here is the caller graph for this function:

◆ setExitAfter()

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

Definition at line 330 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

Referenced by ilFileDelivery\deliverFileLegacy().

330  : void
331  {
332  $this->exit_after = $exit_after;
333  }
+ Here is the caller graph for this function:

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

Definition at line 136 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().

136  : void
137  {
138  $this->checkExisting();
139  if ($this->isSendMimeType()) {
140  $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_TYPE, $this->getMimeType());
141  $this->http->saveResponse($response);
142  }
143  if ($this->isConvertFileNameToAsci()) {
144  $this->cleanDownloadFileName();
145  }
146  if ($this->hasHashFilename()) {
147  $this->setDownloadFileName(md5($this->getDownloadFileName()));
148  }
149  $this->setDispositionHeaders();
150  $response = $this->http->response()->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
151  $this->http->saveResponse($response);
152  if ($this->getDeliveryType() === DeliveryMethod::PHP
153  && $this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
154  ) {
155  $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_LENGTH, (string) filesize($this->getPathToFile()));
156  $this->http->saveResponse($response);
157  }
158  $response = $this->http->response()->withHeader(ResponseHeader::CONNECTION, "close");
159  $this->http->saveResponse($response);
160  }
$response
Definition: xapitoken.php:93
static http()
Fetches the global http state from ILIAS.
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:484
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:294
+ 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 378 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

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

378  : void
379  {
380  $this->has_context = $has_context;
381  }
+ Here is the caller graph for this function:

◆ setHashFilename()

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

Definition at line 402 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

402  : void
403  {
404  $this->hash_filename = $hash_filename;
405  }

◆ setMimeType()

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

Definition at line 270 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

270  : void
271  {
272  $this->mime_type = $mime_type;
273  }
+ Here is the caller graph for this function:

◆ setPathToFile()

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

Definition at line 282 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

282  : void
283  {
284  $this->path_to_file = $path_to_file;
285  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

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

Definition at line 318 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

318  : void
319  {
320  $this->send_mime_type = $send_mime_type;
321  }

◆ setShowLastModified()

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

Definition at line 366 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

366  : void
367  {
368  $this->show_last_modified = $show_last_modified;
369  }
+ 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 59 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 44 of file Delivery.php.

◆ $disposition

◆ $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 61 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 60 of file Delivery.php.

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

◆ $mime_type

◆ $path_to_file

◆ $resource

FileStream ILIAS\FileDelivery\Delivery::$resource = null
private

Definition at line 62 of file Delivery.php.

◆ $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 40 of file Delivery.php.

Referenced by ILIAS\Repository\HTTP\HTTPUtil\deliverString().

◆ DISP_ATTACHMENT

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

Definition at line 41 of file Delivery.php.

Referenced by ILIAS\Repository\HTTP\HTTPUtil\deliverString().

◆ DISP_INLINE

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

Definition at line 42 of file Delivery.php.

◆ EXPIRES_IN

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

Definition at line 43 of file Delivery.php.


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