ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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'
 

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

111  {
112  assert(is_string($path_to_file));
113  $this->httpService = $httpState;
114  if ($path_to_file == self::DIRECT_PHP_OUTPUT) {
115  $this->setPathToFile(self::DIRECT_PHP_OUTPUT);
116  } else {
118  $this->detemineDeliveryType();
119  $this->determineMimeType();
120  $this->determineDownloadFileName();
121  }
122  $this->setHasContext(\ilContext::getType() !== null);
123  $this->fileDeliveryTypeFactory = new FileDeliveryTypeFactory($httpState);
124  }
setPathToFile($path_to_file)
Definition: Delivery.php:346
setHasContext($has_context)
Definition: Delivery.php:490
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 600 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().

601  {
602  if ($this->hasCache()) {
603  $this->generateEtag();
604  $this->sendEtagHeader();
605  $this->setShowLastModified(true);
606  $this->setCachingHeaders();
607  }
608  }
setShowLastModified($show_last_modified)
Definition: Delivery.php:472
+ 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 628 of file Delivery.php.

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

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

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

644  {
645  $download_file_name = self::returnASCIIFileName($this->getDownloadFileName());
647  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:364
+ 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 614 of file Delivery.php.

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

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

◆ close()

ILIAS\FileDelivery\Delivery::close ( )

Definition at line 210 of file Delivery.php.

References exit.

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

211  {
212  exit;
213  }
+ Here is the caller graph for this function:

◆ deliver()

ILIAS\FileDelivery\Delivery::deliver ( )

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

143  {
144  $response = $this->httpService->response()->withHeader('X-ILIAS-FileDelivery-Method', $this->getDeliveryType());
145  if (!$this->delivery()->doesFileExists($this->path_to_file)) {
146  $response = $this->httpService->response()->withStatus(404);
147  $this->httpService->saveResponse($response);
148  $this->httpService->sendResponse();
149  $this->close();
150  }
151  $this->httpService->saveResponse($response);
152 
153  $this->clearBuffer();
154  $this->checkCache();
155  $this->setGeneralHeaders();
156  $this->delivery()->prepare($this->getPathToFile());
157  $this->delivery()->deliver($this->getPathToFile(), $this->isDeleteFile());
158  if ($this->isDeleteFile()) {
159  $this->delivery()->handleFileDeletion($this->getPathToFile());
160  }
161  if ($this->isExitAfter()) {
162  $this->close();
163  }
164  }
$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 136 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\getDeliveryType().

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

137  {
138  return $this->fileDeliveryTypeFactory->getInstance($this->getDeliveryType());
139  }
+ 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 255 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().

256  {
257  if (self::$delivery_type_static) {
258  \ilWACLog::getInstance()->write('used cached delivery type');
259  $this->setDeliveryType(self::$delivery_type_static);
260 
261  return true;
262  }
263 
264  if (function_exists('apache_get_modules')
265  && in_array('mod_xsendfile', apache_get_modules())
266  ) {
268  }
269 
270  if (is_file('./Services/FileDelivery/classes/override.php')) {
271  $override_delivery_type = false;
272  require_once('./Services/FileDelivery/classes/override.php');
273  if ($override_delivery_type) {
274  $this->setDeliveryType($override_delivery_type);
275  }
276  }
277 
278  require_once('./Services/Environment/classes/class.ilRuntime.php');
279  $ilRuntime = \ilRuntime::getInstance();
280  if ((!$ilRuntime->isFPM() && !$ilRuntime->isHHVM())
282  ) {
284  }
285 
287  && strpos($this->getPathToFile(), './data') !== 0
288  ) {
290  }
291 
292  self::$delivery_type_static = $this->getDeliveryType();
293 
294  return true;
295  }
static getInstance()
setDeliveryType($delivery_type)
Definition: Delivery.php:310
+ 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 243 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().

244  {
245  if (!$this->getDownloadFileName()) {
246  $download_file_name = basename($this->getPathToFile());
248  }
249  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:364
+ 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 219 of file Delivery.php.

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

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

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

◆ generateEtag()

ILIAS\FileDelivery\Delivery::generateEtag ( )

Definition at line 204 of file Delivery.php.

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

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

205  {
206  $this->setEtag(md5(filemtime($this->getPathToFile()) . filesize($this->getPathToFile())));
207  }
+ 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 373 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

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

◆ getDownloadFileName()

ILIAS\FileDelivery\Delivery::getDownloadFileName ( )

◆ getEtag()

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

Definition at line 445 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

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

◆ getMimeType()

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

Definition at line 319 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

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

◆ getPathToFile()

◆ getShowLastModified()

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

Definition at line 463 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

464  {
466  }
+ Here is the caller graph for this function:

◆ hasCache()

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

Definition at line 499 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

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

◆ hasHashFilename()

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

Definition at line 517 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

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

◆ isConvertFileNameToAsci()

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

Definition at line 427 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

428  {
430  }
+ Here is the caller graph for this function:

◆ isDEBUG()

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

Definition at line 581 of file Delivery.php.

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

◆ isDeleteFile()

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

Definition at line 706 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

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

◆ isExitAfter()

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

Definition at line 409 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

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

◆ isHasContext()

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

Definition at line 481 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

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

◆ isSendMimeType()

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

Definition at line 391 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

392  {
393  return $this->send_mime_type;
394  }
+ 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 657 of file Delivery.php.

References $ascii_filename, and array.

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

◆ sendEtagHeader()

ILIAS\FileDelivery\Delivery::sendEtagHeader ( )
private

Definition at line 532 of file Delivery.php.

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

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

533  {
534  if ($this->getEtag()) {
535  $response = $this->httpService->response()->withHeader('ETag', $this->getEtag());
536  $this->httpService->saveResponse($response);
537  }
538  }
$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 541 of file Delivery.php.

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

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

542  {
543  if ($this->getShowLastModified()) {
544  $response = $this->httpService->response()->withHeader(
545  'Last-Modified',
546  date("D, j M Y H:i:s", filemtime($this->getPathToFile()))
547  . " GMT"
548  );
549  $this->httpService->saveResponse($response);
550  }
551  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$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 508 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$cache.

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

◆ setCachingHeaders()

ILIAS\FileDelivery\Delivery::setCachingHeaders ( )

Definition at line 194 of file Delivery.php.

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

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

195  {
196  $response = $this->httpService->response()->withHeader(ResponseHeader::CACHE_CONTROL, 'must-revalidate, post-check=0, pre-check=0')->withHeader(ResponseHeader::PRAGMA, 'public');
197 
198  $this->httpService->saveResponse($response);
199  $this->sendEtagHeader();
200  $this->sendLastModified();
201  }
$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 436 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$convert_file_name_to_asci.

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

◆ setDEBUG()

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

Definition at line 590 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$DEBUG.

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

◆ setDeleteFile()

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

Definition at line 717 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delete_file.

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

◆ setDeliveryType()

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

Definition at line 310 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$delivery_type.

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

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

◆ setDisposition()

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

Definition at line 382 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$disposition.

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

◆ setDispositionHeaders()

ILIAS\FileDelivery\Delivery::setDispositionHeaders ( )
private

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

725  {
726  $response = $this->httpService->response();
727  $response = $response->withHeader(
729  $this->getDisposition()
730  . '; filename="'
731  . $this->getDownloadFileName()
732  . '"'
733  );
734  $response = $response->withHeader('Content-Description', $this->getDownloadFileName());
735  $this->httpService->saveResponse($response);
736  }
$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 364 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().

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

◆ setEtag()

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

Definition at line 454 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$etag.

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

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

◆ setExitAfter()

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

Definition at line 418 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$exit_after.

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

◆ setGeneralHeaders()

ILIAS\FileDelivery\Delivery::setGeneralHeaders ( )

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

168  {
169  $this->checkExisting();
170  if ($this->isSendMimeType()) {
171  $response = $this->httpService->response()->withHeader(ResponseHeader::CONTENT_TYPE, $this->getMimeType());
172  $this->httpService->saveResponse($response);
173  }
174  if ($this->isConvertFileNameToAsci()) {
175  $this->cleanDownloadFileName();
176  }
177  if ($this->hasHashFilename()) {
178  $this->setDownloadFileName(md5($this->getDownloadFileName()));
179  }
180  $this->setDispositionHeaders();
181  $response = $this->httpService->response()->withHeader(ResponseHeader::ACCEPT_RANGES, 'bytes');
182  $this->httpService->saveResponse($response);
183  if ($this->getDeliveryType() == DeliveryMethod::PHP
184  && $this->getPathToFile() != self::DIRECT_PHP_OUTPUT
185  ) {
186  $response = $this->httpService->response()->withHeader(ResponseHeader::CONTENT_LENGTH, (string) filesize($this->getPathToFile()));
187  $this->httpService->saveResponse($response);
188  }
189  $response = $this->httpService->response()->withHeader(ResponseHeader::CONNECTION, "close");
190  $this->httpService->saveResponse($response);
191  }
setDownloadFileName($download_file_name)
Definition: Delivery.php:364
cleanDownloadFileName()
Converts the filename to ASCII.
Definition: Delivery.php:643
$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 490 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$has_context.

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

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

◆ setHashFilename()

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

Definition at line 526 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$hash_filename.

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

◆ setMimeType()

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

Definition at line 328 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$mime_type.

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

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

◆ setPathToFile()

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

Definition at line 346 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$path_to_file.

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

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

◆ setSendMimeType()

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

Definition at line 400 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$send_mime_type.

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

◆ setShowLastModified()

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

Definition at line 472 of file Delivery.php.

References ILIAS\FileDelivery\Delivery\$show_last_modified.

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

473  {
474  $this->show_last_modified = $show_last_modified;
475  }
+ 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 95 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 35 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 103 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 99 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.


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