@@ -101,7 +101,7 @@ |
||
101 | 101 | $res->messages[] = "Unknown processor - {$processor} in prepareAnswer"; |
102 | 102 | } |
103 | 103 | } catch (Throwable $exception) { |
104 | - $res->messages[] = 'Exception on WorkerApiCommands - ' . $exception->getMessage(); |
|
104 | + $res->messages[] = 'Exception on WorkerApiCommands - '.$exception->getMessage(); |
|
105 | 105 | } finally { |
106 | 106 | $message->reply(json_encode($res->getResult())); |
107 | 107 | $this->checkNeedReload($res->data); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $res = new PBXApiResult(); |
58 | 58 | $res->processor = __METHOD__; |
59 | 59 | $res->success = true; |
60 | - $filter = [ |
|
60 | + $filter = [ |
|
61 | 61 | 'order' => 'id', |
62 | 62 | 'columns' => 'start,answer,endtime,src_num,dst_num,did,linkedid', |
63 | 63 | 'miko_tmp_db' => true, |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $message = $client->request(json_encode($filter), 2); |
67 | 67 | if ($message === false) { |
68 | 68 | $res->data = []; |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | $res->data[] = $message; |
71 | 71 | } |
72 | 72 | return $res; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $res->processor = __METHOD__; |
84 | 84 | $res->success = true; |
85 | 85 | |
86 | - $filter = [ |
|
86 | + $filter = [ |
|
87 | 87 | 'endtime IS NULL', |
88 | 88 | 'order' => 'id', |
89 | 89 | 'columns' => 'start,answer,src_chan,dst_chan,src_num,dst_num,did,linkedid', |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $data = json_decode(file_get_contents($result), true); |
105 | 105 | unlink($result); |
106 | 106 | foreach ($data as $row) { |
107 | - if ( ! isset($active_chans[$row['linkedid']])) { |
|
107 | + if (!isset($active_chans[$row['linkedid']])) { |
|
108 | 108 | // Вызов уже не существует. |
109 | 109 | continue; |
110 | 110 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | $message = $client->request(json_encode($filter), 2); |
67 | 67 | if ($message === false) { |
68 | 68 | $res->data = []; |
69 | - }else{ |
|
69 | + } else{ |
|
70 | 70 | $res->data[] = $message; |
71 | 71 | } |
72 | 72 | return $res; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $from_name = $settings['MailSMTPFromUsername']; |
79 | 79 | } |
80 | 80 | |
81 | - $mail->Port = (integer)$settings['MailSMTPPort']; |
|
81 | + $mail->Port = (integer) $settings['MailSMTPPort']; |
|
82 | 82 | $mail->CharSet = 'UTF-8'; |
83 | 83 | |
84 | 84 | $mail->setFrom($from_address, $from_name); |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $mail->Subject = $subject; |
91 | 91 | $mail->Body = $message; |
92 | 92 | |
93 | - if ( ! $mail->send()) { |
|
93 | + if (!$mail->send()) { |
|
94 | 94 | $messages[] = $mail->ErrorInfo; |
95 | 95 | } |
96 | 96 | } catch (Throwable $e) { |
97 | 97 | $messages[] = $e->getMessage(); |
98 | 98 | } |
99 | 99 | |
100 | - if (count($messages)>0) { |
|
100 | + if (count($messages) > 0) { |
|
101 | 101 | Util::sysLogMsg('PHPMailer', implode(' ', $messages), LOG_ERR); |
102 | 102 | return false; |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $settings = $mikoPBXConfig->getGeneralSettings(); |
110 | 110 | $systemNotificationsEmail = $settings['SystemNotificationsEmail']; |
111 | 111 | $result = self::sendMail($systemNotificationsEmail, 'Test mail from MIKO PBX', '<b>Test message</b><hr>'); |
112 | - return ($result===true); |
|
112 | + return ($result === true); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | $mikoPBXConfig = new MikoPBXConfig(); |
123 | 123 | $settings = $mikoPBXConfig->getGeneralSettings(); |
124 | 124 | |
125 | - $conf = "defaults\n" . |
|
126 | - "auth on\n" . |
|
125 | + $conf = "defaults\n". |
|
126 | + "auth on\n". |
|
127 | 127 | // "logfile /var/log/msmtp.log\n". |
128 | - "timeout 10\n" . |
|
128 | + "timeout 10\n". |
|
129 | 129 | "syslog LOG_LOCAL0\n\n"; |
130 | 130 | |
131 | 131 | if (isset($settings["MailSMTPUseTLS"]) && $settings["MailSMTPUseTLS"] == "1") { |
@@ -29,7 +29,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -609,7 +609,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'slin' => 'Signed Linear PCM', |
84 | 84 | 'opus' => 'Opus', |
85 | 85 | ]; |
86 | - $codecs = Codecs::find(); |
|
86 | + $codecs = Codecs::find(); |
|
87 | 87 | // Удалим лишние кодеки |
88 | 88 | /** @var Codecs $codec */ |
89 | 89 | foreach ($codecs as $codec) { |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $this->checkDisabledCodec($codec); |
92 | 92 | continue; |
93 | 93 | } |
94 | - if ( ! $codec->delete()) { |
|
94 | + if (!$codec->delete()) { |
|
95 | 95 | Util::sysLogMsg( |
96 | 96 | __CLASS__, |
97 | - 'Can not delete codec ' . $codec->name . ' from MikoPBX\Common\Models\Codecs' |
|
97 | + 'Can not delete codec '.$codec->name.' from MikoPBX\Common\Models\Codecs' |
|
98 | 98 | ); |
99 | 99 | } |
100 | 100 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | private function checkDisabledCodec(Codecs $codec): void |
111 | 111 | { |
112 | - if ( ! in_array($codec->disabled, ['0', '1'], true)) { |
|
112 | + if (!in_array($codec->disabled, ['0', '1'], true)) { |
|
113 | 113 | $codec->disabled = '0'; |
114 | 114 | $codec->save(); |
115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | private function addNewCodecs(array $availCodecs): void |
124 | 124 | { |
125 | 125 | foreach ($availCodecs as $availCodec => $desc) { |
126 | - $codecData = Codecs::findFirst('name="' . $availCodec . '"'); |
|
126 | + $codecData = Codecs::findFirst('name="'.$availCodec.'"'); |
|
127 | 127 | if ($codecData === null) { |
128 | 128 | $codecData = new Codecs(); |
129 | 129 | } elseif ($codecData->description === $desc) { |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | } |
139 | 139 | $codecData->type = $type; |
140 | 140 | $codecData->description = $desc; |
141 | - if ( ! $codecData->save()) { |
|
141 | + if (!$codecData->save()) { |
|
142 | 142 | Util::sysLogMsg( |
143 | 143 | __CLASS__, |
144 | - 'Can not update codec info ' . $codecData->name . ' from \MikoPBX\Common\Models\Codecs' |
|
144 | + 'Can not update codec info '.$codecData->name.' from \MikoPBX\Common\Models\Codecs' |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | $astDbPath = $this->config->path('astDatabase.dbfile'); |
194 | 194 | if (file_exists($astDbPath)) { |
195 | 195 | $table = 'astdb'; |
196 | - $sql = 'DELETE FROM ' . $table . ' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"'; |
|
196 | + $sql = 'DELETE FROM '.$table.' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"'; |
|
197 | 197 | $db = new SQLite3($astDbPath); |
198 | 198 | try { |
199 | 199 | $db->exec($sql); |
200 | 200 | } catch (Throwable $e) { |
201 | - Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...' . $e->getMessage()); |
|
201 | + Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...'.$e->getMessage()); |
|
202 | 202 | sleep(2); |
203 | 203 | } |
204 | 204 | $db->close(); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | */ |
212 | 212 | private function copyMohFilesToStorage(): void |
213 | 213 | { |
214 | - $oldMohDir = $this->config->path('asterisk.astvarlibdir') . '/sounds/moh'; |
|
215 | - if ( ! file_exists($oldMohDir)) { |
|
214 | + $oldMohDir = $this->config->path('asterisk.astvarlibdir').'/sounds/moh'; |
|
215 | + if (!file_exists($oldMohDir)) { |
|
216 | 216 | return; |
217 | 217 | } |
218 | 218 | $currentMohDir = $this->config->path('asterisk.mohdir'); |
219 | - if ( ! Util::mwMkdir($currentMohDir)) { |
|
219 | + if (!Util::mwMkdir($currentMohDir)) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | 222 | |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | if (in_array($file, ['.', '..'])) { |
226 | 226 | continue; |
227 | 227 | } |
228 | - if (copy($oldMohDir . '/' . $file, $currentMohDir . '/' . $file)) { |
|
228 | + if (copy($oldMohDir.'/'.$file, $currentMohDir.'/'.$file)) { |
|
229 | 229 | $sound_file = new SoundFiles(); |
230 | - $sound_file->path = $currentMohDir . '/' . $file; |
|
230 | + $sound_file->path = $currentMohDir.'/'.$file; |
|
231 | 231 | $sound_file->category = SoundFiles::CATEGORY_MOH; |
232 | 232 | $sound_file->name = $file; |
233 | 233 | $sound_file->save(); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | Extensions::TYPE_CONFERENCE, |
292 | 292 | |
293 | 293 | ]; |
294 | - $extensions = Extensions::find(); |
|
294 | + $extensions = Extensions::find(); |
|
295 | 295 | foreach ($extensions as $extension) { |
296 | 296 | if (in_array($extension->type, $showInPhonebookTypes)) { |
297 | 297 | $extension->show_in_phonebook = '1'; |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | */ |
307 | 307 | private function moveReadOnlySoundsToStorage(): void |
308 | 308 | { |
309 | - $currentMediaDir = $this->config->path('asterisk.customSoundDir') . '/'; |
|
310 | - if ( ! is_dir($currentMediaDir)) { |
|
309 | + $currentMediaDir = $this->config->path('asterisk.customSoundDir').'/'; |
|
310 | + if (!is_dir($currentMediaDir)) { |
|
311 | 311 | Util::mwMkdir($currentMediaDir); |
312 | 312 | } |
313 | 313 | $soundFiles = SoundFiles::find(); |
314 | 314 | foreach ($soundFiles as $soundFile) { |
315 | 315 | if (stripos($soundFile->path, '/offload/asterisk/sounds/other/') === 0) { |
316 | - $newPath = $currentMediaDir . pathinfo($soundFile->path)['basename']; |
|
316 | + $newPath = $currentMediaDir.pathinfo($soundFile->path)['basename']; |
|
317 | 317 | if (copy($soundFile->path, $newPath)) { |
318 | 318 | $soundFile->path = $newPath; |
319 | 319 | $soundFile->update(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $moduleModelClass = "MikoPBX\\Common\\Models\\{$className}"; |
60 | 60 | try { |
61 | 61 | $this->createUpdateDbTableByAnnotations($moduleModelClass); |
62 | - } catch (Throwable $exception){ |
|
62 | + } catch (Throwable $exception) { |
|
63 | 63 | Util::echoWithSyslog('Errors within update table '.$className.' '.$exception->getMessage()); |
64 | 64 | } |
65 | 65 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $result = true; |
80 | 80 | if ( |
81 | - ! class_exists($modelClassName) |
|
81 | + !class_exists($modelClassName) |
|
82 | 82 | || count(get_class_vars($modelClassName)) === 0) { |
83 | 83 | return true; |
84 | 84 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'isNumeric' => false, |
119 | 119 | 'primary' => false, |
120 | 120 | ]; |
121 | - $previousAttribute = $attribute; |
|
121 | + $previousAttribute = $attribute; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | // Set data types |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | |
227 | 227 | $connectionService->begin(); |
228 | 228 | |
229 | - if ( ! $connectionService->tableExists($tableName)) { |
|
230 | - Util::echoWithSyslog(' - UpdateDatabase: Create new table: ' . $tableName . ' '); |
|
229 | + if (!$connectionService->tableExists($tableName)) { |
|
230 | + Util::echoWithSyslog(' - UpdateDatabase: Create new table: '.$tableName.' '); |
|
231 | 231 | $result = $connectionService->createTable($tableName, '', $columnsNew); |
232 | 232 | Util::echoGreenDone(); |
233 | 233 | } else { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $currentColumnsArr = $connectionService->describeColumns($tableName, ''); |
236 | 236 | |
237 | 237 | if ($this->isTableStructureNotEqual($currentColumnsArr, $columns)) { |
238 | - Util::echoWithSyslog(' - UpdateDatabase: Upgrade table: ' . $tableName . ' '); |
|
238 | + Util::echoWithSyslog(' - UpdateDatabase: Upgrade table: '.$tableName.' '); |
|
239 | 239 | // Create new table and copy all data |
240 | 240 | $currentStateColumnList = []; |
241 | 241 | $oldColNames = []; // Старые названия колонок |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | if ($oldField->$compared_setting() !== $newField->$compared_setting()) { |
326 | 326 | // Sqlite transform "1" to ""1"" in default settings, but it is normal |
327 | 327 | if ($compared_setting === 'getDefault' |
328 | - && $oldField->$compared_setting() === '"' . $newField->$compared_setting() . '"') { |
|
328 | + && $oldField->$compared_setting() === '"'.$newField->$compared_setting().'"') { |
|
329 | 329 | continue; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Description for "length" is integer, but table structure store it as string |
333 | 333 | if ($compared_setting === 'getSize' |
334 | - && (string)$oldField->$compared_setting() === (string)$newField->$compared_setting()) { |
|
334 | + && (string) $oldField->$compared_setting() === (string) $newField->$compared_setting()) { |
|
335 | 335 | continue; |
336 | 336 | } |
337 | 337 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | // Drop not exist indexes |
360 | 360 | foreach ($currentIndexes as $indexName => $currentIndex) { |
361 | 361 | if (stripos($indexName, 'sqlite_autoindex') === false |
362 | - && ! array_key_exists($indexName, $indexes) |
|
362 | + && !array_key_exists($indexName, $indexes) |
|
363 | 363 | ) { |
364 | 364 | Util::echoWithSyslog(" - UpdateDatabase: Delete index: {$indexName} "); |
365 | 365 | $result = $result + $connectionService->dropIndex($tableName, '', $indexName); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if (file_exists('/etc/TZ')) { |
176 | 176 | $origin_tz = file_get_contents("/etc/TZ"); |
177 | 177 | } |
178 | - if ($origin_tz !== $db_tz){ |
|
178 | + if ($origin_tz !== $db_tz) { |
|
179 | 179 | self::timezoneConfigure(); |
180 | 180 | } |
181 | 181 | $origin_tz = $db_tz; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | if ($timezone) { |
247 | 247 | $zone_file = "/usr/share/zoneinfo/{$timezone}"; |
248 | - if ( ! file_exists($zone_file)) { |
|
248 | + if (!file_exists($zone_file)) { |
|
249 | 249 | return; |
250 | 250 | } |
251 | 251 | $cpPath = Util::which('cp'); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | try { |
284 | 284 | /** @var \MikoPBX\Modules\Config\ConfigClass $appClass */ |
285 | 285 | $appClass->onAfterPbxStarted(); |
286 | - }catch (Throwable $e){ |
|
286 | + } catch (Throwable $e) { |
|
287 | 287 | Util::sysLogMsg('onAfterPbxStarted', $e->getMessage()); |
288 | 288 | } |
289 | 289 | } |
@@ -283,7 +283,7 @@ |
||
283 | 283 | try { |
284 | 284 | /** @var \MikoPBX\Modules\Config\ConfigClass $appClass */ |
285 | 285 | $appClass->onAfterPbxStarted(); |
286 | - }catch (Throwable $e){ |
|
286 | + } catch (Throwable $e){ |
|
287 | 287 | Util::sysLogMsg('onAfterPbxStarted', $e->getMessage()); |
288 | 288 | } |
289 | 289 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $freeExtension = '2200100'; |
113 | 113 | for ($i = 100; ; $i++) { |
114 | 114 | $freeExtension = "2200{$i}"; |
115 | - if ( ! in_array(['number' => $freeExtension], $result, false)) { |
|
115 | + if (!in_array(['number' => $freeExtension], $result, false)) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | $relatedModel = $relation->getReferencedModel(); |
422 | 422 | $referencedFields = is_array($referencedFields) ? $referencedFields : [$referencedFields]; |
423 | 423 | foreach ($referencedFields as $referencedField) { |
424 | - $parameters = [ |
|
425 | - 'conditions' => $referencedField . '= :oldNumber:', |
|
424 | + $parameters = [ |
|
425 | + 'conditions' => $referencedField.'= :oldNumber:', |
|
426 | 426 | 'bind' => ['oldNumber' => $snapShotData['number']], |
427 | 427 | ]; |
428 | 428 | $relatedRecords = call_user_func([$relatedModel, 'find'], $parameters); |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | $relatedModel = $relation->getReferencedModel(); |
477 | 477 | $referencedFields = is_array($referencedFields) ? $referencedFields : [$referencedFields]; |
478 | 478 | foreach ($referencedFields as $referencedField) { |
479 | - $parameters = [ |
|
480 | - 'conditions' => $referencedField . '= :Number:', |
|
479 | + $parameters = [ |
|
480 | + 'conditions' => $referencedField.'= :Number:', |
|
481 | 481 | 'bind' => ['Number' => $this->number], |
482 | 482 | ]; |
483 | 483 | $relatedRecords = call_user_func([$relatedModel, 'find'], $parameters); |
@@ -50,10 +50,10 @@ |
||
50 | 50 | { |
51 | 51 | $di->setShared( |
52 | 52 | self::SERVICE_NAME, |
53 | - function () { |
|
53 | + function() { |
|
54 | 54 | try { |
55 | 55 | return new License('http://127.0.0.1:8223'); |
56 | - } catch (Throwable $exception){ |
|
56 | + } catch (Throwable $exception) { |
|
57 | 57 | Util::sysLogMsg(__CLASS__, $exception); |
58 | 58 | } |
59 | 59 | return null; |
@@ -50,7 +50,8 @@ |
||
50 | 50 | { |
51 | 51 | $di->setShared( |
52 | 52 | self::SERVICE_NAME, |
53 | - function () { |
|
53 | + function () |
|
54 | + { |
|
54 | 55 | try { |
55 | 56 | return new License('http://127.0.0.1:8223'); |
56 | 57 | } catch (Throwable $exception){ |