@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | $this->setConfig($config); |
73 | 73 | |
74 | 74 | // Prep the port |
75 | - $this->config[ 'port' ] = empty($this->config[ 'port' ]) ? 21 : (int)$this->config[ 'port' ]; |
|
75 | + $this->config['port'] = empty($this->config['port']) ? 21 : (int)$this->config['port']; |
|
76 | 76 | |
77 | 77 | // Prep the hostname |
78 | - $this->config[ 'hostname' ] = preg_replace('|.+?://|', '', $this->config[ 'hostname' ]); |
|
78 | + $this->config['hostname'] = preg_replace('|.+?://|', '', $this->config['hostname']); |
|
79 | 79 | |
80 | 80 | language() |
81 | 81 | ->addFilePath(str_replace('Handlers', '', __DIR__) . DIRECTORY_SEPARATOR) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function connect() |
96 | 96 | { |
97 | - if (false === ($this->handle = @ftp_connect($this->config[ 'hostname' ], $this->config[ 'port' ]))) { |
|
97 | + if (false === ($this->handle = @ftp_connect($this->config['hostname'], $this->config['port']))) { |
|
98 | 98 | if ($this->debugMode === true) { |
99 | 99 | throw new RuntimeException('FTP_E_UNABLE_TO_CONNECT'); |
100 | 100 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - if (false !== (@ftp_login($this->handle, $this->config[ 'username' ], $this->config[ 'password' ]))) { |
|
107 | + if (false !== (@ftp_login($this->handle, $this->config['username'], $this->config['password']))) { |
|
108 | 108 | if ($this->debugMode === true) { |
109 | 109 | throw new RuntimeException('FTP_E_UNABLE_TO_LOGIN'); |
110 | 110 | } |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | for ($i = 0, $c = count($list); $i < $c; $i++) { |
360 | 360 | // If we can't delete the item it's probaly a directory, |
361 | 361 | // so we'll recursively call delete_dir() |
362 | - if ( ! preg_match('#/\.\.?$#', $list[ $i ]) && ! @ftp_delete($this->handle, $list[ $i ])) { |
|
363 | - $this->deleteDir($list[ $i ]); |
|
362 | + if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->handle, $list[$i])) { |
|
363 | + $this->deleteDir($list[$i]); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | |
434 | 434 | // Recursively read the local directory |
435 | 435 | while (false !== ($file = readdir($fp))) { |
436 | - if (is_dir($localPath . $file) && $file[ 0 ] !== '.') { |
|
436 | + if (is_dir($localPath . $file) && $file[0] !== '.') { |
|
437 | 437 | $this->mirror($localPath . $file . '/', $remotePath . $file . '/'); |
438 | - } elseif ($file[ 0 ] !== '.') { |
|
438 | + } elseif ($file[0] !== '.') { |
|
439 | 439 | // Get the file extension so we can se the upload type |
440 | 440 | $ext = $this->getExtension($file); |
441 | 441 | $mode = $this->getTransferMode($ext); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | $this->filesize = strlen($this->filedata); |
194 | - $this->filemime = mime_content_type($this->fileinfo[ 'filename' ]); |
|
194 | + $this->filemime = mime_content_type($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; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function download($filename = null) |
249 | 249 | { |
250 | - $filename = isset($filename) ? $filename : $this->fileinfo[ 'basename' ]; |
|
250 | + $filename = isset($filename) ? $filename : $this->fileinfo['basename']; |
|
251 | 251 | |
252 | 252 | if ($this->partialRequest) { |
253 | 253 | if ($this->resumeable) { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // Work On Download Speed Limit |
279 | 279 | if ($this->speedLimit) { |
280 | 280 | // how many buffers ticks per second |
281 | - $bufferTicks = 10; //10 |
|
281 | + $bufferTicks = 10; //10 |
|
282 | 282 | // how long one buffering tick takes by micro second |
283 | 283 | $bufferMicroTime = 150; // 100 |
284 | 284 | // Calculate sleep micro time after each tick |
@@ -309,17 +309,17 @@ discard block |
||
309 | 309 | if ($downloadFileBytes > $this->bufferSize) { |
310 | 310 | // send buffer size |
311 | 311 | echo fread($this->filedata, $this->bufferSize); // this also will seek to after last read byte |
312 | - $downloaded += $this->bufferSize; // updated downloaded |
|
313 | - $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
312 | + $downloaded += $this->bufferSize; // updated downloaded |
|
313 | + $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
314 | 314 | } else { |
315 | 315 | // send required size |
316 | 316 | // this will happens when we reaches the end of the file normally we wll download remaining bytes |
317 | - echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
317 | + echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
318 | 318 | |
319 | - $downloaded += $downloadFileBytes; // Add to downloaded |
|
319 | + $downloaded += $downloadFileBytes; // Add to downloaded |
|
320 | 320 | |
321 | 321 | |
322 | - $downloadFileBytes = 0; // Here last bytes have been written |
|
322 | + $downloadFileBytes = 0; // Here last bytes have been written |
|
323 | 323 | } |
324 | 324 | // send to buffer |
325 | 325 | flush(); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function resumeable($status = true) |
384 | 384 | { |
385 | - $this->partialRequest = $this->resumeable = ( bool )$status; |
|
385 | + $this->partialRequest = $this->resumeable = (bool)$status; |
|
386 | 386 | |
387 | 387 | return $this; |
388 | 388 | } |