@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $activeProcesses = Util::getPidOfProcess(static::class, getmypid()); |
| 38 | 38 | if ($this->maxProc === 1) { |
| 39 | - if ( ! empty($activeProcesses)) { |
|
| 39 | + if (!empty($activeProcesses)) { |
|
| 40 | 40 | $killApp = Util::which('kill'); |
| 41 | 41 | // Завершаем старый процесс. |
| 42 | 42 | Util::mwExec("{$killApp} {$activeProcesses}"); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | // Запустим нехдостающие процессы |
| 49 | 49 | $countProc = count($processes); |
| 50 | 50 | while ($countProc < $this->maxProc) { |
| 51 | - Util::processPHPWorker(static::class,'start','multiStart'); |
|
| 51 | + Util::processPHPWorker(static::class, 'start', 'multiStart'); |
|
| 52 | 52 | $countProc++; |
| 53 | 53 | } |
| 54 | 54 | // Получим количество лишних процессов. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $killApp = Util::which('kill'); |
| 57 | 57 | // Завершим лишние |
| 58 | 58 | while ($countProc >= 0) { |
| 59 | - if ( ! isset($processes[$countProc])) { |
|
| 59 | + if (!isset($processes[$countProc])) { |
|
| 60 | 60 | break; |
| 61 | 61 | } |
| 62 | 62 | // Завершаем старый процесс. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function pingCallBack(BeanstalkClient $message): void |
| 93 | 93 | { |
| 94 | - $message->reply(json_encode($message->getBody() . ':pong')); |
|
| 94 | + $message->reply(json_encode($message->getBody().':pong')); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | { |
| 106 | 106 | $pingTube = $this->makePingTubeName(static::class); |
| 107 | 107 | if ($pingTube === $parameters['UserEvent']) { |
| 108 | - $this->am->UserEvent("{$pingTube}Pong", []); |
|
| 108 | + $this->am->UserEvent("{$pingTube}pong", []); |
|
| 109 | 109 | |
| 110 | 110 | return true; |
| 111 | 111 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $arrWorkers = $this->prepareWorkersList(); |
| 44 | 44 | ReactKernel::start( |
| 45 | - function () use ($arrWorkers) { |
|
| 45 | + function() use ($arrWorkers) { |
|
| 46 | 46 | // Parallel execution https://github.com/recoilphp/recoil |
| 47 | 47 | foreach ($arrWorkers as $workersWithCurrentType) { |
| 48 | 48 | foreach ($workersWithCurrentType as $worker) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function prepareWorkersList(): array |
| 63 | 63 | { |
| 64 | - $arrWorkers = [ |
|
| 64 | + $arrWorkers = [ |
|
| 65 | 65 | self::CHECK_BY_AMI => |
| 66 | 66 | [ |
| 67 | 67 | WorkerAmiListener::class, |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | PBX::waitFullyBooted(); |
| 124 | 124 | $arrWorkers = $this->prepareWorkersList(); |
| 125 | 125 | ReactKernel::start( |
| 126 | - function () use ($arrWorkers) { |
|
| 126 | + function() use ($arrWorkers) { |
|
| 127 | 127 | // Parallel execution https://github.com/recoilphp/recoil |
| 128 | 128 | foreach ($arrWorkers as $workerType => $workersWithCurrentType) { |
| 129 | 129 | foreach ($workersWithCurrentType as $worker) { |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | } catch (\Error $e) { |
| 175 | 175 | global $errorLogger; |
| 176 | 176 | $errorLogger->captureException($e); |
| 177 | - Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage()); |
|
| 177 | + Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage()); |
|
| 178 | 178 | } catch (DeadlineSoonException $e) { |
| 179 | - Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage()); |
|
| 179 | + Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage()); |
|
| 180 | 180 | } |
| 181 | 181 | yield; |
| 182 | 182 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } catch (\Error $e) { |
| 250 | 250 | global $errorLogger; |
| 251 | 251 | $errorLogger->captureException($e); |
| 252 | - Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage()); |
|
| 252 | + Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage()); |
|
| 253 | 253 | } |
| 254 | 254 | yield; |
| 255 | 255 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | if (false === $result) { |
| 164 | 164 | Util::processPHPWorker($workerClassName); |
| 165 | - Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started."); |
|
| 165 | + Util::sysLogMsg(__CLASS__, "service {$workerClassName} started."); |
|
| 166 | 166 | } |
| 167 | 167 | $time_elapsed_secs = microtime(true) - $start; |
| 168 | 168 | if ($time_elapsed_secs > 10) { |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | if ($res_ping === false && $level < 10) { |
| 234 | 234 | Util::processPHPWorker($workerClassName); |
| 235 | - Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started."); |
|
| 235 | + Util::sysLogMsg(__CLASS__, "service {$workerClassName} started."); |
|
| 236 | 236 | // Wait 1 second while service will be ready to listen requests |
| 237 | 237 | sleep(1); |
| 238 | 238 | |
@@ -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 | Util::mwExec("{$umountPath} {$device}"); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( ! self::isStorageDiskMounted($device)) { |
|
| 104 | + if (!self::isStorageDiskMounted($device)) { |
|
| 105 | 105 | Util::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 | Util::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 | Util::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0"); |
| 342 | 342 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 | Util::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 = Util::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); |
@@ -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 | Util::processPHPWorker(WorkerRemoveOldRecords::class); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -262,32 +262,32 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $WorkerPID = self::getPidOfProcess($proc_name); |
| 264 | 264 | |
| 265 | - switch ($action) { |
|
| 266 | - case 'status': |
|
| 265 | + switch ($action) { |
|
| 266 | + case 'status': |
|
| 267 | 267 | $status = ($WorkerPID !== '') ? 'Started' : 'Stoped'; |
| 268 | - return ['status' => $status, 'app' => $proc_name, 'PID' => $WorkerPID]; |
|
| 269 | - case 'restart': |
|
| 268 | + return ['status' => $status, 'app' => $proc_name, 'PID' => $WorkerPID]; |
|
| 269 | + case 'restart': |
|
| 270 | 270 | // Firstly start new process |
| 271 | 271 | self::mwExec("{$path_nohup} {$cmd} {$param} > {$out_file} 2>&1 &"); |
| 272 | - // Then kill the old one |
|
| 273 | - if ($WorkerPID !== '') { |
|
| 274 | - self::mwExec("{$path_kill} -9 {$WorkerPID} > /dev/null 2>&1 &"); |
|
| 275 | - } |
|
| 276 | - break; |
|
| 277 | - case 'stop': |
|
| 272 | + // Then kill the old one |
|
| 273 | + if ($WorkerPID !== '') { |
|
| 274 | + self::mwExec("{$path_kill} -9 {$WorkerPID} > /dev/null 2>&1 &"); |
|
| 275 | + } |
|
| 276 | + break; |
|
| 277 | + case 'stop': |
|
| 278 | 278 | if ($WorkerPID !== '') { |
| 279 | - self::mwExec("{$path_kill} -9 {$WorkerPID} > /dev/null 2>&1 &"); |
|
| 280 | - } |
|
| 281 | - break; |
|
| 282 | - case 'start': |
|
| 279 | + self::mwExec("{$path_kill} -9 {$WorkerPID} > /dev/null 2>&1 &"); |
|
| 280 | + } |
|
| 281 | + break; |
|
| 282 | + case 'start': |
|
| 283 | 283 | if ($WorkerPID === '') { |
| 284 | - self::mwExec("{$path_nohup} {$cmd} {$param} > {$out_file} 2>&1 &"); |
|
| 285 | - } |
|
| 286 | - break; |
|
| 287 | - case 'multiStart': |
|
| 284 | + self::mwExec("{$path_nohup} {$cmd} {$param} > {$out_file} 2>&1 &"); |
|
| 285 | + } |
|
| 286 | + break; |
|
| 287 | + case 'multiStart': |
|
| 288 | 288 | self::mwExec("{$path_nohup} {$cmd} {$param} > {$out_file} 2>&1 &"); |
| 289 | - break; |
|
| 290 | - default: |
|
| 289 | + break; |
|
| 290 | + default: |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return true; |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}"; |
| 376 | 376 | |
| 377 | 377 | return $am->Originate($channel, |
| 378 | - $dest_number, |
|
| 379 | - $context, |
|
| 380 | - '1', null, null, null, null, $variable, null, true); |
|
| 378 | + $dest_number, |
|
| 379 | + $context, |
|
| 380 | + '1', null, null, null, null, $variable, null, true); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | if (is_array($value)) { |
| 46 | 46 | array_unshift($value, ' '); |
| 47 | - $result_config .= trim(implode("\n{$key} = ", $value)) . "\n"; |
|
| 47 | + $result_config .= trim(implode("\n{$key} = ", $value))."\n"; |
|
| 48 | 48 | } else { |
| 49 | 49 | $result_config .= "{$key} = {$value}\n"; |
| 50 | 50 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $killallPath = self::which('killall'); |
| 66 | 66 | |
| 67 | - return self::mwExec($killallPath . ' ' . escapeshellarg($procName)); |
|
| 67 | + return self::mwExec($killallPath.' '.escapeshellarg($procName)); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public static function mwExec($command, &$outArr = null, &$retVal = null): int |
| 80 | 80 | { |
| 81 | 81 | $retVal = 0; |
| 82 | - $outArr = []; |
|
| 82 | + $outArr = []; |
|
| 83 | 83 | $di = Di::getDefault(); |
| 84 | 84 | |
| 85 | 85 | if ($di !== null && $di->getShared('config')->path('core.debugMode')) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $rmPath = self::which('rm'); |
| 106 | 106 | $sleepPath = self::which('sleep'); |
| 107 | 107 | if ($sleep_time > 0) { |
| 108 | - $filename = '/tmp/' . time() . '_noop.sh'; |
|
| 108 | + $filename = '/tmp/'.time().'_noop.sh'; |
|
| 109 | 109 | file_put_contents($filename, "{$sleepPath} {$sleep_time}; {$command}; {$rmPath} -rf {$filename}"); |
| 110 | 110 | $noop_command = "{$nohupPath} {$shPath} {$filename} > {$out_file} 2>&1 &"; |
| 111 | 111 | } else { |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return bool |
| 169 | 169 | */ |
| 170 | - public static function mwMkdir(string $parameters, bool $addWWWRights=false): bool |
|
| 170 | + public static function mwMkdir(string $parameters, bool $addWWWRights = false): bool |
|
| 171 | 171 | { |
| 172 | 172 | $result = true; |
| 173 | 173 | if (posix_getuid() === 0) { |
| 174 | 174 | $arrPaths = explode(' ', $parameters); |
| 175 | 175 | if (count($arrPaths) > 0) { |
| 176 | 176 | foreach ($arrPaths as $path) { |
| 177 | - if ( ! empty($path) |
|
| 178 | - && ! file_exists($path) |
|
| 179 | - && ! mkdir($path, 0755, true) |
|
| 180 | - && ! is_dir($path)) { |
|
| 177 | + if (!empty($path) |
|
| 178 | + && !file_exists($path) |
|
| 179 | + && !mkdir($path, 0755, true) |
|
| 180 | + && !is_dir($path)) { |
|
| 181 | 181 | $result = false; |
| 182 | 182 | self::sysLogMsg('Util', 'Error on create folder '.$path); |
| 183 | 183 | } |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | * @param string $param |
| 198 | 198 | * @param string $action |
| 199 | 199 | */ |
| 200 | - public static function processPHPWorker(string $className, string $param = 'start', string $action='restart'): void |
|
| 200 | + public static function processPHPWorker(string $className, string $param = 'start', string $action = 'restart'): void |
|
| 201 | 201 | { |
| 202 | 202 | $workerPath = self::getFilePathByClassName($className); |
| 203 | - if ( ! empty($workerPath)) { |
|
| 203 | + if (!empty($workerPath)) { |
|
| 204 | 204 | $command = "php -f {$workerPath}"; |
| 205 | 205 | self::processWorker($command, $param, $className, $action); |
| 206 | 206 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $reflection = new ReflectionClass($className); |
| 222 | 222 | $filename = $reflection->getFileName(); |
| 223 | 223 | } catch (\ReflectionException $exception) { |
| 224 | - self::sysLogMsg('Util', 'Error ' . $exception->getMessage()); |
|
| 224 | + self::sysLogMsg('Util', 'Error '.$exception->getMessage()); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $filename; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param ?int $level |
| 236 | 236 | * @param ?int $facility |
| 237 | 237 | */ |
| 238 | - public static function sysLogMsg($log_name, $text, $level = null, $facility=LOG_AUTH): void |
|
| 238 | + public static function sysLogMsg($log_name, $text, $level = null, $facility = LOG_AUTH): void |
|
| 239 | 239 | { |
| 240 | 240 | $level = ($level === null) ? LOG_WARNING : $level; |
| 241 | 241 | openlog("$log_name", LOG_PID | LOG_PERROR, $facility); |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $name = addslashes($name); |
| 348 | 348 | $filter_cmd = ''; |
| 349 | - if ( ! empty($exclude)) { |
|
| 350 | - $filter_cmd = "| $path_grep -v " . escapeshellarg($exclude); |
|
| 349 | + if (!empty($exclude)) { |
|
| 350 | + $filter_cmd = "| $path_grep -v ".escapeshellarg($exclude); |
|
| 351 | 351 | } |
| 352 | 352 | $out = []; |
| 353 | 353 | self::mwExec( |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | public static function amiOriginate($peer_number, $peer_mobile, $dest_number): array |
| 370 | 370 | { |
| 371 | 371 | $am = self::getAstManager('off'); |
| 372 | - $channel = 'Local/' . $peer_number . '@internal-originate'; |
|
| 372 | + $channel = 'Local/'.$peer_number.'@internal-originate'; |
|
| 373 | 373 | $context = 'all_peers'; |
| 374 | 374 | $IS_ORGNT = self::generateRandomString(); |
| 375 | 375 | $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}"; |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | public static function getAstManager($events = 'on'): AsteriskManager |
| 391 | 391 | { |
| 392 | - if($events === 'on'){ |
|
| 392 | + if ($events === 'on') { |
|
| 393 | 393 | $nameService = 'amiListner'; |
| 394 | - }else{ |
|
| 394 | + } else { |
|
| 395 | 395 | $nameService = 'amiCommander'; |
| 396 | 396 | } |
| 397 | 397 | |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | for ($i = 0; $i < $length; $i++) { |
| 418 | 418 | try { |
| 419 | 419 | $randomString .= $characters[random_int(0, $charactersLength - 1)]; |
| 420 | - }catch (\Exception $e ){ |
|
| 420 | + } catch (\Exception $e) { |
|
| 421 | 421 | $randomString = ''; |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | public static function getExtensionOfFile($filename) |
| 598 | 598 | { |
| 599 | 599 | $path_parts = pathinfo($filename); |
| 600 | - return $path_parts['extension']??''; |
|
| 600 | + return $path_parts['extension'] ?? ''; |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -611,10 +611,10 @@ discard block |
||
| 611 | 611 | public static function trimExtensionForFile($filename, $delimiter = '.'): string |
| 612 | 612 | { |
| 613 | 613 | // Отсечем расширение файла. |
| 614 | - $tmp_arr = explode((string)$delimiter, $filename); |
|
| 614 | + $tmp_arr = explode((string) $delimiter, $filename); |
|
| 615 | 615 | if (count($tmp_arr) > 1) { |
| 616 | 616 | unset($tmp_arr[count($tmp_arr) - 1]); |
| 617 | - $filename = implode((string)$delimiter, $tmp_arr); |
|
| 617 | + $filename = implode((string) $delimiter, $tmp_arr); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | return $filename; |
@@ -686,14 +686,14 @@ discard block |
||
| 686 | 686 | $objects = scandir($dir); |
| 687 | 687 | foreach ($objects as $object) { |
| 688 | 688 | if ($object != "." && $object != "..") { |
| 689 | - if (filetype($dir . "/" . $object) == "dir") { |
|
| 690 | - self::rRmDir($dir . "/" . $object); |
|
| 689 | + if (filetype($dir."/".$object) == "dir") { |
|
| 690 | + self::rRmDir($dir."/".$object); |
|
| 691 | 691 | } else { |
| 692 | - unlink($dir . "/" . $object); |
|
| 692 | + unlink($dir."/".$object); |
|
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | - if($objects !== false){ |
|
| 696 | + if ($objects !== false) { |
|
| 697 | 697 | reset($objects); |
| 698 | 698 | } |
| 699 | 699 | rmdir($dir); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | public static function generateSslCert($options = null, $config_args_pkey = null, $config_args_csr = null): array |
| 713 | 713 | { |
| 714 | 714 | // Инициализация настроек. |
| 715 | - if ( ! $options) { |
|
| 715 | + if (!$options) { |
|
| 716 | 716 | $options = [ |
| 717 | 717 | "countryName" => 'RU', |
| 718 | 718 | "stateOrProvinceName" => 'Moscow', |
@@ -724,11 +724,11 @@ discard block |
||
| 724 | 724 | ]; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - if ( ! $config_args_csr) { |
|
| 727 | + if (!$config_args_csr) { |
|
| 728 | 728 | $config_args_csr = ['digest_alg' => 'sha256']; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - if ( ! $config_args_pkey) { |
|
| 731 | + if (!$config_args_pkey) { |
|
| 732 | 732 | $config_args_pkey = [ |
| 733 | 733 | "private_key_bits" => 2048, |
| 734 | 734 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | $row = trim($row); |
| 875 | 875 | $pos = strpos($row, ']'); |
| 876 | 876 | if ($pos !== false && strpos($row, '[') === 0) { |
| 877 | - $row = "\n" . substr($row, 0, $pos); |
|
| 877 | + $row = "\n".substr($row, 0, $pos); |
|
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | unset($row); |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | foreach ($sections as $section) { |
| 887 | 887 | $data_rows = explode("\n", trim($section)); |
| 888 | 888 | $section_name = trim($data_rows[0] ?? ''); |
| 889 | - if ( ! empty($section_name)) { |
|
| 889 | + if (!empty($section_name)) { |
|
| 890 | 890 | unset($data_rows[0]); |
| 891 | 891 | $manual_data[$section_name] = []; |
| 892 | 892 | foreach ($data_rows as $row) { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct($tube = 'default', $port = '') |
| 39 | 39 | { |
| 40 | - $this->tube = str_replace("\\", '-', $tube);; |
|
| 40 | + $this->tube = str_replace("\\", '-', $tube); ; |
|
| 41 | 41 | $this->job_options = ['priority' => 250, 'delay' => 0, 'ttr' => 3600]; |
| 42 | 42 | $this->port = $port; |
| 43 | 43 | $this->reconnect(); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $config = $this->di->get('config')->beanstalk; |
| 52 | 52 | $port = $config->port; |
| 53 | - if(!empty($this->port) && is_numeric($this->port)){ |
|
| 53 | + if (!empty($this->port) && is_numeric($this->port)) { |
|
| 54 | 54 | $port = $this->port; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | $tube = str_replace("\\", '-', $tube); |
| 130 | 130 | // Change tube |
| 131 | - if ( ! empty($tube) && $this->tube !== $tube) { |
|
| 131 | + if (!empty($tube) && $this->tube !== $tube) { |
|
| 132 | 132 | $this->queue->useTube($tube); |
| 133 | 133 | } |
| 134 | 134 | $job_data = serialize($job_data); |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Processing job over callable function attached in $this->subscribe |
| 183 | - if(json_decode($job->getData(), true) !==null){ |
|
| 184 | - $mData = $job->getData(); |
|
| 185 | - }else{ |
|
| 183 | + if (json_decode($job->getData(), true) !== null) { |
|
| 184 | + $mData = $job->getData(); |
|
| 185 | + } else { |
|
| 186 | 186 | $mData = unserialize($job->getData(), [false]); |
| 187 | 187 | } |
| 188 | 188 | $this->message = $mData; |
@@ -262,28 +262,28 @@ discard block |
||
| 262 | 262 | /** |
| 263 | 263 | * Drops orphaned tasks |
| 264 | 264 | */ |
| 265 | - public function cleanTube(){ |
|
| 265 | + public function cleanTube() { |
|
| 266 | 266 | $tubes = $this->queue->listTubes(); |
| 267 | - foreach ($tubes as $tube){ |
|
| 268 | - if(strpos($tube, "INBOX_") !== 0){ |
|
| 267 | + foreach ($tubes as $tube) { |
|
| 268 | + if (strpos($tube, "INBOX_") !== 0) { |
|
| 269 | 269 | continue; |
| 270 | 270 | } |
| 271 | 271 | try { |
| 272 | 272 | $statData = $this->queue->statsTube($tube)->getArrayCopy(); |
| 273 | 273 | $watching = $statData['current-watching']; |
| 274 | - if($watching !== '0'){ |
|
| 274 | + if ($watching !== '0') { |
|
| 275 | 275 | continue; |
| 276 | 276 | } |
| 277 | 277 | // Нужно удалить все Jobs. |
| 278 | 278 | $this->queue->watch($tube); |
| 279 | - while (true){ |
|
| 279 | + while (true) { |
|
| 280 | 280 | $job = $this->queue->reserveWithTimeout(1); |
| 281 | - if($job === null){ |
|
| 281 | + if ($job === null) { |
|
| 282 | 282 | break; |
| 283 | 283 | } |
| 284 | 284 | $this->queue->delete($job); |
| 285 | 285 | } |
| 286 | - }catch (\Exception $e){ |
|
| 286 | + } catch (\Exception $e) { |
|
| 287 | 287 | continue; |
| 288 | 288 | } |
| 289 | 289 | |