ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\FileDelivery\Delivery Class Reference

Class Delivery. More...

+ Collaboration diagram for ILIAS\FileDelivery\Delivery:

Public Types

enum  Disposition : string { INLINE = 'inline' }
 

Public Member Functions

 __construct ($input, private 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
 
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 39 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,
private Services  $http 
)
Parameters
string | FileStream$path_to_file
Services$http

Definition at line 81 of file Delivery.php.

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

82  {
83  if ($input instanceof FileStream) {
84  $this->resource = $input;
85  $this->path_to_file = $input->getMetadata('uri');
86  } elseif ($input === self::DIRECT_PHP_OUTPUT) {
87  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
88  } else {
89  $this->setPathToFile($input);
90  }
91 
92  $this->detemineDeliveryType();
93  $this->determineMimeType();
95 
96  $this->setHasContext(\ilContext::getType() !== null);
97  $this->factory = new FileDeliveryTypeFactory($this->http);
98  }
setHasContext(bool $has_context)
Definition: Delivery.php:390
factory()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
static getType()
Get context type.
setPathToFile(string $path_to_file)
Definition: Delivery.php:294
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )

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

453  : void
454  {
455  if ($this->hasCache()) {
456  $this->generateEtag();
457  $this->sendEtagHeader();
458  $this->setShowLastModified(true);
459  $this->setCachingHeaders();
460  }
461  }
setShowLastModified(bool $show_last_modified)
Definition: Delivery.php:378
+ 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 483 of file Delivery.php.

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

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

483  : void
484  {
485  if ($this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
486  && !file_exists($this->getPathToFile())
487  ) {
488  $this->close();
489  }
490  }
+ 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 496 of file Delivery.php.

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

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

496  : void
497  {
498  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
500  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:306
+ 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 467 of file Delivery.php.

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

467  : bool
468  {
469  try {
470  $ob_get_contents = ob_get_contents();
471  if ($ob_get_contents) {
472  // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
473  // . $ob_get_contents);
474  }
475  ob_end_clean(); // fixed 0016469, 0016467, 0016468
476  return true;
477  } catch (\Throwable) {
478  return false;
479  }
480  }
+ Here is the caller graph for this function:

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 187 of file Delivery.php.

References ILIAS\FileDelivery\http().

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

187  : void
188  {
189  $this->http->close();
190  }
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 116 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().

116  : void
117  {
118  $response = $this->http->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
119  if (
120  !$this->delivery()->doesFileExists($this->path_to_file)
121  && $this->path_to_file !== self::DIRECT_PHP_OUTPUT
122  ) {
123  $response = $this->http->response()->withStatus(404);
124  $this->http->saveResponse($response);
125  $this->http->sendResponse();
126  $this->close();
127  }
128  $this->http->saveResponse($response);
129 
130  $this->clearBuffer();
131  $this->checkCache();
132  $this->setGeneralHeaders();
133  $this->delivery()->prepare($this->getPathToFile(), $this->resource);
134  $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
135  if ($this->isDeleteFile()) {
136  $this->delivery()->handleFileDeletion($this->getPathToFile());
137  }
138  if ($this->isExitAfter()) {
139  $this->close();
140  }
141  }
$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 110 of file Delivery.php.

References factory(), and ILIAS\FileDelivery\Delivery\getDeliveryType().

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

110  : ilFileDeliveryType
111  {
112  return $this->factory->getInstance($this->getDeliveryType());
113  }
factory()
+ 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 221 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().

221  : void
222  {
223  if (self::$delivery_type_static) {
224  $this->setDeliveryType(self::$delivery_type_static);
225 
226  return;
227  }
228 
229  if (function_exists('apache_get_modules')
230  && in_array('mod_xsendfile', apache_get_modules(), true)
231  ) {
233  }
234 
235  // if (function_exists('apache_get_version') && strpos(apache_get_version(), '2.4.') !== false) {
236  // $this->setDeliveryType(DeliveryMethod::XSENDFILE);
237  // }
238 
239  if (is_file('./components/ILIAS/FileDelivery/classes/override.php')) {
240  $override_delivery_type = false;
242  require_once('./components/ILIAS/FileDelivery/classes/override.php');
243  if ($override_delivery_type) {
244  $this->setDeliveryType($override_delivery_type);
245  }
246  }
247  $ilRuntime = \ilRuntime::getInstance();
248  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
250  ) {
252  }
253 
254  if ($this->getDeliveryType() === DeliveryMethod::XACCEL
255  && !str_starts_with($this->getPathToFile(), './public/data')
256  ) {
258  }
259 
260  self::$delivery_type_static = $this->getDeliveryType();
261  }
static getInstance()
setDeliveryType(string $delivery_type)
Definition: Delivery.php:270
+ 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 212 of file Delivery.php.

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

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

212  : void
213  {
214  if ($this->getDownloadFileName() === '' || $this->getDownloadFileName() === '0') {
215  $download_file_name = basename($this->getPathToFile());
217  }
218  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:306
+ 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 193 of file Delivery.php.

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

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

193  : void
194  {
196  if ($info !== '' && $info !== '0') {
197  $this->setMimeType($info);
198 
199  return;
200  }
201  $finfo = finfo_open(FILEINFO_MIME_TYPE);
202  $info = finfo_file($finfo, $this->getPathToFile());
203  finfo_close($finfo);
204  if ($info) {
205  $this->setMimeType($info);
206 
207  return;
208  }
209  }
setMimeType(string $mime_type)
Definition: Delivery.php:282
static lookupMimeType(string $path_to_file, string $fallback=self::APPLICATION__OCTET_STREAM, bool $a_external=false)
Definition: MimeType.php:544
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ILIAS\FileDelivery\Delivery::generateEtag ( )

Definition at line 181 of file Delivery.php.

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

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

181  : void
182  {
183  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
184  }
+ 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 312 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

312  : string
313  {
314  return $this->disposition;
315  }
+ Here is the caller graph for this function:

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )

Definition at line 360 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

360  : string
361  {
362  return $this->etag;
363  }
+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )

Definition at line 276 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

276  : string
277  {
278  return $this->mime_type;
279  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )

Definition at line 372 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

372  : bool
373  {
375  }
+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )

Definition at line 396 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

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

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )

Definition at line 408 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

408  : bool
409  {
410  return $this->hash_filename;
411  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )

Definition at line 348 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

348  : bool
349  {
351  }
+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 441 of file Delivery.php.

441  : bool
442  {
443  return self::$DEBUG;
444  }

◆ isDeleteFile()

ILIAS\FileDelivery\Delivery::isDeleteFile ( )

Definition at line 539 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

539  : bool
540  {
541  return $this->delete_file;
542  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )

Definition at line 336 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

336  : bool
337  {
338  return $this->exit_after;
339  }
+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )

Definition at line 384 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

384  : bool
385  {
386  return $this->has_context;
387  }

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )

Definition at line 324 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

324  : bool
325  {
326  return $this->send_mime_type;
327  }
+ 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 510 of file Delivery.php.

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

510  : string
511  {
512  $umlaut_mapping = [
513  "Ä" => "Ae",
514  "Ö" => "Oe",
515  "Ü" => "Ue",
516  "ä" => "ae",
517  "ö" => "oe",
518  "ü" => "ue",
519  "ß" => "ss"
520  ];
521  foreach ($umlaut_mapping as $src => $tgt) {
522  $original_filename = str_replace($src, $tgt, $original_filename);
523  }
524 
525  $ascii_filename = htmlentities($original_filename, ENT_NOQUOTES, 'UTF-8');
526  $ascii_filename = preg_replace('/\&(.)[^;]*;/', '\\1', $ascii_filename);
527  $ascii_filename = preg_replace('/[\x7f-\xff]/', '_', (string) $ascii_filename);
528 
529  // OS do not allow the following characters in filenames: \/:*?"<>|
530  $ascii_filename = preg_replace(
531  '/[:\x5c\/\*\?\"<>\|]/',
532  '_',
533  (string) $ascii_filename
534  );
535  return $ascii_filename;
536  }
+ Here is the caller graph for this function:

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

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

420  : void
421  {
422  if ($this->getEtag() !== '' && $this->getEtag() !== '0') {
423  $response = $this->http->response()->withHeader('ETag', $this->getEtag());
424  $this->http->saveResponse($response);
425  }
426  }
$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 429 of file Delivery.php.

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

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

429  : void
430  {
431  if ($this->getShowLastModified()) {
432  $response = $this->http->response()->withHeader(
433  'Last-Modified',
434  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
435  . " GMT"
436  );
437  $this->http->saveResponse($response);
438  }
439  }
$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 402 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 171 of file Delivery.php.

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

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

171  : void
172  {
173  $response = $this->http->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
174 
175  $this->http->saveResponse($response->withHeader(ResponseHeader::EXPIRES, date("D, j M Y H:i:s", strtotime(self::EXPIRES_IN)) . " GMT"));
176  $this->sendEtagHeader();
177  $this->sendLastModified();
178  }
$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 354 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

Referenced by ilFileDelivery\deliverFileLegacy().

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

◆ setDEBUG()

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

Definition at line 447 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

447  : void
448  {
449  self::$DEBUG = $DEBUG;
450  }

◆ setDeleteFile()

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

Definition at line 545 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

Referenced by ilFileDelivery\deliverFileLegacy().

545  : void
546  {
547  $this->delete_file = $delete_file;
548  }
+ Here is the caller graph for this function:

◆ setDeliveryType()

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

Definition at line 270 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

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

◆ setDisposition()

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

Definition at line 318 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

Referenced by ilFileDelivery\deliverFileLegacy().

318  : void
319  {
320  $this->disposition = $disposition;
321  }
+ Here is the caller graph for this function:

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

Definition at line 551 of file Delivery.php.

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

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

551  : void
552  {
553  $response = $this->http->response();
554  $response = $response->withHeader(
556  $this->getDisposition()
557  . '; filename="'
558  . $this->getDownloadFileName()
559  . '"'
560  );
561  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
562  $this->http->saveResponse($response);
563  }
$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 366 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

366  : void
367  {
368  $this->etag = $etag;
369  }
+ Here is the caller graph for this function:

◆ setExitAfter()

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

Definition at line 342 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

Referenced by ilFileDelivery\deliverFileLegacy().

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

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

Definition at line 144 of file Delivery.php.

References $response, ILIAS\StaticURL\Response\Response\ResponseHeader\ACCEPT_RANGES, ILIAS\FileDelivery\Delivery\checkExisting(), ILIAS\FileDelivery\Delivery\cleanDownloadFileName(), ILIAS\StaticURL\Response\Response\ResponseHeader\CONNECTION, ILIAS\StaticURL\Response\Response\ResponseHeader\CONTENT_LENGTH, ILIAS\StaticURL\Response\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().

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

References ILIAS\FileDelivery\Delivery\$has_context.

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

390  : void
391  {
392  $this->has_context = $has_context;
393  }
+ Here is the caller graph for this function:

◆ setHashFilename()

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

Definition at line 414 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

414  : void
415  {
416  $this->hash_filename = $hash_filename;
417  }

◆ setMimeType()

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

Definition at line 282 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

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

◆ setPathToFile()

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

Definition at line 294 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

294  : void
295  {
296  $this->path_to_file = $path_to_file;
297  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

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

Definition at line 330 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

330  : void
331  {
332  $this->send_mime_type = $send_mime_type;
333  }

◆ setShowLastModified()

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

Definition at line 378 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

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

◆ stream()

ILIAS\FileDelivery\Delivery::stream ( )

Definition at line 101 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\deliver(), ILIAS\FileDelivery\Delivery\delivery(), ILIAS\FileDelivery\FileDeliveryTypes\DeliveryMethod\PHP_CHUNKED, and ILIAS\FileDelivery\Delivery\setDeliveryType().

101  : void
102  {
103  if (!$this->delivery()->supportsStreaming()) {
105  }
106  $this->deliver();
107  }
setDeliveryType(string $delivery_type)
Definition: Delivery.php:270
+ Here is the call graph for this function:

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 72 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 57 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 73 of file Delivery.php.

◆ $has_context

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

◆ $hash_filename

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

◆ $mime_type

◆ $path_to_file

◆ $resource

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

Definition at line 74 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'

◆ DISP_ATTACHMENT

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

◆ DISP_INLINE

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

Definition at line 52 of file Delivery.php.

◆ EXPIRES_IN

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

Definition at line 56 of file Delivery.php.


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