ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

@Internal

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.

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.

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 }
factory()
setHasContext(bool $has_context)
Definition: Delivery.php:393
setPathToFile(string $path_to_file)
Definition: Delivery.php:297
static getType()
Get context type.
The base interface for all filesystem streams.
Definition: FileStream.php:32
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )

Definition at line 456 of file Delivery.php.

456 : void
457 {
458 if ($this->hasCache()) {
459 $this->generateEtag();
460 $this->sendEtagHeader();
461 $this->setShowLastModified(true);
462 $this->setCachingHeaders();
463 }
464 }
setShowLastModified(bool $show_last_modified)
Definition: Delivery.php:381

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().

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

486 : void
487 {
488 if ($this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
489 && !file_exists($this->getPathToFile())
490 ) {
491 $this->close();
492 }
493 }

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

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

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

499 : void
500 {
503 }
static returnASCIIFileName(string $original_filename)
Converts a UTF-8 filename to ASCII.
Definition: Delivery.php:513
setDownloadFileName(string $download_file_name)
Definition: Delivery.php:309

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

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

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

470 : bool
471 {
472 try {
473 $ob_get_contents = ob_get_contents();
474 if ($ob_get_contents) {
475 // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
476 // . $ob_get_contents);
477 }
478 ob_end_clean(); // fixed 0016469, 0016467, 0016468
479 return true;
480 } catch (\Throwable) {
481 return false;
482 }
483 }

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

+ Here is the caller graph for this function:

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 190 of file Delivery.php.

190 : void
191 {
192 $this->http->close();
193 }

References ILIAS\FileDelivery\http().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deliver()

ILIAS\FileDelivery\Delivery::deliver ( )

Definition at line 119 of file Delivery.php.

119 : void
120 {
121 $response = $this->http->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
122 if (
123 !$this->delivery()->doesFileExists($this->path_to_file)
124 && $this->path_to_file !== self::DIRECT_PHP_OUTPUT
125 ) {
126 $response = $this->http->response()->withStatus(404);
127 $this->http->saveResponse($response);
128 $this->http->sendResponse();
129 $this->close();
130 }
131 $this->http->saveResponse($response);
132
133 $this->clearBuffer();
134 $this->checkCache();
135 $this->setGeneralHeaders();
136 $this->delivery()->prepare($this->getPathToFile(), $this->resource);
137 $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
138 if ($this->isDeleteFile()) {
139 $this->delivery()->handleFileDeletion($this->getPathToFile());
140 }
141 if ($this->isExitAfter()) {
142 $this->close();
143 }
144 }
$response
Definition: xapitoken.php:93

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 ILIAS\FileDelivery\Delivery\StreamDelivery\inline(), ILIAS\FileDelivery\Delivery\LegacyDelivery\inline(), and ILIAS\FileDelivery\Delivery\stream().

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

110 {
111 if ($this->isDeleteFile()) {
112 return $this->factory->getInstance(DeliveryMethod::PHP);
113 }
114
115 return $this->factory->getInstance($this->getDeliveryType());
116 }

References factory(), 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detemineDeliveryType()

ILIAS\FileDelivery\Delivery::detemineDeliveryType ( )
private

@noRector

Definition at line 224 of file Delivery.php.

224 : void
225 {
226 if (self::$delivery_type_static) {
227 $this->setDeliveryType(self::$delivery_type_static);
228
229 return;
230 }
231
232 if (function_exists('apache_get_modules')
233 && in_array('mod_xsendfile', apache_get_modules(), true)
234 ) {
236 }
237
238 // if (function_exists('apache_get_version') && strpos(apache_get_version(), '2.4.') !== false) {
239 // $this->setDeliveryType(DeliveryMethod::XSENDFILE);
240 // }
241
242 if (is_file('./components/ILIAS/FileDelivery/classes/override.php')) {
243 $override_delivery_type = false;
245 require_once('./components/ILIAS/FileDelivery/classes/override.php');
246 if ($override_delivery_type) {
247 $this->setDeliveryType($override_delivery_type);
248 }
249 }
250 $ilRuntime = \ilRuntime::getInstance();
251 if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
252 && $this->getDeliveryType() === DeliveryMethod::XACCEL
253 ) {
255 }
256
258 && !str_starts_with($this->getPathToFile(), './public/data')
259 ) {
261 }
262
263 self::$delivery_type_static = $this->getDeliveryType();
264 }
setDeliveryType(string $delivery_type)
Definition: Delivery.php:273
static getInstance()

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().

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

215 : void
216 {
217 if ($this->getDownloadFileName() === '' || $this->getDownloadFileName() === '0') {
218 $download_file_name = basename($this->getPathToFile());
220 }
221 }

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

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

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

196 : void
197 {
199 if ($info !== '' && $info !== '0') {
200 $this->setMimeType($info);
201
202 return;
203 }
204 $finfo = finfo_open(FILEINFO_MIME_TYPE);
205 $info = finfo_file($finfo, $this->getPathToFile());
206 finfo_close($finfo);
207 if ($info) {
208 $this->setMimeType($info);
209
210 return;
211 }
212 }
setMimeType(string $mime_type)
Definition: Delivery.php:285
static lookupMimeType(string $path_to_file, string $fallback=self::APPLICATION__OCTET_STREAM, bool $a_external=false)
Definition: MimeType.php:544
$info
Definition: entry_point.php:21

References $info, 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ILIAS\FileDelivery\Delivery::generateEtag ( )

Definition at line 184 of file Delivery.php.

184 : void
185 {
186 $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
187 }

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

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

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

315 : string
316 {
317 return $this->disposition;
318 }

References ILIAS\FileDelivery\Delivery\$disposition.

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

+ Here is the caller graph for this function:

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )

Definition at line 363 of file Delivery.php.

363 : string
364 {
365 return $this->etag;
366 }

References ILIAS\FileDelivery\Delivery\$etag.

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

+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )

Definition at line 279 of file Delivery.php.

279 : string
280 {
281 return $this->mime_type;
282 }

References ILIAS\FileDelivery\Delivery\$mime_type.

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

+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )

Definition at line 375 of file Delivery.php.

375 : bool
376 {
378 }

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )

Definition at line 399 of file Delivery.php.

399 : bool
400 {
401 return $this->cache;
402 }

References ILIAS\FileDelivery\Delivery\$cache.

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

+ Here is the caller graph for this function:

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )

Definition at line 411 of file Delivery.php.

411 : bool
412 {
414 }

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )

Definition at line 351 of file Delivery.php.

351 : bool
352 {
354 }

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 444 of file Delivery.php.

444 : bool
445 {
446 return self::$DEBUG;
447 }

References ILIAS\FileDelivery\Delivery\$DEBUG.

◆ isDeleteFile()

ILIAS\FileDelivery\Delivery::isDeleteFile ( )

Definition at line 542 of file Delivery.php.

542 : bool
543 {
544 return $this->delete_file;
545 }

References ILIAS\FileDelivery\Delivery\$delete_file.

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

+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )

Definition at line 339 of file Delivery.php.

339 : bool
340 {
341 return $this->exit_after;
342 }

References ILIAS\FileDelivery\Delivery\$exit_after.

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

+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )

Definition at line 387 of file Delivery.php.

387 : bool
388 {
389 return $this->has_context;
390 }

References ILIAS\FileDelivery\Delivery\$has_context.

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )

Definition at line 327 of file Delivery.php.

327 : bool
328 {
330 }

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

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

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

Referenced by ILIAS\FileDelivery\Delivery\cleanDownloadFileName(), ilFileDataForumDraftsRCImplementation\deliverZipFile(), and ilFileDataForumRCImplementation\deliverZipFile().

+ Here is the caller graph for this function:

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

Definition at line 423 of file Delivery.php.

423 : void
424 {
425 if ($this->getEtag() !== '' && $this->getEtag() !== '0') {
426 $response = $this->http->response()->withHeader('ETag', $this->getEtag());
427 $this->http->saveResponse($response);
428 }
429 }

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

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

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

432 : void
433 {
434 if ($this->getShowLastModified()) {
435 $response = $this->http->response()->withHeader(
436 'Last-Modified',
437 date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
438 . " GMT"
439 );
440 $this->http->saveResponse($response);
441 }
442 }

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

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

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

405 : void
406 {
407 $this->cache = $cache;
408 }

References ILIAS\FileDelivery\Delivery\$cache.

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 174 of file Delivery.php.

174 : void
175 {
176 $response = $this->http->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
177
178 $this->http->saveResponse($response->withHeader(ResponseHeader::EXPIRES, date("D, j M Y H:i:s", strtotime(self::EXPIRES_IN)) . " GMT"));
179 $this->sendEtagHeader();
180 $this->sendLastModified();
181 }

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().

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

357 : void
358 {
359 $this->convert_file_name_to_asci = $convert_file_name_to_asci;
360 }

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

◆ setDEBUG()

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

Definition at line 450 of file Delivery.php.

450 : void
451 {
452 self::$DEBUG = $DEBUG;
453 }

References ILIAS\FileDelivery\Delivery\$DEBUG.

◆ setDeleteFile()

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

Definition at line 548 of file Delivery.php.

548 : void
549 {
550 $this->delete_file = $delete_file;
551 }

References ILIAS\FileDelivery\Delivery\$delete_file.

◆ setDeliveryType()

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

Definition at line 273 of file Delivery.php.

273 : void
274 {
275 $this->delivery_type = $delivery_type;
276 }

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

+ Here is the caller graph for this function:

◆ setDisposition()

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

Definition at line 321 of file Delivery.php.

321 : void
322 {
323 $this->disposition = $disposition;
324 }

References ILIAS\FileDelivery\Delivery\$disposition.

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

Definition at line 554 of file Delivery.php.

554 : void
555 {
556 $response = $this->http->response();
557 $response = $response->withHeader(
559 $this->getDisposition()
560 . '; filename="'
561 . $this->getDownloadFileName()
562 . '"'
563 );
564 $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
565 $this->http->saveResponse($response);
566 }

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().

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

369 : void
370 {
371 $this->etag = $etag;
372 }

References ILIAS\FileDelivery\Delivery\$etag.

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

+ Here is the caller graph for this function:

◆ setExitAfter()

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

Definition at line 345 of file Delivery.php.

345 : void
346 {
347 $this->exit_after = $exit_after;
348 }

References ILIAS\FileDelivery\Delivery\$exit_after.

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

Definition at line 147 of file Delivery.php.

147 : void
148 {
149 $this->checkExisting();
150 if ($this->isSendMimeType()) {
151 $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_TYPE, $this->getMimeType());
152 $this->http->saveResponse($response);
153 }
154 if ($this->isConvertFileNameToAsci()) {
155 $this->cleanDownloadFileName();
156 }
157 if ($this->hasHashFilename()) {
158 $this->setDownloadFileName(md5($this->getDownloadFileName()));
159 }
160 $this->setDispositionHeaders();
161 $response = $this->http->response()->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
162 $this->http->saveResponse($response);
163 if ($this->getDeliveryType() === DeliveryMethod::PHP
164 && $this->getPathToFile() !== self::DIRECT_PHP_OUTPUT
165 ) {
166 $response = $this->http->response()->withHeader(ResponseHeader::CONTENT_LENGTH, (string) filesize($this->getPathToFile()));
167 $this->http->saveResponse($response);
168 }
169 $response = $this->http->response()->withHeader(ResponseHeader::CONNECTION, "close");
170 $this->http->saveResponse($response);
171 }
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:499

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().

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

393 : void
394 {
395 $this->has_context = $has_context;
396 }

References ILIAS\FileDelivery\Delivery\$has_context.

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

+ Here is the caller graph for this function:

◆ setHashFilename()

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

Definition at line 417 of file Delivery.php.

417 : void
418 {
419 $this->hash_filename = $hash_filename;
420 }

References ILIAS\FileDelivery\Delivery\$hash_filename.

◆ setMimeType()

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

Definition at line 285 of file Delivery.php.

285 : void
286 {
287 $this->mime_type = $mime_type;
288 }

References ILIAS\FileDelivery\Delivery\$mime_type.

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

+ Here is the caller graph for this function:

◆ setPathToFile()

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

Definition at line 297 of file Delivery.php.

297 : void
298 {
299 $this->path_to_file = $path_to_file;
300 }

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

+ Here is the caller graph for this function:

◆ setSendMimeType()

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

Definition at line 333 of file Delivery.php.

333 : void
334 {
335 $this->send_mime_type = $send_mime_type;
336 }

References ILIAS\FileDelivery\Delivery\$send_mime_type.

◆ setShowLastModified()

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

Definition at line 381 of file Delivery.php.

381 : void
382 {
383 $this->show_last_modified = $show_last_modified;
384 }

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

+ 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

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

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

◆ $download_file_name

◆ $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'

Definition at line 44 of file Delivery.php.

◆ DISP_ATTACHMENT

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

Definition at line 48 of file Delivery.php.

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