@@ -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(); |
@@ -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 |
@@ -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 | /** |
@@ -1102,13 +1102,13 @@ discard block |
||
1102 | 1102 | $cacheDirs[] = $this->config->path('www.downloadCacheDir'); |
1103 | 1103 | $cacheDirs[] = $this->config->path('www.managedCacheDir'); |
1104 | 1104 | $cacheDirs[] = $this->config->path('www.modelsCacheDir'); |
1105 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js'; |
|
1106 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css'; |
|
1107 | - $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img'; |
|
1105 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js'; |
|
1106 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css'; |
|
1107 | + $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img'; |
|
1108 | 1108 | $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir'); |
1109 | 1109 | $rmPath = Util::which('rm'); |
1110 | 1110 | foreach ($cacheDirs as $cacheDir) { |
1111 | - if ( ! empty($cacheDir)) { |
|
1111 | + if (!empty($cacheDir)) { |
|
1112 | 1112 | Processes::mwExec("{$rmPath} -rf {$cacheDir}/*"); |
1113 | 1113 | } |
1114 | 1114 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $countBlock = $swapSize * $bs; |
1219 | 1219 | $ddCmd = Util::which('dd'); |
1220 | 1220 | |
1221 | - Util::sysLogMsg('Swap', 'make swap ' . $swapFile, LOG_INFO, LOG_INFO); |
|
1221 | + Util::sysLogMsg('Swap', 'make swap '.$swapFile, LOG_INFO, LOG_INFO); |
|
1222 | 1222 | Processes::mwExec("{$ddCmd} if=/dev/zero of={$swapFile} bs={$bs} count={$countBlock}"); |
1223 | 1223 | |
1224 | 1224 | $mkSwapCmd = Util::which('mkswap'); |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | $swapOnCmd = Util::which('swapon'); |
1228 | 1228 | $result = Processes::mwExec("{$swapOnCmd} {$swapFile}"); |
1229 | - Util::sysLogMsg('Swap', 'connect swap result: ' . $result, LOG_INFO, LOG_INFO); |
|
1229 | + Util::sysLogMsg('Swap', 'connect swap result: '.$result, LOG_INFO, LOG_INFO); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | $size = 0; |
1240 | 1240 | $mntDir = ''; |
1241 | 1241 | $mounted = self::isStorageDiskMounted('', $mntDir); |
1242 | - if ( ! $mounted) { |
|
1242 | + if (!$mounted) { |
|
1243 | 1243 | return 0; |
1244 | 1244 | } |
1245 | 1245 | $hd = $this->getAllHdd(true); |
@@ -1260,12 +1260,12 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | public function saveDiskSettings($data, $id = '1'): void |
1262 | 1262 | { |
1263 | - if ( ! is_array($data)) { |
|
1263 | + if (!is_array($data)) { |
|
1264 | 1264 | return; |
1265 | 1265 | } |
1266 | 1266 | $disk_data = $this->getDiskSettings($id); |
1267 | 1267 | if (count($disk_data) === 0) { |
1268 | - $uniqid = strtoupper('STORAGE-DISK-' . md5(time())); |
|
1268 | + $uniqid = strtoupper('STORAGE-DISK-'.md5(time())); |
|
1269 | 1269 | $storage_settings = new StorageModel(); |
1270 | 1270 | foreach ($data as $key => $val) { |
1271 | 1271 | $storage_settings->writeAttribute($key, $val); |
@@ -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; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function configure() |
33 | 33 | { |
34 | 34 | $lofFile = '/var/log/lastlog'; |
35 | - if(!file_exists($lofFile)){ |
|
35 | + if (!file_exists($lofFile)) { |
|
36 | 36 | file_put_contents($lofFile, ''); |
37 | 37 | } |
38 | 38 | $dropbear_dir = '/etc/dropbear'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $dropbearkeyPath = Util::which('dropbearkey'); |
48 | 48 | $dropbearPath = Util::which('dropbear'); |
49 | 49 | foreach ($keytypes as $keytype => $db_key) { |
50 | - $res_keyfilepath = "{$dropbear_dir}/dropbear_" . $keytype . "_host_key"; |
|
50 | + $res_keyfilepath = "{$dropbear_dir}/dropbear_".$keytype."_host_key"; |
|
51 | 51 | $key = $this->mikoPBXConfig->getGeneralSettings($db_key); |
52 | 52 | $key = (isset($key) && is_string($key)) ? trim($key) : ""; |
53 | 53 | if (strlen($key) > 100) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | file_put_contents($res_keyfilepath, base64_decode($key)); |
56 | 56 | } |
57 | 57 | // If key not exists, we will generate and store new one into file and database |
58 | - if ( ! file_exists($res_keyfilepath)) { |
|
58 | + if (!file_exists($res_keyfilepath)) { |
|
59 | 59 | // Generation |
60 | 60 | Processes::mwExec("{$dropbearkeyPath} -t $keytype -f $res_keyfilepath"); |
61 | 61 | // Storing |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | echo $killPath.' -QUIT '.$pid."\n"; |
65 | 65 | } |
66 | 66 | $timeStart = time(); |
67 | - while (true){ |
|
68 | - if(time() - $timeStart > 20){ |
|
67 | + while (true) { |
|
68 | + if (time() - $timeStart > 20) { |
|
69 | 69 | break; |
70 | 70 | } |
71 | 71 | usleep(50000); |
72 | 72 | $pid = Processes::getPidOfProcess('nginx: master process'); |
73 | - if($pid !== ''){ |
|
73 | + if ($pid !== '') { |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | $result = Processes::mwExec($NginxPath); |
77 | - if($result === 0){ |
|
77 | + if ($result === 0) { |
|
78 | 78 | break; |
79 | 79 | } |
80 | 80 | echo "RESULT -- $result\n"; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $RedirectToHttps = $this->mikoPBXConfig->getGeneralSettings('RedirectToHttps'); |
114 | 114 | if ($RedirectToHttps === '1' && $not_ssl === false) { |
115 | - $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {' . PHP_EOL |
|
116 | - . ' ' . 'return 301 https://$host:' . $WEBHTTPSPort . '$request_uri;' . PHP_EOL |
|
117 | - . ' }' . PHP_EOL; |
|
115 | + $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {'.PHP_EOL |
|
116 | + . ' '.'return 301 https://$host:'.$WEBHTTPSPort.'$request_uri;'.PHP_EOL |
|
117 | + . ' }'.PHP_EOL; |
|
118 | 118 | $config = str_replace('include mikopbx/locations/*.conf;', $conf_data, $config); |
119 | 119 | } |
120 | 120 | file_put_contents($httpConfigFile, $config); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $WEBHTTPSPrivateKey = $this->mikoPBXConfig->getGeneralSettings('WEBHTTPSPrivateKey'); |
125 | 125 | if ( |
126 | 126 | $not_ssl === false |
127 | - && ! empty($WEBHTTPSPublicKey) |
|
128 | - && ! empty($WEBHTTPSPrivateKey) |
|
127 | + && !empty($WEBHTTPSPublicKey) |
|
128 | + && !empty($WEBHTTPSPrivateKey) |
|
129 | 129 | ) { |
130 | 130 | $public_filename = '/etc/ssl/certs/nginx.crt'; |
131 | 131 | $private_filename = '/etc/ssl/private/nginx.key'; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | // Test work |
142 | 142 | $currentConfigIsGood = $this->testCurrentNginxConfig(); |
143 | - if ($level < 1 && ! $currentConfigIsGood) { |
|
143 | + if ($level < 1 && !$currentConfigIsGood) { |
|
144 | 144 | ++$level; |
145 | 145 | Util::sysLogMsg('nginx', 'Failed test config file. SSL will be disable...'); |
146 | 146 | $this->generateConf(true, $level); |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function generateModulesConf(): void |
171 | 171 | { |
172 | - $locationsPath = self::MODULES_LOCATIONS_PATH; |
|
173 | - if (!is_dir($locationsPath)){ |
|
174 | - Util::mwMkdir($locationsPath,true); |
|
172 | + $locationsPath = self::MODULES_LOCATIONS_PATH; |
|
173 | + if (!is_dir($locationsPath)) { |
|
174 | + Util::mwMkdir($locationsPath, true); |
|
175 | 175 | } |
176 | 176 | $additionalModules = $this->di->getShared('pbxConfModules'); |
177 | 177 | $rmPath = Util::which('rm'); |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | foreach ($additionalModules as $appClass) { |
180 | 180 | if (method_exists($appClass, 'createNginxLocations')) { |
181 | 181 | $locationContent = $appClass->createNginxLocations(); |
182 | - if ( ! empty($locationContent)) { |
|
182 | + if (!empty($locationContent)) { |
|
183 | 183 | $confFileName = "{$locationsPath}/{$appClass->moduleUniqueId}.conf"; |
184 | 184 | file_put_contents($confFileName, $locationContent); |
185 | - if ( ! $this->testCurrentNginxConfig()) { |
|
185 | + if (!$this->testCurrentNginxConfig()) { |
|
186 | 186 | Processes::mwExec("{$rmPath} {$confFileName}"); |
187 | - Util::sysLogMsg('nginx', 'Failed test config file for module' . $appClass->moduleUniqueId); |
|
187 | + Util::sysLogMsg('nginx', 'Failed test config file for module'.$appClass->moduleUniqueId); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |