Passed
Push — develop ( 89ed24...6b9531 )
by Nikolay
04:52
created
src/PBXCoreREST/Config/RegisterDIServices.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 
68 68
         foreach ($pbxRestAPIProviders as $provider) {
69 69
             // Delete previous provider
70
-            if (property_exists($provider,'SERVICE_NAME')
70
+            if (property_exists($provider, 'SERVICE_NAME')
71 71
                 && $di->has($provider::SERVICE_NAME)) {
72 72
                 $di->remove($provider::SERVICE_NAME);
73 73
             }
Please login to merge, or discard this patch.
src/PBXCoreREST/Providers/ResponseProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     {
31 31
         $di->setShared(
32 32
             self::SERVICE_NAME,
33
-            function () {
33
+            function() {
34 34
                 $response = new Response();
35 35
 
36 36
                 /**
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@
 block discarded – undo
30 30
     {
31 31
         $di->setShared(
32 32
             self::SERVICE_NAME,
33
-            function () {
33
+            function ()
34
+            {
34 35
                 $response = new Response();
35 36
 
36 37
                 /**
Please login to merge, or discard this patch.
src/PBXCoreREST/Providers/BeanstalkConnectionProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     {
34 34
         $di->setShared(
35 35
             self::SERVICE_NAME,
36
-            function () {
36
+            function() {
37 37
                 return new BeanstalkClient(WorkerApiCommands::class);
38 38
             }
39 39
         );
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
     {
34 34
         $di->setShared(
35 35
             self::SERVICE_NAME,
36
-            function () {
36
+            function ()
37
+            {
37 38
                 return new BeanstalkClient(WorkerApiCommands::class);
38 39
             }
39 40
         );
Please login to merge, or discard this patch.
src/PBXCoreREST/Providers/DispatcherProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     {
36 36
         $di->setShared(
37 37
             self::SERVICE_NAME,
38
-            function () {
38
+            function() {
39 39
                 // Create a events manager
40 40
                 $eventsManager = new EventsManager();
41 41
                 $dispatcher = new Dispatcher();
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@
 block discarded – undo
35 35
     {
36 36
         $di->setShared(
37 37
             self::SERVICE_NAME,
38
-            function () {
38
+            function ()
39
+            {
39 40
                 // Create a events manager
40 41
                 $eventsManager = new EventsManager();
41 42
                 $dispatcher = new Dispatcher();
Please login to merge, or discard this patch.
src/Core/Config/RegisterDIServices.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 
89 89
         foreach ($providersList as $provider) {
90 90
             // Delete previous provider
91
-            if (property_exists($provider,'SERVICE_NAME')
91
+            if (property_exists($provider, 'SERVICE_NAME')
92 92
                 && $di->has($provider::SERVICE_NAME)) {
93 93
                 $di->remove($provider::SERVICE_NAME);
94 94
             }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         foreach ($dbProvidersList as $provider) {
115 115
             // Delete previous provider
116
-            if (property_exists($provider,'SERVICE_NAME')
116
+            if (property_exists($provider, 'SERVICE_NAME')
117 117
                 && $di->has($provider::SERVICE_NAME)) {
118 118
                 $di->remove($provider::SERVICE_NAME);
119 119
             }
Please login to merge, or discard this patch.
src/Core/System/Util.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             }
45 45
             if (is_array($value)) {
46 46
                 array_unshift($value, ' ');
47
-                $result_config .= trim(implode("\n{$key} = ", $value)) . "\n";
47
+                $result_config .= trim(implode("\n{$key} = ", $value))."\n";
48 48
             } else {
49 49
                 $result_config .= "{$key} = {$value}\n";
50 50
             }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $killallPath = self::which('killall');
66 66
 
67
-        return self::mwExec($killallPath . ' ' . escapeshellarg($procName));
67
+        return self::mwExec($killallPath.' '.escapeshellarg($procName));
68 68
     }
69 69
 
70 70
     /**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $rmPath    = self::which('rm');
106 106
         $sleepPath = self::which('sleep');
107 107
         if ($sleep_time > 0) {
108
-            $filename = '/tmp/' . time() . '_noop.sh';
108
+            $filename = '/tmp/'.time().'_noop.sh';
109 109
             file_put_contents($filename, "{$sleepPath} {$sleep_time}; {$command}; {$rmPath} -rf {$filename}");
110 110
             $noop_command = "{$nohupPath} {$shPath} {$filename} > {$out_file} 2>&1 &";
111 111
         } else {
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
      *
168 168
      * @return bool
169 169
      */
170
-    public static function mwMkdir(string $parameters, bool $addWWWRights=false): bool
170
+    public static function mwMkdir(string $parameters, bool $addWWWRights = false): bool
171 171
     {
172 172
         $result = true;
173 173
         if (posix_getuid() === 0) {
174 174
             $arrPaths = explode(' ', $parameters);
175 175
             if (count($arrPaths) > 0) {
176 176
                 foreach ($arrPaths as $path) {
177
-                    if ( ! empty($path)
178
-                        && ! file_exists($path)
179
-                        && ! mkdir($path, 0755, true)
180
-                        && ! is_dir($path)) {
177
+                    if (!empty($path)
178
+                        && !file_exists($path)
179
+                        && !mkdir($path, 0755, true)
180
+                        && !is_dir($path)) {
181 181
                         $result = false;
182 182
                         self::sysLogMsg('Util', 'Error on create folder '.$path);
183 183
                     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     public static function restartPHPWorker(string $className, string $param = 'start'): void
200 200
     {
201 201
         $workerPath = self::getFilePathByClassName($className);
202
-        if ( ! empty($workerPath)) {
202
+        if (!empty($workerPath)) {
203 203
             $command = "php -f {$workerPath}";
204 204
             self::processWorker($command, $param, $className, 'restart');
205 205
         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             $reflection = new ReflectionClass($className);
220 220
             $filename   = $reflection->getFileName();
221 221
         } catch (\ReflectionException $exception) {
222
-            self::sysLogMsg('Util', 'Error ' . $exception->getMessage());
222
+            self::sysLogMsg('Util', 'Error '.$exception->getMessage());
223 223
         }
224 224
 
225 225
         return $filename;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param ?int $level
234 234
      * @param ?int $facility
235 235
      */
236
-    public static function sysLogMsg($log_name, $text, $level = null, $facility=LOG_AUTH): void
236
+    public static function sysLogMsg($log_name, $text, $level = null, $facility = LOG_AUTH): void
237 237
     {
238 238
         $level = ($level === null) ? LOG_WARNING : $level;
239 239
         openlog("$log_name", LOG_PID | LOG_PERROR, $facility);
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 
334 334
         $name       = addslashes($name);
335 335
         $filter_cmd = '';
336
-        if ( ! empty($exclude)) {
337
-            $filter_cmd = "| $path_grep -v " . escapeshellarg($exclude);
336
+        if (!empty($exclude)) {
337
+            $filter_cmd = "| $path_grep -v ".escapeshellarg($exclude);
338 338
         }
339 339
         $out = [];
340 340
         self::mwExec(
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
     public static function amiOriginate($peer_number, $peer_mobile, $dest_number): array
357 357
     {
358 358
         $am       = self::getAstManager('off');
359
-        $channel  = 'Local/' . $peer_number . '@internal-originate';
359
+        $channel  = 'Local/'.$peer_number.'@internal-originate';
360 360
         $context  = 'all_peers';
361 361
         $IS_ORGNT = self::generateRandomString();
362 362
         $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}";
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
      */
377 377
     public static function getAstManager($events = 'on'): AsteriskManager
378 378
     {
379
-        if($events === 'on'){
379
+        if ($events === 'on') {
380 380
             $nameService = 'amiListner';
381
-        }else{
381
+        } else {
382 382
             $nameService = 'amiCommander';
383 383
         }
384 384
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
         for ($i = 0; $i < $length; $i++) {
409 409
             try {
410 410
                 $randomString .= $characters[random_int(0, $charactersLength - 1)];
411
-            }catch (\Exception $e ){
411
+            } catch (\Exception $e) {
412 412
                 $randomString = '';
413 413
             }
414 414
         }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
             file_put_contents($filename_orgn, $data);
518 518
         }
519 519
 
520
-        if ( ! $res) {
520
+        if (!$res) {
521 521
             // Файл еще не зарегистрирован в базе. Сделаем это.
522 522
             $res = new CustomFiles();
523 523
             $res->writeAttribute('filepath', $filename);
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
     public static function getExtensionOfFile($filename)
589 589
     {
590 590
         $path_parts = pathinfo($filename);
591
-        return $path_parts['extension']??'';
591
+        return $path_parts['extension'] ?? '';
592 592
     }
593 593
 
594 594
     /**
@@ -602,10 +602,10 @@  discard block
 block discarded – undo
602 602
     public static function trimExtensionForFile($filename, $delimiter = '.'): string
603 603
     {
604 604
         // Отсечем расширение файла.
605
-        $tmp_arr = explode((string)$delimiter, $filename);
605
+        $tmp_arr = explode((string) $delimiter, $filename);
606 606
         if (count($tmp_arr) > 1) {
607 607
             unset($tmp_arr[count($tmp_arr) - 1]);
608
-            $filename = implode((string)$delimiter, $tmp_arr);
608
+            $filename = implode((string) $delimiter, $tmp_arr);
609 609
         }
610 610
 
611 611
         return $filename;
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         $total_files_on_server_size = 0;
677 677
         foreach (scandir($temp_dir) as $file) {
678 678
             $temp_total                 = $total_files_on_server_size;
679
-            $tempfilesize               = filesize($temp_dir . '/' . $file);
679
+            $tempfilesize               = filesize($temp_dir.'/'.$file);
680 680
             $total_files_on_server_size = $temp_total + $tempfilesize;
681 681
         }
682 682
         // check that all the parts are present
@@ -707,19 +707,19 @@  discard block
 block discarded – undo
707 707
         $progress_dir = ''
708 708
     ) {
709 709
         if (empty($result_file)) {
710
-            $result_file = dirname($temp_dir) . '/' . $fileName;
710
+            $result_file = dirname($temp_dir).'/'.$fileName;
711 711
         }
712 712
 
713 713
         $show_progress = file_exists($progress_dir);
714
-        $progress_file = $progress_dir . '/progress';
715
-        if ($show_progress && ! file_exists($progress_file)) {
714
+        $progress_file = $progress_dir.'/progress';
715
+        if ($show_progress && !file_exists($progress_file)) {
716 716
             file_put_contents($progress_file, '0');
717 717
         }
718 718
 
719 719
         // create the final destination file
720 720
         if (($fp = fopen($result_file, 'w')) !== false) {
721 721
             for ($i = 1; $i <= $total_files; $i++) {
722
-                $tmp_file = $temp_dir . '/' . $fileName . '.part' . $i;
722
+                $tmp_file = $temp_dir.'/'.$fileName.'.part'.$i;
723 723
                 fwrite($fp, file_get_contents($tmp_file));
724 724
                 // Удаляем временный файл.
725 725
                 unlink($tmp_file);
@@ -729,15 +729,15 @@  discard block
 block discarded – undo
729 729
             }
730 730
             fclose($fp);
731 731
         } else {
732
-            self::sysLogMsg('UploadFile', 'cannot create the destination file - ' . $result_file);
732
+            self::sysLogMsg('UploadFile', 'cannot create the destination file - '.$result_file);
733 733
 
734 734
             return false;
735 735
         }
736
-        self::sysLogMsg('UploadFile', 'destination file - ' . $result_file);
736
+        self::sysLogMsg('UploadFile', 'destination file - '.$result_file);
737 737
         // rename the temporary directory (to avoid access from other
738 738
         // concurrent chunks uploads) and than delete it
739
-        if (rename($temp_dir, $temp_dir . '_UNUSED')) {
740
-            self::rRmDir($temp_dir . '_UNUSED');
739
+        if (rename($temp_dir, $temp_dir.'_UNUSED')) {
740
+            self::rRmDir($temp_dir.'_UNUSED');
741 741
         } else {
742 742
             self::rRmDir($temp_dir);
743 743
         }
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
             $objects = scandir($dir);
765 765
             foreach ($objects as $object) {
766 766
                 if ($object != "." && $object != "..") {
767
-                    if (filetype($dir . "/" . $object) == "dir") {
768
-                        self::rRmDir($dir . "/" . $object);
767
+                    if (filetype($dir."/".$object) == "dir") {
768
+                        self::rRmDir($dir."/".$object);
769 769
                     } else {
770
-                        unlink($dir . "/" . $object);
770
+                        unlink($dir."/".$object);
771 771
                     }
772 772
                 }
773 773
             }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
     public static function generateSslCert($options = null, $config_args_pkey = null, $config_args_csr = null): array
789 789
     {
790 790
         // Инициализация настроек.
791
-        if ( ! $options) {
791
+        if (!$options) {
792 792
             $options = [
793 793
                 "countryName"            => 'RU',
794 794
                 "stateOrProvinceName"    => 'Moscow',
@@ -800,11 +800,11 @@  discard block
 block discarded – undo
800 800
             ];
801 801
         }
802 802
 
803
-        if ( ! $config_args_csr) {
803
+        if (!$config_args_csr) {
804 804
             $config_args_csr = ['digest_alg' => 'sha256'];
805 805
         }
806 806
 
807
-        if ( ! $config_args_pkey) {
807
+        if (!$config_args_pkey) {
808 808
             $config_args_pkey = [
809 809
                 "private_key_bits" => 2048,
810 810
                 "private_key_type" => OPENSSL_KEYTYPE_RSA,
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
             $row = trim($row);
951 951
             $pos = strpos($row, ']');
952 952
             if ($pos !== false && strpos($row, '[') === 0) {
953
-                $row = "\n" . substr($row, 0, $pos);
953
+                $row = "\n".substr($row, 0, $pos);
954 954
             }
955 955
         }
956 956
         unset($row);
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
         foreach ($sections as $section) {
963 963
             $data_rows    = explode("\n", trim($section));
964 964
             $section_name = trim($data_rows[0] ?? '');
965
-            if ( ! empty($section_name)) {
965
+            if (!empty($section_name)) {
966 966
                 unset($data_rows[0]);
967 967
                 $manual_data[$section_name] = [];
968 968
                 foreach ($data_rows as $row) {
Please login to merge, or discard this patch.
src/Core/System/Storage.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
     public static function isStorageDisk($device): bool
83 83
     {
84 84
         $result = false;
85
-        if ( ! file_exists("{$device}")) {
85
+        if (!file_exists("{$device}")) {
86 86
             return $result;
87 87
         }
88 88
 
89
-        $tmp_dir = '/tmp/mnt_' . time();
89
+        $tmp_dir = '/tmp/mnt_'.time();
90 90
         Util::mwMkdir($tmp_dir);
91 91
         $out = [];
92 92
 
93 93
         $storage  = new Storage();
94
-        $uid_part = 'UUID=' . $storage->getUuid($device) . '';
94
+        $uid_part = 'UUID='.$storage->getUuid($device).'';
95 95
         $format   = $storage->getFsType($device);
96 96
         if ($format === '') {
97 97
             return false;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             Util::mwExec("{$umountPath} {$device}");
111 111
         }
112 112
 
113
-        if ( ! self::isStorageDiskMounted($device)) {
113
+        if (!self::isStorageDiskMounted($device)) {
114 114
             Util::mwExec("{$rmPath} -rf '{$tmp_dir}'");
115 115
         }
116 116
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
         $timeoutPath = Util::which('timeout');
241 241
         $sshfsPath   = Util::which('sshfs');
242 242
 
243
-        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' " .
244
-            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n" .
245
-            "{$pass}\n" .
243
+        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' ".
244
+            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n".
245
+            "{$pass}\n".
246 246
             "EOF\n";
247 247
         // file_put_contents('/tmp/sshfs_'.$host, $command);
248 248
         Util::mwExec($command, $out);
@@ -274,19 +274,19 @@  discard block
 block discarded – undo
274 274
 
275 275
         // Собираем строку подключения к ftp.
276 276
         $auth_line = '';
277
-        if ( ! empty($user)) {
278
-            $auth_line .= 'user="' . $user;
279
-            if ( ! empty($pass)) {
277
+        if (!empty($user)) {
278
+            $auth_line .= 'user="'.$user;
279
+            if (!empty($pass)) {
280 280
                 $auth_line .= ":{$pass}";
281 281
             }
282 282
             $auth_line .= '",';
283 283
         }
284 284
 
285
-        $connect_line = 'ftp://' . $host;
286
-        if ( ! empty($port)) {
285
+        $connect_line = 'ftp://'.$host;
286
+        if (!empty($port)) {
287 287
             $connect_line .= ":{$port}";
288 288
         }
289
-        if ( ! empty($remout_dir)) {
289
+        if (!empty($remout_dir)) {
290 290
             $connect_line .= "$remout_dir";
291 291
         }
292 292
 
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
      */
313 313
     public static function mkfs_disk($dev)
314 314
     {
315
-        if ( ! file_exists($dev)) {
315
+        if (!file_exists($dev)) {
316 316
             $dev = "/dev/{$dev}";
317 317
         }
318
-        if ( ! file_exists($dev)) {
318
+        if (!file_exists($dev)) {
319 319
             return false;
320 320
         }
321 321
         $dir = '';
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             Util::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0");
351 351
             Util::mwExec("{$umountPath} {$dir}");
352 352
         }
353
-        $result = ! self::isStorageDiskMounted($dir);
353
+        $result = !self::isStorageDiskMounted($dir);
354 354
         if ($result && file_exists($dir)) {
355 355
             // Если диск не смонтирован, то удаляем каталог.
356 356
             Util::mwExec("{$rmPath} -rf '{$dir}'");
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public static function statusMkfs($dev): string
422 422
     {
423
-        if ( ! file_exists($dev)) {
423
+        if (!file_exists($dev)) {
424 424
             $dev = "/dev/{$dev}";
425 425
         }
426 426
         $out      = [];
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         }
444 444
         $config        = $di->getShared('config');
445 445
         $phpSessionDir = $config->path('www.phpSessionDir');
446
-        if ( ! empty($phpSessionDir)) {
446
+        if (!empty($phpSessionDir)) {
447 447
             $rmPath = Util::which('rm');
448 448
             Util::mwExec("{$rmPath} -rf {$phpSessionDir}/*");
449 449
         }
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         // Создание больщого файла для тестов.
460 460
         // head -c 1500MB /dev/urandom > /storage/usbdisk1/big_file.mp3
461 461
         foreach ($hdd as $disk) {
462
-            if ($disk['sys_disk'] === true && ! self::isStorageDiskMounted("{$disk['id']}4")) {
462
+            if ($disk['sys_disk'] === true && !self::isStorageDiskMounted("{$disk['id']}4")) {
463 463
                 // Это системный диск (4ый раздел). Он не смонтирован.
464 464
                 continue;
465 465
             }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
                 Util::restartPHPWorker(WorkerRemoveOldRecords::class);
484 484
             }
485 485
 
486
-            if ( ! $need_alert) {
486
+            if (!$need_alert) {
487 487
                 continue;
488 488
             }
489 489
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
                 $m_size      = round(($disk_data[1] + $disk_data[2]) / 1024, 1);
524 524
                 $res_disks[] = [
525 525
                     'id'         => $disk_data[0],
526
-                    'size'       => "" . $m_size,
527
-                    'size_text'  => "" . $m_size . " Mb",
526
+                    'size'       => "".$m_size,
527
+                    'size_text'  => "".$m_size." Mb",
528 528
                     'vendor'     => 'Debian',
529 529
                     'mounted'    => '/storage/usbdisk1',
530 530
                     'free_space' => round($disk_data[2] / 1024, 1),
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 
547 547
         $cf_disk   = '';
548 548
         $varEtcDir = $this->config->path('core.varEtcDir');
549
-        if (file_exists($varEtcDir . '/cfdevice')) {
550
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
549
+        if (file_exists($varEtcDir.'/cfdevice')) {
550
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
551 551
         }
552 552
 
553 553
         foreach ($disks as $disk) {
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
             $sys_disk = ($cf_disk == $disk);
564 564
 
565 565
             $mb_size = 0;
566
-            if (is_file("/sys/block/" . $disk . "/size")) {
567
-                $original_size = trim(file_get_contents("/sys/block/" . $disk . "/size"));
566
+            if (is_file("/sys/block/".$disk."/size")) {
567
+                $original_size = trim(file_get_contents("/sys/block/".$disk."/size"));
568 568
                 $original_size = ($original_size * 512 / 1024 / 1024);
569 569
                 $mb_size       = $original_size;
570 570
             }
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
     private function getVendorDisk($disk): string
672 672
     {
673 673
         $temp_vendor = [];
674
-        if (is_file("/sys/block/" . $disk . "/device/vendor")) {
675
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/vendor"));
674
+        if (is_file("/sys/block/".$disk."/device/vendor")) {
675
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/vendor"));
676 676
             if ($data != '') {
677 677
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
678 678
             }
679 679
         }
680
-        if (is_file("/sys/block/" . $disk . "/device/model")) {
681
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/model"));
680
+        if (is_file("/sys/block/".$disk."/device/model")) {
681
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/model"));
682 682
             if ($data != '') {
683 683
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
684 684
             }
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
         if (count($temp_vendor) == 0) {
687 687
             $temp_vendor[] = $disk;
688 688
         }
689
-        if (is_file("/sys/block/" . $disk . "/device/type")) {
690
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/type"));
689
+        if (is_file("/sys/block/".$disk."/device/type")) {
690
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/type"));
691 691
             if ($data != '') {
692 692
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
693 693
             }
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
         Util::mwExec("{$dfPath} -m | {$grepPath} {$hdd} | {$awkPath} '{print $4}'", $out);
714 714
         $result = 0;
715 715
         foreach ($out as $res) {
716
-            if ( ! is_numeric($res)) {
716
+            if (!is_numeric($res)) {
717 717
                 continue;
718 718
             }
719 719
             $result += (1 * $res);
@@ -750,19 +750,19 @@  discard block
 block discarded – undo
750 750
                 $path_size_info = $tmp_path;
751 751
             }
752 752
             if (empty($path_size_info)) {
753
-                $tmp_path = "/sys/block/" . substr($dev, 0, 3) . "/{$dev}/size";
753
+                $tmp_path = "/sys/block/".substr($dev, 0, 3)."/{$dev}/size";
754 754
                 if (file_exists($tmp_path)) {
755 755
                     $path_size_info = $tmp_path;
756 756
                 }
757 757
             }
758 758
 
759
-            if ( ! empty($path_size_info)) {
759
+            if (!empty($path_size_info)) {
760 760
                 $original_size = trim(file_get_contents($path_size_info));
761 761
                 $original_size = ($original_size * 512 / 1024 / 1024);
762 762
                 $mb_size       = $original_size;
763 763
             }
764 764
 
765
-            $tmp_dir = "/tmp/{$dev}_" . time();
765
+            $tmp_dir = "/tmp/{$dev}_".time();
766 766
             $out     = [];
767 767
 
768 768
             $fs           = null;
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
         }
820 820
         Util::mwMkdir($dir);
821 821
 
822
-        if ( ! file_exists($dir)) {
822
+        if (!file_exists($dir)) {
823 823
             Util::sysLogMsg('Storage', "Unable mount $dev $format to $dir. Unable create dir.");
824 824
 
825 825
             return false;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
             Util::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out);
831 831
         } else {
832 832
             $storage   = new Storage();
833
-            $uid_part  = 'UUID=' . $storage->getUuid("/dev/{$dev}") . '';
833
+            $uid_part  = 'UUID='.$storage->getUuid("/dev/{$dev}").'';
834 834
             $mountPath = Util::which('mount');
835 835
             Util::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out);
836 836
         }
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
             unlink($storage_dev_file);
851 851
         }
852 852
 
853
-        if (file_exists($varEtcDir . '/cfdevice')) {
854
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
853
+        if (file_exists($varEtcDir.'/cfdevice')) {
854
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
855 855
         }
856 856
 
857 857
         $disks = $this->getDiskSettings();
@@ -865,18 +865,18 @@  discard block
 block discarded – undo
865 865
                 // Если это системный диск, то пытаемся подключить раздел 4.
866 866
                 $dev = "{$disk['device']}4";
867 867
             }
868
-            if ( ! $this->hddExists($dev)) {
868
+            if (!$this->hddExists($dev)) {
869 869
                 // Диск не существует.
870 870
                 continue;
871 871
             }
872
-            if ($disk['media'] === '1' || ! file_exists($storage_dev_file)) {
872
+            if ($disk['media'] === '1' || !file_exists($storage_dev_file)) {
873 873
                 file_put_contents($storage_dev_file, "/storage/usbdisk{$disk['id']}");
874 874
                 $this->updateConfigWithNewMountPoint("/storage/usbdisk{$disk['id']}");
875 875
             }
876 876
 
877
-            $str_uid     = 'UUID=' . $this->getUuid($dev) . '';
877
+            $str_uid     = 'UUID='.$this->getUuid($dev).'';
878 878
             $format_p4   = $this->getFsType($dev);
879
-            $conf        .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
879
+            $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
880 880
             $mount_point = "/storage/usbdisk{$disk['id']}";
881 881
             Util::mwMkdir($mount_point);
882 882
         }
@@ -991,11 +991,11 @@  discard block
 block discarded – undo
991 991
         Util::mwMkdir('/storage');
992 992
         $chmodPath = Util::which('chmod');
993 993
         Util::mwExec("{$chmodPath} 755 /storage");
994
-        if ( ! file_exists($varEtcDir . '/cfdevice')) {
994
+        if (!file_exists($varEtcDir.'/cfdevice')) {
995 995
             return;
996 996
         }
997 997
         $fstab     = '';
998
-        $file_data = file_get_contents($varEtcDir . '/cfdevice');
998
+        $file_data = file_get_contents($varEtcDir.'/cfdevice');
999 999
         $cf_disk   = trim($file_data);
1000 1000
         if ('' == $cf_disk) {
1001 1001
             return;
@@ -1005,9 +1005,9 @@  discard block
 block discarded – undo
1005 1005
         $part3 = (strpos($cf_disk, 'mmcblk') !== false) ? "{$cf_disk}p3" : "{$cf_disk}3"; // Conf
1006 1006
 
1007 1007
 
1008
-        $uid_part2 = 'UUID=' . $this->getUuid("/dev/{$part2}") . '';
1008
+        $uid_part2 = 'UUID='.$this->getUuid("/dev/{$part2}").'';
1009 1009
         $format_p2 = $this->getFsType($part2);
1010
-        $uid_part3 = 'UUID=' . $this->getUuid("/dev/{$part3}") . '';
1010
+        $uid_part3 = 'UUID='.$this->getUuid("/dev/{$part3}").'';
1011 1011
         $format_p3 = $this->getFsType($part3);
1012 1012
 
1013 1013
         // $fstab .= "/dev/{$part1} /cf msdos ro 1 1\n"; // НЕ МОНТИРУЕМ!
@@ -1052,12 +1052,12 @@  discard block
 block discarded – undo
1052 1052
             }
1053 1053
         }
1054 1054
 
1055
-        if ( ! empty($path)) {
1055
+        if (!empty($path)) {
1056 1056
             Util::mwMkdir($path);
1057 1057
         }
1058 1058
 
1059 1059
         $downloadCacheDir = appPath('sites/pbxcore/files/cache');
1060
-        if ( ! $isLiveCd) {
1060
+        if (!$isLiveCd) {
1061 1061
             Util::mwMkdir($downloadCacheDir);
1062 1062
             Util::createUpdateSymlink($this->config->path('www.downloadCacheDir'), $downloadCacheDir);
1063 1063
         }
@@ -1094,13 +1094,13 @@  discard block
 block discarded – undo
1094 1094
     public function createAssetsSymlinks(): void
1095 1095
     {
1096 1096
         $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache');
1097
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/js', $jsCacheDir);
1097
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/js', $jsCacheDir);
1098 1098
 
1099 1099
         $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache');
1100
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/css', $cssCacheDir);
1100
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/css', $cssCacheDir);
1101 1101
 
1102 1102
         $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
1103
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/img', $imgCacheDir);
1103
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/img', $imgCacheDir);
1104 1104
     }
1105 1105
 
1106 1106
     /**
@@ -1113,13 +1113,13 @@  discard block
 block discarded – undo
1113 1113
         $cacheDirs[] = $this->config->path('www.downloadCacheDir');
1114 1114
         $cacheDirs[] = $this->config->path('www.managedCacheDir');
1115 1115
         $cacheDirs[] = $this->config->path('www.modelsCacheDir');
1116
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js';
1117
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css';
1118
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img';
1116
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js';
1117
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css';
1118
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img';
1119 1119
         $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir');
1120 1120
         $rmPath      = Util::which('rm');
1121 1121
         foreach ($cacheDirs as $cacheDir) {
1122
-            if ( ! empty($cacheDir)) {
1122
+            if (!empty($cacheDir)) {
1123 1123
                 Util::mwExec("{$rmPath} -rf {$cacheDir}/*");
1124 1124
             }
1125 1125
         }
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
         $countBlock = $swapSize * $bs;
1230 1230
         $ddCmd      = Util::which('dd');
1231 1231
 
1232
-        Util::sysLogMsg('Swap', 'make swap ' . $swapFile, LOG_INFO, LOG_INFO);
1232
+        Util::sysLogMsg('Swap', 'make swap '.$swapFile, LOG_INFO, LOG_INFO);
1233 1233
         Util::mwExec("{$ddCmd} if=/dev/zero of={$swapFile} bs={$bs} count={$countBlock}");
1234 1234
 
1235 1235
         $mkSwapCmd = Util::which('mkswap');
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 
1238 1238
         $swapOnCmd = Util::which('swapon');
1239 1239
         $result    = Util::mwExec("{$swapOnCmd} {$swapFile}");
1240
-        Util::sysLogMsg('Swap', 'connect swap result: ' . $result, LOG_INFO, LOG_INFO);
1240
+        Util::sysLogMsg('Swap', 'connect swap result: '.$result, LOG_INFO, LOG_INFO);
1241 1241
     }
1242 1242
 
1243 1243
     /**
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
         $size    = 0;
1251 1251
         $mntDir  = '';
1252 1252
         $mounted = self::isStorageDiskMounted('', $mntDir);
1253
-        if ( ! $mounted) {
1253
+        if (!$mounted) {
1254 1254
             return 0;
1255 1255
         }
1256 1256
         $hd = $this->getAllHdd(true);
@@ -1271,12 +1271,12 @@  discard block
 block discarded – undo
1271 1271
      */
1272 1272
     public function saveDiskSettings($data, $id = '1'): void
1273 1273
     {
1274
-        if ( ! is_array($data)) {
1274
+        if (!is_array($data)) {
1275 1275
             return;
1276 1276
         }
1277 1277
         $disk_data = $this->getDiskSettings($id);
1278 1278
         if (count($disk_data) === 0) {
1279
-            $uniqid           = strtoupper('STORAGE-DISK-' . md5(time()));
1279
+            $uniqid           = strtoupper('STORAGE-DISK-'.md5(time()));
1280 1280
             $storage_settings = new StorageModel();
1281 1281
             foreach ($data as $key => $val) {
1282 1282
                 $storage_settings->writeAttribute($key, $val);
Please login to merge, or discard this patch.
src/Common/Models/FirewallRules.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -129,14 +129,14 @@
 block discarded – undo
129 129
 
130 130
         //Add modules firewall rules
131 131
         $di = Di::getDefault();
132
-        if ($di!==null) {
132
+        if ($di !== null) {
133 133
             $pbxConfModules = $di->get('pbxConfModules');
134
-            foreach ($pbxConfModules as $pbxConfModule){
134
+            foreach ($pbxConfModules as $pbxConfModule) {
135 135
                 $additionalRules = $pbxConfModule->getDefaultFirewallRules();
136
-                if ($additionalRules!==[]){
136
+                if ($additionalRules !== []) {
137 137
                     $additionalRules = array_change_key_case($additionalRules, CASE_UPPER);
138
-                    foreach ($additionalRules as $key=>$rule){
139
-                        $template[$key]=$rule;
138
+                    foreach ($additionalRules as $key=>$rule) {
139
+                        $template[$key] = $rule;
140 140
                     }
141 141
                 }
142 142
             }
Please login to merge, or discard this patch.
src/Common/Providers/NatsConnectionProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         $gnatsConfig = $di->getShared('config')->get('gnats');
35 35
         $di->setShared(
36 36
             self::SERVICE_NAME,
37
-            function () use ($gnatsConfig) {
37
+            function() use ($gnatsConfig) {
38 38
                 $connectionOptions = new NatsConnectionOptions();
39 39
                 $host              = $gnatsConfig->host;
40 40
                 $port              = $gnatsConfig->port;
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@
 block discarded – undo
34 34
         $gnatsConfig = $di->getShared('config')->get('gnats');
35 35
         $di->setShared(
36 36
             self::SERVICE_NAME,
37
-            function () use ($gnatsConfig) {
37
+            function () use ($gnatsConfig)
38
+            {
38 39
                 $connectionOptions = new NatsConnectionOptions();
39 40
                 $host              = $gnatsConfig->host;
40 41
                 $port              = $gnatsConfig->port;
Please login to merge, or discard this patch.