@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @param string $id |
| 118 | 118 | * @param string $p |
| 119 | - * @param string $version |
|
| 119 | + * @param integer $version |
|
| 120 | 120 | */ |
| 121 | 121 | public function postRestore(int $version, ?string $id = null, ?string $p = null): Response |
| 122 | 122 | { |
@@ -406,6 +406,9 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | 408 | * Get Parent. |
| 409 | + * @param string|null $id |
|
| 410 | + * @param string|null $p |
|
| 411 | + * @param string|null $collection |
|
| 409 | 412 | */ |
| 410 | 413 | protected function getParent($id, $p, $collection): Collection |
| 411 | 414 | { |
@@ -427,7 +430,7 @@ discard block |
||
| 427 | 430 | /** |
| 428 | 431 | * Add or update file. |
| 429 | 432 | * |
| 430 | - * @param ObjecId $session |
|
| 433 | + * @param SessionInterface $session |
|
| 431 | 434 | * @param string $id |
| 432 | 435 | * @param string $p |
| 433 | 436 | * @param string $collection |
@@ -129,6 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Send notification. |
| 132 | + * @param User $sender |
|
| 132 | 133 | */ |
| 133 | 134 | public function notify(iterable $receiver, ?User $sender, MessageInterface $message): bool |
| 134 | 135 | { |
@@ -212,6 +213,7 @@ discard block |
||
| 212 | 213 | |
| 213 | 214 | /** |
| 214 | 215 | * Add notification. |
| 216 | + * @param User $sender |
|
| 215 | 217 | */ |
| 216 | 218 | public function postNotification(User $receiver, ?User $sender, MessageInterface $message): ObjectId |
| 217 | 219 | { |
@@ -238,6 +240,8 @@ discard block |
||
| 238 | 240 | |
| 239 | 241 | /** |
| 240 | 242 | * Get notifications. |
| 243 | + * @param integer $offset |
|
| 244 | + * @param integer $limit |
|
| 241 | 245 | */ |
| 242 | 246 | public function getNotifications(User $user, array $query = [], ?int $offset = null, ?int $limit = null, ?int &$total = null): iterable |
| 243 | 247 | { |
@@ -65,6 +65,7 @@ |
||
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Set preview. |
| 68 | + * @param resource $stream |
|
| 68 | 69 | */ |
| 69 | 70 | public function setPreview(File $file, $stream): ObjectId |
| 70 | 71 | { |
@@ -590,6 +590,7 @@ |
||
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | 592 | * Create new file as a child from this collection. |
| 593 | + * @param string $name |
|
| 593 | 594 | */ |
| 594 | 595 | public function addFile($name, ?SessionInterface $session = null, array $attributes = [], int $conflict = NodeInterface::CONFLICT_NOACTION, bool $clone = false): File |
| 595 | 596 | { |
@@ -89,6 +89,7 @@ |
||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Update. |
| 92 | + * @param resource $stream |
|
| 92 | 93 | */ |
| 93 | 94 | public function update(User $user, SessionInterface $resource, Collection $parent, $stream): bool |
| 94 | 95 | { |
@@ -40,69 +40,69 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $response |
| 43 | - ->setOutputFormat(null) |
|
| 44 | - ->setBody(function () use ($file) { |
|
| 45 | - $stream = $file->get(); |
|
| 46 | - $name = $file->getName(); |
|
| 47 | - |
|
| 48 | - if (null === $stream) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $size = $file->getSize(); |
|
| 53 | - $length = $size; |
|
| 54 | - $start = 0; |
|
| 55 | - $end = $size - 1; |
|
| 56 | - |
|
| 57 | - set_time_limit(0); |
|
| 58 | - if (isset($_SERVER['HTTP_RANGE']) && strpos($_SERVER['HTTP_RANGE'], '=') !== false) { |
|
| 59 | - header('Accept-Ranges: bytes'); |
|
| 60 | - $c_start = $start; |
|
| 61 | - $c_end = $end; |
|
| 62 | - list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 63 | - |
|
| 64 | - if (strpos($range, ',') !== false) { |
|
| 65 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 66 | - |
|
| 67 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if ($range == '-') { |
|
| 71 | - $c_start = $size - substr($range, 1); |
|
| 72 | - } else { |
|
| 73 | - $range = explode('-', $range); |
|
| 74 | - $c_start = $range[0]; |
|
| 75 | - $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 79 | - if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 80 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 81 | - |
|
| 82 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $start = (int) $c_start; |
|
| 86 | - $end = (int) $c_end; |
|
| 87 | - $length = (int) $end - $start + 1; |
|
| 88 | - fseek($stream, $start); |
|
| 89 | - header('HTTP/1.1 206 Partial Content'); |
|
| 90 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - header('Content-Length: '.$length); |
|
| 94 | - $buffer = 1024 * 8; |
|
| 95 | - |
|
| 96 | - while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 97 | - if ($p + $buffer > $end) { |
|
| 98 | - $buffer = $end - $p + 1; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - echo fread($stream, $buffer); |
|
| 102 | - flush(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - fclose($stream); |
|
| 106 | - }); |
|
| 43 | + ->setOutputFormat(null) |
|
| 44 | + ->setBody(function () use ($file) { |
|
| 45 | + $stream = $file->get(); |
|
| 46 | + $name = $file->getName(); |
|
| 47 | + |
|
| 48 | + if (null === $stream) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $size = $file->getSize(); |
|
| 53 | + $length = $size; |
|
| 54 | + $start = 0; |
|
| 55 | + $end = $size - 1; |
|
| 56 | + |
|
| 57 | + set_time_limit(0); |
|
| 58 | + if (isset($_SERVER['HTTP_RANGE']) && strpos($_SERVER['HTTP_RANGE'], '=') !== false) { |
|
| 59 | + header('Accept-Ranges: bytes'); |
|
| 60 | + $c_start = $start; |
|
| 61 | + $c_end = $end; |
|
| 62 | + list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 63 | + |
|
| 64 | + if (strpos($range, ',') !== false) { |
|
| 65 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 66 | + |
|
| 67 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if ($range == '-') { |
|
| 71 | + $c_start = $size - substr($range, 1); |
|
| 72 | + } else { |
|
| 73 | + $range = explode('-', $range); |
|
| 74 | + $c_start = $range[0]; |
|
| 75 | + $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 79 | + if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 80 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 81 | + |
|
| 82 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $start = (int) $c_start; |
|
| 86 | + $end = (int) $c_end; |
|
| 87 | + $length = (int) $end - $start + 1; |
|
| 88 | + fseek($stream, $start); |
|
| 89 | + header('HTTP/1.1 206 Partial Content'); |
|
| 90 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + header('Content-Length: '.$length); |
|
| 94 | + $buffer = 1024 * 8; |
|
| 95 | + |
|
| 96 | + while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 97 | + if ($p + $buffer > $end) { |
|
| 98 | + $buffer = $end - $p + 1; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + echo fread($stream, $buffer); |
|
| 102 | + flush(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + fclose($stream); |
|
| 106 | + }); |
|
| 107 | 107 | } |
| 108 | 108 | } |