9 require_once(
'./Services/FileDelivery/interfaces/int.ilFileDeliveryType.php');
34 $this->httpService = $httpState;
43 return is_readable($path_to_file);
59 public function deliver($path_to_file, $file_marked_to_delete)
61 $file = $path_to_file;
62 $fp = @
fopen($file,
'rb');
64 $size = filesize($file);
80 $response = $this->httpService->response()->withHeader(
"Accept-Ranges",
"0-$length");
81 $this->httpService->saveResponse(
$response);
82 $server = $this->httpService->request()->getServerParams();
86 if (isset(
$server[
'HTTP_RANGE'])) {
91 list(, $range) = explode(
'=',
$server[
'HTTP_RANGE'], 2);
93 if (strpos($range,
',') !==
false) {
98 $this->httpService->saveResponse(
$response);
107 if ($range[0] ==
'-') {
109 $c_start =
$size - substr($range, 1);
111 $range = explode(
'-', $range);
112 $c_start = $range[0];
113 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
119 $c_end = ($c_end >
$end) ?
$end : $c_end;
121 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
124 $this->httpService->saveResponse(
$response);
134 $response = $this->httpService->response()->withStatus(206);
136 $this->httpService->saveResponse(
$response);
142 $this->httpService->saveResponse(
$response);
145 $this->httpService->sendResponse();
149 while (!feof($fp) && ($p = ftell($fp)) <=
$end) {
150 if ($p + $buffer >
$end) {
153 $buffer =
$end - $p + 1;
157 echo fread($fp, $buffer);
197 $this->httpService->sendResponse();
207 return unlink($path_to_file);
Interface GlobalHttpState.
__construct(GlobalHttpState $httpState)
PHP constructor.
supportsInlineDelivery()
bool
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 ...
supportsAttachmentDelivery()
bool