Passed
Pull Request — master (#23)
by Nikolay
09:42 queued 03:08
created
src/Core/Workers/WorkerBase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             file_put_contents($this->getPidFile(), $activeProcesses);
48 48
         } else {
49 49
             $pidFilesDir = dirname($this->getPidFile());
50
-            $pidFile     = $pidFilesDir . '/' . pathinfo($this->getPidFile(), PATHINFO_BASENAME);
50
+            $pidFile     = $pidFilesDir.'/'.pathinfo($this->getPidFile(), PATHINFO_BASENAME);
51 51
             // Delete old PID files
52 52
             $rm = Util::which('rm');
53 53
             Processes::mwExec("{$rm} -rf {$pidFile}*");
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function pingCallBack(BeanstalkClient $message): void
87 87
     {
88
-        $message->reply(json_encode($message->getBody() . ':pong'));
88
+        $message->reply(json_encode($message->getBody().':pong'));
89 89
     }
90 90
 
91 91
     /**
Please login to merge, or discard this patch.
src/Core/System/Processes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     {
28 28
         $killallPath = Util::which('killall');
29 29
 
30
-        return self::mwExec($killallPath . ' ' . escapeshellarg($procName));
30
+        return self::mwExec($killallPath.' '.escapeshellarg($procName));
31 31
     }
32 32
 
33 33
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         }
136 136
         $currentProcCount = count($processes);
137 137
 
138
-        if ( ! class_exists($className)) {
138
+        if (!class_exists($className)) {
139 139
             return;
140 140
         }
141 141
         $workerObject    = new $className();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     $countProc4Kill = $neededProcCount - $currentProcCount;
178 178
                     // Send SIGUSR1 command to them
179 179
                     while ($countProc4Kill >= 0) {
180
-                        if ( ! isset($processes[$countProc4Kill])) {
180
+                        if (!isset($processes[$countProc4Kill])) {
181 181
                             break;
182 182
                         }
183 183
                         // Kill old processes with timeout, maybe it is soft restart and worker die without any help
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 
208 208
         $name       = addslashes($name);
209 209
         $filter_cmd = '';
210
-        if ( ! empty($exclude)) {
211
-            $filter_cmd = "| $path_grep -v " . escapeshellarg($exclude);
210
+        if (!empty($exclude)) {
211
+            $filter_cmd = "| $path_grep -v ".escapeshellarg($exclude);
212 212
         }
213 213
         $out = [];
214 214
         self::mwExec(
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $rmPath    = Util::which('rm');
234 234
         $sleepPath = Util::which('sleep');
235 235
         if ($sleep_time > 0) {
236
-            $filename = '/tmp/' . time() . '_noop.sh';
236
+            $filename = '/tmp/'.time().'_noop.sh';
237 237
             file_put_contents($filename, "{$sleepPath} {$sleep_time}; {$command}; {$rmPath} -rf {$filename}");
238 238
             $noop_command = "{$nohupPath} {$shPath} {$filename} > {$out_file} 2>&1 &";
239 239
         } else {
Please login to merge, or discard this patch.
src/Core/Asterisk/agi-bin/cdr_connector.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
     $orign_chan     = $agi->get_variable("orign_chan", true);
33 33
     $id             = $agi->get_variable("pt1c_UNIQUEID", true);
34 34
     $IS_ORGNT       = $agi->get_variable("IS_ORGNT", true);
35
-    if ($id == '' || ! empty($QUEUE_SRC_CHAN)) {
35
+    if ($id == '' || !empty($QUEUE_SRC_CHAN)) {
36 36
         // Если это вызов на агента очереди !empty($QUEUE_SRC_CHAN).
37 37
         // Если это новый вызов $id == ''.
38
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
38
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
39 39
     }
40 40
     // Канал, AGI скрипта.
41 41
     $channel  = $agi->request['agi_channel'];
42
-    $is_local = ! (stripos($channel, 'local/') === false);
42
+    $is_local = !(stripos($channel, 'local/') === false);
43 43
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
44 44
         // Это LOCAL, Переопределим на исходный.
45 45
         $channel = $QUEUE_SRC_CHAN;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     $data['action'] = "$action";
57
-    if ( ! empty($IS_ORGNT)) {
57
+    if (!empty($IS_ORGNT)) {
58 58
         $dst_num            = $agi->request['agi_callerid'];
59 59
         $src_num            = $agi->request['agi_extension'];
60 60
         $data['dialstatus'] = 'ORIGINATE';
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $num     = substr($agi->request['agi_channel'], $p_start, $p_end);
66 66
 
67 67
         $p_start  = strpos($agi->request['agi_channel'], ';');
68
-        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start) . ';1';
68
+        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start).';1';
69 69
 
70
-        $id               = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $num . '_' . $IS_ORGNT;
70
+        $id               = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$num.'_'.$IS_ORGNT;
71 71
         $data['dst_chan'] = $dst_chan;
72 72
     } else {
73 73
         $src_num = $agi->request['agi_callerid'];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     $data['agi_channel']  = $agi->request['agi_channel'];
85 85
     $data['did']          = $agi->get_variable("FROM_DID", true);
86 86
     $data['from_account'] = $from_account;
87
-    $data['IS_ORGNT']     = ! empty($IS_ORGNT);
87
+    $data['IS_ORGNT']     = !empty($IS_ORGNT);
88 88
 
89 89
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
90 90
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
118
-    if ( ! empty($IS_ORGNT)) {
118
+    if (!empty($IS_ORGNT)) {
119 119
         // Вероятно необходимо переопределить искать по двум ID.
120 120
         // Применимо только для Originate, когда в качестве звонящего используем два канала
121 121
         // мобильный и внутренний номер.
122 122
         $peer_mobile = $agi->get_variable("peer_mobile", true);
123
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
123
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
125 125
             $data['org_id'] = $id;
126 126
         }
127 127
     }
@@ -154,22 +154,22 @@  discard block
 block discarded – undo
154 154
     $data['BRIDGEPEER']      = $agi->get_variable("FROM_CHAN", true);
155 155
 
156 156
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
157
-    if ( ! empty($IS_ORGNT)) {
157
+    if (!empty($IS_ORGNT)) {
158 158
         // Вероятно необходимо переопределить ID.
159 159
         // Применимо только для Originate, когда в качестве звонящего используем два канала
160 160
         // мобильный и внутренний номер.
161 161
         $peer_mobile = $agi->get_variable("peer_mobile", true);
162
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
162
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
164 164
             $data['org_id'] = $id;
165 165
         }
166 166
     }
167 167
 
168
-    if ( ! empty($data['ENDCALLONANSWER'])) {
168
+    if (!empty($data['ENDCALLONANSWER'])) {
169 169
         $agi->set_variable("__ENDCALLONANSWER", "");
170 170
     }
171 171
 
172
-    $PICKUPEER     = trim('' . $agi->get_variable("PICKUPEER", true));
172
+    $PICKUPEER     = trim(''.$agi->get_variable("PICKUPEER", true));
173 173
     $data['dnid']  = $agi->request['agi_dnid'];
174 174
     $mikoPBXConfig = new MikoPBXConfig();
175 175
     $pickupexten   = $mikoPBXConfig->getGeneralSettings('PBXFeaturePickupExten');
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         // Очищаем переменную канала. Больше не требуется.
185 185
         $agi->set_variable("PICKUPEER", "");
186 186
         $data['old_id'] = $id;
187
-        $data['id']     = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
187
+        $data['id']     = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
188 188
     }
189 189
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
190 190
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $data['linkedid']    = $agi->get_variable("CHANNEL(linkedid)", true);
212 212
     $data['did']         = $agi->get_variable("FROM_DID", true);
213 213
 
214
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
214
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
215 215
 
216 216
     return $data;
217 217
 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 function Event_transfer_dial($agi, $action)
228 228
 {
229 229
     $now = Util::getNowDate();
230
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
230
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
231 231
 
232 232
     // Пытаемся определить канал.
233 233
     $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true);
234 234
     $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true);
235
-    $is_local       = ! (stripos($TRANSFERERNAME, 'local/') === false);
235
+    $is_local       = !(stripos($TRANSFERERNAME, 'local/') === false);
236 236
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
237 237
         // Это LOCAL, Переопределим на исходный.
238 238
         $channel = $QUEUE_SRC_CHAN;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     $data                = [];
249 249
     $data['action']      = "$action";
250
-    $data['agi_channel'] = $channel;// $agi->request['agi_channel'];
250
+    $data['agi_channel'] = $channel; // $agi->request['agi_channel'];
251 251
     $data['linkedid']    = $agi->get_variable("CHANNEL(linkedid)", true);
252 252
     $data['src_chan']    = $channel;
253 253
     $data['did']         = $agi->get_variable("FROM_DID", true);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     $data['did']          = $agi->get_variable("FROM_DID", true);
322 322
     $data['action']       = "$action";
323 323
     $data['agi_channel']  = $agi->request['agi_channel'];
324
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
324
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
325 325
 
326 326
     $pos = stripos($data['agi_channel'], 'local/');
327 327
     if ($pos === false) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     $data                 = [];
351 351
     $data['action']       = "$action";
352 352
     $data['did']          = $agi->get_variable("FROM_DID", true);
353
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
353
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
354 354
 
355 355
     $data['linkedid']   = $agi->get_variable("CHANNEL(linkedid)", true);
356 356
     $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true);
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']);
386 386
 
387 387
     // Сбор данных для генерации CDR.
388
-    $id      = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
388
+    $id      = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
389 389
     $channel = $agi->request['agi_channel'];
390 390
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
391 391
     $data                 = [];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
         $data['src_chan'] = $channel;
404 404
         $data['src_num']  = $agi->request['agi_callerid'];
405 405
         $data['dst_num']  = $agi->request['agi_extension'];
406
-        $data['dst_chan'] = 'Park:' . $agi->request['agi_extension'];
406
+        $data['dst_chan'] = 'Park:'.$agi->request['agi_extension'];
407 407
     } elseif (true === $park_row['pt1c_is_dst']) {
408 408
         $data['src_chan'] = $channel;
409 409
         $data['dst_chan'] = $park_row['ParkeeChannel'];
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
     if (trim($park_row['ParkingDuration']) !== '') {
420 420
         $time_start           = date("Y-m-d H:i:s", time() - 1 * ($park_row['ParkingDuration']));
421 421
         $data_parking         = [
422
-            'UNIQUEID' => $id . '_' . Util::generateRandomString(3),
422
+            'UNIQUEID' => $id.'_'.Util::generateRandomString(3),
423 423
             'src_chan' => $park_row['ParkeeChannel'],
424 424
             'src_num'  => $park_row['ParkeeCallerIDNum'],
425 425
             'dst_num'  => $park_row['ParkingSpace'],
426
-            'dst_chan' => 'Park:' . $park_row['ParkingSpace'],
426
+            'dst_chan' => 'Park:'.$park_row['ParkingSpace'],
427 427
             'start'    => $time_start,
428 428
             'answer'   => $time_start,
429 429
             'endtime'  => $now,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 function Event_unpark_call_timeout($agi, $action)
449 449
 {
450 450
     $now = Util::getNowDate();
451
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
451
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
452 452
     // PARKER=SIP/206
453 453
     $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true);
454 454
     $PARKING_DURATION = ($PARKING_DURATION == '') ? 45 : $PARKING_DURATION;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ???
461 461
         'src_num'  => $agi->request['agi_callerid'],
462 462
         'dst_num'  => $PARKING_SPACE,
463
-        'dst_chan' => 'Park:' . $PARKING_SPACE,
463
+        'dst_chan' => 'Park:'.$PARKING_SPACE,
464 464
         'start'    => $time_start,
465 465
         'answer'   => $time_start,
466 466
         'endtime'  => $now,
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     ];
473 473
 
474 474
 
475
-    $id2 = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
475
+    $id2 = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
476 476
     $agi->set_variable("__pt1c_UNIQUEID", "$id2");
477 477
 
478 478
     return $data;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     $id         = $agi->get_variable("pt1c_UNIQUEID", true);
494 494
     $ISTRANSFER = $agi->get_variable("ISTRANSFER", true);
495 495
 
496
-    if (empty($id) || ! empty($ISTRANSFER)) {
497
-        $id         = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
496
+    if (empty($id) || !empty($ISTRANSFER)) {
497
+        $id         = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
498 498
         $time_start = $now;
499 499
     }
500 500
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         // 'src_chan' => $agi->request['agi_channel'],
504 504
         // 'src_num'  => $agi->request['agi_callerid'],
505 505
         'dst_num'  => $agi->request['agi_extension'],
506
-        'dst_chan' => 'Queue:' . $agi->request['agi_extension'],
506
+        'dst_chan' => 'Queue:'.$agi->request['agi_extension'],
507 507
         // 'answer'   => $time_start,
508 508
         // 'end'  	   => $now,
509 509
         'did'      => $agi->get_variable("FROM_DID", true),
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         'UNIQUEID' => $id,
512 512
         'linkedid' => $agi->get_variable("CHANNEL(linkedid)", true),
513 513
     ];
514
-    if ( ! empty($time_start)) {
514
+    if (!empty($time_start)) {
515 515
         $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true);
516 516
         $data['src_num']  = $agi->request['agi_callerid'];
517 517
         $data['start']    = $time_start;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         $data['transfer'] = '0';
520 520
         $agi->set_variable("__pt1c_q_UNIQUEID", "$id");
521 521
     }
522
-    if ( ! empty($ISTRANSFER)) {
522
+    if (!empty($ISTRANSFER)) {
523 523
         $data['transfer'] = '1';
524 524
     } else {
525 525
         $data['transfer'] = '0';
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
     $is_conf   = ($agi->get_variable('CALLERID(num)', true) === 'Conference_Room');
592 592
     $not_local = (stripos($agi->request['agi_channel'], 'local/') === false);
593
-    if ($not_local && ! $is_conf) {
593
+    if ($not_local && !$is_conf) {
594 594
         $am         = Util::getAstManager();
595 595
         $res        = $am->meetMeCollectInfo($exten, ['conf_1c']);
596 596
         $callid     = $agi->request['agi_callerid'];
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     if (empty($id)) {
631
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
631
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
632 632
     }
633 633
 
634 634
     $recordingfile = CdrDb::MeetMeSetRecFilename($id);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         'src_chan'      => $agi->request['agi_channel'],
638 638
         'src_num'       => $src_num,
639 639
         'dst_num'       => $dst_num,
640
-        'dst_chan'      => 'MeetMe:' . $mikoidconf,
640
+        'dst_chan'      => 'MeetMe:'.$mikoidconf,
641 641
         'start'         => $time_start,
642 642
         'answer'        => $time_start,
643 643
         'recordingfile' => "{$recordingfile}.mp3",
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     $lamePath = Util::which('lame');
680 680
     $nicePath = Util::which('nice');
681 681
     $chmodPath = Util::which('chmod');
682
-    $command               = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
682
+    $command = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
683 683
     Processes::mwExecBg($command);
684 684
 
685 685
     return $data;
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function Event_dial_app($agi, $action)
697 697
 {
698
-    $id        = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
698
+    $id        = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
699 699
     $extension = $agi->get_variable("APPEXTEN", true);
700 700
     if (empty($extension)) {
701 701
         $extension = $agi->request['agi_extension'];
702 702
     }
703 703
 
704 704
     $data             = Event_dial($agi, $action);
705
-    $data['dst_chan'] = 'App:' . $extension;
705
+    $data['dst_chan'] = 'App:'.$extension;
706 706
     $data['dst_num']  = $extension;
707 707
     $data['is_app']   = 1;
708 708
     $data['UNIQUEID'] = $id;
@@ -743,5 +743,5 @@  discard block
 block discarded – undo
743 743
     $result = $func_name($agi, $action);
744 744
     // Оповещение без задержек.
745 745
     $data = base64_encode(json_encode($result));
746
-    $agi->exec("UserEvent", "CdrConnector,AgiData:" . base64_encode(json_encode($result)));
746
+    $agi->exec("UserEvent", "CdrConnector,AgiData:".base64_encode(json_encode($result)));
747 747
 }
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/SIPConf.php 2 patches
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
         $conf .= $this->generateProvidersPj();
56 56
         $conf .= $this->generatePeersPj();
57 57
 
58
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
58
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
59 59
         $pjConf = '[log_mappings]'."\n".
60 60
             'type=log_mappings'."\n".
61 61
             'asterisk_error = 0'."\n".
62 62
             'asterisk_warning = 2'."\n".
63 63
             'asterisk_debug = 1,3,4,5,6'."\n\n";
64 64
 
65
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf);
66
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
65
+        file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf);
66
+        file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
67 67
 
68 68
         $db = new AstDB();
69 69
         foreach ($this->data_peers as $peer) {
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function generateGeneralPj(): string
86 86
     {
87
-        $lang    = $this->generalSettings['PBXLanguage'];
87
+        $lang = $this->generalSettings['PBXLanguage'];
88 88
         [$topology, $extipaddr, $exthostname, $subnets] = $this->getTopologyData();
89 89
 
90 90
         $codecs = $this->getCodecs();
91 91
         $codecConf = '';
92
-        foreach ($codecs as $codec){
93
-            $codecConf.= "allow = {$codec}\n";
92
+        foreach ($codecs as $codec) {
93
+            $codecConf .= "allow = {$codec}\n";
94 94
         }
95 95
 
96 96
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
             foreach ($subnets as $net) {
100 100
                 $natConf .= "local_net={$net}\n";
101 101
             }
102
-            if ( ! empty($exthostname)) {
102
+            if (!empty($exthostname)) {
103 103
                 $parts = explode(':', $exthostname);
104
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
105
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
106
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
107
-            } elseif ( ! empty($extipaddr)) {
104
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
105
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
106
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
107
+            } elseif (!empty($extipaddr)) {
108 108
                 $parts = explode(':', $extipaddr);
109
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
110
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
111
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
109
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
110
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
111
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
112 112
             }
113 113
         }
114 114
 
115
-        $conf = "[general] \n" .
116
-            "disable_multi_domain=on\n" .
117
-            "transport = udp \n\n" .
115
+        $conf = "[general] \n".
116
+            "disable_multi_domain=on\n".
117
+            "transport = udp \n\n".
118 118
 
119
-            "[global] \n" .
120
-            "type = global\n" .
121
-            "endpoint_identifier_order=username,ip,anonymous\n" .
122
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
119
+            "[global] \n".
120
+            "type = global\n".
121
+            "endpoint_identifier_order=username,ip,anonymous\n".
122
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
123 123
 
124
-            "[anonymous]\n" .
125
-            "type = endpoint\n" .
124
+            "[anonymous]\n".
125
+            "type = endpoint\n".
126 126
             $codecConf.
127 127
             "language={$lang}\n".
128
-            "timers = no\n" .
128
+            "timers = no\n".
129 129
             "context = public-direct-dial\n\n".
130 130
 
131
-            "[transport-udp]\n" .
132
-            "type = transport\n" .
133
-            "protocol = udp\n" .
131
+            "[transport-udp]\n".
132
+            "type = transport\n".
133
+            "protocol = udp\n".
134 134
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
135 135
             "{$natConf}\n\n".
136 136
 
137
-            "[transport-tcp]\n" .
138
-            "type = transport\n" .
139
-            "protocol = tcp\n" .
137
+            "[transport-tcp]\n".
138
+            "type = transport\n".
139
+            "protocol = tcp\n".
140 140
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
141 141
             "{$natConf}\n\n".
142 142
             '';
143 143
 
144 144
         $varEtcDir = $this->config->path('core.varEtcDir');
145
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr. $this->generalSettings['SIPPort']));
145
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr.$this->generalSettings['SIPPort']));
146 146
         $conf .= "\n";
147 147
 
148 148
         return $conf;
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
      * @return bool
155 155
      */
156 156
     public function needAsteriskRestart():bool{
157
-        $di     = Di::getDefault();
157
+        $di = Di::getDefault();
158 158
         if ($di === null) {
159 159
             return false;
160 160
         }
161
-        $mikoPBXConfig  = new MikoPBXConfig();
161
+        $mikoPBXConfig = new MikoPBXConfig();
162 162
         [$topology, $extipaddr, $exthostname] = $this->getTopologyData();
163 163
 
164 164
         $generalSettings = $mikoPBXConfig->getGeneralSettings();
165
-        $now_hadh = md5($topology . $exthostname . $extipaddr. $generalSettings['SIPPort']);
166
-        $old_hash   = '';
165
+        $now_hadh = md5($topology.$exthostname.$extipaddr.$generalSettings['SIPPort']);
166
+        $old_hash = '';
167 167
         $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
168
-        if (file_exists($varEtcDir . '/topology_hash')) {
169
-            $old_hash = file_get_contents($varEtcDir . '/topology_hash');
168
+        if (file_exists($varEtcDir.'/topology_hash')) {
169
+            $old_hash = file_get_contents($varEtcDir.'/topology_hash');
170 170
         }
171 171
 
172 172
         return $old_hash !== $now_hadh;
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
             }
191 191
             try {
192 192
                 $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
193
-            }catch (\Throwable $e){
193
+            } catch (\Throwable $e) {
194 194
                 Util::sysLogMsg(self::class, $e->getMessage());
195 195
                 continue;
196 196
             }
197
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
197
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
198 198
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
199 199
                 $subnets[] = $net;
200 200
             }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         $conf        = '';
233 233
         $reg_strings = '';
234 234
         $prov_config = '';
235
-        if ($this->data_providers===null){
235
+        if ($this->data_providers === null) {
236 236
             $this->getSettings();
237 237
         }
238 238
         $additionalModules = $this->di->getShared('pbxConfModules');
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
      */
264 264
     private function generateProviderRegistrationAuth(array $provider, array $additionalModules, array $manual_attributes): string{
265 265
         $conf = '';
266
-        if($provider['noregister'] === '1'){
266
+        if ($provider['noregister'] === '1') {
267 267
             return $conf;
268 268
         }
269
-        $options     = [
269
+        $options = [
270 270
             'type'     => 'registration-auth',
271 271
             'username' => $provider['username'],
272 272
             'password' => $provider['secret'],
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
      */
290 290
     private function generateProviderRegistration(array $provider, array $additionalModules, array $manual_attributes): string{
291 291
         $conf = '';
292
-        if($provider['noregister'] === '1'){
292
+        if ($provider['noregister'] === '1') {
293 293
             return $conf;
294 294
         }
295
-        $options     = [
295
+        $options = [
296 296
             'type'                        => 'registration',
297 297
             'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
298 298
             'contact_user'                => $provider['username'],
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         if ('1' === $provider['receive_calls_without_auth']) {
325 325
             return $conf;
326 326
         }
327
-        $options     = [
327
+        $options = [
328 328
             'type'     => 'endpoint-auth',
329 329
             'username' => $provider['username'],
330 330
             'password' => $provider['secret'],
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     private function generateProviderAor(array $provider, array $additionalModules, array $manual_attributes): string{
349 349
         $conf = '';
350 350
         $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
351
-        if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
351
+        if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
352 352
             $contact = "sip:$defaultuser@{$provider['host']}:{$provider['port']}";
353 353
         } else {
354 354
             $contact = "sip:{$provider['host']}:{$provider['port']}";
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
362 362
             'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
363 363
         ];
364
-        if($provider['qualify'] === '1'){
364
+        if ($provider['qualify'] === '1') {
365 365
             $options['qualify_frequency'] = $provider['qualifyfreq'];
366 366
             $options['qualify_timeout']   = '3.0';
367 367
         }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
      */
437 437
     private function generateProviderIdentify(array $provider, array $additionalModules, array $manual_attributes): string{
438 438
         $conf = '';
439
-        $options     = [
439
+        $options = [
440 440
             'type'     => 'identify',
441 441
             'endpoint' => $provider['uniqid'],
442 442
             'match'    => $provider['host'],
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
             'pl-pl' => 'pl',
469 469
             'pt-br' => 'pt',
470 470
         ];
471
-        $toneZone = $settings[$lang]??'';
472
-        if(!empty($toneZone)){
471
+        $toneZone = $settings[$lang] ?? '';
472
+        if (!empty($toneZone)) {
473 473
             $options['inband_progress'] = 'yes';
474 474
             $options['tone_zone'] = $toneZone;
475 475
         }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
      */
484 484
     public function generatePeersPj(): string
485 485
     {
486
-        if ($this->data_peers===null){
486
+        if ($this->data_peers === null) {
487 487
             $this->getSettings();
488 488
         }
489 489
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
         $language = (trim($language) === '') ? 'en-en' : $language;
579 579
 
580 580
         $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
581
-        $busylevel = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
581
+        $busylevel = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
582 582
 
583 583
         $dtmfmode = ($peer['dtmfmode'] === 'rfc2833') ? 'rfc4733' : $peer['dtmfmode'];
584 584
         $options = [
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             'conditions'=>'disabled="0"',
705 705
             'order' => 'type, priority',
706 706
         ];
707
-        $codecs     = Codecs::find($filter);
707
+        $codecs = Codecs::find($filter);
708 708
         foreach ($codecs as $codec_data) {
709 709
             $arr_codecs[] = $codec_data->name;
710 710
         }
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
             // Получим используемые кодеки.
735 735
             $arr_data['codecs'] = $this->getCodecs();
736 736
 
737
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
738
-            if ( ! isset($this->contexts_data[$context_id])) {
737
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
738
+            if (!isset($this->contexts_data[$context_id])) {
739 739
                 $this->contexts_data[$context_id] = [];
740 740
             }
741 741
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
      */
755 755
     private function getOutRoutes(): array
756 756
     {
757
-        if ($this->data_peers===null){
757
+        if ($this->data_peers === null) {
758 758
             $this->getSettings();
759 759
         }
760 760
         /** @var OutgoingRoutingTable $rout */
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
      */
790 790
     public function extensionGenContexts(): string
791 791
     {
792
-        if ($this->data_peers===null){
792
+        if ($this->data_peers === null) {
793 793
             $this->getSettings();
794 794
         }
795 795
         // Генерация внутреннего номерного плана.
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
             $contexts_data = $this->contexts_data[$provider['context_id']];
808 808
             if (count($contexts_data) === 1) {
809 809
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
810
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
811
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
810
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
811
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
812 812
                     $contexts_data,
813 813
                     null,
814 814
                     $provider['context_id']
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
      */
828 828
     public function extensionGenHints(): string
829 829
     {
830
-        if ($this->data_peers===null){
830
+        if ($this->data_peers === null) {
831 831
             $this->getSettings();
832 832
         }
833 833
         $conf = '';
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
     public function extensionGenInternal(): string
842 842
     {
843
-        if ($this->data_peers===null){
843
+        if ($this->data_peers === null) {
844 844
             $this->getSettings();
845 845
         }
846 846
         // Генерация внутреннего номерного плана.
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 
856 856
     public function extensionGenInternalTransfer(): string
857 857
     {
858
-        if ($this->data_peers===null){
858
+        if ($this->data_peers === null) {
859 859
             $this->getSettings();
860 860
         }
861 861
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
             }
191 191
             try {
192 192
                 $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
193
-            }catch (\Throwable $e){
193
+            } catch (\Throwable $e){
194 194
                 Util::sysLogMsg(self::class, $e->getMessage());
195 195
                 continue;
196 196
             }
Please login to merge, or discard this patch.
src/Core/System/Upgrade/UpdateSystemConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         if ($previous_version !== $current_version) {
44 44
             $upgradeClasses      = [];
45 45
             $upgradeClassesDir   = appPath('src/Core/System/Upgrade/Releases');
46
-            $upgradeClassesFiles = glob($upgradeClassesDir . '/*.php', GLOB_NOSORT);
46
+            $upgradeClassesFiles = glob($upgradeClassesDir.'/*.php', GLOB_NOSORT);
47 47
             foreach ($upgradeClassesFiles as $file) {
48 48
                 $className        = pathinfo($file)['filename'];
49 49
                 $moduleModelClass = "\\MikoPBX\\Core\\System\\Upgrade\\Releases\\{$className}";
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 if (version_compare($previous_version, $releaseNumber, '<')) {
58 58
                     $processor = new $upgradeClass();
59 59
                     $processor->processUpdate();
60
-                    Util::echoWithSyslog(' - UpdateConfigs: Upgrade system up to ' . $releaseNumber . ' ');
60
+                    Util::echoWithSyslog(' - UpdateConfigs: Upgrade system up to '.$releaseNumber.' ');
61 61
                     Util::echoGreenDone();
62 62
                 }
63 63
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $modules = PbxExtensionModules::find();
79 79
         $modulesDir = $this->getDI()->getShared('config')->path('core.modulesDir');
80 80
         foreach ($modules as $module) {
81
-            if ( ! is_dir("{$modulesDir}/{$module->uniqid}")) {
81
+            if (!is_dir("{$modulesDir}/{$module->uniqid}")) {
82 82
                 $module->delete();
83 83
             }
84 84
         }
Please login to merge, or discard this patch.
src/Common/Models/PbxSettings.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $cacheKey        = explode('\\', static::class)[3];
45 45
         $parameters      = [
46 46
             'cache' => [
47
-                'key'      => $cacheKey . '-getAllPbxSettings',
47
+                'key'      => $cacheKey.'-getAllPbxSettings',
48 48
                 'lifetime' => 300,
49 49
             ],
50 50
         ];
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         return [
70 70
             'Name'                            => 'PBX system',
71
-            'VirtualHardwareType'             => 'REAL',//VMWARE,HYPERV,AWS,AZURE
71
+            'VirtualHardwareType'             => 'REAL', //VMWARE,HYPERV,AWS,AZURE
72 72
             'Description'                     => '',
73 73
             'RestartEveryNight'               => '0',
74 74
             'SIPPort'                         => '5060',
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
             'MailTplVoicemailSubject'         => 'VoiceMail from PBX',
111 111
             'MailTplVoicemailBody'            => 'See attach',
112 112
             'MailTplVoicemailFooter'          => '',
113
-            'NTPServer'                       => '0.pool.ntp.org' . PHP_EOL . '1.pool.ntp.org' . PHP_EOL,
113
+            'NTPServer'                       => '0.pool.ntp.org'.PHP_EOL.'1.pool.ntp.org'.PHP_EOL,
114 114
             'VoicemailNotificationsEmail'     => '[email protected]',
115 115
             'VoicemailExten'                  => '*001',
116 116
             'PBXLanguage'                     => 'en-en',
117
-            'PBXInternalExtensionLength'      => '3',// Длина внутреннего номера
117
+            'PBXInternalExtensionLength'      => '3', // Длина внутреннего номера
118 118
             'PBXRecordCalls'                  => '1',
119 119
             'PBXSplitAudioThread'             => '0',
120 120
             'PBXCallParkingExt'               => '800',
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $cacheKey        = explode('\\', static::class)[3];
152 152
         $parameters      = [
153 153
             'cache' => [
154
-                'key'      => $cacheKey . '-getValueByKey',
154
+                'key'      => $cacheKey.'-getValueByKey',
155 155
                 'lifetime' => 300,
156 156
             ],
157 157
         ];
Please login to merge, or discard this patch.