ILIAS  release_8 Revision v8.24
PHP.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
9
10/******************************************************************************
11 *
12 * This file is part of ILIAS, a powerful learning management system.
13 *
14 * ILIAS is licensed with the GPL-3.0, you should have received a copy
15 * of said license along with the source code.
16 *
17 * If this is not the case or you just want to try ILIAS, you'll find
18 * us at:
19 * https://www.ilias.de
20 * https://github.com/ILIAS-eLearning
21 *
22 *****************************************************************************/
32final class PHP implements ilFileDeliveryType
33{
37 protected $file;
38 protected \ILIAS\HTTP\Services $httpService;
39
40
46 public function __construct(Services $httpState)
47 {
48 $this->httpService = $httpState;
49 }
50
51
55 public function doesFileExists(string $path_to_file): bool
56 {
57 return is_readable($path_to_file);
58 }
59
60
64 public function prepare(string $path_to_file): bool
65 {
66 set_time_limit(0);
67 $this->file = fopen($path_to_file, "rb");
68
69 return true;
70 }
71
72
76 public function deliver(string $path_to_file, bool $file_marked_to_delete): void
77 {
78 $this->httpService->sendResponse();
79 fpassthru($this->file);
80 // Fix for mantis 22594
81 fclose($this->file);
82 }
83
84
88 public function supportsInlineDelivery(): bool
89 {
90 return true;
91 }
92
93
97 public function supportsAttachmentDelivery(): bool
98 {
99 return true;
100 }
101
102
106 public function supportsStreaming(): bool
107 {
108 return false;
109 }
110
111
115 public function handleFileDeletion(string $path_to_file): bool
116 {
117 return unlink($path_to_file);
118 }
119}
doesFileExists(string $path_to_file)
@inheritDoc
Definition: PHP.php:55
prepare(string $path_to_file)
bool
Definition: PHP.php:64
handleFileDeletion(string $path_to_file)
bool
Definition: PHP.php:115
deliver(string $path_to_file, bool $file_marked_to_delete)
void
Definition: PHP.php:76
ILIAS HTTP Services $httpService
Definition: PHP.php:38
__construct(Services $httpState)
PHP constructor.
Definition: PHP.php:46
Class Services.
Definition: Services.php:38