ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\FileDelivery\Delivery Class Reference

Class Delivery. More...

+ Collaboration diagram for ILIAS\FileDelivery\Delivery:

Public Member Functions

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

Static Public Member Functions

static isDEBUG ()
 
static setDEBUG ($DEBUG)
 
static returnASCIIFileName ($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

 $delivery_type = DeliveryMethod::PHP
 
 $mime_type = ''
 
 $path_to_file = ''
 
 $download_file_name = ''
 
 $disposition = self::DISP_ATTACHMENT
 
 $send_mime_type = true
 
 $exit_after = true
 
 $convert_file_name_to_asci = true
 
 $etag = ''
 
 $show_last_modified = true
 
 $has_context = true
 
 $cache = false
 
 $hash_filename = false
 
 $delete_file = false
 
 $httpService
 
 $fileDeliveryTypeFactory
 

Static Private Attributes

static $delivery_type_static = null
 
static $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 27 of file Delivery.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileDelivery\Delivery::__construct (   $path_to_file,
GlobalHttpState  $httpState 
)
Parameters
string$path_to_file
GlobalHttpState$httpState

Definition at line 111 of file Delivery.php.

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

112  {
113  assert(is_string($path_to_file));
114  $this->httpService = $httpState;
115  if ($path_to_file == self::DIRECT_PHP_OUTPUT) {
116  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
117  } else {
119  $this->detemineDeliveryType();
120  $this->determineMimeType();
121  $this->determineDownloadFileName();
122  }
123  $this->setHasContext(\ilContext::getType() !== null);
124  $this->fileDeliveryTypeFactory = new FileDeliveryTypeFactory($httpState);
125  }
setPathToFile($path_to_file)
Definition: Delivery.php:347
setHasContext($has_context)
Definition: Delivery.php:491
static getType()
Get context type.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkCache()

ILIAS\FileDelivery\Delivery::checkCache ( )
Returns
void

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

602  {
603  if ($this->hasCache()) {
604  $this->generateEtag();
605  $this->sendEtagHeader();
606  $this->setShowLastModified(true);
607  $this->setCachingHeaders();
608  }
609  }
setShowLastModified($show_last_modified)
Definition: Delivery.php:473
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExisting()

ILIAS\FileDelivery\Delivery::checkExisting ( )
private
Returns
void

Definition at line 629 of file Delivery.php.

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

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

630  {
631  if ($this->getPathToFile() != self::DIRECT_PHP_OUTPUT
632  && !file_exists($this->getPathToFile())
633  ) {
634  $this->close();
635  }
636  }
+ 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.

Returns
void

Definition at line 644 of file Delivery.php.

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

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

645  {
646  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
648  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:365
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearBuffer()

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

Definition at line 615 of file Delivery.php.

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

616  {
617  $ob_get_contents = ob_get_contents();
618  if ($ob_get_contents) {
619  // \ilWACLog::getInstance()->write(__CLASS__ . ' had output before file delivery: '
620  // . $ob_get_contents);
621  }
622  ob_end_clean(); // fixed 0016469, 0016467, 0016468
623  }
+ Here is the caller graph for this function:

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 211 of file Delivery.php.

References exit.

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

212  {
213  exit;
214  }
exit
Definition: login.php:29
+ Here is the caller graph for this function:

◆ deliver()

ILIAS\FileDelivery\Delivery::deliver ( )

Definition at line 143 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\Delivery\isDeleteFile(), ILIAS\FileDelivery\Delivery\isExitAfter(), and ILIAS\FileDelivery\Delivery\setGeneralHeaders().

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

144  {
145  $response = $this->httpService->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
146  if (!$this->delivery()->doesFileExists($this->path_to_file)) {
147  $response = $this->httpService->response()->withStatus(404);
148  $this->httpService->saveResponse($response);
149  $this->httpService->sendResponse();
150  $this->close();
151  }
152  $this->httpService->saveResponse($response);
153 
154  $this->clearBuffer();
155  $this->checkCache();
156  $this->setGeneralHeaders();
157  $this->delivery()->prepare($this->getPathToFile());
158  $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
159  if ($this->isDeleteFile()) {
160  $this->delivery()->handleFileDeletion($this->getPathToFile());
161  }
162  if ($this->isExitAfter()) {
163  $this->close();
164  }
165  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delivery()

ILIAS\FileDelivery\Delivery::delivery ( )
private

Definition at line 137 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDeliveryType().

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

138  {
139  return $this->fileDeliveryTypeFactory->getInstance($this->getDeliveryType());
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ detemineDeliveryType()

ILIAS\FileDelivery\Delivery::detemineDeliveryType ( )
private
Returns
bool

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

257  {
258  if (self::$delivery_type_static) {
259  \ilWACLog::getInstance()->write('used cached delivery type');
260  $this->setDeliveryType(self::$delivery_type_static);
261 
262  return true;
263  }
264 
265  if (function_exists('apache_get_modules')
266  && in_array('mod_xsendfile', apache_get_modules())
267  ) {
269  }
270 
271  if (is_file('./Services/FileDelivery/classes/override.php')) {
272  $override_delivery_type = false;
273  require_once('./Services/FileDelivery/classes/override.php');
274  if ($override_delivery_type) {
275  $this->setDeliveryType($override_delivery_type);
276  }
277  }
278 
279  require_once('./Services/Environment/classes/class.ilRuntime.php');
280  $ilRuntime = \ilRuntime::getInstance();
281  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
283  ) {
285  }
286 
288  && strpos($this->getPathToFile(), './data') !== 0
289  ) {
291  }
292 
293  self::$delivery_type_static = $this->getDeliveryType();
294 
295  return true;
296  }
static getInstance()
setDeliveryType($delivery_type)
Definition: Delivery.php:311
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineDownloadFileName()

ILIAS\FileDelivery\Delivery::determineDownloadFileName ( )
private
Returns
void

Definition at line 244 of file Delivery.php.

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

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

245  {
246  if (!$this->getDownloadFileName()) {
247  $download_file_name = basename($this->getPathToFile());
249  }
250  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:365
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineMimeType()

ILIAS\FileDelivery\Delivery::determineMimeType ( )
private
Returns
bool

Definition at line 220 of file Delivery.php.

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

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

221  {
223  if ($info) {
224  $this->setMimeType($info);
225 
226  return true;
227  }
228  $finfo = finfo_open(FILEINFO_MIME_TYPE);
229  $info = finfo_file($finfo, $this->getPathToFile());
230  finfo_close($finfo);
231  if ($info) {
232  $this->setMimeType($info);
233 
234  return true;
235  }
236 
237  return false;
238  }
static lookupMimeType($path_to_file, $fallback=self::APPLICATION__OCTET_STREAM, $a_external=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateEtag()

ILIAS\FileDelivery\Delivery::generateEtag ( )

Definition at line 205 of file Delivery.php.

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

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

206  {
207  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
208  }
+ 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 ( )
Returns
string

Definition at line 374 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

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

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

ILIAS\FileDelivery\Delivery::getEtag ( )
Returns
string

Definition at line 446 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

447  {
448  return $this->etag;
449  }
+ Here is the caller graph for this function:

◆ getMimeType()

ILIAS\FileDelivery\Delivery::getMimeType ( )
Returns
string

Definition at line 320 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

321  {
322  return $this->mime_type;
323  }
+ Here is the caller graph for this function:

◆ getPathToFile()

◆ getShowLastModified()

ILIAS\FileDelivery\Delivery::getShowLastModified ( )
Returns
boolean

Definition at line 464 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

465  {
467  }
+ Here is the caller graph for this function:

◆ hasCache()

ILIAS\FileDelivery\Delivery::hasCache ( )
Returns
boolean

Definition at line 500 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

501  {
502  return $this->cache;
503  }
+ Here is the caller graph for this function:

◆ hasHashFilename()

ILIAS\FileDelivery\Delivery::hasHashFilename ( )
Returns
boolean

Definition at line 518 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

519  {
520  return $this->hash_filename;
521  }
+ Here is the caller graph for this function:

◆ isConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::isConvertFileNameToAsci ( )
Returns
boolean

Definition at line 428 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

429  {
431  }
+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 582 of file Delivery.php.

583  {
584  return (bool) self::$DEBUG;
585  }

◆ isDeleteFile()

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

Definition at line 707 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

708  {
709  return (bool) $this->delete_file;
710  }
+ Here is the caller graph for this function:

◆ isExitAfter()

ILIAS\FileDelivery\Delivery::isExitAfter ( )
Returns
boolean

Definition at line 410 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

411  {
412  return $this->exit_after;
413  }
+ Here is the caller graph for this function:

◆ isHasContext()

ILIAS\FileDelivery\Delivery::isHasContext ( )
Returns
boolean

Definition at line 482 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

483  {
484  return $this->has_context;
485  }

◆ isSendMimeType()

ILIAS\FileDelivery\Delivery::isSendMimeType ( )
Returns
boolean

Definition at line 392 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

393  {
394  return $this->send_mime_type;
395  }
+ Here is the caller graph for this function:

◆ returnASCIIFileName()

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

Converts a UTF-8 filename to ASCII.

Parameters
$original_filenamestring UFT8-Filename
Returns
string ASCII-Filename

Implementation note: The proper way to convert charsets is mb_convert_encoding. Unfortunately Multibyte String functions are not an installation requirement for ILIAS 3. Codelines behind three slashes '///' show how we would do it using mb_convert_encoding. Note that mb_convert_encoding has the bad habit of substituting unconvertable characters with HTML entitities. Thats why we need a regular expression which replaces HTML entities with their first character. e.g. ä => a

$ascii_filename = mb_convert_encoding($a_filename,'US-ASCII','UTF-8'); $ascii_filename = preg_replace('/&(.)[^;]*;/','\1', $ascii_filename);

Definition at line 658 of file Delivery.php.

References $ascii_filename.

659  {
660  // The filename must be converted to ASCII, as of RFC 2183,
661  // section 2.3.
662 
674 
677 
678  // #15914 - try to fix german umlauts
679  $umlauts = array(
680  "Ä" => "Ae",
681  "Ö" => "Oe",
682  "Ü" => "Ue",
683  "ä" => "ae",
684  "ö" => "oe",
685  "ü" => "ue",
686  "ß" => "ss",
687  );
688  foreach ($umlauts as $src => $tgt) {
689  $original_filename = str_replace($src, $tgt, $original_filename);
690  }
691 
692  $ascii_filename = htmlentities($original_filename, ENT_NOQUOTES, 'UTF-8');
693  $ascii_filename = preg_replace('/\&(.)[^;]*;/', '\\1', $ascii_filename);
694  $ascii_filename = preg_replace('/[\x7f-\xff]/', '_', $ascii_filename);
695 
696  // OS do not allow the following characters in filenames: \/:*?"<>|
697  $ascii_filename = preg_replace('/[:\x5c\/\*\?\"<>\|]/', '_', $ascii_filename);
698 
699  return (string) $ascii_filename;
700  // return iconv("UTF-8", "ASCII//TRANSLIT", $original_name); // proposal
701  }
$ascii_filename
Definition: metadata.php:361

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

Definition at line 533 of file Delivery.php.

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

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

534  {
535  if ($this->getEtag()) {
536  $response = $this->httpService->response()->withHeader('ETag', $this->getEtag());
537  $this->httpService->saveResponse($response);
538  }
539  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendLastModified()

ILIAS\FileDelivery\Delivery::sendLastModified ( )
private

Definition at line 542 of file Delivery.php.

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

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

543  {
544  if ($this->getShowLastModified()) {
545  $response = $this->httpService->response()->withHeader(
546  'Last-Modified',
547  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
548  . " GMT"
549  );
550  $this->httpService->saveResponse($response);
551  }
552  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCache()

ILIAS\FileDelivery\Delivery::setCache (   $cache)
Parameters
boolean$cache

Definition at line 509 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

510  {
511  $this->cache = $cache;
512  }

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 195 of file Delivery.php.

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

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

196  {
197  $response = $this->httpService->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
198 
199  $this->httpService->saveResponse($response->withHeader(ResponseHeader::EXPIRES, date("D, j M Y H:i:s", strtotime(self::EXPIRES_IN)) . " GMT"));
200  $this->sendEtagHeader();
201  $this->sendLastModified();
202  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConvertFileNameToAsci()

ILIAS\FileDelivery\Delivery::setConvertFileNameToAsci (   $convert_file_name_to_asci)
Parameters
boolean$convert_file_name_to_asci

Definition at line 437 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

438  {
439  $this->convert_file_name_to_asci = $convert_file_name_to_asci;
440  }

◆ setDEBUG()

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

Definition at line 591 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

592  {
593  assert(is_bool($DEBUG));
594  self::$DEBUG = $DEBUG;
595  }

◆ setDeleteFile()

ILIAS\FileDelivery\Delivery::setDeleteFile (   $delete_file)
Parameters
bool$delete_file
Returns
void

Definition at line 718 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

719  {
720  assert(is_bool($delete_file));
721  $this->delete_file = $delete_file;
722  }

◆ setDeliveryType()

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

Definition at line 311 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

312  {
313  $this->delivery_type = $delivery_type;
314  }
+ Here is the caller graph for this function:

◆ setDisposition()

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

Definition at line 383 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

384  {
385  $this->disposition = $disposition;
386  }

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

Definition at line 725 of file Delivery.php.

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

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

726  {
727  $response = $this->httpService->response();
728  $response = $response->withHeader(
730  $this->getDisposition()
731  . '; filename="'
732  . $this->getDownloadFileName()
733  . '"'
734  );
735  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
736  $this->httpService->saveResponse($response);
737  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDownloadFileName()

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

Definition at line 365 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$download_file_name.

Referenced by ILIAS\FileDelivery\Delivery\cleanDownloadFileName(), ILIAS\FileDelivery\Delivery\determineDownloadFileName(), and ILIAS\FileDelivery\Delivery\setGeneralHeaders().

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

◆ setEtag()

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

Definition at line 455 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

456  {
457  $this->etag = $etag;
458  }
+ Here is the caller graph for this function:

◆ setExitAfter()

ILIAS\FileDelivery\Delivery::setExitAfter (   $exit_after)
Parameters
boolean$exit_after

Definition at line 419 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

420  {
421  $this->exit_after = $exit_after;
422  }

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

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

169  {
170  $this->checkExisting();
171  if ($this->isSendMimeType()) {
172  $response = $this->httpService->response()->withHeader(ResponseHeader::CONTENT_TYPE, $this->getMimeType());
173  $this->httpService->saveResponse($response);
174  }
175  if ($this->isConvertFileNameToAsci()) {
176  $this->cleanDownloadFileName();
177  }
178  if ($this->hasHashFilename()) {
179  $this->setDownloadFileName(md5($this->getDownloadFileName()));
180  }
181  $this->setDispositionHeaders();
182  $response = $this->httpService->response()->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
183  $this->httpService->saveResponse($response);
184  if ($this->getDeliveryType() == DeliveryMethod::PHP
185  && $this->getPathToFile() != self::DIRECT_PHP_OUTPUT
186  ) {
187  $response = $this->httpService->response()->withHeader(ResponseHeader::CONTENT_LENGTH, (string) filesize($this->getPathToFile()));
188  $this->httpService->saveResponse($response);
189  }
190  $response = $this->httpService->response()->withHeader(ResponseHeader::CONNECTION, "close");
191  $this->httpService->saveResponse($response);
192  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:365
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:644
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHasContext()

ILIAS\FileDelivery\Delivery::setHasContext (   $has_context)
Parameters
boolean$has_context

Definition at line 491 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

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

492  {
493  $this->has_context = $has_context;
494  }
+ Here is the caller graph for this function:

◆ setHashFilename()

ILIAS\FileDelivery\Delivery::setHashFilename (   $hash_filename)
Parameters
boolean$hash_filename

Definition at line 527 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

528  {
529  $this->hash_filename = $hash_filename;
530  }

◆ setMimeType()

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

Definition at line 329 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

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

◆ setPathToFile()

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

Definition at line 347 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

348  {
349  $this->path_to_file = $path_to_file;
350  }
+ Here is the caller graph for this function:

◆ setSendMimeType()

ILIAS\FileDelivery\Delivery::setSendMimeType (   $send_mime_type)
Parameters
boolean$send_mime_type

Definition at line 401 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

402  {
403  $this->send_mime_type = $send_mime_type;
404  }

◆ setShowLastModified()

ILIAS\FileDelivery\Delivery::setShowLastModified (   $show_last_modified)
Parameters
boolean$show_last_modified

Definition at line 473 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

474  {
475  $this->show_last_modified = $show_last_modified;
476  }
+ Here is the caller graph for this function:

◆ stream()

ILIAS\FileDelivery\Delivery::stream ( )

Field Documentation

◆ $cache

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

◆ $convert_file_name_to_asci

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

◆ $DEBUG

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

Definition at line 96 of file Delivery.php.

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

◆ $delete_file

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

◆ $delivery_type

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

◆ $delivery_type_static

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

Definition at line 36 of file Delivery.php.

◆ $disposition

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

◆ $download_file_name

◆ $etag

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

◆ $exit_after

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

◆ $fileDeliveryTypeFactory

FileDeliveryTypeFactory ILIAS\FileDelivery\Delivery::$fileDeliveryTypeFactory
private

Definition at line 104 of file Delivery.php.

◆ $has_context

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

◆ $hash_filename

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

◆ $httpService

HTTPServices ILIAS\FileDelivery\Delivery::$httpService
private

Definition at line 100 of file Delivery.php.

◆ $mime_type

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

◆ $path_to_file

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

◆ $send_mime_type

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

◆ $show_last_modified

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

◆ DIRECT_PHP_OUTPUT

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

Definition at line 29 of file Delivery.php.

◆ DISP_ATTACHMENT

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

Definition at line 30 of file Delivery.php.

◆ DISP_INLINE

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

Definition at line 31 of file Delivery.php.

◆ EXPIRES_IN

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

Definition at line 32 of file Delivery.php.


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