Passed
Push — master ( 6427d5...5783a1 )
by Nikolay
13:52 queued 05:42
created
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
         }
@@ -165,39 +165,39 @@  discard block
 block discarded – undo
165 165
     public function generatePdnsdConfig($named_dns): void
166 166
     {
167 167
         $tempDir   = $this->di->getShared('config')->path('core.tempDir');
168
-        $cache_dir = $tempDir . '/pdnsd/cache';
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
 
195
-        $pdnsdConfFile  = '/etc/pdnsd.conf';
195
+        $pdnsdConfFile = '/etc/pdnsd.conf';
196 196
         $savedConf = '';
197
-        if(file_exists($pdnsdConfFile)){
197
+        if (file_exists($pdnsdConfFile)) {
198 198
             $savedConf = file_get_contents($pdnsdConfFile);
199 199
         }
200
-        if($savedConf != $conf){
200
+        if ($savedConf != $conf) {
201 201
             file_put_contents($pdnsdConfFile, $conf);
202 202
         }
203 203
         $pdnsdPath = Util::which('pdnsd');
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         if (!empty($pid) && $savedConf === $conf) {
206 206
             // Выполним дополнительную проверку, работает ли сервер.
207 207
             $resultResolve = gethostbynamel('lic.miko.ru');
208
-            if($resultResolve !== false){
208
+            if ($resultResolve !== false) {
209 209
                 // Ничего делать не нужно. Конфиг не изменился. Рестарт не требуется.
210 210
                 return;
211 211
             }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                  */
283 283
                 $pid_file = "/var/run/udhcpc_{$if_name}";
284 284
                 $pid_pcc  = Util::getPidOfProcess($pid_file);
285
-                if ( ! empty($pid_pcc) && file_exists($pid_file)) {
285
+                if (!empty($pid_pcc) && file_exists($pid_file)) {
286 286
                     // Завершаем старый процесс.
287 287
                     $killPath = Util::which('kill');
288 288
                     $catPath  = Util::which('cat');
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
 
412 412
             $result = [''];
413 413
             if (file_exists('/etc/static-routes')) {
414
-                $command = "{$catPath} /etc/static-routes " .
415
-                    "| {$grepPath} '^rout' " .
416
-                    "| {$busyboxPath} awk -F ';' '{print $1}' " .
417
-                    "| {$grepPath} '{$if_name}\$' " .
414
+                $command = "{$catPath} /etc/static-routes ".
415
+                    "| {$grepPath} '^rout' ".
416
+                    "| {$busyboxPath} awk -F ';' '{print $1}' ".
417
+                    "| {$grepPath} '{$if_name}\$' ".
418 418
                     "| {$awkPath} -F 'dev {$if_name}' '{ print $1 }'";
419 419
                 Util::mwExec($command, $result);
420 420
             }
@@ -424,19 +424,19 @@  discard block
 block discarded – undo
424 424
 
425 425
             if ($if_data['vlanid'] > 0) {
426 426
                 // Пока только статика.
427
-                $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n" .
428
-                    "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n" .
429
-                    "address {$ipaddr}\n" .
430
-                    "netmask {$subnet}\n" .
431
-                    "gateway {$gateway}\n" .
432
-                    "dns-nameservers 127.0.0.1\n" .
433
-                    "vlan_raw_device {$if_data['interface_orign']}\n" .
434
-                    "{$routs_add}\n" .
427
+                $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n".
428
+                    "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n".
429
+                    "address {$ipaddr}\n".
430
+                    "netmask {$subnet}\n".
431
+                    "gateway {$gateway}\n".
432
+                    "dns-nameservers 127.0.0.1\n".
433
+                    "vlan_raw_device {$if_data['interface_orign']}\n".
434
+                    "{$routs_add}\n".
435 435
                     "{$routs_rem}\n";
436 436
             } elseif (trim($if_data['dhcp']) === '1') {
437
-                $lan_config = "auto {$if_name}\n" .
438
-                    "iface {$if_name} inet dhcp\n" .
439
-                    "{$routs_add}\n" .
437
+                $lan_config = "auto {$if_name}\n".
438
+                    "iface {$if_name} inet dhcp\n".
439
+                    "{$routs_add}\n".
440 440
                     "{$routs_rem}\n";
441 441
             } else {
442 442
                 if (empty($ipaddr)) {
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
                     echo "Caught exception: $ipaddr $subnet", $e->getMessage(), "\n";
450 450
                     continue;
451 451
                 }
452
-                $lan_config = "auto {$if_name}\n" .
453
-                    "iface {$if_name} inet static\n" .
454
-                    "address {$ipaddr}\n" .
455
-                    "netmask {$subnet}\n" .
456
-                    "gateway {$gateway}\n" .
457
-                    "dns-nameservers 127.0.0.1\n" .
458
-                    "{$routs_add}\n" .
452
+                $lan_config = "auto {$if_name}\n".
453
+                    "iface {$if_name} inet static\n".
454
+                    "address {$ipaddr}\n".
455
+                    "netmask {$subnet}\n".
456
+                    "gateway {$gateway}\n".
457
+                    "dns-nameservers 127.0.0.1\n".
458
+                    "{$routs_add}\n".
459 459
                     "{$routs_rem}\n";
460 460
             }
461 461
             file_put_contents("/etc/network/interfaces.d/{$if_name}", $lan_config);
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         $net_mask = explode(".", $net_mask);
547 547
 
548 548
         foreach ($net_mask as $oct_ect) {
549
-            $bits += strlen(str_replace("0", "", decbin((int)$oct_ect)));
549
+            $bits += strlen(str_replace("0", "", decbin((int) $oct_ect)));
550 550
         }
551 551
 
552 552
         return $bits;
@@ -603,13 +603,13 @@  discard block
 block discarded – undo
603 603
         $data->name      = $name;
604 604
         $data->interface = $name;
605 605
         $data->dhcp      = '1';
606
-        $data->internet  = ($general === true) ? '1' : '0';;
606
+        $data->internet  = ($general === true) ? '1' : '0'; ;
607 607
         $data->disabled  = '0';
608 608
         $data->vlanid    = '0';
609 609
         $data->hostname  = 'mikopbx';
610 610
         $data->domain    = '';
611 611
         $data->topology  = 'private';
612
-        $data->primarydns= '';
612
+        $data->primarydns = '';
613 613
         $data->save();
614 614
 
615 615
         return $data->toArray();
@@ -630,15 +630,15 @@  discard block
 block discarded – undo
630 630
     public function hostnameConfigure(): void
631 631
     {
632 632
         $data       = Network::getHostName();
633
-        $hosts_conf = "127.0.0.1 localhost\n" .
633
+        $hosts_conf = "127.0.0.1 localhost\n".
634 634
             "127.0.0.1 {$data['hostname']}\n";
635
-        if ( ! empty($data['domain'])) {
635
+        if (!empty($data['domain'])) {
636 636
             $hosts_conf .= "127.0.0.1 {$data['hostname']}.{$data['domain']}\n";
637 637
         }
638 638
         Util::fileWriteContent('/etc/hosts', $hosts_conf);
639 639
 
640 640
         $hostnamePath = Util::which('hostname');
641
-        Util::mwExec($hostnamePath . ' ' . escapeshellarg("{$data['hostname']}"));
641
+        Util::mwExec($hostnamePath.' '.escapeshellarg("{$data['hostname']}"));
642 642
     }
643 643
 
644 644
     /**
@@ -652,12 +652,12 @@  discard block
 block discarded – undo
652 652
 
653 653
         $pidFile = '/var/run/openvpn.pid';
654 654
         $pid     = Util::getPidOfProcess('openvpn');
655
-        if ( ! empty($pid)) {
655
+        if (!empty($pid)) {
656 656
             // Завершаем процесс.
657 657
             $busyboxPath = Util::which('busybox');
658 658
             Util::mwExec("{$busyboxPath} kill '$pid'");
659 659
         }
660
-        if ( ! empty($data)) {
660
+        if (!empty($data)) {
661 661
             $openvpnPath = Util::which('openvpn');
662 662
             Util::mwExecBg("{$openvpnPath} --config /etc/openvpn.ovpn --writepid {$pidFile}", '/dev/null', 5);
663 663
         }
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
         if ($res === null) {
868 868
             return;
869 869
         }
870
-        if (empty($res->primarydns) && ! empty($data['primarydns'])) {
870
+        if (empty($res->primarydns) && !empty($data['primarydns'])) {
871 871
             $res->writeAttribute('primarydns', $data['primarydns']);
872 872
         } elseif (empty($res->secondarydns) && $res->primarydns !== $data['primarydns']) {
873 873
             $res->writeAttribute('secondarydns', $data['primarydns']);
874 874
         }
875
-        if (empty($res->secondarydns) && ! empty($data['secondarydns'])) {
875
+        if (empty($res->secondarydns) && !empty($data['secondarydns'])) {
876 876
             $res->writeAttribute('secondarydns', $data['secondarydns']);
877 877
         }
878 878
         $res->save();
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
     {
916 916
         // Настройка по умолчанию.
917 917
         $interface = trim(getenv('interface'));
918
-        if ( ! Util::isSystemctl()) {
918
+        if (!Util::isSystemctl()) {
919 919
             // Для MIKO LFS Edition.
920 920
             $busyboxPath = Util::which('busybox');
921 921
             Util::mwExec("{$busyboxPath} ifconfig $interface 192.168.2.1 netmask 255.255.255.0");
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/FilesManagementProcessor.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
         }
91 91
         $parameters['uploadDir'] = $di->getShared('config')->path('www.uploadDir');
92 92
         $parameters['tempDir']   = "{$parameters['uploadDir']}/{$parameters['resumableIdentifier']}";
93
-        if ( ! Util::mwMkdir($parameters['tempDir'])) {
94
-            $res->messages[] = 'Temp dir does not exist ' . $parameters['tempDir'];
93
+        if (!Util::mwMkdir($parameters['tempDir'])) {
94
+            $res->messages[] = 'Temp dir does not exist '.$parameters['tempDir'];
95 95
 
96 96
             return $res;
97 97
         }
98 98
 
99 99
         $fileName                           = pathinfo($parameters['resumableFilename'], PATHINFO_FILENAME);
100
-        $fileName                           = preg_replace( '/[\W]/', '', $fileName);
101
-        if (strlen($fileName)<10){
100
+        $fileName                           = preg_replace('/[\W]/', '', $fileName);
101
+        if (strlen($fileName) < 10) {
102 102
             $fileName = ''.md5(time()).'-'.$fileName;
103 103
         }
104
-        $fileName                           .= '.'.pathinfo($parameters['resumableFilename'], PATHINFO_EXTENSION);
104
+        $fileName .= '.'.pathinfo($parameters['resumableFilename'], PATHINFO_EXTENSION);
105 105
         $parameters['resumableFilename']    = $fileName;
106 106
         $parameters['fullUploadedFileName'] = "{$parameters['tempDir']}/{$fileName}";
107 107
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
         foreach ($parameters['files'] as $file_data) {
118
-            if ( ! self::moveUploadedPartToSeparateDir($parameters, $file_data)) {
119
-                $res->messages[] = 'Does not found any uploaded chunks on with path ' . $file_data['file_path'];
118
+            if (!self::moveUploadedPartToSeparateDir($parameters, $file_data)) {
119
+                $res->messages[] = 'Does not found any uploaded chunks on with path '.$file_data['file_path'];
120 120
 
121 121
                 return $res;
122 122
             }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     private static function moveUploadedPartToSeparateDir(array $parameters, array $file_data): bool
146 146
     {
147
-        if ( ! file_exists($file_data['file_path'])) {
147
+        if (!file_exists($file_data['file_path'])) {
148 148
             return false;
149 149
         }
150 150
         $factory          = new StreamFactory();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     {
178 178
         $totalFilesOnServerSize = 0;
179 179
         foreach (scandir($parameters['tempDir']) as $file) {
180
-            $totalFilesOnServerSize += filesize($parameters['tempDir'] . '/' . $file);
180
+            $totalFilesOnServerSize += filesize($parameters['tempDir'].'/'.$file);
181 181
         }
182 182
 
183 183
         if ($totalFilesOnServerSize >= $parameters['resumableTotalSize']) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 'resumableTotalSize'   => $parameters['resumableTotalSize'],
190 190
                 'resumableTotalChunks' => $parameters['resumableTotalChunks'],
191 191
             ];
192
-            $settings_file  = "{$parameters['tempDir']}/merge_settings";
192
+            $settings_file = "{$parameters['tempDir']}/merge_settings";
193 193
             file_put_contents(
194 194
                 $settings_file,
195 195
                 json_encode($merge_settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
         $uploadDir = $di->getShared('config')->path('www.uploadDir');
227 227
 
228 228
         $upload_id     = $postData['id'] ?? null;
229
-        $progress_dir  = $uploadDir . '/' . $upload_id;
230
-        $progress_file = $progress_dir . '/merging_progress';
229
+        $progress_dir  = $uploadDir.'/'.$upload_id;
230
+        $progress_file = $progress_dir.'/merging_progress';
231 231
         if (empty($upload_id)) {
232 232
             $res->success                   = false;
233 233
             $res->data['d_status_progress'] = '0';
234 234
             $res->data['d_status']          = 'ID_NOT_SET';
235 235
             $res->messages[]                = 'Upload ID does not set';
236
-        } elseif ( ! file_exists($progress_file) && file_exists($progress_dir)) {
236
+        } elseif (!file_exists($progress_file) && file_exists($progress_dir)) {
237 237
             $res->success                   = true;
238 238
             $res->data['d_status_progress'] = '0';
239 239
             $res->data['d_status']          = 'INPROGRESS';
240
-        } elseif ( ! file_exists($progress_dir)) {
240
+        } elseif (!file_exists($progress_dir)) {
241 241
             $res->success                   = false;
242 242
             $res->data['d_status_progress'] = '0';
243 243
             $res->data['d_status']          = 'NOT_FOUND';
244
-            $res->messages[]                = 'Does not found anything with path: ' . $progress_dir;
244
+            $res->messages[]                = 'Does not found anything with path: '.$progress_dir;
245 245
         } elseif ('100' === file_get_contents($progress_file)) {
246 246
             $res->success                   = true;
247 247
             $res->data['d_status_progress'] = '100';
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
         $res            = new PBXApiResult();
268 268
         $res->processor = __METHOD__;
269 269
         $extension      = Util::getExtensionOfFile($filePath);
270
-        if ( ! in_array($extension, ['mp3', 'wav', 'alaw'])) {
270
+        if (!in_array($extension, ['mp3', 'wav', 'alaw'])) {
271 271
             $res->success    = false;
272 272
             $res->messages[] = "It is forbidden to remove the file type $extension.";
273 273
 
274 274
             return $res;
275 275
         }
276 276
 
277
-        if ( ! file_exists($filePath)) {
277
+        if (!file_exists($filePath)) {
278 278
             $res->success         = true;
279 279
             $res->data['message'] = "File '{$filePath}' already deleted";
280 280
 
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
         $out = [];
285 285
 
286 286
         $arrDeletedFiles = [
287
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".wav"),
288
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".mp3"),
289
-            escapeshellarg(Util::trimExtensionForFile($filePath) . ".alaw"),
287
+            escapeshellarg(Util::trimExtensionForFile($filePath).".wav"),
288
+            escapeshellarg(Util::trimExtensionForFile($filePath).".mp3"),
289
+            escapeshellarg(Util::trimExtensionForFile($filePath).".alaw"),
290 290
         ];
291 291
 
292 292
         $rmPath = Util::which('rm');
293
-        Util::mwExec("{$rmPath} -rf " . implode(' ', $arrDeletedFiles), $out);
293
+        Util::mwExec("{$rmPath} -rf ".implode(' ', $arrDeletedFiles), $out);
294 294
         if (file_exists($filePath)) {
295 295
             $res->success  = false;
296 296
             $res->messages = $out;
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
             $cat          = Util::which('cat');
324 324
             $di           = Di::getDefault();
325 325
             $dirsConfig   = $di->getShared('config');
326
-            $filenameTmp  = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.conf';
326
+            $filenameTmp  = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.conf';
327 327
             $cmd          = "{$cat} {$filename} > {$filenameTmp}";
328 328
             Util::mwExec("{$cmd}; chown www:www {$filenameTmp}");
329 329
             $res->data['filename'] = $filenameTmp;
330 330
         } else {
331 331
             $res->success    = false;
332
-            $res->messages[] = 'No access to the file ' . $filename;
332
+            $res->messages[] = 'No access to the file '.$filename;
333 333
         }
334 334
 
335 335
         return $res;
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         $res->success   = true;
399 399
 
400 400
         $firmwareDirTmp = dirname($imgFileName);
401
-        $progress_file  = $firmwareDirTmp . '/progress';
401
+        $progress_file  = $firmwareDirTmp.'/progress';
402 402
 
403 403
         // Wait until download process started
404 404
         $d_pid = Util::getPidOfProcess("{$firmwareDirTmp}/download_settings.json");
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
             $error = trim(file_get_contents("{$firmwareDirTmp}/error"));
411 411
         }
412 412
 
413
-        if ( ! file_exists($progress_file)) {
413
+        if (!file_exists($progress_file)) {
414 414
             $res->data['d_status_progress'] = '0';
415 415
             $res->messages[]                = 'NOT_FOUND';
416 416
             $res->success                   = false;
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
         } else {
515 515
             $tempDir = '/tmp';
516 516
         }
517
-        $moduleDirTmp  = $tempDir . '/' . $moduleUniqueID;
518
-        $progress_file = $moduleDirTmp . '/progress';
517
+        $moduleDirTmp  = $tempDir.'/'.$moduleUniqueID;
518
+        $progress_file = $moduleDirTmp.'/progress';
519 519
         $error         = '';
520
-        if (file_exists($moduleDirTmp . '/error')) {
521
-            $error = trim(file_get_contents($moduleDirTmp . '/error'));
520
+        if (file_exists($moduleDirTmp.'/error')) {
521
+            $error = trim(file_get_contents($moduleDirTmp.'/error'));
522 522
         }
523 523
 
524 524
         // Wait until download process started
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             usleep(500000);
528 528
         }
529 529
 
530
-        if ( ! file_exists($progress_file)) {
530
+        if (!file_exists($progress_file)) {
531 531
             $res->data['d_status_progress'] = '0';
532 532
             $res->data['d_status']          = 'NOT_FOUND';
533 533
             $res->success                   = false;
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
             $res->data['d_status']          = 'DOWNLOAD_ERROR';
536 536
             $res->data['d_status_progress'] = file_get_contents($progress_file);
537 537
             $res->data['d_error']           = $error;
538
-            $res->messages[]                = file_get_contents($moduleDirTmp . '/error');
538
+            $res->messages[]                = file_get_contents($moduleDirTmp.'/error');
539 539
             $res->success                   = false;
540 540
         } elseif ('100' === file_get_contents($progress_file)) {
541 541
             $res->data['d_status_progress'] = '100';
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
             $res->success                   = true;
545 545
         } else {
546 546
             $res->data['d_status_progress'] = file_get_contents($progress_file);
547
-            $d_pid                          = Util::getPidOfProcess($moduleDirTmp . '/download_settings.json');
547
+            $d_pid                          = Util::getPidOfProcess($moduleDirTmp.'/download_settings.json');
548 548
             if (empty($d_pid)) {
549 549
                 $res->data['d_status'] = 'DOWNLOAD_ERROR';
550
-                if (file_exists($moduleDirTmp . '/error')) {
551
-                    $res->messages[] = file_get_contents($moduleDirTmp . '/error');
550
+                if (file_exists($moduleDirTmp.'/error')) {
551
+                    $res->messages[] = file_get_contents($moduleDirTmp.'/error');
552 552
                 } else {
553 553
                     $res->messages[] = "Download process interrupted at {$res->data['d_status_progress']}%";
554 554
                 }
@@ -579,13 +579,13 @@  discard block
 block discarded – undo
579 579
             $grepPath    = Util::which('grep');
580 580
             $echoPath    = Util::which('echo');
581 581
             $awkPath     = Util::which('awk');
582
-            $cmd         = 'f="' . $filePath . '"; p=`' . $sevenZaPath . ' l $f | ' . $grepPath . ' module.json`;if [ "$?" == "0" ]; then ' . $sevenZaPath . ' -so e -y -r $f `' . $echoPath . ' $p |  ' . $awkPath . ' -F" " \'{print $6}\'`; fi';
582
+            $cmd         = 'f="'.$filePath.'"; p=`'.$sevenZaPath.' l $f | '.$grepPath.' module.json`;if [ "$?" == "0" ]; then '.$sevenZaPath.' -so e -y -r $f `'.$echoPath.' $p |  '.$awkPath.' -F" " \'{print $6}\'`; fi';
583 583
 
584 584
             Util::mwExec($cmd, $out);
585 585
             $settings = json_decode(implode("\n", $out), true);
586 586
 
587 587
             $moduleUniqueID = $settings['moduleUniqueID'] ?? null;
588
-            if ( ! $moduleUniqueID) {
588
+            if (!$moduleUniqueID) {
589 589
                 $res->messages[] = 'The" moduleUniqueID " in the module file is not described.the json or file does not exist.';
590 590
 
591 591
                 return $res;
Please login to merge, or discard this patch.
src/Modules/Setup/PbxExtensionSetupBase.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
         $this->messages = [];
115 115
         $this->db      = $this->di->getShared('db');
116 116
         $this->config  = $this->di->getShared('config');
117
-        $this->license =  $this->di->getShared('license');
118
-        $this->moduleDir = $this->config->path('core.modulesDir') . '/' . $this->moduleUniqueID;
117
+        $this->license = $this->di->getShared('license');
118
+        $this->moduleDir = $this->config->path('core.modulesDir').'/'.$this->moduleUniqueID;
119 119
         $settings_file = "{$this->moduleDir}/module.json";
120 120
         if (file_exists($settings_file)) {
121 121
             $module_settings = json_decode(file_get_contents($settings_file), true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             }
140 140
         }
141 141
 
142
-        $this->messages  = [];
142
+        $this->messages = [];
143 143
 
144 144
 
145 145
     }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
     {
155 155
         $result = true;
156 156
         try {
157
-            if ( ! $this->activateLicense()) {
157
+            if (!$this->activateLicense()) {
158 158
                 $this->messages[] = 'License activate error';
159 159
                 $result           = false;
160 160
             }
161
-            if ( ! $this->installFiles()) {
161
+            if (!$this->installFiles()) {
162 162
                 $this->messages[] = ' installFiles error';
163 163
                 $result           = false;
164 164
             }
165
-            if ( ! $this->installDB()) {
165
+            if (!$this->installDB()) {
166 166
                 $this->messages[] = ' installDB error';
167 167
                 $result           = false;
168 168
             }
169 169
             $this->fixFilesRights();
170 170
         } catch (\Exception $exception) {
171
-            $result         = false;
171
+            $result = false;
172 172
             $this->messages[] = $exception->getMessage();
173 173
         }
174 174
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         PbxExtensionUtils::createAgiBinSymlinks($this->moduleUniqueID);
200 200
 
201 201
         // Restore database settings
202
-        $modulesDir          = $this->config->path('core.modulesDir');
202
+        $modulesDir = $this->config->path('core.modulesDir');
203 203
         $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}";
204 204
         if (is_dir($backupPath)) {
205 205
             $cpPath = Util::which('cp');
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
             "{$this->moduleDir}/bin"
223 223
         ];
224 224
         foreach ($dirs as $dir) {
225
-            if(file_exists($dir) && is_dir($dir)){
225
+            if (file_exists($dir) && is_dir($dir)) {
226 226
                 // Add executable right to module's binary
227 227
                 Util::addExecutableRights($dir);
228 228
             }
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
     {
258 258
         $result = true;
259 259
         try {
260
-            if ( ! $this->unInstallDB($keepSettings)) {
260
+            if (!$this->unInstallDB($keepSettings)) {
261 261
                 $this->messages[] = ' unInstallDB error';
262 262
                 $result           = false;
263 263
             }
264
-            if ($result && ! $this->unInstallFiles($keepSettings)) {
264
+            if ($result && !$this->unInstallFiles($keepSettings)) {
265 265
                 $this->messages[] = ' unInstallFiles error';
266 266
                 $result           = false;
267 267
             }
268 268
         } catch (\Exception $exception) {
269
-            $result         = false;
269
+            $result = false;
270 270
             $this->messages[] = $exception->getMessage();
271 271
         }
272 272
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     {
315 315
         $cpPath = Util::which('cp');
316 316
         $rmPath = Util::which('rm');
317
-        $modulesDir          = $this->config->path('core.modulesDir');
317
+        $modulesDir = $this->config->path('core.modulesDir');
318 318
         $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}";
319 319
         Util::mwExec("{$rmPath} -rf {$backupPath}");
320 320
         if ($keepSettings) {
@@ -327,21 +327,21 @@  discard block
 block discarded – undo
327 327
         // IMG
328 328
         $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
329 329
         $moduleImageCacheDir = "{$imgCacheDir}/{$this->moduleUniqueID}";
330
-        if (file_exists($moduleImageCacheDir)){
330
+        if (file_exists($moduleImageCacheDir)) {
331 331
             unlink($moduleImageCacheDir);
332 332
         }
333 333
 
334 334
         // CSS
335 335
         $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache');
336 336
         $moduleCSSCacheDir = "{$cssCacheDir}/{$this->moduleUniqueID}";
337
-        if (file_exists($moduleCSSCacheDir)){
337
+        if (file_exists($moduleCSSCacheDir)) {
338 338
             unlink($moduleCSSCacheDir);
339 339
         }
340 340
 
341 341
         // JS
342 342
         $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache');
343 343
         $moduleJSCacheDir = "{$jsCacheDir}/{$this->moduleUniqueID}";
344
-        if (file_exists($moduleJSCacheDir)){
344
+        if (file_exists($moduleJSCacheDir)) {
345 345
             unlink($moduleJSCacheDir);
346 346
         }
347 347
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         }
376 376
 
377 377
         $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID);
378
-        if ( ! $module) {
378
+        if (!$module) {
379 379
             $module           = new PbxExtensionModules();
380 380
             $module->name     = $this->locString("Breadcrumb{$this->moduleUniqueID}");
381 381
             $module->disabled = '1';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $language             = substr(PbxSettings::getValueByKey('WebAdminLanguage'), 0, 2);
402 402
         $translates           = [];
403 403
         $extensionsTranslates = [[]];
404
-        $results              = glob($this->moduleDir . '/{Messages}/en.php', GLOB_BRACE);
404
+        $results              = glob($this->moduleDir.'/{Messages}/en.php', GLOB_BRACE);
405 405
         foreach ($results as $path) {
406 406
             $langArr = require $path;
407 407
             if (is_array($langArr)) {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
         }
414 414
         if ($language !== 'en') {
415 415
             $additionalTranslates = [[]];
416
-            $results              = glob($this->moduleDir . "/{Messages}/{$language}.php", GLOB_BRACE);
416
+            $results              = glob($this->moduleDir."/{Messages}/{$language}.php", GLOB_BRACE);
417 417
             foreach ($results as $path) {
418 418
                 $langArr = require $path;
419 419
                 if (is_array($langArr)) {
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
         // Add new connection for this module after add new Models folder
445 445
         RegisterDIServices::recreateModulesDBConnections();
446 446
 
447
-        $results = glob($this->moduleDir . '/Models/*.php', GLOB_NOSORT);
447
+        $results = glob($this->moduleDir.'/Models/*.php', GLOB_NOSORT);
448 448
         $dbUpgrade = new UpdateDatabase();
449 449
         foreach ($results as $file) {
450 450
             $className        = pathinfo($file)['filename'];
451 451
             $moduleModelClass = "\\Modules\\{$this->moduleUniqueID}\\Models\\{$className}";
452 452
             $upgradeResult = $dbUpgrade->createUpdateDbTableByAnnotations($moduleModelClass);
453
-            if (!$upgradeResult){
453
+            if (!$upgradeResult) {
454 454
                 return false;
455 455
             }
456 456
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
             $menuSettings      = new PbxSettings();
477 477
             $menuSettings->key = $menuSettingsKey;
478 478
         }
479
-        $value               = [
479
+        $value = [
480 480
             'uniqid'        => $this->moduleUniqueID,
481 481
             'href'          => "/admin-cabinet/{$unCamelizedControllerName}",
482 482
             'group'         => 'modules',
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
         $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID);
378 378
         if ( ! $module) {
379 379
             $module           = new PbxExtensionModules();
380
-            $module->name     = $this->locString("Breadcrumb{$this->moduleUniqueID}");
380
+            $module->name     = $this->locString("breadcrumb{$this->moduleUniqueID}");
381 381
             $module->disabled = '1';
382 382
         }
383 383
         $module->uniqid        = $this->moduleUniqueID;
384 384
         $module->developer     = $this->developer;
385 385
         $module->version       = $this->version;
386
-        $module->description   = $this->locString("SubHeader{$this->moduleUniqueID}");
386
+        $module->description   = $this->locString("subheader{$this->moduleUniqueID}");
387 387
         $module->support_email = $this->support_email;
388 388
 
389 389
         return $module->save();
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      */
470 470
     public function addToSidebar(): bool
471 471
     {
472
-        $menuSettingsKey           = "AdditionalMenuItem{$this->moduleUniqueID}";
472
+        $menuSettingsKey           = "additionalmenuitem{$this->moduleUniqueID}";
473 473
         $unCamelizedControllerName = Text::uncamelize($this->moduleUniqueID, '-');
474 474
         $menuSettings              = PbxSettings::findFirstByKey($menuSettingsKey);
475 475
         if ($menuSettings === null) {
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             'href'          => "/admin-cabinet/{$unCamelizedControllerName}",
482 482
             'group'         => 'modules',
483 483
             'iconClass'     => 'puzzle',
484
-            'caption'       => "Breadcrumb{$this->moduleUniqueID}",
484
+            'caption'       => "breadcrumb{$this->moduleUniqueID}",
485 485
             'showAtSidebar' => true,
486 486
         ];
487 487
         $menuSettings->value = json_encode($value);
Please login to merge, or discard this patch.
src/Core/System/PBX.php 1 patch
Spacing   +9 added lines, -9 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
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             Util::mwExec("{$asteriskPath} -rx 'module reload acl'");
235 235
             Util::mwExec("{$asteriskPath} -rx 'core reload'");
236 236
         } else {
237
-            Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk',LOG_INFO, LOG_INFO);
237
+            Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk', LOG_INFO, LOG_INFO);
238 238
             // Завершаем каналы.
239 239
             Util::mwExec("{$asteriskPath} -rx 'channel request hangup all'");
240 240
             usleep(500000);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function iaxReload(): void
249 249
     {
250
-        $iax    = new IAXConf();
250
+        $iax = new IAXConf();
251 251
         $iax->generateConfig();
252 252
         $asteriskPath = Util::which('asterisk');
253 253
         Util::mwExec("{$asteriskPath} -rx 'iax2 reload'");
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             'result' => 'ERROR',
305 305
         ];
306 306
 
307
-        if ( ! $this->di->getShared('registry')->booting) {
307
+        if (!$this->di->getShared('registry')->booting) {
308 308
             $this->stop();
309 309
         }
310 310
         /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         // Создание базы данных истории звонков.
321 321
         /** @var \Phalcon\Db\Adapter\Pdo\Sqlite $connection */
322 322
         $connection = $this->di->get('dbCDR');
323
-        if ( ! $connection->tableExists('cdr')) {
323
+        if (!$connection->tableExists('cdr')) {
324 324
             RegisterDIServices::recreateDBConnections();
325 325
         } else {
326 326
             CdrDb::checkDb();
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/SIPConf.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
         $conf .= $this->generateProvidersPj();
56 56
         $conf .= $this->generatePeersPj();
57 57
 
58
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
58
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
59 59
         $pjConf = '[log_mappings]'."\n".
60 60
             'type=log_mappings'."\n".
61 61
             'asterisk_error = 0'."\n".
62 62
             'asterisk_warning = 2'."\n".
63 63
             'asterisk_debug = 1,3,4,5,6'."\n\n";
64 64
 
65
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf);
66
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
65
+        file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf);
66
+        file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
67 67
 
68 68
         $db = new AstDB();
69 69
         foreach ($this->data_peers as $peer) {
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function generateGeneralPj(): string
86 86
     {
87
-        $lang    = $this->generalSettings['PBXLanguage'];
87
+        $lang = $this->generalSettings['PBXLanguage'];
88 88
         [$topology, $extipaddr, $exthostname, $subnets] = $this->getTopologyData();
89 89
 
90 90
         $codecs = $this->getCodecs();
91 91
         $codecConf = '';
92
-        foreach ($codecs as $codec){
93
-            $codecConf.= "allow = {$codec}\n";
92
+        foreach ($codecs as $codec) {
93
+            $codecConf .= "allow = {$codec}\n";
94 94
         }
95 95
 
96 96
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
             foreach ($subnets as $net) {
100 100
                 $natConf .= "local_net={$net}\n";
101 101
             }
102
-            if ( ! empty($exthostname)) {
102
+            if (!empty($exthostname)) {
103 103
                 $parts = explode(':', $exthostname);
104
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
105
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
106
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
107
-            } elseif ( ! empty($extipaddr)) {
104
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
105
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
106
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
107
+            } elseif (!empty($extipaddr)) {
108 108
                 $parts = explode(':', $extipaddr);
109
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
110
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
111
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
109
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
110
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
111
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
112 112
             }
113 113
         }
114 114
 
115
-        $conf = "[general] \n" .
116
-            "disable_multi_domain=on\n" .
117
-            "transport = udp \n\n" .
115
+        $conf = "[general] \n".
116
+            "disable_multi_domain=on\n".
117
+            "transport = udp \n\n".
118 118
 
119
-            "[global] \n" .
120
-            "type = global\n" .
121
-            "endpoint_identifier_order=username,ip,anonymous\n" .
122
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
119
+            "[global] \n".
120
+            "type = global\n".
121
+            "endpoint_identifier_order=username,ip,anonymous\n".
122
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
123 123
 
124
-            "[anonymous]\n" .
125
-            "type = endpoint\n" .
124
+            "[anonymous]\n".
125
+            "type = endpoint\n".
126 126
             $codecConf.
127 127
             "language={$lang}\n".
128
-            "timers = no\n" .
128
+            "timers = no\n".
129 129
             "context = public-direct-dial\n\n".
130 130
 
131
-            "[transport-udp]\n" .
132
-            "type = transport\n" .
133
-            "protocol = udp\n" .
131
+            "[transport-udp]\n".
132
+            "type = transport\n".
133
+            "protocol = udp\n".
134 134
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
135 135
             "{$natConf}\n\n".
136 136
 
137
-            "[transport-tcp]\n" .
138
-            "type = transport\n" .
139
-            "protocol = tcp\n" .
137
+            "[transport-tcp]\n".
138
+            "type = transport\n".
139
+            "protocol = tcp\n".
140 140
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
141 141
             "{$natConf}\n\n".
142 142
             '';
143 143
 
144 144
         $varEtcDir = $this->config->path('core.varEtcDir');
145
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr. $this->generalSettings['SIPPort']));
145
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr.$this->generalSettings['SIPPort']));
146 146
         $conf .= "\n";
147 147
 
148 148
         return $conf;
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
      * @return bool
155 155
      */
156 156
     public function needAsteriskRestart():bool{
157
-        $di     = Di::getDefault();
157
+        $di = Di::getDefault();
158 158
         if ($di === null) {
159 159
             return false;
160 160
         }
161
-        $mikoPBXConfig  = new MikoPBXConfig();
161
+        $mikoPBXConfig = new MikoPBXConfig();
162 162
         [$topology, $extipaddr, $exthostname] = $this->getTopologyData();
163 163
 
164 164
         $generalSettings = $mikoPBXConfig->getGeneralSettings();
165
-        $now_hadh = md5($topology . $exthostname . $extipaddr. $generalSettings['SIPPort']);
166
-        $old_hash   = '';
165
+        $now_hadh = md5($topology.$exthostname.$extipaddr.$generalSettings['SIPPort']);
166
+        $old_hash = '';
167 167
         $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
168
-        if (file_exists($varEtcDir . '/topology_hash')) {
169
-            $old_hash = file_get_contents($varEtcDir . '/topology_hash');
168
+        if (file_exists($varEtcDir.'/topology_hash')) {
169
+            $old_hash = file_get_contents($varEtcDir.'/topology_hash');
170 170
         }
171 171
 
172 172
         return $old_hash !== $now_hadh;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 continue;
190 190
             }
191 191
             $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
192
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
192
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
193 193
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
194 194
                 $subnets[] = $net;
195 195
             }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $conf        = '';
228 228
         $reg_strings = '';
229 229
         $prov_config = '';
230
-        if ($this->data_providers===null){
230
+        if ($this->data_providers === null) {
231 231
             $this->getSettings();
232 232
         }
233 233
         foreach ($this->data_providers as $provider) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
             $need_register = $provider['noregister'] !== '1';
238 238
             if ($need_register) {
239
-                $options     = [
239
+                $options = [
240 240
                     'type'     => 'auth',
241 241
                     'username' => $provider['username'],
242 242
                     'password' => $provider['secret'],
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n";
245 245
                 $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth');
246 246
 
247
-                $options     = [
247
+                $options = [
248 248
                     'type'                        => 'registration',
249 249
                     // 'transport'                   => 'transport-udp',
250 250
                     'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             }
263 263
 
264 264
             if ('1' !== $provider['receive_calls_without_auth']) {
265
-                $options     = [
265
+                $options = [
266 266
                     'type'     => 'auth',
267 267
                     'username' => $provider['username'],
268 268
                     'password' => $provider['secret'],
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             }
273 273
 
274 274
             $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
275
-            if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
275
+            if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
276 276
                 $contact = "sip:$defaultuser@{$provider['host']}:{$port}";
277 277
             } else {
278 278
                 $contact = "sip:{$provider['host']}:{$port}";
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                 'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
287 287
                 'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
288 288
             ];
289
-            if($provider['qualify'] === '1'){
289
+            if ($provider['qualify'] === '1') {
290 290
                 $options['qualify_frequency'] = $provider['qualifyfreq'];
291 291
                 $options['qualify_timeout']   = '3.0';
292 292
             }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             $prov_config .= "[{$provider['uniqid']}]\n";
295 295
             $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor');
296 296
 
297
-            $options     = [
297
+            $options = [
298 298
                 'type'     => 'identify',
299 299
                 'endpoint' => $provider['uniqid'],
300 300
                 'match'    => $provider['host'],
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public function generatePeersPj(): string
357 357
     {
358
-        if ($this->data_peers===null){
358
+        if ($this->data_peers === null) {
359 359
             $this->getSettings();
360 360
         }
361 361
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             $language = (trim($language) === '') ? 'en-en' : $language;
370 370
 
371 371
             $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
372
-            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
372
+            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
373 373
 
374 374
             $options = [
375 375
                 'type'     => 'auth',
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             'conditions'=>'disabled="0"',
522 522
             'order' => 'type, priority',
523 523
         ];
524
-        $codecs     = Codecs::find($filter);
524
+        $codecs = Codecs::find($filter);
525 525
         foreach ($codecs as $codec_data) {
526 526
             $arr_codecs[] = $codec_data->name;
527 527
         }
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
             // Получим используемые кодеки.
552 552
             $arr_data['codecs'] = $this->getCodecs();
553 553
 
554
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
555
-            if ( ! isset($this->contexts_data[$context_id])) {
554
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
555
+            if (!isset($this->contexts_data[$context_id])) {
556 556
                 $this->contexts_data[$context_id] = [];
557 557
             }
558 558
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
      */
572 572
     private function getOutRoutes(): array
573 573
     {
574
-        if ($this->data_peers===null){
574
+        if ($this->data_peers === null) {
575 575
             $this->getSettings();
576 576
         }
577 577
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      */
607 607
     public function extensionGenContexts(): string
608 608
     {
609
-        if ($this->data_peers===null){
609
+        if ($this->data_peers === null) {
610 610
             $this->getSettings();
611 611
         }
612 612
         // Генерация внутреннего номерного плана.
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
             $contexts_data = $this->contexts_data[$provider['context_id']];
625 625
             if (count($contexts_data) === 1) {
626 626
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
627
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
628
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
627
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
628
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
629 629
                     $contexts_data,
630 630
                     null,
631 631
                     $provider['context_id']
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
      */
645 645
     public function extensionGenHints(): string
646 646
     {
647
-        if ($this->data_peers===null){
647
+        if ($this->data_peers === null) {
648 648
             $this->getSettings();
649 649
         }
650 650
         $conf = '';
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
     public function extensionGenInternal(): string
659 659
     {
660
-        if ($this->data_peers===null){
660
+        if ($this->data_peers === null) {
661 661
             $this->getSettings();
662 662
         }
663 663
         // Генерация внутреннего номерного плана.
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 
673 673
     public function extensionGenInternalTransfer(): string
674 674
     {
675
-        if ($this->data_peers===null){
675
+        if ($this->data_peers === null) {
676 676
             $this->getSettings();
677 677
         }
678 678
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCdr.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public const SELECT_CDR_TUBE = 'select_cdr_tube';
25 25
     public const UPDATE_CDR_TUBE = 'update_cdr_tube';
26
-    protected int $maxProc=1;
26
+    protected int $maxProc = 1;
27 27
 
28 28
 
29 29
     private BeanstalkClient $client_queue;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
         $result = json_decode($result_data, true);
94 94
         if (file_exists($result)) {
95 95
             $file_data = json_decode(file_get_contents($result), true);
96
-            if(!is_dir($result)){
96
+            if (!is_dir($result)) {
97 97
                 Util::mwExec("rm -rf {$result}");
98 98
             }
99 99
             $result = $file_data;
100 100
         }
101
-        if ( ! is_array($result) && ! is_object($result)) {
101
+        if (!is_array($result) && !is_object($result)) {
102 102
             return;
103 103
         }
104 104
         if (count($result) < 1) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             if (trim($row['recordingfile']) !== '') {
116 116
                 // Если каналов не существует с ID, то можно удалить временные файлы.
117 117
                 $p_info = pathinfo($row['recordingfile']);
118
-                $fname  = $p_info['dirname'] . '/' . $p_info['filename'] . '.wav';
118
+                $fname  = $p_info['dirname'].'/'.$p_info['filename'].'.wav';
119 119
                 if (file_exists($fname) && !is_dir($fname)) {
120 120
                     Util::mwExec("rm -rf {$fname}");
121 121
                 }
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
                 $row['answer'] = '';
140 140
                 $billsec       = 0;
141 141
 
142
-                if ( ! empty($row['recordingfile'])) {
142
+                if (!empty($row['recordingfile'])) {
143 143
                     $p_info    = pathinfo($row['recordingfile']);
144 144
                     $file_list = [
145
-                        $p_info['dirname'] . '/' . $p_info['filename'] . '.mp3',
146
-                        $p_info['dirname'] . '/' . $p_info['filename'] . '.wav',
147
-                        $p_info['dirname'] . '/' . $p_info['filename'] . '_in.wav',
148
-                        $p_info['dirname'] . '/' . $p_info['filename'] . '_out.wav',
145
+                        $p_info['dirname'].'/'.$p_info['filename'].'.mp3',
146
+                        $p_info['dirname'].'/'.$p_info['filename'].'.wav',
147
+                        $p_info['dirname'].'/'.$p_info['filename'].'_in.wav',
148
+                        $p_info['dirname'].'/'.$p_info['filename'].'_out.wav',
149 149
                     ];
150 150
                     foreach ($file_list as $file) {
151
-                        if ( ! file_exists($file)) {
151
+                        if (!file_exists($file)) {
152 152
                             continue;
153 153
                         }
154
-                        if(!is_dir($file)){
154
+                        if (!is_dir($file)) {
155 155
                             Util::mwExec("rm -rf {$file}");
156 156
                         }
157 157
                     }
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
                 if (file_exists($row['recordingfile']) && !is_dir($row['recordingfile'])) {
163 163
                     Util::mwExec("rm -rf {$row['recordingfile']}");
164 164
                 }
165
-            } elseif (  ! empty($row['recordingfile']) &&
166
-                        ! file_exists(Util::trimExtensionForFile($row['recordingfile']) . 'wav') &&
167
-                        ! file_exists( $row['recordingfile']) ) {
165
+            } elseif (!empty($row['recordingfile']) &&
166
+                        !file_exists(Util::trimExtensionForFile($row['recordingfile']).'wav') &&
167
+                        !file_exists($row['recordingfile'])) {
168 168
                 /** @var CallDetailRecordsTmp $rec_data */
169 169
                 $rec_data = CallDetailRecordsTmp::findFirst(
170 170
                     "linkedid='{$row['linkedid']}' AND dst_chan='{$row['dst_chan']}'"
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     private function getActiveIdChannels(): array
215 215
     {
216
-        $am           = Util::getAstManager('off');
216
+        $am = Util::getAstManager('off');
217 217
         return $am->GetChannels(true);
218 218
     }
219 219
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             $this->no_answered_calls[$row['linkedid']]['NOANSWER'] = false;
229 229
             return;
230 230
         }
231
-        if ( ! array_key_exists($row['dst_num'], $this->internal_numbers)) {
231
+        if (!array_key_exists($row['dst_num'], $this->internal_numbers)) {
232 232
             // dst_num - не является номером сотрудника. Это исходящий.
233 233
             return;
234 234
         }
Please login to merge, or discard this patch.
src/Core/System/BeanstalkClient.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __construct($tube = 'default', $port = '')
38 38
     {
39
-        $this->tube        = str_replace("\\", '-', $tube);;
39
+        $this->tube        = str_replace("\\", '-', $tube); ;
40 40
         $this->job_options = ['priority' => 250, 'delay' => 0, 'ttr' => 3600];
41 41
         $this->port = $port;
42 42
         $this->reconnect();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $config = $this->di->get('config')->beanstalk;
51 51
         $port   = $config->port;
52
-        if(!empty($this->port) && is_numeric($this->port)){
52
+        if (!empty($this->port) && is_numeric($this->port)) {
53 53
             $port = $this->port;
54 54
         }
55 55
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $tube = str_replace("\\", '-', $tube);
128 128
         // Change tube
129
-        if ( ! empty($tube) && $this->tube !== $tube) {
129
+        if (!empty($tube) && $this->tube !== $tube) {
130 130
             $this->queue->useTube($tube);
131 131
         }
132 132
         $job_data = serialize($job_data);
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
         }
179 179
 
180 180
         // Processing job over callable function attached in $this->subscribe
181
-        if(json_decode($job->getData(), true) !==null){
182
-            $mData =  $job->getData();
183
-        }else{
181
+        if (json_decode($job->getData(), true) !== null) {
182
+            $mData = $job->getData();
183
+        } else {
184 184
             $mData = unserialize($job->getData(), [false]);
185 185
         }
186 186
         $this->message = $mData;
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
         try {
199 199
             $this->queue->delete($job);
200
-        }catch (\Pheanstalk\Exception\JobNotFoundException $e){
200
+        } catch (\Pheanstalk\Exception\JobNotFoundException $e) {
201 201
             // Игнорируем ошибку, задачи не существует, нечего удалять.
202
-        }catch (\Error $e){
202
+        } catch (\Error $e) {
203 203
             // Аналогично, нечего удалять.
204 204
             // Если задача и не удалена, то это будет исправлено позже при очистке.
205 205
         }
@@ -266,28 +266,28 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Drops orphaned tasks
268 268
      */
269
-    public function cleanTube(){
269
+    public function cleanTube() {
270 270
         $tubes = $this->queue->listTubes();
271
-        foreach ($tubes as $tube){
272
-            if(strpos($tube, "INBOX_") !== 0){
271
+        foreach ($tubes as $tube) {
272
+            if (strpos($tube, "INBOX_") !== 0) {
273 273
                 continue;
274 274
             }
275 275
             try {
276 276
                 $statData = $this->queue->statsTube($tube)->getArrayCopy();
277 277
                 $watching = $statData['current-watching'];
278
-                if($watching !== '0'){
278
+                if ($watching !== '0') {
279 279
                     continue;
280 280
                 }
281 281
                 // Нужно удалить все Jobs.
282 282
                 $this->queue->watch($tube);
283
-                while (true){
283
+                while (true) {
284 284
                     $job = $this->queue->reserveWithTimeout(1);
285
-                    if($job === null){
285
+                    if ($job === null) {
286 286
                         break;
287 287
                     }
288 288
                     $this->queue->delete($job);
289 289
                 }
290
-            }catch (\Exception $e){
290
+            } catch (\Exception $e) {
291 291
                 continue;
292 292
             }
293 293
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
         $job_data,
84 84
         int $timeout = 10,
85 85
         int $priority = PheanstalkInterface::DEFAULT_PRIORITY
86
-    )
87
-    {
86
+    ) {
88 87
         $this->message = false;
89 88
         $inbox_tube    = uniqid('INBOX_', true);
90 89
         $this->queue->watch($inbox_tube);
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
         // Processing job over callable function attached in $this->subscribe
181 180
         if(json_decode($job->getData(), true) !==null){
182 181
             $mData =  $job->getData();
183
-        }else{
182
+        } else{
184 183
             $mData = unserialize($job->getData(), [false]);
185 184
         }
186 185
         $this->message = $mData;
@@ -197,9 +196,9 @@  discard block
 block discarded – undo
197 196
 
198 197
         try {
199 198
             $this->queue->delete($job);
200
-        }catch (\Pheanstalk\Exception\JobNotFoundException $e){
199
+        } catch (\Pheanstalk\Exception\JobNotFoundException $e){
201 200
             // Игнорируем ошибку, задачи не существует, нечего удалять.
202
-        }catch (\Error $e){
201
+        } catch (\Error $e){
203 202
             // Аналогично, нечего удалять.
204 203
             // Если задача и не удалена, то это будет исправлено позже при очистке.
205 204
         }
@@ -266,7 +265,8 @@  discard block
 block discarded – undo
266 265
     /**
267 266
      * Drops orphaned tasks
268 267
      */
269
-    public function cleanTube(){
268
+    public function cleanTube()
269
+    {
270 270
         $tubes = $this->queue->listTubes();
271 271
         foreach ($tubes as $tube){
272 272
             if(strpos($tube, "INBOX_") !== 0){
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                     }
288 288
                     $this->queue->delete($job);
289 289
                 }
290
-            }catch (\Exception $e){
290
+            } catch (\Exception $e){
291 291
                 continue;
292 292
             }
293 293
 
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/FeaturesConf.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
     protected function generateConfigProtected(): void
21 21
     {
22
-        $conf             = "[general]\n" .
23
-            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n" .
24
-            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n" .
25
-            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n" .
26
-            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n" .
27
-            "atxferabort = *0\n" .
28
-            "\n" .
29
-            "[featuremap]\n" .
30
-            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n" .
31
-            "disconnect = *0\n" .
22
+        $conf = "[general]\n".
23
+            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n".
24
+            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n".
25
+            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n".
26
+            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n".
27
+            "atxferabort = *0\n".
28
+            "\n".
29
+            "[featuremap]\n".
30
+            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n".
31
+            "disconnect = *0\n".
32 32
             "blindxfer => {$this->generalSettings['PBXFeatureBlindTransfer']}\n";
33 33
 
34 34
         $additionalModules = $this->di->getShared('pbxConfModules');
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
             $conf .= $appClass->getFeatureMap();
37 37
         }
38 38
 
39
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/features.conf', $conf);
39
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/features.conf', $conf);
40 40
     }
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/Asterisk/agi-bin/cdr_connector.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
     $orign_chan     = $agi->get_variable("orign_chan", true);
33 33
     $id             = $agi->get_variable("pt1c_UNIQUEID", true);
34 34
     $IS_ORGNT       = $agi->get_variable("IS_ORGNT", true);
35
-    if ($id == '' || ! empty($QUEUE_SRC_CHAN)) {
35
+    if ($id == '' || !empty($QUEUE_SRC_CHAN)) {
36 36
         // Если это вызов на агента очереди !empty($QUEUE_SRC_CHAN).
37 37
         // Если это новый вызов $id == ''.
38
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
38
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
39 39
     }
40 40
     // Канал, AGI скрипта.
41 41
     $channel  = $agi->request['agi_channel'];
42
-    $is_local = ! (stripos($channel, 'local/') === false);
42
+    $is_local = !(stripos($channel, 'local/') === false);
43 43
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
44 44
         // Это LOCAL, Переопределим на исходный.
45 45
         $channel = $QUEUE_SRC_CHAN;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     $data['action'] = "$action";
57
-    if ( ! empty($IS_ORGNT)) {
57
+    if (!empty($IS_ORGNT)) {
58 58
         $dst_num            = $agi->request['agi_callerid'];
59 59
         $src_num            = $agi->request['agi_extension'];
60 60
         $data['dialstatus'] = 'ORIGINATE';
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $num     = substr($agi->request['agi_channel'], $p_start, $p_end);
66 66
 
67 67
         $p_start  = strpos($agi->request['agi_channel'], ';');
68
-        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start) . ';1';
68
+        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start).';1';
69 69
 
70
-        $id               = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $num . '_' . $IS_ORGNT;
70
+        $id               = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$num.'_'.$IS_ORGNT;
71 71
         $data['dst_chan'] = $dst_chan;
72 72
     } else {
73 73
         $src_num = $agi->request['agi_callerid'];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     $data['agi_channel']  = $agi->request['agi_channel'];
85 85
     $data['did']          = $agi->get_variable("FROM_DID", true);
86 86
     $data['from_account'] = $from_account;
87
-    $data['IS_ORGNT']     = ! empty($IS_ORGNT);
87
+    $data['IS_ORGNT']     = !empty($IS_ORGNT);
88 88
 
89 89
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
90 90
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
118
-    if ( ! empty($IS_ORGNT)) {
118
+    if (!empty($IS_ORGNT)) {
119 119
         // Вероятно необходимо переопределить искать по двум ID.
120 120
         // Применимо только для Originate, когда в качестве звонящего используем два канала
121 121
         // мобильный и внутренний номер.
122 122
         $peer_mobile = $agi->get_variable("peer_mobile", true);
123
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
123
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
125 125
             $data['org_id'] = $id;
126 126
         }
127 127
     }
@@ -154,22 +154,22 @@  discard block
 block discarded – undo
154 154
     $data['BRIDGEPEER']      = $agi->get_variable("FROM_CHAN", true);
155 155
 
156 156
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
157
-    if ( ! empty($IS_ORGNT)) {
157
+    if (!empty($IS_ORGNT)) {
158 158
         // Вероятно необходимо переопределить ID.
159 159
         // Применимо только для Originate, когда в качестве звонящего используем два канала
160 160
         // мобильный и внутренний номер.
161 161
         $peer_mobile = $agi->get_variable("peer_mobile", true);
162
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
162
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
164 164
             $data['org_id'] = $id;
165 165
         }
166 166
     }
167 167
 
168
-    if ( ! empty($data['ENDCALLONANSWER'])) {
168
+    if (!empty($data['ENDCALLONANSWER'])) {
169 169
         $agi->set_variable("__ENDCALLONANSWER", "");
170 170
     }
171 171
 
172
-    $PICKUPEER     = trim('' . $agi->get_variable("PICKUPEER", true));
172
+    $PICKUPEER     = trim(''.$agi->get_variable("PICKUPEER", true));
173 173
     $data['dnid']  = $agi->request['agi_dnid'];
174 174
     $mikoPBXConfig = new MikoPBXConfig();
175 175
     $pickupexten   = $mikoPBXConfig->getGeneralSettings('PBXFeaturePickupExten');
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         // Очищаем переменную канала. Больше не требуется.
185 185
         $agi->set_variable("PICKUPEER", "");
186 186
         $data['old_id'] = $id;
187
-        $data['id']     = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
187
+        $data['id']     = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
188 188
     }
189 189
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
190 190
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $data['linkedid']    = $agi->get_variable("CDR(linkedid)", true);
212 212
     $data['did']         = $agi->get_variable("FROM_DID", true);
213 213
 
214
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
214
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
215 215
 
216 216
     return $data;
217 217
 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 function Event_transfer_dial($agi, $action)
228 228
 {
229 229
     $now = Util::getNowDate();
230
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
230
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
231 231
 
232 232
     // Пытаемся определить канал.
233 233
     $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true);
234 234
     $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true);
235
-    $is_local       = ! (stripos($TRANSFERERNAME, 'local/') === false);
235
+    $is_local       = !(stripos($TRANSFERERNAME, 'local/') === false);
236 236
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
237 237
         // Это LOCAL, Переопределим на исходный.
238 238
         $channel = $QUEUE_SRC_CHAN;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     $data                = [];
249 249
     $data['action']      = "$action";
250
-    $data['agi_channel'] = $channel;// $agi->request['agi_channel'];
250
+    $data['agi_channel'] = $channel; // $agi->request['agi_channel'];
251 251
     $data['linkedid']    = $agi->get_variable("CDR(linkedid)", true);
252 252
     $data['src_chan']    = $channel;
253 253
     $data['did']         = $agi->get_variable("FROM_DID", true);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     $data['did']          = $agi->get_variable("FROM_DID", true);
322 322
     $data['action']       = "$action";
323 323
     $data['agi_channel']  = $agi->request['agi_channel'];
324
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
324
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
325 325
 
326 326
     $pos = stripos($data['agi_channel'], 'local/');
327 327
     if ($pos === false) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     $data                 = [];
351 351
     $data['action']       = "$action";
352 352
     $data['did']          = $agi->get_variable("FROM_DID", true);
353
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
353
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
354 354
 
355 355
     $data['linkedid']   = $agi->get_variable("CDR(linkedid)", true);
356 356
     $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true);
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']);
386 386
 
387 387
     // Сбор данных для генерации CDR.
388
-    $id      = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
388
+    $id      = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
389 389
     $channel = $agi->request['agi_channel'];
390 390
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
391 391
     $data                 = [];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
         $data['src_chan'] = $channel;
404 404
         $data['src_num']  = $agi->request['agi_callerid'];
405 405
         $data['dst_num']  = $agi->request['agi_extension'];
406
-        $data['dst_chan'] = 'Park:' . $agi->request['agi_extension'];
406
+        $data['dst_chan'] = 'Park:'.$agi->request['agi_extension'];
407 407
     } elseif (true === $park_row['pt1c_is_dst']) {
408 408
         $data['src_chan'] = $channel;
409 409
         $data['dst_chan'] = $park_row['ParkeeChannel'];
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
     if (trim($park_row['ParkingDuration']) !== '') {
420 420
         $time_start           = date("Y-m-d H:i:s", time() - 1 * ($park_row['ParkingDuration']));
421 421
         $data_parking         = [
422
-            'UNIQUEID' => $id . '_' . Util::generateRandomString(3),
422
+            'UNIQUEID' => $id.'_'.Util::generateRandomString(3),
423 423
             'src_chan' => $park_row['ParkeeChannel'],
424 424
             'src_num'  => $park_row['ParkeeCallerIDNum'],
425 425
             'dst_num'  => $park_row['ParkingSpace'],
426
-            'dst_chan' => 'Park:' . $park_row['ParkingSpace'],
426
+            'dst_chan' => 'Park:'.$park_row['ParkingSpace'],
427 427
             'start'    => $time_start,
428 428
             'answer'   => $time_start,
429 429
             'endtime'  => $now,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 function Event_unpark_call_timeout($agi, $action)
449 449
 {
450 450
     $now = Util::getNowDate();
451
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
451
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
452 452
     // PARKER=SIP/206
453 453
     $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true);
454 454
     $PARKING_DURATION = ($PARKING_DURATION == '') ? 45 : $PARKING_DURATION;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ???
461 461
         'src_num'  => $agi->request['agi_callerid'],
462 462
         'dst_num'  => $PARKING_SPACE,
463
-        'dst_chan' => 'Park:' . $PARKING_SPACE,
463
+        'dst_chan' => 'Park:'.$PARKING_SPACE,
464 464
         'start'    => $time_start,
465 465
         'answer'   => $time_start,
466 466
         'endtime'  => $now,
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     ];
473 473
 
474 474
 
475
-    $id2 = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
475
+    $id2 = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
476 476
     $agi->set_variable("__pt1c_UNIQUEID", "$id2");
477 477
 
478 478
     return $data;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     $id         = $agi->get_variable("pt1c_UNIQUEID", true);
494 494
     $ISTRANSFER = $agi->get_variable("ISTRANSFER", true);
495 495
 
496
-    if (empty($id) || ! empty($ISTRANSFER)) {
497
-        $id         = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
496
+    if (empty($id) || !empty($ISTRANSFER)) {
497
+        $id         = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
498 498
         $time_start = $now;
499 499
     }
500 500
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         // 'src_chan' => $agi->request['agi_channel'],
504 504
         // 'src_num'  => $agi->request['agi_callerid'],
505 505
         'dst_num'  => $agi->request['agi_extension'],
506
-        'dst_chan' => 'Queue:' . $agi->request['agi_extension'],
506
+        'dst_chan' => 'Queue:'.$agi->request['agi_extension'],
507 507
         // 'answer'   => $time_start,
508 508
         // 'end'  	   => $now,
509 509
         'did'      => $agi->get_variable("FROM_DID", true),
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         'UNIQUEID' => $id,
512 512
         'linkedid' => $agi->get_variable("CDR(linkedid)", true),
513 513
     ];
514
-    if ( ! empty($time_start)) {
514
+    if (!empty($time_start)) {
515 515
         $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true);
516 516
         $data['src_num']  = $agi->request['agi_callerid'];
517 517
         $data['start']    = $time_start;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         $data['transfer'] = '0';
520 520
         $agi->set_variable("__pt1c_q_UNIQUEID", "$id");
521 521
     }
522
-    if ( ! empty($ISTRANSFER)) {
522
+    if (!empty($ISTRANSFER)) {
523 523
         $data['transfer'] = '1';
524 524
     } else {
525 525
         $data['transfer'] = '0';
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
     $is_conf   = ($agi->get_variable('CALLERID(num)', true) === 'Conference_Room');
592 592
     $not_local = (stripos($agi->request['agi_channel'], 'local/') === false);
593
-    if ($not_local && ! $is_conf) {
593
+    if ($not_local && !$is_conf) {
594 594
         $am         = Util::getAstManager();
595 595
         $res        = $am->meetMeCollectInfo($exten, ['conf_1c']);
596 596
         $callid     = $agi->request['agi_callerid'];
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     if (empty($id)) {
631
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
631
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
632 632
     }
633 633
 
634 634
     $recordingfile = CdrDb::MeetMeSetRecFilename($id);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         'src_chan'      => $agi->request['agi_channel'],
638 638
         'src_num'       => $src_num,
639 639
         'dst_num'       => $dst_num,
640
-        'dst_chan'      => 'MeetMe:' . $mikoidconf,
640
+        'dst_chan'      => 'MeetMe:'.$mikoidconf,
641 641
         'start'         => $time_start,
642 642
         'answer'        => $time_start,
643 643
         'recordingfile' => "{$recordingfile}.mp3",
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     $lamePath = Util::which('lame');
680 680
     $nicePath = Util::which('nice');
681 681
     $chmodPath = Util::which('chmod');
682
-    $command               = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
682
+    $command = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
683 683
     Util::mwExecBg($command);
684 684
 
685 685
     return $data;
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function Event_dial_app($agi, $action)
697 697
 {
698
-    $id        = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
698
+    $id        = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
699 699
     $extension = $agi->get_variable("APPEXTEN", true);
700 700
     if (empty($extension)) {
701 701
         $extension = $agi->request['agi_extension'];
702 702
     }
703 703
 
704 704
     $data             = Event_dial($agi, $action);
705
-    $data['dst_chan'] = 'App:' . $extension;
705
+    $data['dst_chan'] = 'App:'.$extension;
706 706
     $data['dst_num']  = $extension;
707 707
     $data['is_app']   = 1;
708 708
     $data['UNIQUEID'] = $id;
@@ -743,5 +743,5 @@  discard block
 block discarded – undo
743 743
     $result = $func_name($agi, $action);
744 744
     // Оповещение без задержек.
745 745
     $data = base64_encode(json_encode($result));
746
-    $agi->exec("UserEvent", "CdrConnector,AgiData:" . base64_encode(json_encode($result)));
746
+    $agi->exec("UserEvent", "CdrConnector,AgiData:".base64_encode(json_encode($result)));
747 747
 }
Please login to merge, or discard this patch.