@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | $this->filesize = strlen($this->filedata); |
194 | - $this->filemime = $this->getMime($this->fileinfo[ 'filename' ]); |
|
194 | + $this->filemime = $this->getMime($this->fileinfo['filename']); |
|
195 | 195 | $this->lastModified = time(); |
196 | 196 | |
197 | 197 | } else { |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | // Range |
204 | - if (isset($_SERVER[ 'HTTP_RANGE' ]) || isset($HTTP_SERVER_VARS[ 'HTTP_RANGE' ])) { |
|
204 | + if (isset($_SERVER['HTTP_RANGE']) || isset($HTTP_SERVER_VARS['HTTP_RANGE'])) { |
|
205 | 205 | $this->partialRequest = true; |
206 | - $http_range = isset($_SERVER[ 'HTTP_RANGE' ]) ? $_SERVER[ 'HTTP_RANGE' ] : $HTTP_SERVER_VARS[ 'HTTP_RANGE' ]; |
|
206 | + $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : $HTTP_SERVER_VARS['HTTP_RANGE']; |
|
207 | 207 | if (stripos($http_range, 'bytes') === false) { |
208 | 208 | output() |
209 | 209 | ->withStatus(416, 'Requested Range Not Satisfiable') |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | $range = substr($http_range, strlen('bytes=')); |
214 | 214 | $range = explode('-', $range, 3); |
215 | - $this->seekStart = ($range[ 0 ] > 0 && $range[ 0 ] < $this->filesize - 1) ? $range[ 0 ] : 0; |
|
216 | - $this->seekEnd = ($range[ 1 ] > 0 && $range[ 1 ] < $this->filesize && $range[ 1 ] > $this->seekStart) ? $range[ 1 ] : $this->filesize - 1; |
|
215 | + $this->seekStart = ($range[0] > 0 && $range[0] < $this->filesize - 1) ? $range[0] : 0; |
|
216 | + $this->seekEnd = ($range[1] > 0 && $range[1] < $this->filesize && $range[1] > $this->seekStart) ? $range[1] : $this->filesize - 1; |
|
217 | 217 | $this->seekFileSize = $this->seekEnd - $this->seekStart + 1; |
218 | 218 | } else { |
219 | 219 | $this->partialRequest = false; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function download($filename = null) |
270 | 270 | { |
271 | - $filename = isset($filename) ? $filename : $this->fileinfo[ 'basename' ]; |
|
271 | + $filename = isset($filename) ? $filename : $this->fileinfo['basename']; |
|
272 | 272 | |
273 | 273 | if ($this->partialRequest) { |
274 | 274 | if ($this->resumeable) { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | // Work On Download Speed Limit |
300 | 300 | if ($this->speedLimit) { |
301 | 301 | // how many buffers ticks per second |
302 | - $bufferTicks = 10; //10 |
|
302 | + $bufferTicks = 10; //10 |
|
303 | 303 | // how long one buffering tick takes by micro second |
304 | 304 | $bufferMicroTime = 150; // 100 |
305 | 305 | // Calculate sleep micro time after each tick |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | if ($downloadFileBytes > $this->bufferSize) { |
331 | 331 | // send buffer size |
332 | 332 | echo fread($this->filedata, $this->bufferSize); // this also will seek to after last read byte |
333 | - $downloaded += $this->bufferSize; // updated downloaded |
|
334 | - $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
333 | + $downloaded += $this->bufferSize; // updated downloaded |
|
334 | + $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
335 | 335 | } else { |
336 | 336 | // send required size |
337 | 337 | // this will happens when we reaches the end of the file normally we wll download remaining bytes |
338 | - echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
338 | + echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
339 | 339 | |
340 | - $downloaded += $downloadFileBytes; // Add to downloaded |
|
340 | + $downloaded += $downloadFileBytes; // Add to downloaded |
|
341 | 341 | |
342 | 342 | |
343 | - $downloadFileBytes = 0; // Here last bytes have been written |
|
343 | + $downloadFileBytes = 0; // Here last bytes have been written |
|
344 | 344 | } |
345 | 345 | // send to buffer |
346 | 346 | flush(); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function resumeable($status = true) |
405 | 405 | { |
406 | - $this->partialRequest = $this->resumeable = ( bool )$status; |
|
406 | + $this->partialRequest = $this->resumeable = (bool)$status; |
|
407 | 407 | |
408 | 408 | return $this; |
409 | 409 | } |