25 require_once(
'./Services/FileDelivery/interfaces/int.ilFileDeliveryType.php');
50 $this->httpService = $httpState;
59 return is_readable($path_to_file);
75 public function deliver($path_to_file, $file_marked_to_delete)
77 $file = $path_to_file;
78 $fp = @fopen($file,
'rb');
81 $response = $this->httpService->response()->withStatus(404);
82 $this->httpService->saveResponse(
$response);
86 $size = filesize($file);
102 $response = $this->httpService->response()->withHeader(
"Accept-Ranges",
"0-$length");
103 $this->httpService->saveResponse(
$response);
104 $server = $this->httpService->request()->getServerParams();
108 if (isset(
$server[
'HTTP_RANGE'])) {
113 list(, $range) = explode(
'=',
$server[
'HTTP_RANGE'], 2);
115 if (strpos($range,
',') !==
false) {
120 $this->httpService->saveResponse(
$response);
129 if ($range[0] ==
'-') {
131 $c_start =
$size - substr($range, 1);
133 $range = explode(
'-', $range);
134 $c_start = $range[0];
135 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
141 $c_end = ($c_end > $end) ? $end : $c_end;
143 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
146 $this->httpService->saveResponse(
$response);
153 $length = $end - $start + 1;
156 $response = $this->httpService->response()->withStatus(206);
158 $this->httpService->saveResponse(
$response);
164 $this->httpService->saveResponse(
$response);
167 $this->httpService->sendResponse();
171 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
172 if ($p + $buffer > $end) {
175 $buffer = $end - $p + 1;
179 echo fread($fp, $buffer);
219 $this->httpService->sendResponse();
229 return unlink($path_to_file);
Interface GlobalHttpState.
__construct(GlobalHttpState $httpState)
PHP constructor.
supportsInlineDelivery()
bool
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilFileDeliveryType.
prepare($path_to_file)
bool
doesFileExists($path_to_file)
handleFileDeletion($path_to_file)
bool
deliver($path_to_file, $file_marked_to_delete)
absolute path to fileThis is needed at this point for header-based delivery methodsbool ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
supportsAttachmentDelivery()
bool