Passed
Push — develop ( 0a248f...2e4521 )
by Nikolay
05:19
created
src/Core/Asterisk/Configs/SIPConf.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $conf .= $this->generateProvidersPj();
47 47
         $conf .= $this->generatePeersPj();
48 48
 
49
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
49
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
50 50
 
51 51
 
52 52
         $db = new AstDB();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 continue;
86 86
             }
87 87
             $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
88
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
88
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
89 89
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
90 90
                 $subnets[] = $net;
91 91
             }
@@ -104,34 +104,34 @@  discard block
 block discarded – undo
104 104
         }
105 105
         $codecs    = Codecs::find()->toArray();
106 106
         $codecConf = '';
107
-        foreach ($codecs as $codec){
108
-            $codecConf.= "allow = {$codec['name']}\n";
107
+        foreach ($codecs as $codec) {
108
+            $codecConf .= "allow = {$codec['name']}\n";
109 109
         }
110 110
 
111 111
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
112 112
 
113
-        $conf = "[general] \n" .
114
-            "disable_multi_domain=on\n" .
115
-            "transport = udp \n\n" .
113
+        $conf = "[general] \n".
114
+            "disable_multi_domain=on\n".
115
+            "transport = udp \n\n".
116 116
 
117
-            "[global] \n" .
118
-            "type = global\n" .
119
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
117
+            "[global] \n".
118
+            "type = global\n".
119
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
120 120
 
121
-            "[anonymous]\n" .
122
-            "type = endpoint\n" .
123
-            "{$codecConf}" .
124
-            "timers = no\n" .
125
-            "context = public-direct-dial\n\n" .
121
+            "[anonymous]\n".
122
+            "type = endpoint\n".
123
+            "{$codecConf}".
124
+            "timers = no\n".
125
+            "context = public-direct-dial\n\n".
126 126
 
127
-            "[transport-udp]\n" .
128
-            "type = transport\n" .
129
-            "protocol = udp\n" .
127
+            "[transport-udp]\n".
128
+            "type = transport\n".
129
+            "protocol = udp\n".
130 130
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n\n".
131 131
 
132
-            "[transport-tcp]\n" .
133
-            "type = transport\n" .
134
-            "protocol = tcp\n" .
132
+            "[transport-tcp]\n".
133
+            "type = transport\n".
134
+            "protocol = tcp\n".
135 135
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n";
136 136
 
137 137
         if ($topology === 'private') {
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
                 $conf .= "local_net={$net}\n";
140 140
             }
141 141
 
142
-            if ( ! empty($exthostname)) {
142
+            if (!empty($exthostname)) {
143 143
                 $parts = explode(':', $exthostname);
144
-                $conf  .= 'external_media_address=' . $parts[0] . "\n";
145
-                $conf  .= 'external_signaling_address=' . $parts[0] . "\n";
146
-                $conf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
147
-            } elseif ( ! empty($extipaddr)) {
144
+                $conf  .= 'external_media_address='.$parts[0]."\n";
145
+                $conf  .= 'external_signaling_address='.$parts[0]."\n";
146
+                $conf  .= 'external_signaling_port='.($parts[1] ?? '5060');
147
+            } elseif (!empty($extipaddr)) {
148 148
                 $parts = explode(':', $extipaddr);
149
-                $conf  .= 'external_media_address=' . $parts[0] . "\n";
150
-                $conf  .= 'external_signaling_address=' . $parts[0] . "\n";
151
-                $conf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
149
+                $conf  .= 'external_media_address='.$parts[0]."\n";
150
+                $conf  .= 'external_signaling_address='.$parts[0]."\n";
151
+                $conf  .= 'external_signaling_port='.($parts[1] ?? '5060');
152 152
             }
153 153
         }
154 154
 
155 155
         $varEtcDir = $this->config->path('core.varEtcDir');
156
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr));
156
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr));
157 157
         $conf .= "\n";
158 158
 
159 159
         return $conf;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $conf        = '';
171 171
         $reg_strings = '';
172 172
         $prov_config = '';
173
-        if ($this->data_providers===null){
173
+        if ($this->data_providers === null) {
174 174
             $this->getSettings();
175 175
         }
176 176
         foreach ($this->data_providers as $provider) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
             $need_register = $provider['noregister'] !== '1';
181 181
             if ($need_register) {
182
-                $options     = [
182
+                $options = [
183 183
                     'type'     => 'auth',
184 184
                     'username' => $provider['username'],
185 185
                     'password' => $provider['secret'],
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n";
188 188
                 $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth');
189 189
 
190
-                $options     = [
190
+                $options = [
191 191
                     'type'                        => 'registration',
192 192
                     // 'transport'                   => 'transport-udp',
193 193
                     'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             }
206 206
 
207 207
             if ('1' !== $provider['receive_calls_without_auth']) {
208
-                $options     = [
208
+                $options = [
209 209
                     'type'     => 'auth',
210 210
                     'username' => $provider['username'],
211 211
                     'password' => $provider['secret'],
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             }
216 216
 
217 217
             $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
218
-            if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
218
+            if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
219 219
                 $contact = "sip:$defaultuser@{$provider['host']}:{$port}";
220 220
             } else {
221 221
                 $contact = "sip:{$provider['host']}:{$port}";
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                 'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
230 230
                 'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
231 231
             ];
232
-            if($provider['qualify'] === '1'){
232
+            if ($provider['qualify'] === '1') {
233 233
                 $options['qualify_frequency'] = $provider['qualifyfreq'];
234 234
                 $options['qualify_timeout']   = '3.0';
235 235
             }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             $prov_config .= "[{$provider['uniqid']}]\n";
238 238
             $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor');
239 239
 
240
-            $options     = [
240
+            $options = [
241 241
                 'type'     => 'identify',
242 242
                 'endpoint' => $provider['uniqid'],
243 243
                 'match'    => $provider['host'],
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function generatePeersPj(): string
302 302
     {
303
-        if ($this->data_peers===null){
303
+        if ($this->data_peers === null) {
304 304
             $this->getSettings();
305 305
         }
306 306
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             $language = (trim($language) === '') ? 'en-en' : $language;
315 315
 
316 316
             $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
317
-            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
317
+            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
318 318
 
319 319
             $options = [
320 320
                 'type'     => 'auth',
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             'bind'  => ['id' => $uniqid],
469 469
             'order' => 'priority',
470 470
         ];
471
-        $codecs     = SipCodecs::find($filter);
471
+        $codecs = SipCodecs::find($filter);
472 472
         foreach ($codecs as $codec_data) {
473 473
             $arr_codecs[] = $codec_data->codec;
474 474
         }
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
             // Получим используемые кодеки.
499 499
             $arr_data['codecs'] = $this->getCodecs($sip_peer->uniqid);
500 500
 
501
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
502
-            if ( ! isset($this->contexts_data[$context_id])) {
501
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
502
+            if (!isset($this->contexts_data[$context_id])) {
503 503
                 $this->contexts_data[$context_id] = [];
504 504
             }
505 505
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     private function getOutRoutes(): array
520 520
     {
521
-        if ($this->data_peers===null){
521
+        if ($this->data_peers === null) {
522 522
             $this->getSettings();
523 523
         }
524 524
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
      */
554 554
     public function extensionGenContexts(): string
555 555
     {
556
-        if ($this->data_peers===null){
556
+        if ($this->data_peers === null) {
557 557
             $this->getSettings();
558 558
         }
559 559
         // Генерация внутреннего номерного плана.
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
             $contexts_data = $this->contexts_data[$provider['context_id']];
572 572
             if (count($contexts_data) === 1) {
573 573
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
574
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
575
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
574
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
575
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
576 576
                     $contexts_data,
577 577
                     null,
578 578
                     $provider['context_id']
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
      */
592 592
     public function extensionGenHints(): string
593 593
     {
594
-        if ($this->data_peers===null){
594
+        if ($this->data_peers === null) {
595 595
             $this->getSettings();
596 596
         }
597 597
         $conf = '';
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 
605 605
     public function extensionGenInternal(): string
606 606
     {
607
-        if ($this->data_peers===null){
607
+        if ($this->data_peers === null) {
608 608
             $this->getSettings();
609 609
         }
610 610
         // Генерация внутреннего номерного плана.
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
     public function extensionGenInternalTransfer(): string
621 621
     {
622
-        if ($this->data_peers===null){
622
+        if ($this->data_peers === null) {
623 623
             $this->getSettings();
624 624
         }
625 625
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
src/Core/Workers/WorkerRemoveOldRecords.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 
15 15
 class WorkerRemoveOldRecords extends WorkerBase
16 16
 {
17
-    protected int $maxProc=1;
17
+    protected int $maxProc = 1;
18 18
 
19 19
     public function start($argv): void
20 20
     {
21 21
         $varEtcDir = $this->di->getShared('config')->path('core.varEtcDir');
22
-        $filename   = "{$varEtcDir}/storage_device";
22
+        $filename = "{$varEtcDir}/storage_device";
23 23
         if (file_exists($filename)) {
24 24
             $mount_point = file_get_contents($filename);
25 25
         } else {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             $out
55 55
         );
56 56
         foreach ($out as $dir_info) {
57
-            if ( ! is_dir($dir_info)) {
57
+            if (!is_dir($dir_info)) {
58 58
                 echo 'error';
59 59
                 continue;
60 60
             }
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCallEvents.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 class WorkerCallEvents extends WorkerBase
19 19
 {
20 20
     // Максимальное количество экземпляров данныого класса.
21
-    protected int $maxProc=1;
21
+    protected int $maxProc = 1;
22 22
 
23 23
     /**
24 24
      * Обработка события начала телефонного звонка.
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         foreach ($m_data as $row) {
51 51
             $row->writeAttribute('endtime', $data['start']);
52 52
             $res = $row->update();
53
-            if ( ! $res) {
53
+            if (!$res) {
54 54
                 Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages()));
55 55
             }
56 56
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             // мобильный и внутренний номер.
70 70
             $filter = [
71 71
                 '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime IS NULL',
72
-                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],],
72
+                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ],
73 73
             ];
74 74
         } else {
75 75
             $filter = [
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
         /** @var CallDetailRecordsTmp $row */
87 87
         $m_data = CallDetailRecordsTmp::find($filter);
88 88
         foreach ($m_data as $row) {
89
-            if ( ! is_object($row)) {
89
+            if (!is_object($row)) {
90 90
                 continue;
91 91
             }
92 92
             ///
93 93
             // Проверим, если более одного канала SIP/256 при входящем.
94 94
             $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan';
95 95
 
96
-            if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
96
+            if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
97 97
                 if ($row_create) {
98 98
                     continue;
99 99
                 }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     $new_row->writeAttribute($attribute, $value);
108 108
                 }
109 109
                 $new_row->writeAttribute($column_chan_name, $data['dst_chan']);
110
-                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']);
110
+                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']);
111 111
                 // Подмена $row;
112 112
                 $row        = $new_row;
113 113
                 $row_create = true;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                 // При оригинации меняется местами srs_chan в поле dst_chan.
121 121
                 $row->writeAttribute('src_chan', $data['dst_chan']);
122 122
             } else {
123
-                if ( ! $rec_start) {
123
+                if (!$rec_start) {
124 124
                     $data['recordingfile'] = CdrDb::MixMonitor(
125 125
                         $data['dst_chan'],
126 126
                         $row->UNIQUEID,
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
                 $row->writeAttribute('dst_chan', $data['dst_chan']);
135 135
             }
136 136
 
137
-            if (isset($data['to_account']) && ! empty($data['to_account'])) {
137
+            if (isset($data['to_account']) && !empty($data['to_account'])) {
138 138
                 $row->writeAttribute($account_col, $data['to_account']);
139 139
             }
140
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
140
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
141 141
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
142 142
             }
143 143
             $res = $row->save();
144
-            if ( ! $res) {
144
+            if (!$res) {
145 145
                 Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages()));
146 146
             }
147 147
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон.
162 162
             $filter = [
163 163
                 'UNIQUEID=:UNIQUEID:',
164
-                'bind' => ['UNIQUEID' => $data['old_id'],],
164
+                'bind' => ['UNIQUEID' => $data['old_id'], ],
165 165
             ];
166 166
             /** @var CallDetailRecordsTmp $m_data */
167 167
             $m_data = CallDetailRecordsTmp::find($filter);
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
                 $new_data['dst_chan']       = $data['agi_channel'];
176 176
                 $new_data['dst_num']        = $data['dst_num'];
177 177
                 $new_data['UNIQUEID']       = $data['id'];
178
-                $new_data['recordingfile']  = CdrDb::MixMonitor($new_data['dst_chan'],  'pickup_'.$new_data['UNIQUEID']);
178
+                $new_data['recordingfile']  = CdrDb::MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']);
179 179
 
180 180
                 unset($new_data['id']);
181 181
                 unset($new_data['end']);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
190 190
             }
191 191
         } else {
192
-            if ( ! empty($data['ENDCALLONANSWER'])) {
192
+            if (!empty($data['ENDCALLONANSWER'])) {
193 193
                 // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации.
194 194
                 // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный.
195 195
                 $filter = [
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                     $row->writeAttribute('endtime', $data['answer']);
207 207
                     $row->writeAttribute('is_app', 1);
208 208
                     $res = $row->save();
209
-                    if ( ! $res) {
209
+                    if (!$res) {
210 210
                         Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages()));
211 211
                     }
212 212
                 }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                     '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer IS NULL AND endtime IS NULL',
229 229
                     'bind' => [
230 230
                         'UNIQUEID'      => $data['id'],
231
-                        'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'],
231
+                        'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'],
232 232
                     ],
233 233
                 ];
234 234
             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                         continue;
242 242
                     }
243 243
                     // Найдем все прочие CDR по данному originate и отметим как завершенные.
244
-                    $filter      = [
244
+                    $filter = [
245 245
                         'linkedid=:linkedid: AND endtime IS NOT NULL AND src_chan <> :src_chan:',
246 246
                         'bind' => [
247 247
                             'linkedid' => $row->linkedid,
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                             $orgn_row->writeAttribute('endtime', $data['answer']);
256 256
                         }
257 257
                         $orgn_row->writeAttribute('dst_chan', '');
258
-                        $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan);
258
+                        $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan);
259 259
                         $orgn_row->update();
260 260
                     }
261 261
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                     $row->writeAttribute('answer', $data['answer']);
269 269
                 }
270 270
                 $res = $row->save();
271
-                if ( ! $res) {
271
+                if (!$res) {
272 272
                     Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages()));
273 273
                 }
274 274
             }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
312 312
             }
313 313
             $res = $row->update();
314
-            if ( ! $res) {
314
+            if (!$res) {
315 315
                 Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages()));
316 316
             }
317 317
 
@@ -341,18 +341,18 @@  discard block
 block discarded – undo
341 341
             $active_chans = $am->GetChannels(false);
342 342
             // TODO / Намек на SIP трансфер.
343 343
             foreach ($channels as $data_chan) {
344
-                if ( ! in_array($data_chan['chan'], $active_chans, true)) {
344
+                if (!in_array($data_chan['chan'], $active_chans, true)) {
345 345
                     // Вызов уже завершен. Не интересно.
346 346
                     continue;
347 347
                 }
348 348
                 $BRIDGEPEER = $am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false);
349
-                if ( ! in_array($BRIDGEPEER, $active_chans, true)) {
349
+                if (!in_array($BRIDGEPEER, $active_chans, true)) {
350 350
                     // Вызов уже завершен. Не интересно.
351 351
                     continue;
352 352
                 }
353 353
                 $linkedid = $am->GetVar($data_chan['chan'], 'CDR(linkedid)', null, false);
354 354
                 $CALLERID = $am->GetVar($BRIDGEPEER, 'CALLERID(num)', null, false);
355
-                if ( ! empty($linkedid) && $linkedid !== $data['linkedid']) {
355
+                if (!empty($linkedid) && $linkedid !== $data['linkedid']) {
356 356
                     $n_data['action']        = 'sip_transfer';
357 357
                     $n_data['src_chan']      = $data_chan['out'] ? $data_chan['chan'] : $BRIDGEPEER;
358 358
                     $n_data['src_num']       = $data_chan['out'] ? $data_chan['num'] : $CALLERID;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
                     $n_data['start']         = date('Y-m-d H:i:s');
362 362
                     $n_data['answer']        = date('Y-m-d H:i:s');
363 363
                     $n_data['linkedid']      = $linkedid;
364
-                    $n_data['UNIQUEID']      = $data['linkedid'] . Util::generateRandomString();
364
+                    $n_data['UNIQUEID']      = $data['linkedid'].Util::generateRandomString();
365 365
                     $n_data['transfer']      = '0';
366 366
                     $n_data['recordingfile'] = CdrDb::MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']);
367 367
                     $n_data['did']           = $data_chan['did'];
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     public static function Action_CreateRowTransfer($action, $data, $calls_data = null): void
401 401
     {
402 402
         if (null === $calls_data) {
403
-            $filter     = [
403
+            $filter = [
404 404
                 'linkedid=:linkedid: AND endtime IS NULL AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)',
405 405
                 'bind'  => [
406 406
                     'linkedid' => $data['linkedid'],
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
                     $insert_data[$fname_chan] = $row_data['dst_chan'];
423 423
                     $insert_data[$fname_num]  = $row_data['dst_num'];
424 424
                 } else {
425
-                    $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
426
-                    $fname_num  = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
425
+                    $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
426
+                    $fname_num  = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
427 427
 
428 428
                     $insert_data[$fname_chan] = $row_data['src_chan'];
429 429
                     $insert_data[$fname_num]  = $row_data['src_num'];
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
             CdrDb::StopMixMonitor($insert_data['dst_chan']);
435 435
             $recordingfile = CdrDb::MixMonitor(
436 436
                 $insert_data['dst_chan'],
437
-                'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid']
437
+                'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid']
438 438
             );
439 439
             //
440 440
             $insert_data['action']        = "{$action}_end_trasfer";
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             CdrDb::LogEvent(json_encode($insert_data));
459 459
         } elseif (empty($calls_data[0]['answer']) && count(
460 460
                 $calls_data
461
-            ) === 1 && ! empty($calls_data[0]['recordingfile'])) {
461
+            ) === 1 && !empty($calls_data[0]['recordingfile'])) {
462 462
             $row_data = $calls_data[0];
463 463
             $chan     = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan'];
464 464
             $filter   = [
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      */
536 536
     public static function Action_transfer_dial_create_chan($data): void
537 537
     {
538
-        $filter     = [
538
+        $filter = [
539 539
             'UNIQUEID=:UNIQUEID: AND endtime IS NULL AND answer IS NULL',
540 540
             'bind' => [
541 541
                 'UNIQUEID' => $data['transfer_UNIQUEID'],
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         foreach ($m_data as $row) {
549 549
             ///
550 550
             // Проверим, если более одного канала SIP/256 при входящем.
551
-            if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
551
+            if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
552 552
                 if ($row_create) {
553 553
                     continue;
554 554
                 }
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
                     $new_row->writeAttribute($attribute, $value);
563 563
                 }
564 564
                 $new_row->writeAttribute('dst_chan', $data['dst_chan']);
565
-                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']);
565
+                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']);
566 566
                 // $new_row->save();
567 567
                 // Подмена $row;
568 568
                 $row        = $new_row;
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 
576 576
             $row->writeAttribute('dst_chan', $data['dst_chan']);
577 577
             $row->writeAttribute('recordingfile', $data['recordingfile']);
578
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
578
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
579 579
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
580 580
             }
581 581
             $res = $row->save();
582
-            if ( ! $res) {
582
+            if (!$res) {
583 583
                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()));
584 584
             }
585 585
         }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
             '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer IS NULL AND endtime IS NULL',
597 597
             'bind' => [
598 598
                 'UNIQUEID'      => $data['transfer_UNIQUEID'],
599
-                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'],
599
+                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'],
600 600
             ],
601 601
         ];
602 602
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         foreach ($m_data as $row) {
607 607
             $row->writeAttribute('answer', $data['answer']);
608 608
             $res = $row->save();
609
-            if ( ! $res) {
609
+            if (!$res) {
610 610
                 Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
611 611
             }
612 612
         }
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                 // Завершим вызов в CDR.
641 641
                 $row->writeAttribute('endtime', $data['end']);
642 642
                 $row->writeAttribute('transfer', 0);
643
-                if ( ! $row->save()) {
643
+                if (!$row->save()) {
644 644
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
645 645
                 }
646 646
             }
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
                 // Ответа не было. Переадресация отменена.
676 676
                 $row->writeAttribute('endtime', $data['end']);
677 677
                 $row->writeAttribute('transfer', 0);
678
-                if ( ! $row->save()) {
678
+                if (!$row->save()) {
679 679
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
680 680
                 }
681 681
             }
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                 CdrDb::MixMonitor($row->src_chan, $info['filename'], $subdir);
696 696
                 // Снимем со строк признак переадресации.
697 697
                 $row->writeAttribute('transfer', 0);
698
-                if ( ! $row->save()) {
698
+                if (!$row->save()) {
699 699
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
700 700
                 }
701 701
             }
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
                 $f_list = $m_data->toArray();
773 773
                 foreach ($data as $attribute => $value) {
774
-                    if ( ! array_key_exists($attribute, $f_list)) {
774
+                    if (!array_key_exists($attribute, $f_list)) {
775 775
                         continue;
776 776
                     }
777 777
                     $m_data->writeAttribute($attribute, $value);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
             $row->writeAttribute('answer', $data['answer']);
843 843
             $row->writeAttribute('endtime', $data['answer']);
844 844
             $res = $row->save();
845
-            if ( ! $res) {
845
+            if (!$res) {
846 846
                 Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages()));
847 847
             }
848 848
         }
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
872 872
             }
873 873
             $res = $row->save();
874
-            if ( ! $res) {
874
+            if (!$res) {
875 875
                 Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages()));
876 876
             }
877 877
         }
@@ -901,11 +901,11 @@  discard block
 block discarded – undo
901 901
             if ($dest_chan === $row->dst_chan) {
902 902
                 $is_local        = (stripos($data['src_chan'], 'local/') !== false);
903 903
                 $is_stored_local = (stripos($row->src_chan, 'local/') !== false);
904
-                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) {
904
+                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) {
905 905
                     $data['src_chan'] = $row->src_chan;
906 906
                 }
907 907
                 if (file_exists($row->recordingfile) || file_exists(
908
-                        Util::trimExtensionForFile($row->recordingfile) . '.wav'
908
+                        Util::trimExtensionForFile($row->recordingfile).'.wav'
909 909
                     )) {
910 910
                     // Переопределим путь к файлу записи разговора. Для конферецнии файл один.
911 911
                     $recordingfile = $row->recordingfile;
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
             // Подменим ID на идентификатор конференции.
918 918
             $row->writeAttribute('linkedid', $data['meetme_id']);
919 919
             $res = $row->save();
920
-            if ( ! $res) {
920
+            if (!$res) {
921 921
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
922 922
             }
923 923
         }
@@ -934,11 +934,11 @@  discard block
 block discarded – undo
934 934
             $row->writeAttribute('transfer', 0);
935 935
             $row->writeAttribute('linkedid', $data['meetme_id']);
936 936
 
937
-            if ( ! empty($recordingfile)) {
937
+            if (!empty($recordingfile)) {
938 938
                 $row->writeAttribute('recordingfile', $recordingfile);
939 939
             }
940 940
             $res = $row->save();
941
-            if ( ! $res) {
941
+            if (!$res) {
942 942
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
943 943
             }
944 944
         }
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
      */
971 971
     public function callEventsWorker($tube): void
972 972
     {
973
-        $data      = json_decode($tube->getBody(), true);
973
+        $data = json_decode($tube->getBody(), true);
974 974
         $funcName = "Action_".$data['action'];
975
-        if ( method_exists($this, $funcName) ) {
975
+        if (method_exists($this, $funcName)) {
976 976
             $this->$funcName($data);
977 977
         }
978 978
         $tube->reply(json_encode(true));
@@ -1001,14 +1001,14 @@  discard block
 block discarded – undo
1001 1001
     public static function updateDataInDbM($data): bool
1002 1002
     {
1003 1003
         if (empty($data['UNIQUEID'])) {
1004
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1004
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1005 1005
 
1006 1006
             return false;
1007 1007
         }
1008 1008
 
1009 1009
         $filter = [
1010 1010
             "UNIQUEID=:id:",
1011
-            'bind' => ['id' => $data['UNIQUEID'],],
1011
+            'bind' => ['id' => $data['UNIQUEID'], ],
1012 1012
         ];
1013 1013
         /** @var CallDetailRecordsTmp $m_data */
1014 1014
         $m_data = CallDetailRecordsTmp::findFirst($filter);
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         }
1018 1018
         $f_list = $m_data->toArray();
1019 1019
         foreach ($data as $attribute => $value) {
1020
-            if ( ! array_key_exists($attribute, $f_list)) {
1020
+            if (!array_key_exists($attribute, $f_list)) {
1021 1021
                 continue;
1022 1022
             }
1023 1023
             if ('UNIQUEID' == $attribute) {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
             $m_data->writeAttribute($attribute, $value);
1027 1027
         }
1028 1028
         $res = $m_data->save();
1029
-        if ( ! $res) {
1029
+        if (!$res) {
1030 1030
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1031 1031
         }
1032 1032
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
     public static function insertDataToDbM($data): bool
1067 1067
     {
1068 1068
         if (empty($data['UNIQUEID'])) {
1069
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1069
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1070 1070
 
1071 1071
             return false;
1072 1072
         }
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
         $m_data = CallDetailRecordsTmp::findFirst(
1077 1077
             [
1078 1078
                 "UNIQUEID=:id:",
1079
-                'bind' => ['id' => $data['UNIQUEID'],],
1079
+                'bind' => ['id' => $data['UNIQUEID'], ],
1080 1080
             ]
1081 1081
         );
1082 1082
         if ($m_data === null) {
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
         } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] == 'dial') {
1086 1086
             if (empty($m_data->endtime)) {
1087 1087
                 // Если это оригинация dial может прийти дважды.
1088
-                if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){
1088
+                if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) {
1089 1089
                     $m_data->dst_num = $data['src_num'];
1090 1090
                     $m_data->save();
1091 1091
                 }
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
                 $new_m_data->transfer     = $data['transfer'];
1111 1111
 
1112 1112
                 $res = $new_m_data->save();
1113
-                if ( ! $res) {
1113
+                if (!$res) {
1114 1114
                     Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1115 1115
                 }
1116 1116
 
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 
1121 1121
         $f_list = $m_data->toArray();
1122 1122
         foreach ($data as $attribute => $value) {
1123
-            if ( ! array_key_exists($attribute, $f_list)) {
1123
+            if (!array_key_exists($attribute, $f_list)) {
1124 1124
                 continue;
1125 1125
             }
1126 1126
             if ($is_new == false && 'UNIQUEID' == $attribute) {
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
             $m_data->writeAttribute($attribute, $value);
1130 1130
         }
1131 1131
         $res = $m_data->save();
1132
-        if ( ! $res) {
1132
+        if (!$res) {
1133 1133
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1134 1134
         }
1135 1135
 
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
         if (isset($filter['miko_result_in_file'])) {
1173 1173
             $di         = Di::getDefault();
1174 1174
             $dirsConfig = $di->getShared('config');
1175
-            $filename   = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true));
1175
+            $filename   = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true));
1176 1176
             file_put_contents($filename, $res_data);
1177 1177
             Util::addRegularWWWRights($filename);
1178 1178
             $res_data = json_encode($filename);
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 
1184 1184
     public function errorHandler($m): void
1185 1185
     {
1186
-        Util::sysLogMsg(self::class . '_ERROR', $m);
1186
+        Util::sysLogMsg(self::class.'_ERROR', $m);
1187 1187
     }
1188 1188
 }
1189 1189
 
Please login to merge, or discard this patch.
src/Core/System/Storage.php 2 patches
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
     public static function isStorageDisk($device): bool
76 76
     {
77 77
         $result = false;
78
-        if ( ! file_exists("{$device}")) {
78
+        if (!file_exists("{$device}")) {
79 79
             return $result;
80 80
         }
81 81
 
82
-        $tmp_dir = '/tmp/mnt_' . time();
82
+        $tmp_dir = '/tmp/mnt_'.time();
83 83
         Util::mwMkdir($tmp_dir);
84 84
         $out = [];
85 85
 
86 86
         $storage  = new Storage();
87
-        $uid_part = 'UUID=' . $storage->getUuid($device) . '';
87
+        $uid_part = 'UUID='.$storage->getUuid($device).'';
88 88
         $format   = $storage->getFsType($device);
89 89
         if ($format === '') {
90 90
             return false;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             Util::mwExec("{$umountPath} {$device}");
104 104
         }
105 105
 
106
-        if ( ! self::isStorageDiskMounted($device)) {
106
+        if (!self::isStorageDiskMounted($device)) {
107 107
             Util::mwExec("{$rmPath} -rf '{$tmp_dir}'");
108 108
         }
109 109
 
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
         $timeoutPath = Util::which('timeout');
234 234
         $sshfsPath   = Util::which('sshfs');
235 235
 
236
-        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' " .
237
-            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n" .
238
-            "{$pass}\n" .
236
+        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' ".
237
+            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n".
238
+            "{$pass}\n".
239 239
             "EOF\n";
240 240
         // file_put_contents('/tmp/sshfs_'.$host, $command);
241 241
         Util::mwExec($command, $out);
@@ -267,19 +267,19 @@  discard block
 block discarded – undo
267 267
 
268 268
         // Собираем строку подключения к ftp.
269 269
         $auth_line = '';
270
-        if ( ! empty($user)) {
271
-            $auth_line .= 'user="' . $user;
272
-            if ( ! empty($pass)) {
270
+        if (!empty($user)) {
271
+            $auth_line .= 'user="'.$user;
272
+            if (!empty($pass)) {
273 273
                 $auth_line .= ":{$pass}";
274 274
             }
275 275
             $auth_line .= '",';
276 276
         }
277 277
 
278
-        $connect_line = 'ftp://' . $host;
279
-        if ( ! empty($port)) {
278
+        $connect_line = 'ftp://'.$host;
279
+        if (!empty($port)) {
280 280
             $connect_line .= ":{$port}";
281 281
         }
282
-        if ( ! empty($remout_dir)) {
282
+        if (!empty($remout_dir)) {
283 283
             $connect_line .= "$remout_dir";
284 284
         }
285 285
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public static function mkfs_disk($dev)
307 307
     {
308
-        if ( ! file_exists($dev)) {
308
+        if (!file_exists($dev)) {
309 309
             $dev = "/dev/{$dev}";
310 310
         }
311
-        if ( ! file_exists($dev)) {
311
+        if (!file_exists($dev)) {
312 312
             return false;
313 313
         }
314 314
         $dir = '';
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             Util::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0");
344 344
             Util::mwExec("{$umountPath} {$dir}");
345 345
         }
346
-        $result = ! self::isStorageDiskMounted($dir);
346
+        $result = !self::isStorageDiskMounted($dir);
347 347
         if ($result && file_exists($dir)) {
348 348
             // Если диск не смонтирован, то удаляем каталог.
349 349
             Util::mwExec("{$rmPath} -rf '{$dir}'");
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      */
414 414
     public static function statusMkfs($dev): string
415 415
     {
416
-        if ( ! file_exists($dev)) {
416
+        if (!file_exists($dev)) {
417 417
             $dev = "/dev/{$dev}";
418 418
         }
419 419
         $out      = [];
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
         if ($di === null) {
435 435
             return;
436 436
         }
437
-        $config         = $di->getShared('config');
437
+        $config = $di->getShared('config');
438 438
         $phpSessionDir = $config->path('www.phpSessionDir');
439
-        if ( ! empty($phpSessionDir)) {
439
+        if (!empty($phpSessionDir)) {
440 440
             $rmPath = Util::which('rm');
441 441
             Util::mwExec("{$rmPath} -rf {$phpSessionDir}/*");
442 442
         }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         // Создание больщого файла для тестов.
453 453
         // head -c 1500MB /dev/urandom > /storage/usbdisk1/big_file.mp3
454 454
         foreach ($hdd as $disk) {
455
-            if ($disk['sys_disk'] === true && ! self::isStorageDiskMounted("{$disk['id']}4")) {
455
+            if ($disk['sys_disk'] === true && !self::isStorageDiskMounted("{$disk['id']}4")) {
456 456
                 // Это системный диск (4ый раздел). Он не смонтирован.
457 457
                 continue;
458 458
             }
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
                 Util::restartPHPWorker(WorkerRemoveOldRecords::class);
477 477
             }
478 478
 
479
-            if ( ! $need_alert) {
479
+            if (!$need_alert) {
480 480
                 continue;
481 481
             }
482 482
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
                 $m_size      = round(($disk_data[1] + $disk_data[2]) / 1024, 1);
517 517
                 $res_disks[] = [
518 518
                     'id'         => $disk_data[0],
519
-                    'size'       => "" . $m_size,
520
-                    'size_text'  => "" . $m_size . " Mb",
519
+                    'size'       => "".$m_size,
520
+                    'size_text'  => "".$m_size." Mb",
521 521
                     'vendor'     => 'Debian',
522 522
                     'mounted'    => '/storage/usbdisk1',
523 523
                     'free_space' => round($disk_data[2] / 1024, 1),
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
         $disks = $this->diskGetDevices();
538 538
         $disks = array_unique($disks);
539 539
 
540
-        $cf_disk    = '';
540
+        $cf_disk = '';
541 541
         $varEtcDir = $this->config->path('core.varEtcDir');
542
-        if (file_exists($varEtcDir . '/cfdevice')) {
543
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
542
+        if (file_exists($varEtcDir.'/cfdevice')) {
543
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
544 544
         }
545 545
 
546 546
         foreach ($disks as $disk) {
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
             $sys_disk = ($cf_disk == $disk);
557 557
 
558 558
             $mb_size = 0;
559
-            if (is_file("/sys/block/" . $disk . "/size")) {
560
-                $original_size = trim(file_get_contents("/sys/block/" . $disk . "/size"));
559
+            if (is_file("/sys/block/".$disk."/size")) {
560
+                $original_size = trim(file_get_contents("/sys/block/".$disk."/size"));
561 561
                 $original_size = ($original_size * 512 / 1024 / 1024);
562 562
                 $mb_size       = $original_size;
563 563
             }
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
     private function getVendorDisk($disk): string
665 665
     {
666 666
         $temp_vendor = [];
667
-        if (is_file("/sys/block/" . $disk . "/device/vendor")) {
668
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/vendor"));
667
+        if (is_file("/sys/block/".$disk."/device/vendor")) {
668
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/vendor"));
669 669
             if ($data != '') {
670 670
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
671 671
             }
672 672
         }
673
-        if (is_file("/sys/block/" . $disk . "/device/model")) {
674
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/model"));
673
+        if (is_file("/sys/block/".$disk."/device/model")) {
674
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/model"));
675 675
             if ($data != '') {
676 676
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
677 677
             }
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
         if (count($temp_vendor) == 0) {
680 680
             $temp_vendor[] = $disk;
681 681
         }
682
-        if (is_file("/sys/block/" . $disk . "/device/type")) {
683
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/type"));
682
+        if (is_file("/sys/block/".$disk."/device/type")) {
683
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/type"));
684 684
             if ($data != '') {
685 685
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
686 686
             }
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         Util::mwExec("{$dfPath} -m | {$grepPath} {$hdd} | {$awkPath} '{print $4}'", $out);
707 707
         $result = 0;
708 708
         foreach ($out as $res) {
709
-            if ( ! is_numeric($res)) {
709
+            if (!is_numeric($res)) {
710 710
                 continue;
711 711
             }
712 712
             $result += (1 * $res);
@@ -743,19 +743,19 @@  discard block
 block discarded – undo
743 743
                 $path_size_info = $tmp_path;
744 744
             }
745 745
             if (empty($path_size_info)) {
746
-                $tmp_path = "/sys/block/" . substr($dev, 0, 3) . "/{$dev}/size";
746
+                $tmp_path = "/sys/block/".substr($dev, 0, 3)."/{$dev}/size";
747 747
                 if (file_exists($tmp_path)) {
748 748
                     $path_size_info = $tmp_path;
749 749
                 }
750 750
             }
751 751
 
752
-            if ( ! empty($path_size_info)) {
752
+            if (!empty($path_size_info)) {
753 753
                 $original_size = trim(file_get_contents($path_size_info));
754 754
                 $original_size = ($original_size * 512 / 1024 / 1024);
755 755
                 $mb_size       = $original_size;
756 756
             }
757 757
 
758
-            $tmp_dir = "/tmp/{$dev}_" . time();
758
+            $tmp_dir = "/tmp/{$dev}_".time();
759 759
             $out     = [];
760 760
 
761 761
             $fs           = null;
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
         }
813 813
         Util::mwMkdir($dir);
814 814
 
815
-        if ( ! file_exists($dir)) {
815
+        if (!file_exists($dir)) {
816 816
             Util::sysLogMsg('Storage', "Unable mount $dev $format to $dir. Unable create dir.");
817 817
 
818 818
             return false;
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
             Util::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out);
824 824
         } else {
825 825
             $storage   = new Storage();
826
-            $uid_part  = 'UUID=' . $storage->getUuid("/dev/{$dev}") . '';
826
+            $uid_part  = 'UUID='.$storage->getUuid("/dev/{$dev}").'';
827 827
             $mountPath = Util::which('mount');
828 828
             Util::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out);
829 829
         }
@@ -837,14 +837,14 @@  discard block
 block discarded – undo
837 837
     public function configure(): void
838 838
     {
839 839
         $cf_disk          = '';
840
-        $varEtcDir       = $this->config->path('core.varEtcDir');
840
+        $varEtcDir = $this->config->path('core.varEtcDir');
841 841
         $storage_dev_file = "{$varEtcDir}/storage_device";
842 842
         if (file_exists($storage_dev_file)) {
843 843
             unlink($storage_dev_file);
844 844
         }
845 845
 
846
-        if (file_exists($varEtcDir . '/cfdevice')) {
847
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
846
+        if (file_exists($varEtcDir.'/cfdevice')) {
847
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
848 848
         }
849 849
 
850 850
         $disks = $this->getDiskSettings();
@@ -858,18 +858,18 @@  discard block
 block discarded – undo
858 858
                 // Если это системный диск, то пытаемся подключить раздел 4.
859 859
                 $dev = "{$disk['device']}4";
860 860
             }
861
-            if ( ! $this->hddExists($dev)) {
861
+            if (!$this->hddExists($dev)) {
862 862
                 // Диск не существует.
863 863
                 continue;
864 864
             }
865
-            if ($disk['media'] === '1' || ! file_exists($storage_dev_file)) {
865
+            if ($disk['media'] === '1' || !file_exists($storage_dev_file)) {
866 866
                 file_put_contents($storage_dev_file, "/storage/usbdisk{$disk['id']}");
867 867
                 $this->updateConfigWithNewMountPoint("/storage/usbdisk{$disk['id']}");
868 868
             }
869 869
 
870
-            $str_uid     = 'UUID=' . $this->getUuid($dev) . '';
870
+            $str_uid     = 'UUID='.$this->getUuid($dev).'';
871 871
             $format_p4   = $this->getFsType($dev);
872
-            $conf        .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
872
+            $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
873 873
             $mount_point = "/storage/usbdisk{$disk['id']}";
874 874
             Util::mwMkdir($mount_point);
875 875
         }
@@ -965,11 +965,11 @@  discard block
 block discarded – undo
965 965
         Util::mwMkdir('/storage');
966 966
         $chmodPath = Util::which('chmod');
967 967
         Util::mwExec("{$chmodPath} 755 /storage");
968
-        if ( ! file_exists($varEtcDir . '/cfdevice')) {
968
+        if (!file_exists($varEtcDir.'/cfdevice')) {
969 969
             return;
970 970
         }
971 971
         $fstab     = '';
972
-        $file_data = file_get_contents($varEtcDir . '/cfdevice');
972
+        $file_data = file_get_contents($varEtcDir.'/cfdevice');
973 973
         $cf_disk   = trim($file_data);
974 974
         if ('' == $cf_disk) {
975 975
             return;
@@ -979,9 +979,9 @@  discard block
 block discarded – undo
979 979
         $part3 = (strpos($cf_disk, 'mmcblk') !== false) ? "{$cf_disk}p3" : "{$cf_disk}3"; // Conf
980 980
 
981 981
 
982
-        $uid_part2 = 'UUID=' . $this->getUuid("/dev/{$part2}") . '';
982
+        $uid_part2 = 'UUID='.$this->getUuid("/dev/{$part2}").'';
983 983
         $format_p2 = $this->getFsType($part2);
984
-        $uid_part3 = 'UUID=' . $this->getUuid("/dev/{$part3}") . '';
984
+        $uid_part3 = 'UUID='.$this->getUuid("/dev/{$part3}").'';
985 985
         $format_p3 = $this->getFsType($part3);
986 986
 
987 987
         // $fstab .= "/dev/{$part1} /cf msdos ro 1 1\n"; // НЕ МОНТИРУЕМ!
@@ -1026,24 +1026,24 @@  discard block
 block discarded – undo
1026 1026
             }
1027 1027
         }
1028 1028
 
1029
-        if ( ! empty($path)) {
1029
+        if (!empty($path)) {
1030 1030
             Util::mwMkdir($path);
1031 1031
         }
1032 1032
 
1033 1033
         $downloadCacheDir = appPath('sites/pbxcore/files/cache');
1034
-        if ( ! $isLiveCd ) {
1034
+        if (!$isLiveCd) {
1035 1035
             Util::mwMkdir($downloadCacheDir);
1036 1036
             Util::createUpdateSymlink($this->config->path('www.downloadCacheDir'), $downloadCacheDir);
1037 1037
         }
1038 1038
 
1039 1039
         $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache');
1040
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/js', $jsCacheDir);
1040
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/js', $jsCacheDir);
1041 1041
 
1042 1042
         $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache');
1043
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/css', $cssCacheDir);
1043
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/css', $cssCacheDir);
1044 1044
 
1045 1045
         $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
1046
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/img', $imgCacheDir);
1046
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/img', $imgCacheDir);
1047 1047
 
1048 1048
         Util::createUpdateSymlink($this->config->path('www.phpSessionDir'), '/var/lib/php/session');
1049 1049
         Util::createUpdateSymlink($this->config->path('www.uploadDir'), '/ultmp');
@@ -1076,13 +1076,13 @@  discard block
 block discarded – undo
1076 1076
         $cacheDirs   = [];
1077 1077
         $cacheDirs[] = $this->config->path('www.uploadDir');
1078 1078
         $cacheDirs[] = $this->config->path('www.downloadCacheDir');
1079
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js';
1080
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css';
1081
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img';
1079
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js';
1080
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css';
1081
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img';
1082 1082
         $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir');
1083 1083
         $rmPath      = Util::which('rm');
1084 1084
         foreach ($cacheDirs as $cacheDir) {
1085
-            if ( ! empty($cacheDir)) {
1085
+            if (!empty($cacheDir)) {
1086 1086
                 Util::mwExec("{$rmPath} -rf {$cacheDir}/*");
1087 1087
             }
1088 1088
         }
@@ -1133,12 +1133,12 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public function saveDiskSettings($data, $id = '1'): void
1135 1135
     {
1136
-        if ( ! is_array($data)) {
1136
+        if (!is_array($data)) {
1137 1137
             return;
1138 1138
         }
1139 1139
         $disk_data = $this->getDiskSettings($id);
1140 1140
         if (count($disk_data) === 0) {
1141
-            $uniqid           = strtoupper('STORAGE-DISK-' . md5(time()));
1141
+            $uniqid           = strtoupper('STORAGE-DISK-'.md5(time()));
1142 1142
             $storage_settings = new StorageModel();
1143 1143
             foreach ($data as $key => $val) {
1144 1144
                 $storage_settings->writeAttribute($key, $val);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -462,17 +462,17 @@
 block discarded – undo
462 462
             $test_alert = '';
463 463
             if ($free < 5) {
464 464
                 $need_alert = true;
465
-                $test_alert = "The {$disk['id']} has less than 5% of free space available.";
465
+                $test_alert = "the {$disk['id']} has less than 5% of free space available.";
466 466
             }
467 467
 
468 468
             if ($disk['free_space'] < 500) {
469 469
                 $need_alert = true;
470
-                $test_alert = "The {$disk['id']} has less than 500MB of free space available.";
470
+                $test_alert = "the {$disk['id']} has less than 500MB of free space available.";
471 471
             }
472 472
 
473 473
             if ($disk['free_space'] < 100) {
474 474
                 $need_alert = true;
475
-                $test_alert = "The {$disk['id']} has less than 100MB of free space available. Old call records will be deleted.";
475
+                $test_alert = "the {$disk['id']} has less than 100MB of free space available. Old call records will be deleted.";
476 476
                 Util::restartPHPWorker(WorkerRemoveOldRecords::class);
477 477
             }
478 478
 
Please login to merge, or discard this patch.
src/Core/System/Network.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         }
30 30
 
31 31
         Util::killByName('pcapsipdump');
32
-        $log_dir = System::getLogDir() . '/pcapsipdump';
32
+        $log_dir = System::getLogDir().'/pcapsipdump';
33 33
         Util::mwMkdir($log_dir);
34 34
 
35 35
         $network = new Network();
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         foreach ($arr_eth as $eth) {
39 39
             $pid_file = "/var/run/pcapsipdump_{$eth}.pid";
40 40
             Util::mwExecBg(
41
-                $pcapsipdumpPath.' -T 120 -P ' . $pid_file . ' -i ' . $eth . ' -m \'^(INVITE|REGISTER)$\' -L ' . $log_dir . '/dump.db'
41
+                $pcapsipdumpPath.' -T 120 -P '.$pid_file.' -i '.$eth.' -m \'^(INVITE|REGISTER)$\' -L '.$log_dir.'/dump.db'
42 42
             );
43 43
         }
44 44
     }
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
         /** @var \MikoPBX\Common\Models\LanInterfaces $res */
147 147
         $res = LanInterfaces::findFirst("internet = '1'");
148 148
         if (null !== $res) {
149
-            if ( ! empty($res->primarydns) && '127.0.0.1' != $res->primarydns) {
149
+            if (!empty($res->primarydns) && '127.0.0.1' != $res->primarydns) {
150 150
                 $dns[] = $res->primarydns;
151 151
             }
152
-            if ( ! empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) {
152
+            if (!empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) {
153 153
                 $dns[] = $res->secondarydns;
154 154
             }
155 155
         }
@@ -164,38 +164,38 @@  discard block
 block discarded – undo
164 164
      */
165 165
     private function generatePdnsdConfig($named_dns): void
166 166
     {
167
-        $tempDir  = $this->di->getShared('config')->path('core.tempDir');
168
-        $cache_dir = $tempDir . '/pdnsd/cache';
167
+        $tempDir = $this->di->getShared('config')->path('core.tempDir');
168
+        $cache_dir = $tempDir.'/pdnsd/cache';
169 169
         Util::mwMkdir($cache_dir);
170 170
 
171
-        $conf = 'global {' . "\n" .
172
-            '	perm_cache=10240;' . "\n" .
173
-            '	cache_dir="' . $cache_dir . '";' . "\n" .
174
-            '	pid_file = /var/run/pdnsd.pid;' . "\n" .
175
-            '	run_as="nobody";' . "\n" .
176
-            '	server_ip = 127.0.0.1;' . "\n" .
177
-            '	status_ctl = on;' . "\n" .
178
-            '	query_method=udp_tcp;' . "\n" .
179
-            '	min_ttl=15m;' . "\n" .
180
-            '	max_ttl=1w;' . "\n" .
181
-            '	timeout=10;' . "\n" .
182
-            '	neg_domain_pol=on;' . "\n" .
183
-            '	run_as=root;' . "\n" .
184
-            '	daemon=on;' . "\n" .
185
-            '}' . "\n" .
186
-            'server {' . "\n" .
187
-            '	label = "main";' . "\n" .
188
-            '	ip = ' . implode(', ', $named_dns) . ';' . "\n" .
189
-            '	interface=lo;' . "\n" .
190
-            '	uptest=if;' . "\n" .
191
-            '	interval=10m;' . "\n" .
192
-            '	purge_cache=off;' . "\n" .
171
+        $conf = 'global {'."\n".
172
+            '	perm_cache=10240;'."\n".
173
+            '	cache_dir="'.$cache_dir.'";'."\n".
174
+            '	pid_file = /var/run/pdnsd.pid;'."\n".
175
+            '	run_as="nobody";'."\n".
176
+            '	server_ip = 127.0.0.1;'."\n".
177
+            '	status_ctl = on;'."\n".
178
+            '	query_method=udp_tcp;'."\n".
179
+            '	min_ttl=15m;'."\n".
180
+            '	max_ttl=1w;'."\n".
181
+            '	timeout=10;'."\n".
182
+            '	neg_domain_pol=on;'."\n".
183
+            '	run_as=root;'."\n".
184
+            '	daemon=on;'."\n".
185
+            '}'."\n".
186
+            'server {'."\n".
187
+            '	label = "main";'."\n".
188
+            '	ip = '.implode(', ', $named_dns).';'."\n".
189
+            '	interface=lo;'."\n".
190
+            '	uptest=if;'."\n".
191
+            '	interval=10m;'."\n".
192
+            '	purge_cache=off;'."\n".
193 193
             '}';
194 194
         file_put_contents('/etc/pdnsd.conf', $conf);
195 195
 
196 196
         $pdnsdPath = Util::which('pdnsd');
197 197
         $pid = Util::getPidOfProcess($pdnsdPath);
198
-        if ( ! empty($pid)) {
198
+        if (!empty($pid)) {
199 199
             // Завершаем процесс.
200 200
             $busyboxPath = Util::which('busybox');
201 201
             Util::mwExec("{$busyboxPath} kill '$pid'");
@@ -211,19 +211,19 @@  discard block
 block discarded – undo
211 211
     /**
212 212
      * Настройка OpenVPN. Если в кастомизации системных файлов определн конфиг, то сеть поднимется.
213 213
      */
214
-    public function openVpnConfigure(){
215
-        $confFile='/etc/openvpn.ovpn';
214
+    public function openVpnConfigure() {
215
+        $confFile = '/etc/openvpn.ovpn';
216 216
         Util::fileWriteContent($confFile, '');
217 217
         $data = file_get_contents($confFile);
218 218
 
219 219
         $pidFile = '/var/run/openvpn.pid';
220 220
         $pid = Util::getPidOfProcess('openvpn');
221
-        if ( ! empty($pid)) {
221
+        if (!empty($pid)) {
222 222
             // Завершаем процесс.
223 223
             $busyboxPath = Util::which('busybox');
224 224
             Util::mwExec("{$busyboxPath} kill '$pid'");
225 225
         }
226
-        if(!empty($data)){
226
+        if (!empty($data)) {
227 227
             $openvpnPath = Util::which('openvpn');
228 228
             Util::mwExecBg("{$openvpnPath} --config /etc/openvpn.ovpn --writepid {$pidFile}", '/dev/null', 5);
229 229
         }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                  */
285 285
                 $pid_file = "/var/run/udhcpc_{$if_name}";
286 286
                 $pid_pcc  = Util::getPidOfProcess($pid_file);
287
-                if ( ! empty($pid_pcc)) {
287
+                if (!empty($pid_pcc)) {
288 288
                     // Завершаем старый процесс.
289 289
                     $killPath = Util::which('kill');
290 290
                     $catPath = Util::which('cat');
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 
413 413
             $result = [''];
414 414
             if (file_exists('/etc/static-routes')) {
415
-                $command = "{$catPath} /etc/static-routes " .
416
-                    "| {$grepPath} '^rout' " .
417
-                    "| {$busyboxPath} awk -F ';' '{print $1}' " .
418
-                    "| {$grepPath} '{$if_name}\$' " .
415
+                $command = "{$catPath} /etc/static-routes ".
416
+                    "| {$grepPath} '^rout' ".
417
+                    "| {$busyboxPath} awk -F ';' '{print $1}' ".
418
+                    "| {$grepPath} '{$if_name}\$' ".
419 419
                     "| {$awkPath} -F 'dev {$if_name}' '{ print $1 }'";
420 420
                 Util::mwExec($command, $result);
421 421
             }
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
 
426 426
             if ($if_data['vlanid'] > 0) {
427 427
                 // Пока только статика.
428
-                $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n" .
429
-                    "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n" .
430
-                    "address {$ipaddr}\n" .
431
-                    "netmask {$subnet}\n" .
432
-                    "gateway {$gateway}\n" .
433
-                    "dns-nameservers 127.0.0.1\n" .
434
-                    "vlan_raw_device {$if_data['interface_orign']}\n" .
435
-                    "{$routs_add}\n" .
428
+                $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n".
429
+                    "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n".
430
+                    "address {$ipaddr}\n".
431
+                    "netmask {$subnet}\n".
432
+                    "gateway {$gateway}\n".
433
+                    "dns-nameservers 127.0.0.1\n".
434
+                    "vlan_raw_device {$if_data['interface_orign']}\n".
435
+                    "{$routs_add}\n".
436 436
                     "{$routs_rem}\n";
437 437
             } elseif (trim($if_data['dhcp']) === '1') {
438
-                $lan_config = "auto {$if_name}\n" .
439
-                    "iface {$if_name} inet dhcp\n" .
440
-                    "{$routs_add}\n" .
438
+                $lan_config = "auto {$if_name}\n".
439
+                    "iface {$if_name} inet dhcp\n".
440
+                    "{$routs_add}\n".
441 441
                     "{$routs_rem}\n";
442 442
             } else {
443 443
                 if (empty($ipaddr)) {
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
                     echo "Caught exception: $ipaddr $subnet", $e->getMessage(), "\n";
451 451
                     continue;
452 452
                 }
453
-                $lan_config = "auto {$if_name}\n" .
454
-                    "iface {$if_name} inet static\n" .
455
-                    "address {$ipaddr}\n" .
456
-                    "netmask {$subnet}\n" .
457
-                    "gateway {$gateway}\n" .
458
-                    "dns-nameservers 127.0.0.1\n" .
459
-                    "{$routs_add}\n" .
453
+                $lan_config = "auto {$if_name}\n".
454
+                    "iface {$if_name} inet static\n".
455
+                    "address {$ipaddr}\n".
456
+                    "netmask {$subnet}\n".
457
+                    "gateway {$gateway}\n".
458
+                    "dns-nameservers 127.0.0.1\n".
459
+                    "{$routs_add}\n".
460 460
                     "{$routs_rem}\n";
461 461
             }
462 462
             file_put_contents("/etc/network/interfaces.d/{$if_name}", $lan_config);
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     {
811 811
         /** @var \MikoPBX\Common\Models\LanInterfaces $res */
812 812
         $res = LanInterfaces::findFirst("interface = '$name' AND vlanid=0");
813
-        if ($res === null){
813
+        if ($res === null) {
814 814
             return;
815 815
         }
816 816
         foreach ($data as $key => $value) {
@@ -829,15 +829,15 @@  discard block
 block discarded – undo
829 829
     {
830 830
         /** @var \MikoPBX\Common\Models\LanInterfaces $res */
831 831
         $res = LanInterfaces::findFirst("interface = '$name' AND vlanid=0");
832
-        if ($res === null){
832
+        if ($res === null) {
833 833
             return;
834 834
         }
835
-        if (empty($res->primarydns) && ! empty($data['primarydns'])) {
835
+        if (empty($res->primarydns) && !empty($data['primarydns'])) {
836 836
             $res->writeAttribute('primarydns', $data['primarydns']);
837 837
         } elseif (empty($res->secondarydns) && $res->primarydns !== $data['primarydns']) {
838 838
             $res->writeAttribute('secondarydns', $data['primarydns']);
839 839
         }
840
-        if (empty($res->secondarydns) && ! empty($data['secondarydns'])) {
840
+        if (empty($res->secondarydns) && !empty($data['secondarydns'])) {
841 841
             $res->writeAttribute('secondarydns', $data['secondarydns']);
842 842
         }
843 843
         $res->save();
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     public function getInterfaceNameById($id_net): string
854 854
     {
855 855
         /** @var \MikoPBX\Common\Models\LanInterfaces $res */
856
-        $res            = LanInterfaces::findFirst("id = '$id_net'");
856
+        $res = LanInterfaces::findFirst("id = '$id_net'");
857 857
         return ($res === null) ? '' : $res->interface;
858 858
     }
859 859
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
     {
878 878
         // Настройка по умолчанию.
879 879
         $interface = trim(getenv('interface'));
880
-        if ( ! Util::isSystemctl()) {
880
+        if (!Util::isSystemctl()) {
881 881
             // Для MIKO LFS Edition.
882 882
             $busyboxPath = Util::which('busybox');
883 883
             Util::mwExec("{$busyboxPath} ifconfig $interface 192.168.2.1 netmask 255.255.255.0");
@@ -998,15 +998,15 @@  discard block
 block discarded – undo
998 998
     public function hostnameConfigure(): int
999 999
     {
1000 1000
         $data       = Network::getHostName();
1001
-        $hosts_conf = "127.0.0.1 localhost\n" .
1001
+        $hosts_conf = "127.0.0.1 localhost\n".
1002 1002
             "127.0.0.1 {$data['hostname']}\n";
1003
-        if ( ! empty($data['domain'])) {
1003
+        if (!empty($data['domain'])) {
1004 1004
             $hosts_conf .= "127.0.0.1 {$data['hostname']}.{$data['domain']}\n";
1005 1005
         }
1006 1006
         Util::fileWriteContent('/etc/hosts', $hosts_conf);
1007 1007
 
1008 1008
         $hostnamePath = Util::which('hostname');
1009
-        return Util::mwExec($hostnamePath.' '. escapeshellarg("{$data['hostname']}"));
1009
+        return Util::mwExec($hostnamePath.' '.escapeshellarg("{$data['hostname']}"));
1010 1010
     }
1011 1011
 
1012 1012
 }
Please login to merge, or discard this patch.
src/Core/System/Configs/NatsConf.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public static function logRotate(): void
35 35
     {
36
-        $log_dir = System::getLogDir() . '/nats';
36
+        $log_dir = System::getLogDir().'/nats';
37 37
         $gnatsdPath = Util::which('gnatsd');
38 38
         $pid     = Util::getPidOfProcess($gnatsdPath, 'custom_modules');
39 39
         $max_size = 1;
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
         if (Util::mFileSize("{$log_dir}/gnatsd.log") > $mb10) {
63 63
             $options = '-f';
64 64
         }
65
-        $di     = Di::getDefault();
66
-        if ($di !== null){
65
+        $di = Di::getDefault();
66
+        if ($di !== null) {
67 67
             $varEtcDir = $di->getConfig()->path('core.varEtcDir');
68 68
         } else {
69 69
             $varEtcDir = '/var/etc';
70 70
         }
71
-        $path_conf  = $varEtcDir . '/gnatsd_logrotate.conf';
71
+        $path_conf = $varEtcDir.'/gnatsd_logrotate.conf';
72 72
         file_put_contents($path_conf, $text_config);
73 73
         if (file_exists("{$log_dir}/gnatsd.log")) {
74 74
             $logrotatePath = Util::which('logrotate');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $confdir = '/etc/nats';
85 85
         Util::mwMkdir($confdir);
86
-        $logdir = System::getLogDir() . '/nats';
86
+        $logdir = System::getLogDir().'/nats';
87 87
         Util::mwMkdir($logdir);
88 88
 
89 89
         $pid_file = '/var/run/gnatsd.pid';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             'sessions_path'    => $logdir,
101 101
             'log_file'         => "{$logdir}/gnatsd.log",
102 102
         ];
103
-        $config   = '';
103
+        $config = '';
104 104
         foreach ($settings as $key => $val) {
105 105
             $config .= "{$key}: {$val} \n";
106 106
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         Util::fileWriteContent($conf_file, $config);
109 109
 
110 110
         $lic = $this->mikoPBXConfig->getGeneralSettings('PBXLicense');
111
-        file_put_contents($logdir . '/license.key', $lic);
111
+        file_put_contents($logdir.'/license.key', $lic);
112 112
 
113 113
         if (file_exists($pid_file)) {
114 114
             $killPath = Util::which('kill');
Please login to merge, or discard this patch.
src/Core/System/Configs/NginxConf.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public function reStart(): void
38 38
     {
39 39
 
40
-        $NginxPath  = Util::which('nginx');
40
+        $NginxPath = Util::which('nginx');
41 41
         $pid = Util::getPidOfProcess($NginxPath);
42 42
         if (!empty($pid)) {
43 43
             Util::mwExec("{$NginxPath} -s reload");
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
         $RedirectToHttps = $this->mikoPBXConfig->getGeneralSettings('RedirectToHttps');
84 84
         if ($RedirectToHttps === '1' && $not_ssl === false) {
85
-            $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {' . PHP_EOL
86
-                . '        ' . 'return 301 https://$host:' . $WEBHTTPSPort . '$request_uri;' . PHP_EOL
87
-                . '       }' . PHP_EOL;
85
+            $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {'.PHP_EOL
86
+                . '        '.'return 301 https://$host:'.$WEBHTTPSPort.'$request_uri;'.PHP_EOL
87
+                . '       }'.PHP_EOL;
88 88
             $config    = str_replace('include mikopbx/locations/*.conf;', $conf_data, $config);
89 89
         }
90 90
         file_put_contents($httpConfigFile, $config);
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
         $WEBHTTPSPrivateKey = $this->mikoPBXConfig->getGeneralSettings('WEBHTTPSPrivateKey');
95 95
         if (
96 96
             $not_ssl === false
97
-            && ! empty($WEBHTTPSPublicKey)
98
-            && ! empty($WEBHTTPSPrivateKey)
97
+            && !empty($WEBHTTPSPublicKey)
98
+            && !empty($WEBHTTPSPrivateKey)
99 99
         ) {
100 100
             $public_filename  = '/etc/ssl/certs/nginx.crt';
101 101
             $private_filename = '/etc/ssl/private/nginx.key';
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         foreach ($additionalModules as $appClass) {
127 127
             if (method_exists($appClass, 'createNginxLocations')) {
128 128
                 $locationContent = $appClass->createNginxLocations();
129
-                if ( ! empty($locationContent)) {
129
+                if (!empty($locationContent)) {
130 130
                     $confFileName = "{$locationsPath}/{$appClass->moduleUniqueId}.conf";
131 131
                     file_put_contents($confFileName, $locationContent);
132 132
                     $out = [];
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                     $res = implode($out);
135 135
                     if (false !== strpos($res, 'test failed')) {
136 136
                         Util::mwExec("{$rmPath} {$confFileName}");
137
-                        Util::sysLogMsg('nginx', 'Failed test config file for module' . $appClass->moduleUniqueId);
137
+                        Util::sysLogMsg('nginx', 'Failed test config file for module'.$appClass->moduleUniqueId);
138 138
                     }
139 139
                 }
140 140
             }
Please login to merge, or discard this patch.
src/Core/System/Configs/PHPConf.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $src_log_file = '/var/log/php_error.log';
28 28
         $dst_log_file = self::getLogFile();
29
-        if ( ! file_exists($src_log_file)) {
29
+        if (!file_exists($src_log_file)) {
30 30
             file_put_contents($src_log_file, '');
31 31
         }
32 32
         $options = file_exists($dst_log_file) ? '>' : '';
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public static function getLogFile(): string
44 44
     {
45
-        $logdir = System::getLogDir() . '/php';
45
+        $logdir = System::getLogDir().'/php';
46 46
         Util::mwMkdir($logdir);
47 47
         return "$logdir/error.log";
48 48
     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         $max_size    = 2;
58 58
         $f_name      = self::getLogFile();
59
-        $text_config = $f_name . " {
59
+        $text_config = $f_name." {
60 60
     nocreate
61 61
     nocopytruncate
62 62
     delaycompress
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
     endscript
71 71
 }";
72 72
         // TODO::Доделать рестарт PHP-FPM после обновление лога
73
-        $di     = Di::getDefault();
74
-        if ($di !== null){
73
+        $di = Di::getDefault();
74
+        if ($di !== null) {
75 75
             $varEtcDir = $di->getConfig()->path('core.varEtcDir');
76 76
         } else {
77 77
             $varEtcDir = '/var/etc';
78 78
         }
79
-        $path_conf   = $varEtcDir . '/php_logrotate_' . basename($f_name) . '.conf';
79
+        $path_conf = $varEtcDir.'/php_logrotate_'.basename($f_name).'.conf';
80 80
         file_put_contents($path_conf, $text_config);
81 81
         $mb10 = $max_size * 1024 * 1024;
82 82
 
Please login to merge, or discard this patch.
src/Core/System/PBX.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             return;
91 91
         }
92 92
         $max_size    = 2;
93
-        $log_dir     = System::getLogDir() . '/asterisk/';
93
+        $log_dir     = System::getLogDir().'/asterisk/';
94 94
         $text_config = "{$log_dir}{$f_name} {
95 95
     nocreate
96 96
     nocopytruncate
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
         {$asteriskPath} -rx 'logger reload' > /dev/null 2> /dev/null
106 106
     endscript
107 107
 }";
108
-        $varEtcDir  = $di->getShared('config')->path('core.varEtcDir');
109
-        $path_conf   = $varEtcDir . '/asterisk_logrotate_' . $f_name . '.conf';
108
+        $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
109
+        $path_conf = $varEtcDir.'/asterisk_logrotate_'.$f_name.'.conf';
110 110
         file_put_contents($path_conf, $text_config);
111 111
         $mb10 = $max_size * 1024 * 1024;
112 112
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
     public static function checkCodec($name, $desc, $type): void
204 204
     {
205
-        $codec = Codecs::findFirst('name="' . $name . '"');
205
+        $codec = Codecs::findFirst('name="'.$name.'"');
206 206
         if ($codec === null) {
207 207
             /** @var \MikoPBX\Common\Models\Codecs $codec_g722 */
208 208
             $codec              = new Codecs();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public static function sipReload():void
220 220
     {
221
-        $di     = Di::getDefault();
221
+        $di = Di::getDefault();
222 222
         if ($di === null) {
223 223
             return;
224 224
         }
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
                 $exthostname = trim($if_data['exthostname']);
240 240
             }
241 241
         }
242
-        $old_hash   = '';
242
+        $old_hash = '';
243 243
         $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
244
-        if (file_exists($varEtcDir . '/topology_hash')) {
245
-            $old_hash = file_get_contents($varEtcDir . '/topology_hash');
244
+        if (file_exists($varEtcDir.'/topology_hash')) {
245
+            $old_hash = file_get_contents($varEtcDir.'/topology_hash');
246 246
         }
247
-        $now_hadh = md5($topology . $exthostname . $extipaddr);
247
+        $now_hadh = md5($topology.$exthostname.$extipaddr);
248 248
 
249 249
         $sip = new SIPConf();
250 250
         $sip->generateConfig();
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public static function iaxReload(): void
273 273
     {
274
-        $iax    = new IAXConf();
274
+        $iax = new IAXConf();
275 275
         $iax->generateConfig();
276 276
         $asteriskPath = Util::which('asterisk');
277 277
         Util::mwExec("{$asteriskPath} -rx 'iax2 reload'");
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             'result' => 'ERROR',
323 323
         ];
324 324
 
325
-        if ( ! $this->di->getShared('registry')->booting) {
325
+        if (!$this->di->getShared('registry')->booting) {
326 326
             $this->stop();
327 327
         }
328 328
         /**
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         // Создание базы данных истории звонков.
339 339
         /** @var \Phalcon\Db\Adapter\Pdo\Sqlite $connection */
340 340
         $connection = $this->di->get('dbCDR');
341
-        if ( ! $connection->tableExists('cdr')) {
341
+        if (!$connection->tableExists('cdr')) {
342 342
             RegisterDIServices::recreateDBConnections();
343 343
         } else {
344 344
             CdrDb::checkDb();
Please login to merge, or discard this patch.