Passed
Push — develop ( 4b7e2c...d0652c )
by Портнов
05:34
created
src/Core/Asterisk/Configs/SIPConf.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
         $conf .= $this->generateProvidersPj();
55 55
         $conf .= $this->generatePeersPj();
56 56
 
57
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
57
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
58 58
         $pjConf = '[log_mappings]'."\n".
59 59
             'type=log_mappings'."\n".
60 60
             'asterisk_error = 0'."\n".
61 61
             'asterisk_warning = 2'."\n".
62 62
             'asterisk_debug = 1,3,4,5,6'."\n\n";
63 63
 
64
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf);
65
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
64
+        file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf);
65
+        file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
66 66
 
67 67
         $db = new AstDB();
68 68
         foreach ($this->data_peers as $peer) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 continue;
98 98
             }
99 99
             $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
100
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
100
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
101 101
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
102 102
                 $subnets[] = $net;
103 103
             }
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
         }
117 117
         $codecs = $this->getCodecs();
118 118
         $codecConf = '';
119
-        foreach ($codecs as $codec){
120
-            $codecConf.= "allow = {$codec}\n";
119
+        foreach ($codecs as $codec) {
120
+            $codecConf .= "allow = {$codec}\n";
121 121
         }
122 122
 
123 123
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
@@ -126,50 +126,50 @@  discard block
 block discarded – undo
126 126
             foreach ($subnets as $net) {
127 127
                 $natConf .= "local_net={$net}\n";
128 128
             }
129
-            if ( ! empty($exthostname)) {
129
+            if (!empty($exthostname)) {
130 130
                 $parts = explode(':', $exthostname);
131
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
132
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
133
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
134
-            } elseif ( ! empty($extipaddr)) {
131
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
132
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
133
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
134
+            } elseif (!empty($extipaddr)) {
135 135
                 $parts = explode(':', $extipaddr);
136
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
137
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
138
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
136
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
137
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
138
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
139 139
             }
140 140
         }
141 141
 
142
-        $conf = "[general] \n" .
143
-            "disable_multi_domain=on\n" .
144
-            "transport = udp \n\n" .
142
+        $conf = "[general] \n".
143
+            "disable_multi_domain=on\n".
144
+            "transport = udp \n\n".
145 145
 
146
-            "[global] \n" .
147
-            "type = global\n" .
148
-            "endpoint_identifier_order=username,ip,anonymous\n" .
149
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
146
+            "[global] \n".
147
+            "type = global\n".
148
+            "endpoint_identifier_order=username,ip,anonymous\n".
149
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
150 150
 
151
-            "[anonymous]\n" .
152
-            "type = endpoint\n" .
151
+            "[anonymous]\n".
152
+            "type = endpoint\n".
153 153
             $codecConf.
154 154
             "language={$lang}\n".
155
-            "timers = no\n" .
155
+            "timers = no\n".
156 156
             "context = public-direct-dial\n\n".
157 157
 
158
-            "[transport-udp]\n" .
159
-            "type = transport\n" .
160
-            "protocol = udp\n" .
158
+            "[transport-udp]\n".
159
+            "type = transport\n".
160
+            "protocol = udp\n".
161 161
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
162 162
             "{$natConf}\n\n".
163 163
 
164
-            "[transport-tcp]\n" .
165
-            "type = transport\n" .
166
-            "protocol = tcp\n" .
164
+            "[transport-tcp]\n".
165
+            "type = transport\n".
166
+            "protocol = tcp\n".
167 167
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
168 168
             "{$natConf}\n\n".
169 169
             '';
170 170
 
171 171
         $varEtcDir = $this->config->path('core.varEtcDir');
172
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr));
172
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr));
173 173
         $conf .= "\n";
174 174
 
175 175
         return $conf;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $conf        = '';
187 187
         $reg_strings = '';
188 188
         $prov_config = '';
189
-        if ($this->data_providers===null){
189
+        if ($this->data_providers === null) {
190 190
             $this->getSettings();
191 191
         }
192 192
         foreach ($this->data_providers as $provider) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
             $need_register = $provider['noregister'] !== '1';
197 197
             if ($need_register) {
198
-                $options     = [
198
+                $options = [
199 199
                     'type'     => 'auth',
200 200
                     'username' => $provider['username'],
201 201
                     'password' => $provider['secret'],
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                 $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n";
204 204
                 $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth');
205 205
 
206
-                $options     = [
206
+                $options = [
207 207
                     'type'                        => 'registration',
208 208
                     // 'transport'                   => 'transport-udp',
209 209
                     'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             }
222 222
 
223 223
             if ('1' !== $provider['receive_calls_without_auth']) {
224
-                $options     = [
224
+                $options = [
225 225
                     'type'     => 'auth',
226 226
                     'username' => $provider['username'],
227 227
                     'password' => $provider['secret'],
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
             }
232 232
 
233 233
             $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
234
-            if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
234
+            if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
235 235
                 $contact = "sip:$defaultuser@{$provider['host']}:{$port}";
236 236
             } else {
237 237
                 $contact = "sip:{$provider['host']}:{$port}";
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
246 246
                 'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
247 247
             ];
248
-            if($provider['qualify'] === '1'){
248
+            if ($provider['qualify'] === '1') {
249 249
                 $options['qualify_frequency'] = $provider['qualifyfreq'];
250 250
                 $options['qualify_timeout']   = '3.0';
251 251
             }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
             $prov_config .= "[{$provider['uniqid']}]\n";
254 254
             $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor');
255 255
 
256
-            $options     = [
256
+            $options = [
257 257
                 'type'     => 'identify',
258 258
                 'endpoint' => $provider['uniqid'],
259 259
                 'match'    => $provider['host'],
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public function generatePeersPj(): string
316 316
     {
317
-        if ($this->data_peers===null){
317
+        if ($this->data_peers === null) {
318 318
             $this->getSettings();
319 319
         }
320 320
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             $language = (trim($language) === '') ? 'en-en' : $language;
329 329
 
330 330
             $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
331
-            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
331
+            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
332 332
 
333 333
             $options = [
334 334
                 'type'     => 'auth',
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             'conditions'=>'disabled="0"',
481 481
             'order' => 'type, priority',
482 482
         ];
483
-        $codecs     = Codecs::find($filter);
483
+        $codecs = Codecs::find($filter);
484 484
         foreach ($codecs as $codec_data) {
485 485
             $arr_codecs[] = $codec_data->name;
486 486
         }
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
             // Получим используемые кодеки.
511 511
             $arr_data['codecs'] = $this->getCodecs();
512 512
 
513
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
514
-            if ( ! isset($this->contexts_data[$context_id])) {
513
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
514
+            if (!isset($this->contexts_data[$context_id])) {
515 515
                 $this->contexts_data[$context_id] = [];
516 516
             }
517 517
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
      */
531 531
     private function getOutRoutes(): array
532 532
     {
533
-        if ($this->data_peers===null){
533
+        if ($this->data_peers === null) {
534 534
             $this->getSettings();
535 535
         }
536 536
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
      */
566 566
     public function extensionGenContexts(): string
567 567
     {
568
-        if ($this->data_peers===null){
568
+        if ($this->data_peers === null) {
569 569
             $this->getSettings();
570 570
         }
571 571
         // Генерация внутреннего номерного плана.
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
             $contexts_data = $this->contexts_data[$provider['context_id']];
584 584
             if (count($contexts_data) === 1) {
585 585
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
586
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
587
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
586
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
587
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
588 588
                     $contexts_data,
589 589
                     null,
590 590
                     $provider['context_id']
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      */
604 604
     public function extensionGenHints(): string
605 605
     {
606
-        if ($this->data_peers===null){
606
+        if ($this->data_peers === null) {
607 607
             $this->getSettings();
608 608
         }
609 609
         $conf = '';
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 
617 617
     public function extensionGenInternal(): string
618 618
     {
619
-        if ($this->data_peers===null){
619
+        if ($this->data_peers === null) {
620 620
             $this->getSettings();
621 621
         }
622 622
         // Генерация внутреннего номерного плана.
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 
632 632
     public function extensionGenInternalTransfer(): string
633 633
     {
634
-        if ($this->data_peers===null){
634
+        if ($this->data_peers === null) {
635 635
             $this->getSettings();
636 636
         }
637 637
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.