Passed
Pull Request — master (#17)
by Nikolay
05:45
created
src/PBXCoreREST/Workers/WorkerApiCommands.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
         } catch (Error $exception) {
109 109
             $res             = new PBXApiResult();
110 110
             $res->processor  = __METHOD__;
111
-            $res->messages[] = 'Exception on WorkerApiCommands - ' . $exception->getMessage();
111
+            $res->messages[] = 'Exception on WorkerApiCommands - '.$exception->getMessage();
112 112
         }
113 113
         $message->reply(json_encode($res->getResult(), JSON_THROW_ON_ERROR));
114 114
         $this->checkNeedReload($res->data);
Please login to merge, or discard this patch.
src/PBXCoreREST/Controllers/System/PostController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,10 +109,10 @@
 block discarded – undo
109 109
         $mohDir                = $di->getShared('config')->path('asterisk.mohdir');
110 110
         switch ($category) {
111 111
             case SoundFiles::CATEGORY_MOH:
112
-                $data['filename'] = "{$mohDir}/" . basename($data['temp_filename']);
112
+                $data['filename'] = "{$mohDir}/".basename($data['temp_filename']);
113 113
                 break;
114 114
             case SoundFiles::CATEGORY_CUSTOM:
115
-                $data['filename'] = "{$mediaDir}/" . basename($data['temp_filename']);
115
+                $data['filename'] = "{$mediaDir}/".basename($data['temp_filename']);
116 116
                 break;
117 117
             default:
118 118
                 $this->sendError(400, 'Category not set');
Please login to merge, or discard this patch.
src/PBXCoreREST/Controllers/Files/PostController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         if ($response !== false) {
98 98
             $response = json_decode($response, true);
99 99
             $filename = $response['data']['filename'] ?? '';
100
-            if ( ! file_exists($filename)) {
100
+            if (!file_exists($filename)) {
101 101
                 $response['messages'][] = 'Config file not found';
102 102
             } else {
103 103
                 $response['data']['filename'] = $filename;
104
-                $response['data']['content']  = mb_convert_encoding('' . file_get_contents($filename), 'UTF-8', 'UTF-8');
104
+                $response['data']['content']  = mb_convert_encoding(''.file_get_contents($filename), 'UTF-8', 'UTF-8');
105 105
                 unlink($filename);
106 106
             }
107 107
             $this->response->setPayloadSuccess($response);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function uploadResumableAction(): void
117 117
     {
118
-        $data   = $this->request->getPost();
118
+        $data = $this->request->getPost();
119 119
         $data['result'] = 'ERROR';
120 120
 
121 121
         if ($this->request->hasFiles() > 0) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 'resumableTotalSize'   => $this->request->getPost('resumableTotalSize'),
128 128
             ];
129 129
             foreach ($this->request->getUploadedFiles() as $file) {
130
-                $data['files'][]= [
130
+                $data['files'][] = [
131 131
                     'file_path' => $file->getTempName(),
132 132
                     'file_size' => $file->getSize(),
133 133
                     'file_error'=> $file->getError(),
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                     'file_type' => $file->getType()
136 136
                 ];
137 137
                 if ($file->getError()) {
138
-                    $data['data'] = 'error ' . $file->getError() . ' in file ' . $file->getTempName();
138
+                    $data['data'] = 'error '.$file->getError().' in file '.$file->getTempName();
139 139
                     $this->sendError(400, $data['data']);
140
-                    Util::sysLogMsg('UploadFile', 'error ' . $file->getError() . ' in file ' . $file->getTempName());
140
+                    Util::sysLogMsg('UploadFile', 'error '.$file->getError().' in file '.$file->getTempName());
141 141
                     return;
142 142
                 }
143 143
             }
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/FilesManagementProcessor.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
         }
90 90
         $parameters['uploadDir'] = $di->getShared('config')->path('www.uploadDir');
91 91
         $parameters['tempDir'] = "{$parameters['uploadDir']}/{$parameters['resumableIdentifier']}";
92
-        if ( ! Util::mwMkdir($parameters['tempDir'])) {
93
-            $res->messages[] = 'Temp dir does not exist ' . $parameters['tempDir'];
92
+        if (!Util::mwMkdir($parameters['tempDir'])) {
93
+            $res->messages[] = 'Temp dir does not exist '.$parameters['tempDir'];
94 94
             return $res;
95 95
         }
96 96
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 
100 100
         // Delete old progress and result file
101 101
         $oldMergeProgressFile = "{$parameters['tempDir']}/merging_progress";
102
-        if (file_exists($oldMergeProgressFile)){
102
+        if (file_exists($oldMergeProgressFile)) {
103 103
             unlink($oldMergeProgressFile);
104 104
         }
105
-        if (file_exists($parameters['fullUploadedFileName'])){
105
+        if (file_exists($parameters['fullUploadedFileName'])) {
106 106
             unlink($parameters['fullUploadedFileName']);
107 107
         }
108 108
 
109 109
         foreach ($parameters['files'] as $file_data) {
110
-            if (!self::moveUploadedPartToSeparateDir($parameters, $file_data)){
110
+            if (!self::moveUploadedPartToSeparateDir($parameters, $file_data)) {
111 111
                 $res->messages[] = 'Does not found any uploaded chunks on with path '.$file_data['file_path'];
112 112
                 return $res;
113 113
             }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     private static function moveUploadedPartToSeparateDir(array $parameters, array $file_data):bool
137 137
     {
138
-        if ( ! file_exists($file_data['file_path'])) {
138
+        if (!file_exists($file_data['file_path'])) {
139 139
             return false;
140 140
         }
141 141
         $factory          = new StreamFactory();
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             $file_data['file_type']
149 149
         );
150 150
         $chunks_dest_file = "{$parameters['tempDir']}/{$parameters['resumableFilename']}.part{$parameters['resumableChunkNumber']}";
151
-        if (file_exists($chunks_dest_file)){
151
+        if (file_exists($chunks_dest_file)) {
152 152
             $rm = Util::which('rm');
153 153
             Util::mwExec("{$rm} -f {$chunks_dest_file}");
154 154
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $totalFilesOnServerSize = 0;
169 169
         foreach (scandir($parameters['tempDir']) as $file) {
170
-            $totalFilesOnServerSize += filesize($parameters['tempDir'] . '/' . $file);
170
+            $totalFilesOnServerSize += filesize($parameters['tempDir'].'/'.$file);
171 171
         }
172 172
 
173 173
         if ($totalFilesOnServerSize >= $parameters['resumableTotalSize']) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                     'resumableTotalSize'   => $parameters['resumableTotalSize'],
180 180
                     'resumableTotalChunks' => $parameters['resumableTotalChunks'],
181 181
             ];
182
-            $settings_file  = "{$parameters['tempDir']}/merge_settings";
182
+            $settings_file = "{$parameters['tempDir']}/merge_settings";
183 183
             file_put_contents(
184 184
                 $settings_file,
185 185
                 json_encode($merge_settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
         $uploadDir = $di->getShared('config')->path('www.uploadDir');
215 215
 
216 216
         $upload_id     = $postData['id'] ?? null;
217
-        $progress_dir  = $uploadDir . '/' . $upload_id;
218
-        $progress_file = $progress_dir . '/merging_progress';
217
+        $progress_dir  = $uploadDir.'/'.$upload_id;
218
+        $progress_file = $progress_dir.'/merging_progress';
219 219
         if (empty($upload_id)) {
220 220
             $res->success                   = false;
221 221
             $res->data['d_status_progress'] = '0';
222 222
             $res->data['d_status']          = 'ID_NOT_SET';
223 223
             $res->messages[]                = 'Upload ID does not set';
224
-        } elseif ( ! file_exists($progress_file) && file_exists($progress_dir)) {
224
+        } elseif (!file_exists($progress_file) && file_exists($progress_dir)) {
225 225
             $res->success                   = true;
226 226
             $res->data['d_status_progress'] = '0';
227 227
             $res->data['d_status']          = 'INPROGRESS';
228
-        } elseif ( ! file_exists($progress_dir)) {
228
+        } elseif (!file_exists($progress_dir)) {
229 229
             $res->success                   = false;
230 230
             $res->data['d_status_progress'] = '0';
231 231
             $res->data['d_status']          = 'NOT_FOUND';
232
-            $res->messages[]                = 'Does not found anything with path: ' . $progress_dir;
232
+            $res->messages[]                = 'Does not found anything with path: '.$progress_dir;
233 233
         } elseif ('100' === file_get_contents($progress_file)) {
234 234
             $res->success                   = true;
235 235
             $res->data['d_status_progress'] = '100';
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
             $cat          = Util::which('cat');
266 266
             $di           = Di::getDefault();
267 267
             $dirsConfig   = $di->getShared('config');
268
-            $filenameTmp  = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.conf';
268
+            $filenameTmp  = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.conf';
269 269
             $cmd          = "{$cat} {$filename} > {$filenameTmp}";
270 270
             Util::mwExec("{$cmd}; chown www:www {$filenameTmp}");
271 271
             $res->data['filename'] = $filenameTmp;
272 272
         } else {
273 273
             $res->success    = false;
274
-            $res->messages[] = 'No access to the file ' . $filename;
274
+            $res->messages[] = 'No access to the file '.$filename;
275 275
         }
276 276
 
277 277
         return $res;
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
         }
295 295
         $rmPath = Util::which('rm');
296 296
         $module = 'NewFirmware';
297
-        if ( ! file_exists($tempDir . "/{$module}")) {
298
-            Util::mwMkdir($tempDir . "/{$module}");
297
+        if (!file_exists($tempDir."/{$module}")) {
298
+            Util::mwMkdir($tempDir."/{$module}");
299 299
         } else {
300 300
             // Чистим файлы, загруженные онлайн.
301 301
             Util::mwExec("{$rmPath} -rf {$tempDir}/{$module}/* ");
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 
316 316
         $workerDownloaderPath = Util::getFilePathByClassName(WorkerDownloader::class);
317 317
 
318
-        file_put_contents($tempDir . "/{$module}/progress", '0');
318
+        file_put_contents($tempDir."/{$module}/progress", '0');
319 319
         file_put_contents(
320
-            $tempDir . "/{$module}/download_settings.json",
320
+            $tempDir."/{$module}/download_settings.json",
321 321
             json_encode($download_settings, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
322 322
         );
323 323
         $phpPath = Util::which('php');
324
-        Util::mwExecBg("{$phpPath} -f {$workerDownloaderPath} " . $tempDir . "/{$module}/download_settings.json");
324
+        Util::mwExecBg("{$phpPath} -f {$workerDownloaderPath} ".$tempDir."/{$module}/download_settings.json");
325 325
 
326 326
         $res                   = new PBXApiResult();
327 327
         $res->processor        = __METHOD__;
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
         } else {
350 350
             $tempDir = '/tmp';
351 351
         }
352
-        $modulesDir    = $tempDir . '/NewFirmware';
353
-        $progress_file = $modulesDir . '/progress';
352
+        $modulesDir    = $tempDir.'/NewFirmware';
353
+        $progress_file = $modulesDir.'/progress';
354 354
 
355 355
         $error = '';
356
-        if (file_exists($modulesDir . '/error')) {
357
-            $error = trim(file_get_contents($modulesDir . '/error'));
356
+        if (file_exists($modulesDir.'/error')) {
357
+            $error = trim(file_get_contents($modulesDir.'/error'));
358 358
         }
359 359
 
360
-        if ( ! file_exists($progress_file)) {
360
+        if (!file_exists($progress_file)) {
361 361
             $res->data['d_status_progress'] = '0';
362 362
             $res->data['d_status']          = 'NOT_FOUND';
363 363
         } elseif ('' !== $error) {
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
             $res->data['filePath']          = "{$tempDir}/NewFirmware/update.img";
371 371
         } else {
372 372
             $res->data['d_status_progress'] = file_get_contents($progress_file);
373
-            $d_pid                          = Util::getPidOfProcess($tempDir . '/NewFirmware/download_settings.json');
373
+            $d_pid                          = Util::getPidOfProcess($tempDir.'/NewFirmware/download_settings.json');
374 374
             if (empty($d_pid)) {
375 375
                 $res->data['d_status'] = 'DOWNLOAD_ERROR';
376 376
                 $error                 = '';
377
-                if (file_exists($modulesDir . '/error')) {
378
-                    $error = file_get_contents($modulesDir . '/error');
377
+                if (file_exists($modulesDir.'/error')) {
378
+                    $error = file_get_contents($modulesDir.'/error');
379 379
                 }
380 380
                 $res->data['d_error'] = $error;
381 381
             } else {
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
         } else {
457 457
             $tempDir = '/tmp';
458 458
         }
459
-        $moduleDirTmp  = $tempDir . '/' . $moduleUniqueID;
460
-        $progress_file = $moduleDirTmp . '/progress';
459
+        $moduleDirTmp  = $tempDir.'/'.$moduleUniqueID;
460
+        $progress_file = $moduleDirTmp.'/progress';
461 461
         $error         = '';
462
-        if (file_exists($moduleDirTmp . '/error')) {
463
-            $error = trim(file_get_contents($moduleDirTmp . '/error'));
462
+        if (file_exists($moduleDirTmp.'/error')) {
463
+            $error = trim(file_get_contents($moduleDirTmp.'/error'));
464 464
         }
465 465
 
466 466
         // Ожидание запуска процесса загрузки.
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
             usleep(500000);
470 470
         }
471 471
 
472
-        if ( ! file_exists($progress_file)) {
472
+        if (!file_exists($progress_file)) {
473 473
             $res->data['d_status_progress'] = '0';
474 474
             $res->data['d_status']          = 'NOT_FOUND';
475 475
             $res->success                   = false;
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
             $res->success                   = true;
486 486
         } else {
487 487
             $res->data['d_status_progress'] = file_get_contents($progress_file);
488
-            $d_pid                          = Util::getPidOfProcess($moduleDirTmp . '/download_settings.json');
488
+            $d_pid                          = Util::getPidOfProcess($moduleDirTmp.'/download_settings.json');
489 489
             if (empty($d_pid)) {
490 490
                 $res->data['d_status'] = 'DOWNLOAD_ERROR';
491
-                if (file_exists($moduleDirTmp . '/error')) {
492
-                    $res->messages[] = file_get_contents($moduleDirTmp . '/error');
491
+                if (file_exists($moduleDirTmp.'/error')) {
492
+                    $res->messages[] = file_get_contents($moduleDirTmp.'/error');
493 493
                 } else {
494
-                    $res->messages[]                 = "Download process interrupted at {$res->data['d_status_progress']}%";
494
+                    $res->messages[] = "Download process interrupted at {$res->data['d_status_progress']}%";
495 495
                 }
496
-                $res->success    = false;
496
+                $res->success = false;
497 497
             } else {
498 498
                 $res->data['d_status'] = 'DOWNLOAD_IN_PROGRESS';
499 499
                 $res->success          = true;
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
         $res            = new PBXApiResult();
516 516
         $res->processor = __METHOD__;
517 517
         $extension      = Util::getExtensionOfFile($filePath);
518
-        if ( ! in_array($extension, ['mp3', 'wav', 'alaw'])) {
518
+        if (!in_array($extension, ['mp3', 'wav', 'alaw'])) {
519 519
             $res->success    = false;
520 520
             $res->messages[] = "It is forbidden to remove the file type $extension.";
521 521
 
522 522
             return $res;
523 523
         }
524 524
 
525
-        if ( ! file_exists($filePath)) {
525
+        if (!file_exists($filePath)) {
526 526
             $res->success         = true;
527 527
             $res->data['message'] = "File '{$filePath}' already deleted";
528 528
 
@@ -532,13 +532,13 @@  discard block
 block discarded – undo
532 532
         $out = [];
533 533
 
534 534
         $arrDeletedFiles = [
535
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".wav"),
536
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".mp3"),
537
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".alaw"),
535
+            escapeshellarg(Util::trimExtensionForFile($filePath).".wav"),
536
+            escapeshellarg(Util::trimExtensionForFile($filePath).".mp3"),
537
+            escapeshellarg(Util::trimExtensionForFile($filePath).".alaw"),
538 538
         ];
539 539
 
540 540
         $rmPath = Util::which('rm');
541
-        Util::mwExec("{$rmPath} -rf " . implode(' ', $arrDeletedFiles), $out);
541
+        Util::mwExec("{$rmPath} -rf ".implode(' ', $arrDeletedFiles), $out);
542 542
         if (file_exists($filePath)) {
543 543
             $res->success  = false;
544 544
             $res->messages = $out;
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
             $grepPath    = Util::which('grep');
568 568
             $echoPath    = Util::which('echo');
569 569
             $awkPath     = Util::which('awk');
570
-            $cmd         = 'f="' . $filePath . '"; p=`' . $sevenZaPath . ' l $f | ' . $grepPath . ' module.json`;if [ "$?" == "0" ]; then ' . $sevenZaPath . ' -so e -y -r $f `' . $echoPath . ' $p |  ' . $awkPath . ' -F" " \'{print $6}\'`; fi';
570
+            $cmd         = 'f="'.$filePath.'"; p=`'.$sevenZaPath.' l $f | '.$grepPath.' module.json`;if [ "$?" == "0" ]; then '.$sevenZaPath.' -so e -y -r $f `'.$echoPath.' $p |  '.$awkPath.' -F" " \'{print $6}\'`; fi';
571 571
 
572 572
             Util::mwExec($cmd, $out);
573 573
             $settings = json_decode(implode("\n", $out), true);
574 574
 
575 575
             $moduleUniqueID = $settings['moduleUniqueID'] ?? null;
576
-            if ( ! $moduleUniqueID) {
576
+            if (!$moduleUniqueID) {
577 577
                 $res->messages[] = 'The" moduleUniqueID " in the module file is not described.the json or file does not exist.';
578 578
 
579 579
                 return $res;
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/SysLogsManagementProcessor.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -76,35 +76,35 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $res            = new PBXApiResult();
78 78
         $res->processor = __METHOD__;
79
-        $filename       = System::getLogDir() . '/' . $filename;
80
-        if ( ! file_exists($filename)) {
79
+        $filename       = System::getLogDir().'/'.$filename;
80
+        if (!file_exists($filename)) {
81 81
             $res->success    = false;
82
-            $res->messages[] = 'No access to the file ' . $filename;
82
+            $res->messages[] = 'No access to the file '.$filename;
83 83
         } else {
84 84
             $res->success = true;
85 85
             $head         = Util::which('head');
86 86
             $grep         = Util::which('grep');
87 87
             $tail         = Util::which('tail');
88 88
             $filter       = escapeshellarg($filter);
89
-            $offset       = (int)$offset;
90
-            $lines        = (int)$lines;
91
-            $linesPlusOffset = $lines+$offset;
89
+            $offset       = (int) $offset;
90
+            $lines        = (int) $lines;
91
+            $linesPlusOffset = $lines + $offset;
92 92
 
93 93
             $di          = Di::getDefault();
94 94
             $dirsConfig  = $di->getShared('config');
95
-            $filenameTmp = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.log';
96
-            if (empty($filter)){
95
+            $filenameTmp = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.log';
96
+            if (empty($filter)) {
97 97
                 $cmd         = "{$tail} -n {$linesPlusOffset} {$filename}";
98 98
             } else {
99 99
                 $cmd         = "{$grep} -F {$filter} {$filename} | $tail -n {$linesPlusOffset}";
100 100
             }
101
-            if ($offset>0){
101
+            if ($offset > 0) {
102 102
                 $cmd .= " | {$head} -n {$lines}";
103 103
             }
104 104
             $cmd .= " > $filenameTmp";
105 105
 
106 106
             Util::mwExec("$cmd; chown www:www $filenameTmp");
107
-            $res->data['cmd']=$cmd;
107
+            $res->data['cmd'] = $cmd;
108 108
             $res->data['filename'] = $filenameTmp;
109 109
         }
110 110
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         $systemInfoFile = "{$logDir}/system-information.log";
163 163
         file_put_contents($systemInfoFile, SysinfoManagementProcessor::prepareSysyinfoContent());
164 164
 
165
-        $futureFileName        = $temp_dir . '/temp-all-log-' . time() . '.zip';
165
+        $futureFileName        = $temp_dir.'/temp-all-log-'.time().'.zip';
166 166
         $res->data['filename'] = $futureFileName;
167 167
         $res->success          = true;
168 168
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $res->processor = __METHOD__;
199 199
 
200 200
         $progress_file = "{$resultFile}.progress";
201
-        if ( ! file_exists($progress_file)) {
201
+        if (!file_exists($progress_file)) {
202 202
             $res->messages[] = 'Archive does not exist. Try again!';
203 203
         } elseif (file_exists($progress_file) && file_get_contents($progress_file) === '100') {
204 204
             $uid          = Util::generateRandomString(36);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             $downloadLink = $di->getShared('config')->path('www.downloadCacheDir');
207 207
             $result_dir   = "{$downloadLink}/{$uid}";
208 208
             Util::mwMkdir($result_dir);
209
-            $link_name = 'MikoPBXLogs_' . basename($resultFile);
209
+            $link_name = 'MikoPBXLogs_'.basename($resultFile);
210 210
             Util::createUpdateSymlink($resultFile, "{$result_dir}/{$link_name}");
211 211
             Util::addRegularWWWRights("{$result_dir}/{$link_name}");
212 212
             $res->success          = true;
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
     {
233 233
         $res            = new PBXApiResult();
234 234
         $res->processor = __METHOD__;
235
-        $filename       = System::getLogDir() . '/' . $filename;
236
-        if ( ! file_exists($filename)) {
235
+        $filename       = System::getLogDir().'/'.$filename;
236
+        if (!file_exists($filename)) {
237 237
             $res->success    = false;
238
-            $res->messages[] = 'File does not exist ' . $filename;
238
+            $res->messages[] = 'File does not exist '.$filename;
239 239
         } else {
240 240
             $uid          = Util::generateRandomString(36);
241 241
             $di           = Di::getDefault();
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
                 continue;
277 277
             }
278 278
 
279
-            $relativePath             = str_ireplace($logDir . '/', '', $entry);
279
+            $relativePath             = str_ireplace($logDir.'/', '', $entry);
280 280
             $fileSizeKB               = ceil($fileSize / 1024);
281 281
             $filesList[$relativePath] =
282 282
                 [
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
                 continue;
314 314
             }
315 315
             //if current file ($d) is a directory, call scanDirRecursively
316
-            if (is_dir($dir . '/' . $d)) {
317
-                $list[] = self::scanDirRecursively($dir . '/' . $d);
316
+            if (is_dir($dir.'/'.$d)) {
317
+                $list[] = self::scanDirRecursively($dir.'/'.$d);
318 318
                 //otherwise, add the file to the list
319
-            } elseif (is_file($dir . '/' . $d) || is_link($dir . '/' . $d)) {
320
-                $list[] = $dir . '/' . $d;
319
+            } elseif (is_file($dir.'/'.$d) || is_link($dir.'/'.$d)) {
320
+                $list[] = $dir.'/'.$d;
321 321
             }
322 322
         }
323 323
 
Please login to merge, or discard this patch.
src/PBXCoreREST/Workers/WorkerDownloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
         ini_set('memory_limit', '300M');
42 42
 
43 43
         $temp_dir            = dirname($this->settings['res_file']);
44
-        $this->progress_file = $temp_dir . '/progress';
45
-        $this->error_file    = $temp_dir . '/error';
44
+        $this->progress_file = $temp_dir.'/progress';
45
+        $this->error_file    = $temp_dir.'/error';
46 46
         Util::mwMkdir($temp_dir);
47 47
 
48 48
         if ($this->getFile()) {
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function action(): void
121 121
     {
122
-        if (empty($this->settings) || ! isset($this->settings['action'])) {
122
+        if (empty($this->settings) || !isset($this->settings['action'])) {
123 123
             return;
124 124
         }
125
-        if ( ! file_exists($this->settings['res_file'])) {
125
+        if (!file_exists($this->settings['res_file'])) {
126 126
             file_put_contents($this->error_file, 'File does not uploaded', FILE_APPEND);
127 127
 
128 128
             return;
129 129
         }
130
-        if ( ! file_exists($this->settings['res_file'])
130
+        if (!file_exists($this->settings['res_file'])
131 131
             || md5_file($this->settings['res_file']) !== $this->settings['md5'])
132 132
         {
133 133
             if (file_exists($this->settings['res_file'])) {
Please login to merge, or discard this patch.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer20202754.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             'slin'  => 'Signed Linear PCM',
82 82
             'opus'  => 'Opus',
83 83
         ];
84
-        $codecs      = Codecs::find();
84
+        $codecs = Codecs::find();
85 85
         // Удалим лишние кодеки
86 86
         /** @var Codecs $codec */
87 87
         foreach ($codecs as $codec) {
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
                 $this->checkDisabledCodec($codec);
90 90
                 continue;
91 91
             }
92
-            if ( ! $codec->delete()) {
92
+            if (!$codec->delete()) {
93 93
                 Util::sysLogMsg(
94 94
                     __CLASS__,
95
-                    'Can not delete codec ' . $codec->name . ' from MikoPBX\Common\Models\Codecs'
95
+                    'Can not delete codec '.$codec->name.' from MikoPBX\Common\Models\Codecs'
96 96
                 );
97 97
             }
98 98
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private function checkDisabledCodec(Codecs $codec): void
109 109
     {
110
-        if ( ! in_array($codec->disabled, ['0', '1'], true)) {
110
+        if (!in_array($codec->disabled, ['0', '1'], true)) {
111 111
             $codec->disabled = '0';
112 112
             $codec->save();
113 113
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     private function addNewCodecs(array $availCodecs): void
122 122
     {
123 123
         foreach ($availCodecs as $availCodec => $desc) {
124
-            $codecData = Codecs::findFirst('name="' . $availCodec . '"');
124
+            $codecData = Codecs::findFirst('name="'.$availCodec.'"');
125 125
             if ($codecData === null) {
126 126
                 $codecData = new Codecs();
127 127
             } elseif ($codecData->description === $desc) {
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
             }
137 137
             $codecData->type        = $type;
138 138
             $codecData->description = $desc;
139
-            if ( ! $codecData->save()) {
139
+            if (!$codecData->save()) {
140 140
                 Util::sysLogMsg(
141 141
                     __CLASS__,
142
-                    'Can not update codec info ' . $codecData->name . ' from \MikoPBX\Common\Models\Codecs'
142
+                    'Can not update codec info '.$codecData->name.' from \MikoPBX\Common\Models\Codecs'
143 143
                 );
144 144
             }
145 145
         }
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
         $astDbPath = $this->config->path('astDatabase.dbfile');
192 192
         if (file_exists($astDbPath)) {
193 193
             $table = 'astdb';
194
-            $sql   = 'DELETE FROM ' . $table . ' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"';
194
+            $sql   = 'DELETE FROM '.$table.' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"';
195 195
             $db    = new \SQLite3($astDbPath);
196 196
             try {
197 197
                 $db->exec($sql);
198 198
             } catch (\Error $e) {
199
-                Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...' . $e->getMessage());
199
+                Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...'.$e->getMessage());
200 200
                 sleep(2);
201 201
             }
202 202
             $db->close();
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function copyMohFilesToStorage(): void
211 211
     {
212
-        $oldMohDir = $this->config->path('asterisk.astvarlibdir') . '/sounds/moh';
213
-        if ( ! file_exists($oldMohDir)) {
212
+        $oldMohDir = $this->config->path('asterisk.astvarlibdir').'/sounds/moh';
213
+        if (!file_exists($oldMohDir)) {
214 214
             return;
215 215
         }
216 216
         $currentMohDir = $this->config->path('asterisk.mohdir');
217
-        if ( ! Util::mwMkdir($currentMohDir)) {
217
+        if (!Util::mwMkdir($currentMohDir)) {
218 218
             return;
219 219
         }
220 220
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
             if (in_array($file, ['.', '..'])) {
224 224
                 continue;
225 225
             }
226
-            if (copy($oldMohDir . '/' . $file, $currentMohDir . '/' . $file)) {
226
+            if (copy($oldMohDir.'/'.$file, $currentMohDir.'/'.$file)) {
227 227
                 $sound_file           = new SoundFiles();
228
-                $sound_file->path     = $currentMohDir . '/' . $file;
228
+                $sound_file->path     = $currentMohDir.'/'.$file;
229 229
                 $sound_file->category = SoundFiles::CATEGORY_MOH;
230 230
                 $sound_file->name     = $file;
231 231
                 $sound_file->save();
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             Extensions::TYPE_CONFERENCE,
290 290
 
291 291
         ];
292
-        $extensions           = Extensions::find();
292
+        $extensions = Extensions::find();
293 293
         foreach ($extensions as $extension) {
294 294
             if (in_array($extension->type, $showInPhonebookTypes)) {
295 295
                 $extension->show_in_phonebook = '1';
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
      */
305 305
     private function moveReadOnlySoundsToStorage(): void
306 306
     {
307
-        $currentMediaDir = $this->config->path('asterisk.customSoundDir') . '/';
308
-        if ( ! is_dir($currentMediaDir)) {
307
+        $currentMediaDir = $this->config->path('asterisk.customSoundDir').'/';
308
+        if (!is_dir($currentMediaDir)) {
309 309
             Util::mwMkdir($currentMediaDir);
310 310
         }
311 311
         $soundFiles = SoundFiles::find();
312 312
         foreach ($soundFiles as $soundFile) {
313 313
             if (stripos($soundFile->path, '/offload/asterisk/sounds/other/') === 0) {
314
-                $newPath = $currentMediaDir . pathinfo($soundFile->path)['basename'];
314
+                $newPath = $currentMediaDir.pathinfo($soundFile->path)['basename'];
315 315
                 if (copy($soundFile->path, $newPath)) {
316 316
                     $soundFile->path = $newPath;
317 317
                     $soundFile->update();
Please login to merge, or discard this patch.
src/Core/System/Notifications.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                 $from_name = $settings['MailSMTPFromUsername'];
78 78
             }
79 79
 
80
-            $mail->Port    = (integer)$settings['MailSMTPPort'];
80
+            $mail->Port    = (integer) $settings['MailSMTPPort'];
81 81
             $mail->CharSet = 'UTF-8';
82 82
 
83 83
             $mail->setFrom($from_address, $from_name);
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
             $mail->Subject = $subject;
90 90
             $mail->Body    = $message;
91 91
 
92
-            if ( ! $mail->send()) {
92
+            if (!$mail->send()) {
93 93
                 $messages[] = $mail->ErrorInfo;
94 94
             }
95 95
         } catch (\Exception $e) {
96 96
             $messages[] = $e->getMessage();
97 97
         }
98 98
 
99
-        if (count($messages)>0) {
99
+        if (count($messages) > 0) {
100 100
             Util::sysLogMsg('PHPMailer', implode(' ', $messages), LOG_ERR);
101 101
             return false;
102 102
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $settings             = $mikoPBXConfig->getGeneralSettings();
109 109
         $systemNotificationsEmail = $settings['SystemNotificationsEmail'];
110 110
         $result = self::sendMail($systemNotificationsEmail, 'Test mail from MIKO PBX', '<b>Test message</b><hr>');
111
-        return ($result===true);
111
+        return ($result === true);
112 112
     }
113 113
 
114 114
     /**
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
         $mikoPBXConfig = new MikoPBXConfig();
122 122
         $settings      = $mikoPBXConfig->getGeneralSettings();
123 123
 
124
-        $conf = "defaults\n" .
125
-            "auth       on\n" .
124
+        $conf = "defaults\n".
125
+            "auth       on\n".
126 126
             // "logfile    /var/log/msmtp.log\n".
127
-            "timeout    10\n" .
127
+            "timeout    10\n".
128 128
             "syslog     LOG_LOCAL0\n\n";
129 129
 
130 130
         if (isset($settings["MailSMTPUseTLS"]) && $settings["MailSMTPUseTLS"] == "1") {
Please login to merge, or discard this patch.
src/Core/Workers/WorkerNotifyByEmail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 class WorkerNotifyByEmail extends WorkerBase
16 16
 {
17
-    protected int $maxProc=1;
17
+    protected int $maxProc = 1;
18 18
     /**
19 19
      * Entry point
20 20
      *
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $tmpArray = [];
51 51
         foreach ($data as $call) {
52 52
             $keyHash = $call['email'].$call['start'].$call['from_number'].$call['to_number'];
53
-            if(in_array($keyHash, $tmpArray, true)){
53
+            if (in_array($keyHash, $tmpArray, true)) {
54 54
                 continue;
55 55
             }
56 56
             $tmpArray[] = $keyHash;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
              * 'language'
59 59
              * 'is_internal'
60 60
              */
61
-            if ( ! isset($emails[$call['email']])) {
61
+            if (!isset($emails[$call['email']])) {
62 62
                 $emails[$call['email']] = '';
63 63
             }
64 64
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 // Start worker process
98 98
 $workerClassname = WorkerNotifyByEmail::class;
99
-$action = $argv[1]??'';
99
+$action = $argv[1] ?? '';
100 100
 if ($action === 'start') {
101 101
     cli_set_process_title($workerClassname);
102 102
     while (true) {
Please login to merge, or discard this patch.