@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected function generateConfigProtected(): void |
20 | 20 | { |
21 | 21 | $conf = ""; |
22 | - file_put_contents($this->config->path('asterisk.astetcdir') . '/confbridge.conf', $conf); |
|
22 | + file_put_contents($this->config->path('asterisk.astetcdir').'/confbridge.conf', $conf); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $conf = ''; |
33 | 33 | $data = self::getConferenceExtensions(); |
34 | 34 | foreach ($data as $conference) { |
35 | - $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
35 | + $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)"."\n"; |
|
36 | 36 | } |
37 | 37 | $conf .= "\n"; |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $conf = ''; |
48 | 48 | $data = self::getConferenceExtensions(); |
49 | 49 | foreach ($data as $conference) { |
50 | - $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
50 | + $conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)"."\n"; |
|
51 | 51 | } |
52 | 52 | $conf .= "\n"; |
53 | 53 | |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $conf .= "[conference-rooms] \n"; |
73 | 73 | $data = self::getConferenceExtensions(); |
74 | 74 | foreach ($data as $conference) { |
75 | - $conf .= 'exten => ' . $conference . ',1,NoOp(---)' . "\n\t"; |
|
76 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())' . "\n\t"; |
|
77 | - $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)' . "\n\t"; |
|
78 | - $conf .= 'same => n,Answer()' . "\n\t"; |
|
79 | - $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)' . "\n\t"; |
|
80 | - $conf .= 'same => n,Meetme(${EXTEN},qdMT' . $rec_options . ')' . "\n\t"; |
|
81 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
75 | + $conf .= 'exten => '.$conference.',1,NoOp(---)'."\n\t"; |
|
76 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())'."\n\t"; |
|
77 | + $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)'."\n\t"; |
|
78 | + $conf .= 'same => n,Answer()'."\n\t"; |
|
79 | + $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)'."\n\t"; |
|
80 | + $conf .= 'same => n,Meetme(${EXTEN},qdMT'.$rec_options.')'."\n\t"; |
|
81 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $conf; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public static function getConferenceExtensions():array{ |
108 | 108 | $confExtensions = []; |
109 | 109 | $conferences = ConferenceRooms::find(['order' => 'extension', 'columns' => 'extension'])->toArray(); |
110 | - foreach ($conferences as $conference){ |
|
110 | + foreach ($conferences as $conference) { |
|
111 | 111 | $confExtensions[] = $conference['extension']; |
112 | 112 | } |
113 | 113 | return $confExtensions; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | Processes::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 | Processes::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 = Processes::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 | Processes::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 | - Processes::mwExec($hostnamePath . ' ' . escapeshellarg("{$data['hostname']}")); |
|
641 | + Processes::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 = Processes::getPidOfProcess('openvpn'); |
655 | - if ( ! empty($pid)) { |
|
655 | + if (!empty($pid)) { |
|
656 | 656 | // Завершаем процесс. |
657 | 657 | $busyboxPath = Util::which('busybox'); |
658 | 658 | Processes::mwExec("{$busyboxPath} kill '$pid'"); |
659 | 659 | } |
660 | - if ( ! empty($data)) { |
|
660 | + if (!empty($data)) { |
|
661 | 661 | $openvpnPath = Util::which('openvpn'); |
662 | 662 | Processes::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 | Processes::mwExec("{$busyboxPath} ifconfig $interface 192.168.2.1 netmask 255.255.255.0"); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $config = $this->di->get('config')->beanstalk; |
50 | 50 | $port = $config->port; |
51 | - if ( ! empty($this->port) && is_numeric($this->port)) { |
|
51 | + if (!empty($this->port) && is_numeric($this->port)) { |
|
52 | 52 | $port = $this->port; |
53 | 53 | } |
54 | 54 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->queue->delete($job); |
103 | 103 | } |
104 | 104 | } catch (Throwable $exception) { |
105 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
105 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
106 | 106 | if ($job !== null) { |
107 | 107 | $this->queue->bury($job); |
108 | 108 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ): Job { |
135 | 135 | $tube = str_replace("\\", '-', $tube); |
136 | 136 | // Change tube |
137 | - if ( ! empty($tube) && $this->tube !== $tube) { |
|
137 | + if (!empty($tube) && $this->tube !== $tube) { |
|
138 | 138 | $this->queue->useTube($tube); |
139 | 139 | } |
140 | 140 | $job_data = serialize($job_data); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | $queueStats = $this->queue->stats()->getArrayCopy(); |
160 | 160 | |
161 | 161 | // Delete buried jobs |
162 | - $countBuried=$queueStats['current-jobs-buried']; |
|
162 | + $countBuried = $queueStats['current-jobs-buried']; |
|
163 | 163 | while ($job = $this->queue->peekBuried()) { |
164 | 164 | $countBuried--; |
165 | - if ($countBuried<0){ |
|
165 | + if ($countBuried < 0) { |
|
166 | 166 | break; |
167 | 167 | } |
168 | 168 | $id = $job->getId(); |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | // Delete outdated jobs |
174 | - $countReady=$queueStats['current-jobs-ready']; |
|
174 | + $countReady = $queueStats['current-jobs-ready']; |
|
175 | 175 | while ($job = $this->queue->peekReady()) { |
176 | 176 | $countReady--; |
177 | - if ($countReady<0){ |
|
177 | + if ($countReady < 0) { |
|
178 | 178 | break; |
179 | 179 | } |
180 | 180 | $id = $job->getId(); |
181 | 181 | $jobStats = $this->queue->statsJob($job)->getArrayCopy(); |
182 | - $age = (int)$jobStats['age']; |
|
183 | - $expectedTimeToExecute = (int)$jobStats['ttr'] * 2; |
|
182 | + $age = (int) $jobStats['age']; |
|
183 | + $expectedTimeToExecute = (int) $jobStats['ttr'] * 2; |
|
184 | 184 | if ($age > $expectedTimeToExecute) { |
185 | 185 | $this->queue->delete($job); |
186 | 186 | Util::sysLogMsg(__METHOD__, "Deleted outdated job with ID {$id} from {$tube}"); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | } catch (Throwable $exception) { |
190 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
190 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $job = $this->queue->reserveWithTimeout($timeout); |
222 | 222 | } catch (Throwable $exception) { |
223 | - Util::sysLogMsg(__METHOD__, 'Exception: ' . $exception->getMessage()); |
|
223 | + Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | if ($job === null) { |
@@ -90,7 +90,7 @@ discard block |
||
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 |
||
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 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | public static function checkCodec($name, $desc, $type): void |
205 | 205 | { |
206 | - $codec = Codecs::findFirst('name="' . $name . '"'); |
|
206 | + $codec = Codecs::findFirst('name="'.$name.'"'); |
|
207 | 207 | if ($codec === null) { |
208 | 208 | /** @var \MikoPBX\Common\Models\Codecs $codec_g722 */ |
209 | 209 | $codec = new Codecs(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function sipReload():void |
221 | 221 | { |
222 | - $di = Di::getDefault(); |
|
222 | + $di = Di::getDefault(); |
|
223 | 223 | if ($di === null) { |
224 | 224 | return; |
225 | 225 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | Processes::mwExec("{$asteriskPath} -rx 'module reload acl'"); |
236 | 236 | Processes::mwExec("{$asteriskPath} -rx 'core reload'"); |
237 | 237 | } else { |
238 | - Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk',LOG_INFO, LOG_INFO); |
|
238 | + Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk', LOG_INFO, LOG_INFO); |
|
239 | 239 | // Завершаем каналы. |
240 | 240 | Processes::mwExec("{$asteriskPath} -rx 'channel request hangup all'"); |
241 | 241 | usleep(500000); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public static function iaxReload(): void |
250 | 250 | { |
251 | - $iax = new IAXConf(); |
|
251 | + $iax = new IAXConf(); |
|
252 | 252 | $iax->generateConfig(); |
253 | 253 | $asteriskPath = Util::which('asterisk'); |
254 | 254 | Processes::mwExec("{$asteriskPath} -rx 'iax2 reload'"); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | 'result' => 'ERROR', |
306 | 306 | ]; |
307 | 307 | |
308 | - if ( ! $this->di->getShared('registry')->booting) { |
|
308 | + if (!$this->di->getShared('registry')->booting) { |
|
309 | 309 | $this->stop(); |
310 | 310 | } |
311 | 311 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | // Создание базы данных истории звонков. |
322 | 322 | /** @var \Phalcon\Db\Adapter\Pdo\Sqlite $connection */ |
323 | 323 | $connection = $this->di->get('dbCDR'); |
324 | - if ( ! $connection->tableExists('cdr')) { |
|
324 | + if (!$connection->tableExists('cdr')) { |
|
325 | 325 | RegisterDIServices::recreateDBConnections(); |
326 | 326 | } else { |
327 | 327 | CdrDb::checkDb(); |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | public static function isStorageDisk($device): bool |
74 | 74 | { |
75 | 75 | $result = false; |
76 | - if ( ! file_exists("{$device}")) { |
|
76 | + if (!file_exists("{$device}")) { |
|
77 | 77 | return $result; |
78 | 78 | } |
79 | 79 | |
80 | - $tmp_dir = '/tmp/mnt_' . time(); |
|
80 | + $tmp_dir = '/tmp/mnt_'.time(); |
|
81 | 81 | Util::mwMkdir($tmp_dir); |
82 | 82 | $out = []; |
83 | 83 | |
84 | 84 | $storage = new Storage(); |
85 | - $uid_part = 'UUID=' . $storage->getUuid($device) . ''; |
|
85 | + $uid_part = 'UUID='.$storage->getUuid($device).''; |
|
86 | 86 | $format = $storage->getFsType($device); |
87 | 87 | if ($format === '') { |
88 | 88 | return false; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | Processes::mwExec("{$umountPath} {$device}"); |
102 | 102 | } |
103 | 103 | |
104 | - if ( ! self::isStorageDiskMounted($device)) { |
|
104 | + if (!self::isStorageDiskMounted($device)) { |
|
105 | 105 | Processes::mwExec("{$rmPath} -rf '{$tmp_dir}'"); |
106 | 106 | } |
107 | 107 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | $timeoutPath = Util::which('timeout'); |
232 | 232 | $sshfsPath = Util::which('sshfs'); |
233 | 233 | |
234 | - $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' " . |
|
235 | - "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n" . |
|
236 | - "{$pass}\n" . |
|
234 | + $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' ". |
|
235 | + "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n". |
|
236 | + "{$pass}\n". |
|
237 | 237 | "EOF\n"; |
238 | 238 | // file_put_contents('/tmp/sshfs_'.$host, $command); |
239 | 239 | Processes::mwExec($command, $out); |
@@ -265,19 +265,19 @@ discard block |
||
265 | 265 | |
266 | 266 | // Собираем строку подключения к ftp. |
267 | 267 | $auth_line = ''; |
268 | - if ( ! empty($user)) { |
|
269 | - $auth_line .= 'user="' . $user; |
|
270 | - if ( ! empty($pass)) { |
|
268 | + if (!empty($user)) { |
|
269 | + $auth_line .= 'user="'.$user; |
|
270 | + if (!empty($pass)) { |
|
271 | 271 | $auth_line .= ":{$pass}"; |
272 | 272 | } |
273 | 273 | $auth_line .= '",'; |
274 | 274 | } |
275 | 275 | |
276 | - $connect_line = 'ftp://' . $host; |
|
277 | - if ( ! empty($port)) { |
|
276 | + $connect_line = 'ftp://'.$host; |
|
277 | + if (!empty($port)) { |
|
278 | 278 | $connect_line .= ":{$port}"; |
279 | 279 | } |
280 | - if ( ! empty($remout_dir)) { |
|
280 | + if (!empty($remout_dir)) { |
|
281 | 281 | $connect_line .= "$remout_dir"; |
282 | 282 | } |
283 | 283 | |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public static function mkfs_disk($dev) |
305 | 305 | { |
306 | - if ( ! file_exists($dev)) { |
|
306 | + if (!file_exists($dev)) { |
|
307 | 307 | $dev = "/dev/{$dev}"; |
308 | 308 | } |
309 | - if ( ! file_exists($dev)) { |
|
309 | + if (!file_exists($dev)) { |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | $dir = ''; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | Processes::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0"); |
342 | 342 | Processes::mwExec("{$umountPath} {$dir}"); |
343 | 343 | } |
344 | - $result = ! self::isStorageDiskMounted($dir); |
|
344 | + $result = !self::isStorageDiskMounted($dir); |
|
345 | 345 | if ($result && file_exists($dir)) { |
346 | 346 | // Если диск не смонтирован, то удаляем каталог. |
347 | 347 | Processes::mwExec("{$rmPath} -rf '{$dir}'"); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public static function statusMkfs($dev): string |
413 | 413 | { |
414 | - if ( ! file_exists($dev)) { |
|
414 | + if (!file_exists($dev)) { |
|
415 | 415 | $dev = "/dev/{$dev}"; |
416 | 416 | } |
417 | 417 | $out = []; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } |
435 | 435 | $config = $di->getShared('config'); |
436 | 436 | $phpSessionDir = $config->path('www.phpSessionDir'); |
437 | - if ( ! empty($phpSessionDir)) { |
|
437 | + if (!empty($phpSessionDir)) { |
|
438 | 438 | $rmPath = Util::which('rm'); |
439 | 439 | Processes::mwExec("{$rmPath} -rf {$phpSessionDir}/*"); |
440 | 440 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | // Создание больщого файла для тестов. |
451 | 451 | // head -c 1500MB /dev/urandom > /storage/usbdisk1/big_file.mp3 |
452 | 452 | foreach ($hdd as $disk) { |
453 | - if ($disk['sys_disk'] === true && ! self::isStorageDiskMounted("{$disk['id']}4")) { |
|
453 | + if ($disk['sys_disk'] === true && !self::isStorageDiskMounted("{$disk['id']}4")) { |
|
454 | 454 | // Это системный диск (4ый раздел). Он не смонтирован. |
455 | 455 | continue; |
456 | 456 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | Processes::processPHPWorker(WorkerRemoveOldRecords::class); |
475 | 475 | } |
476 | 476 | |
477 | - if ( ! $need_alert) { |
|
477 | + if (!$need_alert) { |
|
478 | 478 | continue; |
479 | 479 | } |
480 | 480 | |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | $m_size = round(($disk_data[1] + $disk_data[2]) / 1024, 1); |
515 | 515 | $res_disks[] = [ |
516 | 516 | 'id' => $disk_data[0], |
517 | - 'size' => "" . $m_size, |
|
518 | - 'size_text' => "" . $m_size . " Mb", |
|
517 | + 'size' => "".$m_size, |
|
518 | + 'size_text' => "".$m_size." Mb", |
|
519 | 519 | 'vendor' => 'Debian', |
520 | 520 | 'mounted' => '/storage/usbdisk1', |
521 | 521 | 'free_space' => round($disk_data[2] / 1024, 1), |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | |
538 | 538 | $cf_disk = ''; |
539 | 539 | $varEtcDir = $this->config->path('core.varEtcDir'); |
540 | - if (file_exists($varEtcDir . '/cfdevice')) { |
|
541 | - $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice')); |
|
540 | + if (file_exists($varEtcDir.'/cfdevice')) { |
|
541 | + $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice')); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | foreach ($disks as $disk) { |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | $sys_disk = ($cf_disk == $disk); |
555 | 555 | |
556 | 556 | $mb_size = 0; |
557 | - if (is_file("/sys/block/" . $disk . "/size")) { |
|
558 | - $original_size = trim(file_get_contents("/sys/block/" . $disk . "/size")); |
|
557 | + if (is_file("/sys/block/".$disk."/size")) { |
|
558 | + $original_size = trim(file_get_contents("/sys/block/".$disk."/size")); |
|
559 | 559 | $original_size = ($original_size * 512 / 1024 / 1024); |
560 | 560 | $mb_size = $original_size; |
561 | 561 | } |
@@ -662,14 +662,14 @@ discard block |
||
662 | 662 | private function getVendorDisk($disk): string |
663 | 663 | { |
664 | 664 | $temp_vendor = []; |
665 | - if (is_file("/sys/block/" . $disk . "/device/vendor")) { |
|
666 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/vendor")); |
|
665 | + if (is_file("/sys/block/".$disk."/device/vendor")) { |
|
666 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/vendor")); |
|
667 | 667 | if ($data != '') { |
668 | 668 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
669 | 669 | } |
670 | 670 | } |
671 | - if (is_file("/sys/block/" . $disk . "/device/model")) { |
|
672 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/model")); |
|
671 | + if (is_file("/sys/block/".$disk."/device/model")) { |
|
672 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/model")); |
|
673 | 673 | if ($data != '') { |
674 | 674 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
675 | 675 | } |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | if (count($temp_vendor) == 0) { |
678 | 678 | $temp_vendor[] = $disk; |
679 | 679 | } |
680 | - if (is_file("/sys/block/" . $disk . "/device/type")) { |
|
681 | - $data = trim(file_get_contents("/sys/block/" . $disk . "/device/type")); |
|
680 | + if (is_file("/sys/block/".$disk."/device/type")) { |
|
681 | + $data = trim(file_get_contents("/sys/block/".$disk."/device/type")); |
|
682 | 682 | if ($data != '') { |
683 | 683 | $temp_vendor[] = trim(str_replace(',', ' ', $data)); |
684 | 684 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | Processes::mwExec("{$dfPath} -m | {$grepPath} {$hdd} | {$awkPath} '{print $4}'", $out); |
705 | 705 | $result = 0; |
706 | 706 | foreach ($out as $res) { |
707 | - if ( ! is_numeric($res)) { |
|
707 | + if (!is_numeric($res)) { |
|
708 | 708 | continue; |
709 | 709 | } |
710 | 710 | $result += (1 * $res); |
@@ -741,19 +741,19 @@ discard block |
||
741 | 741 | $path_size_info = $tmp_path; |
742 | 742 | } |
743 | 743 | if (empty($path_size_info)) { |
744 | - $tmp_path = "/sys/block/" . substr($dev, 0, 3) . "/{$dev}/size"; |
|
744 | + $tmp_path = "/sys/block/".substr($dev, 0, 3)."/{$dev}/size"; |
|
745 | 745 | if (file_exists($tmp_path)) { |
746 | 746 | $path_size_info = $tmp_path; |
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | - if ( ! empty($path_size_info)) { |
|
750 | + if (!empty($path_size_info)) { |
|
751 | 751 | $original_size = trim(file_get_contents($path_size_info)); |
752 | 752 | $original_size = ($original_size * 512 / 1024 / 1024); |
753 | 753 | $mb_size = $original_size; |
754 | 754 | } |
755 | 755 | |
756 | - $tmp_dir = "/tmp/{$dev}_" . time(); |
|
756 | + $tmp_dir = "/tmp/{$dev}_".time(); |
|
757 | 757 | $out = []; |
758 | 758 | |
759 | 759 | $fs = null; |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | Util::mwMkdir($dir); |
812 | 812 | |
813 | - if ( ! file_exists($dir)) { |
|
813 | + if (!file_exists($dir)) { |
|
814 | 814 | Util::sysLogMsg('Storage', "Unable mount $dev $format to $dir. Unable create dir."); |
815 | 815 | |
816 | 816 | return false; |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | Processes::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out); |
822 | 822 | } else { |
823 | 823 | $storage = new Storage(); |
824 | - $uid_part = 'UUID=' . $storage->getUuid("/dev/{$dev}") . ''; |
|
824 | + $uid_part = 'UUID='.$storage->getUuid("/dev/{$dev}").''; |
|
825 | 825 | $mountPath = Util::which('mount'); |
826 | 826 | Processes::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out); |
827 | 827 | } |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | unlink($storage_dev_file); |
842 | 842 | } |
843 | 843 | |
844 | - if (file_exists($varEtcDir . '/cfdevice')) { |
|
845 | - $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice')); |
|
844 | + if (file_exists($varEtcDir.'/cfdevice')) { |
|
845 | + $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice')); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | $disks = $this->getDiskSettings(); |
@@ -856,18 +856,18 @@ discard block |
||
856 | 856 | // Если это системный диск, то пытаемся подключить раздел 4. |
857 | 857 | $dev = "{$disk['device']}4"; |
858 | 858 | } |
859 | - if ( ! $this->hddExists($dev)) { |
|
859 | + if (!$this->hddExists($dev)) { |
|
860 | 860 | // Диск не существует. |
861 | 861 | continue; |
862 | 862 | } |
863 | - if ($disk['media'] === '1' || ! file_exists($storage_dev_file)) { |
|
863 | + if ($disk['media'] === '1' || !file_exists($storage_dev_file)) { |
|
864 | 864 | file_put_contents($storage_dev_file, "/storage/usbdisk{$disk['id']}"); |
865 | 865 | $this->updateConfigWithNewMountPoint("/storage/usbdisk{$disk['id']}"); |
866 | 866 | } |
867 | 867 | |
868 | - $str_uid = 'UUID=' . $this->getUuid($dev) . ''; |
|
868 | + $str_uid = 'UUID='.$this->getUuid($dev).''; |
|
869 | 869 | $format_p4 = $this->getFsType($dev); |
870 | - $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n"; |
|
870 | + $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n"; |
|
871 | 871 | $mount_point = "/storage/usbdisk{$disk['id']}"; |
872 | 872 | Util::mwMkdir($mount_point); |
873 | 873 | } |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | Util::mwMkdir('/storage'); |
980 | 980 | $chmodPath = Util::which('chmod'); |
981 | 981 | Processes::mwExec("{$chmodPath} 755 /storage"); |
982 | - if ( ! file_exists($varEtcDir . '/cfdevice')) { |
|
982 | + if (!file_exists($varEtcDir.'/cfdevice')) { |
|
983 | 983 | return; |
984 | 984 | } |
985 | 985 | $fstab = ''; |
986 | - $file_data = file_get_contents($varEtcDir . '/cfdevice'); |
|
986 | + $file_data = file_get_contents($varEtcDir.'/cfdevice'); |
|
987 | 987 | $cf_disk = trim($file_data); |
988 | 988 | if ('' == $cf_disk) { |
989 | 989 | return; |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | $part3 = (strpos($cf_disk, 'mmcblk') !== false) ? "{$cf_disk}p3" : "{$cf_disk}3"; // Conf |
994 | 994 | |
995 | 995 | |
996 | - $uid_part2 = 'UUID=' . $this->getUuid("/dev/{$part2}") . ''; |
|
996 | + $uid_part2 = 'UUID='.$this->getUuid("/dev/{$part2}").''; |
|
997 | 997 | $format_p2 = $this->getFsType($part2); |
998 | - $uid_part3 = 'UUID=' . $this->getUuid("/dev/{$part3}") . ''; |
|
998 | + $uid_part3 = 'UUID='.$this->getUuid("/dev/{$part3}").''; |
|
999 | 999 | $format_p3 = $this->getFsType($part3); |
1000 | 1000 | |
1001 | 1001 | // $fstab .= "/dev/{$part1} /cf msdos ro 1 1\n"; // НЕ МОНТИРУЕМ! |
@@ -1040,12 +1040,12 @@ discard block |
||
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - if ( ! empty($path)) { |
|
1043 | + if (!empty($path)) { |
|
1044 | 1044 | Util::mwMkdir($path); |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $downloadCacheDir = appPath('sites/pbxcore/files/cache'); |
1048 | - if ( ! $isLiveCd) { |
|
1048 | + if (!$isLiveCd) { |
|
1049 | 1049 | Util::mwMkdir($downloadCacheDir); |
1050 | 1050 | Util::createUpdateSymlink($this->config->path('www.downloadCacheDir'), $downloadCacheDir); |
1051 | 1051 | } |
@@ -1083,13 +1083,13 @@ discard block |
||
1083 | 1083 | public function createAssetsSymlinks(): void |
1084 | 1084 | { |
1085 | 1085 | $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache'); |
1086 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/js', $jsCacheDir); |
|
1086 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/js', $jsCacheDir); |
|
1087 | 1087 | |
1088 | 1088 | $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache'); |
1089 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/css', $cssCacheDir); |
|
1089 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/css', $cssCacheDir); |
|
1090 | 1090 | |
1091 | 1091 | $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache'); |
1092 | - Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/img', $imgCacheDir); |
|
1092 | + Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/img', $imgCacheDir); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1100,13 +1100,13 @@ discard block |
||
1100 | 1100 | $cacheDirs = []; |
1101 | 1101 | $cacheDirs[] = $this->config->path('www.uploadDir'); |
1102 | 1102 | $cacheDirs[] = $this->config->path('www.downloadCacheDir'); |
1103 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js'; |
|
1104 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css'; |
|
1105 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img'; |
|
1103 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js'; |
|
1104 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css'; |
|
1105 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img'; |
|
1106 | 1106 | $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir'); |
1107 | 1107 | $rmPath = Util::which('rm'); |
1108 | 1108 | foreach ($cacheDirs as $cacheDir) { |
1109 | - if ( ! empty($cacheDir)) { |
|
1109 | + if (!empty($cacheDir)) { |
|
1110 | 1110 | Processes::mwExec("{$rmPath} -rf {$cacheDir}/*"); |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | $countBlock = $swapSize * $bs; |
1217 | 1217 | $ddCmd = Util::which('dd'); |
1218 | 1218 | |
1219 | - Util::sysLogMsg('Swap', 'make swap ' . $swapFile, LOG_INFO, LOG_INFO); |
|
1219 | + Util::sysLogMsg('Swap', 'make swap '.$swapFile, LOG_INFO, LOG_INFO); |
|
1220 | 1220 | Processes::mwExec("{$ddCmd} if=/dev/zero of={$swapFile} bs={$bs} count={$countBlock}"); |
1221 | 1221 | |
1222 | 1222 | $mkSwapCmd = Util::which('mkswap'); |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | |
1225 | 1225 | $swapOnCmd = Util::which('swapon'); |
1226 | 1226 | $result = Processes::mwExec("{$swapOnCmd} {$swapFile}"); |
1227 | - Util::sysLogMsg('Swap', 'connect swap result: ' . $result, LOG_INFO, LOG_INFO); |
|
1227 | + Util::sysLogMsg('Swap', 'connect swap result: '.$result, LOG_INFO, LOG_INFO); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | $size = 0; |
1238 | 1238 | $mntDir = ''; |
1239 | 1239 | $mounted = self::isStorageDiskMounted('', $mntDir); |
1240 | - if ( ! $mounted) { |
|
1240 | + if (!$mounted) { |
|
1241 | 1241 | return 0; |
1242 | 1242 | } |
1243 | 1243 | $hd = $this->getAllHdd(true); |
@@ -1258,12 +1258,12 @@ discard block |
||
1258 | 1258 | */ |
1259 | 1259 | public function saveDiskSettings($data, $id = '1'): void |
1260 | 1260 | { |
1261 | - if ( ! is_array($data)) { |
|
1261 | + if (!is_array($data)) { |
|
1262 | 1262 | return; |
1263 | 1263 | } |
1264 | 1264 | $disk_data = $this->getDiskSettings($id); |
1265 | 1265 | if (count($disk_data) === 0) { |
1266 | - $uniqid = strtoupper('STORAGE-DISK-' . md5(time())); |
|
1266 | + $uniqid = strtoupper('STORAGE-DISK-'.md5(time())); |
|
1267 | 1267 | $storage_settings = new StorageModel(); |
1268 | 1268 | foreach ($data as $key => $val) { |
1269 | 1269 | $storage_settings->writeAttribute($key, $val); |
@@ -460,17 +460,17 @@ |
||
460 | 460 | $test_alert = ''; |
461 | 461 | if ($free < 5) { |
462 | 462 | $need_alert = true; |
463 | - $test_alert = "The {$disk['id']} has less than 5% of free space available."; |
|
463 | + $test_alert = "the {$disk['id']} has less than 5% of free space available."; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | if ($disk['free_space'] < 500) { |
467 | 467 | $need_alert = true; |
468 | - $test_alert = "The {$disk['id']} has less than 500MB of free space available."; |
|
468 | + $test_alert = "the {$disk['id']} has less than 500MB of free space available."; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | if ($disk['free_space'] < 100) { |
472 | 472 | $need_alert = true; |
473 | - $test_alert = "The {$disk['id']} has less than 100MB of free space available. Old call records will be deleted."; |
|
473 | + $test_alert = "the {$disk['id']} has less than 100MB of free space available. Old call records will be deleted."; |
|
474 | 474 | Processes::processPHPWorker(WorkerRemoveOldRecords::class); |
475 | 475 | } |
476 | 476 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | if (is_array($value)) { |
49 | 49 | array_unshift($value, ' '); |
50 | - $result_config .= trim(implode("\n{$key} = ", $value)) . "\n"; |
|
50 | + $result_config .= trim(implode("\n{$key} = ", $value))."\n"; |
|
51 | 51 | } else { |
52 | 52 | $result_config .= "{$key} = {$value}\n"; |
53 | 53 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public static function amiOriginate($peer_number, $peer_mobile, $dest_number): array |
70 | 70 | { |
71 | 71 | $am = self::getAstManager('off'); |
72 | - $channel = 'Local/' . $peer_number . '@internal-originate'; |
|
72 | + $channel = 'Local/'.$peer_number.'@internal-originate'; |
|
73 | 73 | $context = 'all_peers'; |
74 | 74 | $IS_ORGNT = self::generateRandomString(); |
75 | 75 | $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}"; |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | public static function trimExtensionForFile($filename, $delimiter = '.'): string |
337 | 337 | { |
338 | 338 | // Отсечем расширение файла. |
339 | - $tmp_arr = explode((string)$delimiter, $filename); |
|
339 | + $tmp_arr = explode((string) $delimiter, $filename); |
|
340 | 340 | if (count($tmp_arr) > 1) { |
341 | 341 | unset($tmp_arr[count($tmp_arr) - 1]); |
342 | - $filename = implode((string)$delimiter, $tmp_arr); |
|
342 | + $filename = implode((string) $delimiter, $tmp_arr); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $filename; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public static function mwExec($command, &$outArr = null, &$retVal = null): int |
420 | 420 | { |
421 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
421 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
422 | 422 | |
423 | 423 | return Processes::mwExec($command, $outArr, $retVal); |
424 | 424 | } |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | $objects = scandir($dir); |
464 | 464 | foreach ($objects as $object) { |
465 | 465 | if ($object != "." && $object != "..") { |
466 | - if (filetype($dir . "/" . $object) == "dir") { |
|
467 | - self::rRmDir($dir . "/" . $object); |
|
466 | + if (filetype($dir."/".$object) == "dir") { |
|
467 | + self::rRmDir($dir."/".$object); |
|
468 | 468 | } else { |
469 | - unlink($dir . "/" . $object); |
|
469 | + unlink($dir."/".$object); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | public static function generateSslCert($options = null, $config_args_pkey = null, $config_args_csr = null): array |
490 | 490 | { |
491 | 491 | // Инициализация настроек. |
492 | - if ( ! $options) { |
|
492 | + if (!$options) { |
|
493 | 493 | $options = [ |
494 | 494 | "countryName" => 'RU', |
495 | 495 | "stateOrProvinceName" => 'Moscow', |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | ]; |
502 | 502 | } |
503 | 503 | |
504 | - if ( ! $config_args_csr) { |
|
504 | + if (!$config_args_csr) { |
|
505 | 505 | $config_args_csr = ['digest_alg' => 'sha256']; |
506 | 506 | } |
507 | 507 | |
508 | - if ( ! $config_args_pkey) { |
|
508 | + if (!$config_args_pkey) { |
|
509 | 509 | $config_args_pkey = [ |
510 | 510 | "private_key_bits" => 2048, |
511 | 511 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
@@ -593,12 +593,12 @@ discard block |
||
593 | 593 | $arrPaths = explode(' ', $parameters); |
594 | 594 | if (count($arrPaths) > 0) { |
595 | 595 | foreach ($arrPaths as $path) { |
596 | - if ( ! empty($path) |
|
597 | - && ! file_exists($path) |
|
598 | - && ! mkdir($path, 0755, true) |
|
599 | - && ! is_dir($path)) { |
|
596 | + if (!empty($path) |
|
597 | + && !file_exists($path) |
|
598 | + && !mkdir($path, 0755, true) |
|
599 | + && !is_dir($path)) { |
|
600 | 600 | $result = false; |
601 | - self::sysLogMsg('Util', 'Error on create folder ' . $path); |
|
601 | + self::sysLogMsg('Util', 'Error on create folder '.$path); |
|
602 | 602 | } |
603 | 603 | if ($addWWWRights) { |
604 | 604 | self::addRegularWWWRights($path); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | $row = trim($row); |
673 | 673 | $pos = strpos($row, ']'); |
674 | 674 | if ($pos !== false && strpos($row, '[') === 0) { |
675 | - $row = "\n" . substr($row, 0, $pos); |
|
675 | + $row = "\n".substr($row, 0, $pos); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | unset($row); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | foreach ($sections as $section) { |
685 | 685 | $data_rows = explode("\n", trim($section)); |
686 | 686 | $section_name = trim($data_rows[0] ?? ''); |
687 | - if ( ! empty($section_name)) { |
|
687 | + if (!empty($section_name)) { |
|
688 | 688 | unset($data_rows[0]); |
689 | 689 | $manual_data[$section_name] = []; |
690 | 690 | foreach ($data_rows as $row) { |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $reflection = new ReflectionClass($className); |
745 | 745 | $filename = $reflection->getFileName(); |
746 | 746 | } catch (ReflectionException $exception) { |
747 | - self::sysLogMsg('Util', 'Error ' . $exception->getMessage()); |
|
747 | + self::sysLogMsg('Util', 'Error '.$exception->getMessage()); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return $filename; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public static function getPidOfProcess($name, $exclude = ''): string |
763 | 763 | { |
764 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
764 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
765 | 765 | |
766 | 766 | return Processes::getPidOfProcess($name, $exclude); |
767 | 767 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public static function processWorker($cmd, $param, $proc_name, $action, $out_file = '/dev/null') |
783 | 783 | { |
784 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
784 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
785 | 785 | |
786 | 786 | return Processes::processWorker($cmd, $param, $proc_name, $action, $out_file); |
787 | 787 | } |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | string $param = 'start', |
800 | 800 | string $action = 'restart' |
801 | 801 | ): void { |
802 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
802 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
803 | 803 | Processes::processPHPWorker($className, $param, $action); |
804 | 804 | } |
805 | 805 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | */ |
814 | 814 | public static function killByName($procName): ?int |
815 | 815 | { |
816 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
816 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
817 | 817 | |
818 | 818 | return Processes::killByName($procName); |
819 | 819 | } |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | */ |
829 | 829 | public static function mwExecBg($command, $out_file = '/dev/null', $sleep_time = 0): void |
830 | 830 | { |
831 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
831 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
832 | 832 | Processes::mwExecBg($command, $out_file, $sleep_time); |
833 | 833 | } |
834 | 834 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public static function mwExecBgWithTimeout($command, $timeout = 4, $logname = '/dev/null'): void |
844 | 844 | { |
845 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
845 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
846 | 846 | Processes::mwExecBgWithTimeout($command, $timeout, $logname); |
847 | 847 | } |
848 | 848 | |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | */ |
857 | 857 | public static function mwExecCommands($arr_cmds, &$out = [], $logname = ''): void |
858 | 858 | { |
859 | - self::sysLogMsg('Util', 'Deprecated call ' . __METHOD__ . ' from ' . static::class); |
|
859 | + self::sysLogMsg('Util', 'Deprecated call '.__METHOD__.' from '.static::class); |
|
860 | 860 | Processes::mwExecCommands($arr_cmds, $out, $logname); |
861 | 861 | } |
862 | 862 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function logRotate(): void |
36 | 36 | { |
37 | - $log_dir = System::getLogDir() . '/nats'; |
|
37 | + $log_dir = System::getLogDir().'/nats'; |
|
38 | 38 | $gnatsdPath = Util::which('gnatsd'); |
39 | 39 | $pid = Processes::getPidOfProcess($gnatsdPath, 'custom_modules'); |
40 | 40 | $max_size = 1; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | if (Util::mFileSize("{$log_dir}/gnatsd.log") > $mb10) { |
64 | 64 | $options = '-f'; |
65 | 65 | } |
66 | - $di = Di::getDefault(); |
|
67 | - if ($di !== null){ |
|
66 | + $di = Di::getDefault(); |
|
67 | + if ($di !== null) { |
|
68 | 68 | $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
69 | 69 | } else { |
70 | 70 | $varEtcDir = '/var/etc'; |
71 | 71 | } |
72 | - $path_conf = $varEtcDir . '/gnatsd_logrotate.conf'; |
|
72 | + $path_conf = $varEtcDir.'/gnatsd_logrotate.conf'; |
|
73 | 73 | file_put_contents($path_conf, $text_config); |
74 | 74 | if (file_exists("{$log_dir}/gnatsd.log")) { |
75 | 75 | $logrotatePath = Util::which('logrotate'); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $confdir = '/etc/nats'; |
86 | 86 | Util::mwMkdir($confdir); |
87 | 87 | |
88 | - $logdir = System::getLogDir() . '/nats'; |
|
88 | + $logdir = System::getLogDir().'/nats'; |
|
89 | 89 | Util::mwMkdir($logdir); |
90 | 90 | |
91 | 91 | $tempDir = $this->di->getShared('config')->path('core.tempDir'); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'sessions_path' => $sessionsDir, |
107 | 107 | 'log_file' => "{$logdir}/gnatsd.log", |
108 | 108 | ]; |
109 | - $config = ''; |
|
109 | + $config = ''; |
|
110 | 110 | foreach ($settings as $key => $val) { |
111 | 111 | $config .= "{$key}: {$val} \n"; |
112 | 112 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $syslog_file = '/var/log/messages'; |
26 | 26 | $log_file = self::getSyslogFile(); |
27 | - if ( ! file_exists($syslog_file)) { |
|
27 | + if (!file_exists($syslog_file)) { |
|
28 | 28 | file_put_contents($syslog_file, ''); |
29 | 29 | } |
30 | 30 | $syslogdPath = Util::which('syslogd'); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | $logreadPath = Util::which('logread'); |
33 | 33 | $killPath = Util::which('kill'); |
34 | 34 | $pid = Processes::getPidOfProcess($syslogdPath); |
35 | - if ( ! empty($pid)) { |
|
35 | + if (!empty($pid)) { |
|
36 | 36 | $options = file_exists($log_file) ? '>' : ''; |
37 | - Processes::mwExec("{$busyboxPath} {$logreadPath} 2> /dev/null >" . $options . $log_file); |
|
37 | + Processes::mwExec("{$busyboxPath} {$logreadPath} 2> /dev/null >".$options.$log_file); |
|
38 | 38 | // Завершаем процесс. |
39 | 39 | Processes::mwExec("{$busyboxPath} {$killPath} '$pid'"); |
40 | 40 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function getSyslogFile(): string |
51 | 51 | { |
52 | - $logdir = System::getLogDir() . '/system'; |
|
52 | + $logdir = System::getLogDir().'/system'; |
|
53 | 53 | Util::mwMkdir($logdir); |
54 | 54 | return "$logdir/messages"; |
55 | 55 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | while (true) { |
39 | 39 | $pid = Processes::getPidOfProcess('beanstalkd'); |
40 | 40 | if (empty($pid)) { |
41 | - Util::echoWithSyslog(' - Wait for start beanstalkd deamon ...' . PHP_EOL); |
|
41 | + Util::echoWithSyslog(' - Wait for start beanstalkd deamon ...'.PHP_EOL); |
|
42 | 42 | sleep(2); |
43 | 43 | } else { |
44 | 44 | break; |