ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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, 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:382
static http()
Fetches the global http state from ILIAS.
static getType()
Get context type.
setPathToFile(string $path_to_file)
Definition: Delivery.php:286
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )

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

445  : void
446  {
447  if ($this->hasCache()) {
448  $this->generateEtag();
449  $this->sendEtagHeader();
450  $this->setShowLastModified(true);
451  $this->setCachingHeaders();
452  }
453  }
setShowLastModified(bool $show_last_modified)
Definition: Delivery.php:370
+ 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 475 of file Delivery.php.

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

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

475  : void
476  {
477  if ($this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
478  && !file_exists($this->getPathToFile())
479  ) {
480  $this->close();
481  }
482  }
+ 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 488 of file Delivery.php.

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

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

488  : void
489  {
490  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
492  }
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:298
+ 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 459 of file Delivery.php.

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

459  : bool
460  {
461  try {
462  $ob_get_contents = ob_get_contents();
463  if ($ob_get_contents) {
464  // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
465  // . $ob_get_contents);
466  }
467  ob_end_clean(); // fixed 0016469, 0016467, 0016468
468  return true;
469  } catch (\Throwable $t) {
470  return false;
471  }
472  }
+ 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:90
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 (function_exists('apache_get_version') && strpos(apache_get_version(), '2.4.') !== false) {
228 // $this->setDeliveryType(DeliveryMethod::XSENDFILE);
229 // }
230 
231  if (is_file('./components/ILIAS/FileDelivery/classes/override.php')) {
232  $override_delivery_type = false;
234  require_once('./components/ILIAS/FileDelivery/classes/override.php');
235  if ($override_delivery_type) {
236  $this->setDeliveryType($override_delivery_type);
237  }
238  }
239  $ilRuntime = \ilRuntime::getInstance();
240  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
242  ) {
244  }
245 
246  if ($this->getDeliveryType() === DeliveryMethod::XACCEL
247  && strpos($this->getPathToFile(), './public/data') !== 0
248  ) {
250  }
251 
252  self::$delivery_type_static = $this->getDeliveryType();
253  }
static getInstance()
setDeliveryType(string $delivery_type)
Definition: Delivery.php:262
+ 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:298
+ 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(), 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:274
Interface Observer Contains several chained tasks and infos about them.
+ 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 304 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

304  : string
305  {
306  return $this->disposition;
307  }
+ Here is the caller graph for this function:

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )

Definition at line 352 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

352  : string
353  {
354  return $this->etag;
355  }
+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )

Definition at line 268 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

268  : string
269  {
270  return $this->mime_type;
271  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )

Definition at line 364 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

364  : bool
365  {
367  }
+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )

Definition at line 388 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

388  : bool
389  {
390  return $this->cache;
391  }
+ Here is the caller graph for this function:

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )

Definition at line 400 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

400  : bool
401  {
402  return $this->hash_filename;
403  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )

Definition at line 340 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

340  : bool
341  {
343  }
+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 433 of file Delivery.php.

433  : bool
434  {
435  return self::$DEBUG;
436  }

◆ isDeleteFile()

ILIAS\FileDelivery\Delivery::isDeleteFile ( )

Definition at line 531 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

531  : bool
532  {
533  return $this->delete_file;
534  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )

Definition at line 328 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

328  : bool
329  {
330  return $this->exit_after;
331  }
+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )

Definition at line 376 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

376  : bool
377  {
378  return $this->has_context;
379  }

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )

Definition at line 316 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

316  : bool
317  {
318  return $this->send_mime_type;
319  }
+ 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 502 of file Delivery.php.

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

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

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

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

412  : void
413  {
414  if ($this->getEtag()) {
415  $response = $this->http->response()->withHeader('ETag', $this->getEtag());
416  $this->http->saveResponse($response);
417  }
418  }
$response
Definition: xapitoken.php:90
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 421 of file Delivery.php.

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

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

421  : void
422  {
423  if ($this->getShowLastModified()) {
424  $response = $this->http->response()->withHeader(
425  'Last-Modified',
426  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
427  . " GMT"
428  );
429  $this->http->saveResponse($response);
430  }
431  }
$response
Definition: xapitoken.php:90
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 394 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

394  : void
395  {
396  $this->cache = $cache;
397  }

◆ 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:90
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 346 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

Referenced by ilFileDelivery\deliverFileLegacy().

346  : void
347  {
348  $this->convert_file_name_to_asci = $convert_file_name_to_asci;
349  }
+ Here is the caller graph for this function:

◆ setDEBUG()

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

Definition at line 439 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

439  : void
440  {
441  self::$DEBUG = $DEBUG;
442  }

◆ setDeleteFile()

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

Definition at line 537 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

Referenced by ilFileDelivery\deliverFileLegacy().

537  : void
538  {
539  $this->delete_file = $delete_file;
540  }
+ Here is the caller graph for this function:

◆ setDeliveryType()

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

Definition at line 262 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

262  : void
263  {
264  $this->delivery_type = $delivery_type;
265  }
+ Here is the caller graph for this function:

◆ setDisposition()

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

Definition at line 310 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

Referenced by ilFileDelivery\deliverFileLegacy().

310  : void
311  {
312  $this->disposition = $disposition;
313  }
+ Here is the caller graph for this function:

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

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

543  : void
544  {
545  $response = $this->http->response();
546  $response = $response->withHeader(
548  $this->getDisposition()
549  . '; filename="'
550  . $this->getDownloadFileName()
551  . '"'
552  );
553  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
554  $this->http->saveResponse($response);
555  }
$response
Definition: xapitoken.php:90
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 358 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

358  : void
359  {
360  $this->etag = $etag;
361  }
+ Here is the caller graph for this function:

◆ setExitAfter()

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

Definition at line 334 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

Referenced by ilFileDelivery\deliverFileLegacy().

334  : void
335  {
336  $this->exit_after = $exit_after;
337  }
+ 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:90
static http()
Fetches the global http state from ILIAS.
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:488
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:298
+ 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 382 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

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

382  : void
383  {
384  $this->has_context = $has_context;
385  }
+ Here is the caller graph for this function:

◆ setHashFilename()

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

Definition at line 406 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

406  : void
407  {
408  $this->hash_filename = $hash_filename;
409  }

◆ setMimeType()

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

Definition at line 274 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

274  : void
275  {
276  $this->mime_type = $mime_type;
277  }
+ Here is the caller graph for this function:

◆ setPathToFile()

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

Definition at line 286 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

286  : void
287  {
288  $this->path_to_file = $path_to_file;
289  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

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

Definition at line 322 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

322  : void
323  {
324  $this->send_mime_type = $send_mime_type;
325  }

◆ setShowLastModified()

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

Definition at line 370 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

370  : void
371  {
372  $this->show_last_modified = $show_last_modified;
373  }
+ 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'

◆ DISP_ATTACHMENT

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

◆ 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: