@@ -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); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $this->filesize = strlen($this->filedata); |
| 95 | - $this->filemime = $this->getMime($this->fileinfo[ 'filename' ]); |
|
| 95 | + $this->filemime = $this->getMime($this->fileinfo['filename']); |
|
| 96 | 96 | $this->lastModified = time(); |
| 97 | 97 | |
| 98 | 98 | } else { |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Range |
| 105 | - if (isset($_SERVER[ 'HTTP_RANGE' ]) || isset($HTTP_SERVER_VARS[ 'HTTP_RANGE' ])) { |
|
| 105 | + if (isset($_SERVER['HTTP_RANGE']) || isset($HTTP_SERVER_VARS['HTTP_RANGE'])) { |
|
| 106 | 106 | $this->partialRequest = true; |
| 107 | - $http_range = isset($_SERVER[ 'HTTP_RANGE' ]) ? $_SERVER[ 'HTTP_RANGE' ] : $HTTP_SERVER_VARS[ 'HTTP_RANGE' ]; |
|
| 107 | + $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : $HTTP_SERVER_VARS['HTTP_RANGE']; |
|
| 108 | 108 | if (stripos($http_range, 'bytes') === false) { |
| 109 | 109 | output() |
| 110 | 110 | ->withStatus(416, 'Requested Range Not Satisfiable') |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $range = substr($http_range, strlen('bytes=')); |
| 115 | 115 | $range = explode('-', $range, 3); |
| 116 | - $this->seekStart = ($range[ 0 ] > 0 && $range[ 0 ] < $this->filesize - 1) ? $range[ 0 ] : 0; |
|
| 117 | - $this->seekEnd = ($range[ 1 ] > 0 && $range[ 1 ] < $this->filesize && $range[ 1 ] > $this->seekStart) ? $range[ 1 ] : $this->filesize - 1; |
|
| 116 | + $this->seekStart = ($range[0] > 0 && $range[0] < $this->filesize - 1) ? $range[0] : 0; |
|
| 117 | + $this->seekEnd = ($range[1] > 0 && $range[1] < $this->filesize && $range[1] > $this->seekStart) ? $range[1] : $this->filesize - 1; |
|
| 118 | 118 | $this->seekFilesize = $this->seekEnd - $this->seekStart + 1; |
| 119 | 119 | } else { |
| 120 | 120 | $this->partialRequest = false; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public function download($filename = null) |
| 147 | 147 | { |
| 148 | - $filename = isset($filename) ? $filename : $this->fileinfo[ 'basename' ]; |
|
| 148 | + $filename = isset($filename) ? $filename : $this->fileinfo['basename']; |
|
| 149 | 149 | |
| 150 | 150 | if ($this->partialRequest) { |
| 151 | 151 | if ($this->resumeable) { |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | // Work On Download Speed Limit |
| 177 | 177 | if ($this->speedLimit) { |
| 178 | 178 | // how many buffers ticks per second |
| 179 | - $bufferTicks = 10; //10 |
|
| 179 | + $bufferTicks = 10; //10 |
|
| 180 | 180 | // how long one buffering tick takes by micro second |
| 181 | 181 | $bufferMicroTime = 150; // 100 |
| 182 | 182 | // Calculate sleep micro time after each tick |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | if ($downloadFileBytes > $this->bufferSize) { |
| 208 | 208 | // send buffer size |
| 209 | 209 | echo fread($this->filedata, $this->bufferSize); // this also will seek to after last read byte |
| 210 | - $downloaded += $this->bufferSize; // updated downloaded |
|
| 211 | - $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
| 210 | + $downloaded += $this->bufferSize; // updated downloaded |
|
| 211 | + $downloadFileBytes -= $this->bufferSize; // update remaining bytes |
|
| 212 | 212 | } else { |
| 213 | 213 | // send required size |
| 214 | 214 | // this will happens when we reaches the end of the file normally we wll download remaining bytes |
| 215 | - echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
| 215 | + echo fread($this->filedata, $downloadFileBytes); // this also will seek to last reat |
|
| 216 | 216 | |
| 217 | - $downloaded += $downloadFileBytes; // Add to downloaded |
|
| 217 | + $downloaded += $downloadFileBytes; // Add to downloaded |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - $downloadFileBytes = 0; // Here last bytes have been written |
|
| 220 | + $downloadFileBytes = 0; // Here last bytes have been written |
|
| 221 | 221 | } |
| 222 | 222 | // send to buffer |
| 223 | 223 | flush(); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function resumeable($status = true) |
| 273 | 273 | { |
| 274 | - $this->partialRequest = $this->resumeable = ( bool )$status; |
|
| 274 | + $this->partialRequest = $this->resumeable = (bool)$status; |
|
| 275 | 275 | |
| 276 | 276 | return $this; |
| 277 | 277 | } |
@@ -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 | |