9require_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');
 
   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);
 
  131            $length = 
$end - $start + 1; 
 
  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);
 
An exception for terminatinating execution or to throw for unit testing.
deliver($path_to_file, $file_marked_to_delete)
bool
handleFileDeletion($path_to_file)
bool
__construct(GlobalHttpState $httpState)
PHP constructor.
doesFileExists($path_to_file)
@inheritDoc
prepare($path_to_file)
bool
supportsInlineDelivery()
bool
supportsAttachmentDelivery()
bool
Interface ilFileDeliveryType.
Interface GlobalHttpState.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file