@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | $string = trim(shell_exec($cmd)); |
256 | 256 | |
257 | 257 | if (preg_match_all('/([0-9a-f]{2}:){5}\w\w/i', $string, $matches)) { |
258 | - if (isset($matches[ 0 ])) { |
|
259 | - return reset($matches[ 0 ]); // get first mac address |
|
258 | + if (isset($matches[0])) { |
|
259 | + return reset($matches[0]); // get first mac address |
|
260 | 260 | } |
261 | 261 | } else { |
262 | 262 | return implode(':', str_split(substr(md5('none'), 0, 12), 2)); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | $rs = sys_getloadavg(); |
280 | 280 | $interval = $interval >= 1 && 3 <= $interval ? $interval : 1; |
281 | - $load = $rs[ $interval ]; |
|
281 | + $load = $rs[$interval]; |
|
282 | 282 | |
283 | 283 | return round(($load * 100) / $this->getCpuCores(), 2); |
284 | 284 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if (is_file('/proc/cpuinfo')) { |
299 | 299 | $cpuinfo = file_get_contents('/proc/cpuinfo'); |
300 | 300 | preg_match_all('/^processor/m', $cpuinfo, $matches); |
301 | - $numCpus = count($matches[ 0 ]); |
|
301 | + $numCpus = count($matches[0]); |
|
302 | 302 | } else { |
303 | 303 | if ('WIN' == strtoupper(substr(PHP_OS, 0, 3))) { |
304 | 304 | $process = @popen('wmic cpu get NumberOfCores', 'rb'); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $output = stream_get_contents($process); |
314 | 314 | preg_match('/hw.ncpu: (\d+)/', $output, $matches); |
315 | 315 | if ($matches) { |
316 | - $numCpus = intval($matches[ 1 ][ 0 ]); |
|
316 | + $numCpus = intval($matches[1][0]); |
|
317 | 317 | } |
318 | 318 | pclose($process); |
319 | 319 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if ($className === 'O2System\Filesystem') { |
21 | 21 | require __DIR__ . DIRECTORY_SEPARATOR . 'File.php'; |
22 | 22 | } elseif (strpos($className, 'O2System\Filesystem\\') === false) { |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | public function connect(array $config = []) |
83 | 83 | { |
84 | 84 | // Prep the port |
85 | - $config[ 'port' ] = empty($config[ 'port' ]) ? 21 : (int)$config[ 'port' ]; |
|
85 | + $config['port'] = empty($config['port']) ? 21 : (int)$config['port']; |
|
86 | 86 | |
87 | 87 | // Prep the hostname |
88 | - $config[ 'hostname' ] = preg_replace('|.+?://|', '', $config[ 'hostname' ]); |
|
88 | + $config['hostname'] = preg_replace('|.+?://|', '', $config['hostname']); |
|
89 | 89 | |
90 | - if (false === ($this->handle = @ftp_connect($config[ 'hostname' ], $config[ 'port' ]))) { |
|
90 | + if (false === ($this->handle = @ftp_connect($config['hostname'], $config['port']))) { |
|
91 | 91 | if ($this->debugMode === true) { |
92 | 92 | throw new RuntimeException('FTP_E_UNABLE_TO_CONNECT'); |
93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if (false !== (@ftp_login($this->handle, $config[ 'username' ], $config[ 'password' ]))) { |
|
98 | + if (false !== (@ftp_login($this->handle, $config['username'], $config['password']))) { |
|
99 | 99 | if ($this->debugMode === true) { |
100 | 100 | throw new RuntimeException('FTP_E_UNABLE_TO_LOGIN'); |
101 | 101 | } |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | for ($i = 0, $c = count($list); $i < $c; $i++) { |
341 | 341 | // If we can't delete the item it's probaly a directory, |
342 | 342 | // so we'll recursively call delete_dir() |
343 | - if ( ! preg_match('#/\.\.?$#', $list[ $i ]) && ! @ftp_delete($this->handle, $list[ $i ])) { |
|
344 | - $this->deleteDir($list[ $i ]); |
|
343 | + if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->handle, $list[$i])) { |
|
344 | + $this->deleteDir($list[$i]); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | |
413 | 413 | // Recursively read the local directory |
414 | 414 | while (false !== ($file = readdir($fp))) { |
415 | - if (is_dir($localPath . $file) && $file[ 0 ] !== '.') { |
|
415 | + if (is_dir($localPath . $file) && $file[0] !== '.') { |
|
416 | 416 | $this->mirror($localPath . $file . '/', $remotePath . $file . '/'); |
417 | - } elseif ($file[ 0 ] !== '.') { |
|
417 | + } elseif ($file[0] !== '.') { |
|
418 | 418 | // Get the file extension so we can se the upload type |
419 | 419 | $ext = $this->getExtension($file); |
420 | 420 | $mode = $this->getTransferMode($ext); |
@@ -108,34 +108,34 @@ discard block |
||
108 | 108 | throw new BadDependencyCallException('UPLOADER_E_FINFO_EXTENSION'); |
109 | 109 | } |
110 | 110 | |
111 | - if (isset($config[ 'path' ])) { |
|
112 | - $config[ 'path' ] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config[ 'path' ]); |
|
111 | + if (isset($config['path'])) { |
|
112 | + $config['path'] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config['path']); |
|
113 | 113 | |
114 | - if (is_dir($config[ 'path' ])) { |
|
115 | - $this->path = $config[ 'path' ]; |
|
114 | + if (is_dir($config['path'])) { |
|
115 | + $this->path = $config['path']; |
|
116 | 116 | } elseif (defined('PATH_STORAGE')) { |
117 | - if (is_dir($config[ 'path' ])) { |
|
118 | - $this->path = $config[ 'path' ]; |
|
117 | + if (is_dir($config['path'])) { |
|
118 | + $this->path = $config['path']; |
|
119 | 119 | } else { |
120 | - $this->path = PATH_STORAGE . str_replace(PATH_STORAGE, '', $config[ 'path' ]); |
|
120 | + $this->path = PATH_STORAGE . str_replace(PATH_STORAGE, '', $config['path']); |
|
121 | 121 | } |
122 | 122 | } else { |
123 | - $this->path = dirname($_SERVER[ 'SCRIPT_FILENAME' ]) . DIRECTORY_SEPARATOR . $config[ 'path' ]; |
|
123 | + $this->path = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . $config['path']; |
|
124 | 124 | } |
125 | 125 | } elseif (defined('PATH_STORAGE')) { |
126 | 126 | $this->path = PATH_STORAGE; |
127 | 127 | } else { |
128 | - $this->path = dirname($_SERVER[ 'SCRIPT_FILENAME' ]) . DIRECTORY_SEPARATOR . 'upload'; |
|
128 | + $this->path = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'upload'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->path = rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
132 | 132 | |
133 | - if (isset($config[ 'allowedMimes' ])) { |
|
134 | - $this->setAllowedMimes($config[ 'allowedMimes' ]); |
|
133 | + if (isset($config['allowedMimes'])) { |
|
134 | + $this->setAllowedMimes($config['allowedMimes']); |
|
135 | 135 | } |
136 | 136 | |
137 | - if (isset($config[ 'allowedExtensions' ])) { |
|
138 | - $this->setAllowedExtensions($config[ 'allowedExtensions' ]); |
|
137 | + if (isset($config['allowedExtensions'])) { |
|
138 | + $this->setAllowedExtensions($config['allowedExtensions']); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $this->uploadedFiles = new ArrayIterator(); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $this->path = PATH_STORAGE . str_replace(PATH_STORAGE, '', $path); |
206 | 206 | } |
207 | 207 | } else { |
208 | - $this->path = dirname($_SERVER[ 'SCRIPT_FILENAME' ]) . DIRECTORY_SEPARATOR . $path; |
|
208 | + $this->path = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . $path; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | break; |
239 | 239 | } |
240 | 240 | |
241 | - $this->allowedFileSize[ 'min' ] = (int)$fileSize; |
|
241 | + $this->allowedFileSize['min'] = (int)$fileSize; |
|
242 | 242 | |
243 | 243 | return $this; |
244 | 244 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | break; |
273 | 273 | } |
274 | 274 | |
275 | - $this->allowedFileSize[ 'max' ] = (int)$fileSize; |
|
275 | + $this->allowedFileSize['max'] = (int)$fileSize; |
|
276 | 276 | |
277 | 277 | return $this; |
278 | 278 | } |
@@ -419,21 +419,21 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | /* Validate min size */ |
422 | - if ($this->allowedFileSize[ 'min' ] > 0) { |
|
423 | - if ($file->getSize() < $this->allowedFileSize[ 'min' ]) { |
|
422 | + if ($this->allowedFileSize['min'] > 0) { |
|
423 | + if ($file->getSize() < $this->allowedFileSize['min']) { |
|
424 | 424 | $this->errors[] = language()->getLine( |
425 | 425 | 'UPLOADER_E_ALLOWED_MIN_FILESIZE', |
426 | - [$this->allowedFileSize[ 'min' ], $file->getSize()] |
|
426 | + [$this->allowedFileSize['min'], $file->getSize()] |
|
427 | 427 | ); |
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | 431 | /* Validate max size */ |
432 | - if ($this->allowedFileSize[ 'min' ] > 0) { |
|
433 | - if ($file->getSize() > $this->allowedFileSize[ 'max' ]) { |
|
432 | + if ($this->allowedFileSize['min'] > 0) { |
|
433 | + if ($file->getSize() > $this->allowedFileSize['max']) { |
|
434 | 434 | $this->errors[] = language()->getLine( |
435 | 435 | 'UPLOADER_E_ALLOWED_MAX_FILESIZE', |
436 | - [$this->allowedFileSize[ 'max' ], $file->getSize()] |
|
436 | + [$this->allowedFileSize['max'], $file->getSize()] |
|
437 | 437 | ); |
438 | 438 | } |
439 | 439 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function show() |
203 | 203 | { |
204 | 204 | if ($mime = $this->getMime()) { |
205 | - $mime = is_array($mime) ? $mime[ 0 ] : $mime; |
|
205 | + $mime = is_array($mime) ? $mime[0] : $mime; |
|
206 | 206 | } elseif (is_file($this->getRealPath())) { |
207 | 207 | $mime = 'application/octet-stream'; |
208 | 208 | } |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | |
226 | 226 | $ETag = '"' . md5($filename) . '"'; |
227 | 227 | |
228 | - if ( ! empty($_SERVER[ 'HTTP_IF_NONE_MATCH' ]) |
|
229 | - && $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == $ETag |
|
228 | + if ( ! empty($_SERVER['HTTP_IF_NONE_MATCH']) |
|
229 | + && $_SERVER['HTTP_IF_NONE_MATCH'] == $ETag |
|
230 | 230 | ) { |
231 | 231 | header('HTTP/1.1 304 Not Modified'); |
232 | 232 | header('Content-Length: ' . $fileSize); |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $mimes = $this->getMimes(); |
269 | 269 | $ext = strtolower($this->getExtension()); |
270 | 270 | |
271 | - if (isset($mimes[ $ext ])) { |
|
272 | - return $mimes[ $ext ]; |
|
271 | + if (isset($mimes[$ext])) { |
|
272 | + return $mimes[$ext]; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return false; |
@@ -58,7 +58,7 @@ |
||
58 | 58 | $result = []; |
59 | 59 | |
60 | 60 | if (false !== ($handle = fopen($filePath, 'r'))) { |
61 | - while (false !== ($data = fgetcsv($handle, $options[ 'length' ], $options[ 'delimiter' ]))) { |
|
61 | + while (false !== ($data = fgetcsv($handle, $options['length'], $options['delimiter']))) { |
|
62 | 62 | $result[] = fgetcsv($handle); |
63 | 63 | } |
64 | 64 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $filePath, |
42 | 42 | (empty($options) |
43 | 43 | ? true |
44 | - : $options[ 'sections' ]) |
|
44 | + : $options['sections']) |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | $this->merge($items); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $sections = (empty($options) |
69 | 69 | ? true |
70 | - : $options[ 'sections' ]); |
|
70 | + : $options['sections']); |
|
71 | 71 | |
72 | 72 | $content = null; |
73 | 73 |
@@ -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 | } |