@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | if ($response !== false) { |
98 | 98 | $response = json_decode($response, true); |
99 | 99 | $filename = $response['data']['filename'] ?? ''; |
100 | - if ( ! file_exists($filename)) { |
|
100 | + if (!file_exists($filename)) { |
|
101 | 101 | $response['messages'][] = 'Config file not found'; |
102 | 102 | } else { |
103 | 103 | $response['data']['filename'] = $filename; |
104 | - $response['data']['content'] = mb_convert_encoding('' . file_get_contents($filename), 'UTF-8', 'UTF-8'); |
|
104 | + $response['data']['content'] = mb_convert_encoding(''.file_get_contents($filename), 'UTF-8', 'UTF-8'); |
|
105 | 105 | unlink($filename); |
106 | 106 | } |
107 | 107 | $this->response->setPayloadSuccess($response); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function uploadResumableAction(): void |
117 | 117 | { |
118 | - $data = $this->request->getPost(); |
|
118 | + $data = $this->request->getPost(); |
|
119 | 119 | $data['result'] = 'ERROR'; |
120 | 120 | |
121 | 121 | if ($this->request->hasFiles() > 0) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'resumableTotalSize' => $this->request->getPost('resumableTotalSize'), |
128 | 128 | ]; |
129 | 129 | foreach ($this->request->getUploadedFiles() as $file) { |
130 | - $data['files'][]= [ |
|
130 | + $data['files'][] = [ |
|
131 | 131 | 'file_path' => $file->getTempName(), |
132 | 132 | 'file_size' => $file->getSize(), |
133 | 133 | 'file_error'=> $file->getError(), |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | 'file_type' => $file->getType() |
136 | 136 | ]; |
137 | 137 | if ($file->getError()) { |
138 | - $data['data'] = 'error ' . $file->getError() . ' in file ' . $file->getTempName(); |
|
138 | + $data['data'] = 'error '.$file->getError().' in file '.$file->getTempName(); |
|
139 | 139 | $this->sendError(400, $data['data']); |
140 | - Util::sysLogMsg('UploadFile', 'error ' . $file->getError() . ' in file ' . $file->getTempName()); |
|
140 | + Util::sysLogMsg('UploadFile', 'error '.$file->getError().' in file '.$file->getTempName()); |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | } |
@@ -76,35 +76,35 @@ discard block |
||
76 | 76 | { |
77 | 77 | $res = new PBXApiResult(); |
78 | 78 | $res->processor = __METHOD__; |
79 | - $filename = System::getLogDir() . '/' . $filename; |
|
80 | - if ( ! file_exists($filename)) { |
|
79 | + $filename = System::getLogDir().'/'.$filename; |
|
80 | + if (!file_exists($filename)) { |
|
81 | 81 | $res->success = false; |
82 | - $res->messages[] = 'No access to the file ' . $filename; |
|
82 | + $res->messages[] = 'No access to the file '.$filename; |
|
83 | 83 | } else { |
84 | 84 | $res->success = true; |
85 | 85 | $head = Util::which('head'); |
86 | 86 | $grep = Util::which('grep'); |
87 | 87 | $tail = Util::which('tail'); |
88 | 88 | $filter = escapeshellarg($filter); |
89 | - $offset = (int)$offset; |
|
90 | - $lines = (int)$lines; |
|
91 | - $linesPlusOffset = $lines+$offset; |
|
89 | + $offset = (int) $offset; |
|
90 | + $lines = (int) $lines; |
|
91 | + $linesPlusOffset = $lines + $offset; |
|
92 | 92 | |
93 | 93 | $di = Di::getDefault(); |
94 | 94 | $dirsConfig = $di->getShared('config'); |
95 | - $filenameTmp = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.log'; |
|
96 | - if (empty($filter)){ |
|
95 | + $filenameTmp = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.log'; |
|
96 | + if (empty($filter)) { |
|
97 | 97 | $cmd = "{$tail} -n {$linesPlusOffset} {$filename}"; |
98 | 98 | } else { |
99 | 99 | $cmd = "{$grep} -F {$filter} {$filename} | $tail -n {$linesPlusOffset}"; |
100 | 100 | } |
101 | - if ($offset>0){ |
|
101 | + if ($offset > 0) { |
|
102 | 102 | $cmd .= " | {$head} -n {$lines}"; |
103 | 103 | } |
104 | 104 | $cmd .= " > $filenameTmp"; |
105 | 105 | |
106 | 106 | Util::mwExec("$cmd; chown www:www $filenameTmp"); |
107 | - $res->data['cmd']=$cmd; |
|
107 | + $res->data['cmd'] = $cmd; |
|
108 | 108 | $res->data['filename'] = $filenameTmp; |
109 | 109 | } |
110 | 110 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $systemInfoFile = "{$logDir}/system-information.log"; |
163 | 163 | file_put_contents($systemInfoFile, SysinfoManagementProcessor::prepareSysyinfoContent()); |
164 | 164 | |
165 | - $futureFileName = $temp_dir . '/temp-all-log-' . time() . '.zip'; |
|
165 | + $futureFileName = $temp_dir.'/temp-all-log-'.time().'.zip'; |
|
166 | 166 | $res->data['filename'] = $futureFileName; |
167 | 167 | $res->success = true; |
168 | 168 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $res->processor = __METHOD__; |
199 | 199 | |
200 | 200 | $progress_file = "{$resultFile}.progress"; |
201 | - if ( ! file_exists($progress_file)) { |
|
201 | + if (!file_exists($progress_file)) { |
|
202 | 202 | $res->messages[] = 'Archive does not exist. Try again!'; |
203 | 203 | } elseif (file_exists($progress_file) && file_get_contents($progress_file) === '100') { |
204 | 204 | $uid = Util::generateRandomString(36); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $downloadLink = $di->getShared('config')->path('www.downloadCacheDir'); |
207 | 207 | $result_dir = "{$downloadLink}/{$uid}"; |
208 | 208 | Util::mwMkdir($result_dir); |
209 | - $link_name = 'MikoPBXLogs_' . basename($resultFile); |
|
209 | + $link_name = 'MikoPBXLogs_'.basename($resultFile); |
|
210 | 210 | Util::createUpdateSymlink($resultFile, "{$result_dir}/{$link_name}"); |
211 | 211 | Util::addRegularWWWRights("{$result_dir}/{$link_name}"); |
212 | 212 | $res->success = true; |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | { |
233 | 233 | $res = new PBXApiResult(); |
234 | 234 | $res->processor = __METHOD__; |
235 | - $filename = System::getLogDir() . '/' . $filename; |
|
236 | - if ( ! file_exists($filename)) { |
|
235 | + $filename = System::getLogDir().'/'.$filename; |
|
236 | + if (!file_exists($filename)) { |
|
237 | 237 | $res->success = false; |
238 | - $res->messages[] = 'File does not exist ' . $filename; |
|
238 | + $res->messages[] = 'File does not exist '.$filename; |
|
239 | 239 | } else { |
240 | 240 | $uid = Util::generateRandomString(36); |
241 | 241 | $di = Di::getDefault(); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | continue; |
277 | 277 | } |
278 | 278 | |
279 | - $relativePath = str_ireplace($logDir . '/', '', $entry); |
|
279 | + $relativePath = str_ireplace($logDir.'/', '', $entry); |
|
280 | 280 | $fileSizeKB = ceil($fileSize / 1024); |
281 | 281 | $filesList[$relativePath] = |
282 | 282 | [ |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | //if current file ($d) is a directory, call scanDirRecursively |
316 | - if (is_dir($dir . '/' . $d)) { |
|
317 | - $list[] = self::scanDirRecursively($dir . '/' . $d); |
|
316 | + if (is_dir($dir.'/'.$d)) { |
|
317 | + $list[] = self::scanDirRecursively($dir.'/'.$d); |
|
318 | 318 | //otherwise, add the file to the list |
319 | - } elseif (is_file($dir . '/' . $d) || is_link($dir . '/' . $d)) { |
|
320 | - $list[] = $dir . '/' . $d; |
|
319 | + } elseif (is_file($dir.'/'.$d) || is_link($dir.'/'.$d)) { |
|
320 | + $list[] = $dir.'/'.$d; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | class WorkerNotifyByEmail extends WorkerBase |
16 | 16 | { |
17 | - protected int $maxProc=1; |
|
17 | + protected int $maxProc = 1; |
|
18 | 18 | /** |
19 | 19 | * Entry point |
20 | 20 | * |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $tmpArray = []; |
51 | 51 | foreach ($data as $call) { |
52 | 52 | $keyHash = $call['email'].$call['start'].$call['from_number'].$call['to_number']; |
53 | - if(in_array($keyHash, $tmpArray, true)){ |
|
53 | + if (in_array($keyHash, $tmpArray, true)) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | $tmpArray[] = $keyHash; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * 'language' |
59 | 59 | * 'is_internal' |
60 | 60 | */ |
61 | - if ( ! isset($emails[$call['email']])) { |
|
61 | + if (!isset($emails[$call['email']])) { |
|
62 | 62 | $emails[$call['email']] = ''; |
63 | 63 | } |
64 | 64 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | // Start worker process |
98 | 98 | $workerClassname = WorkerNotifyByEmail::class; |
99 | -$action = $argv[1]??''; |
|
99 | +$action = $argv[1] ?? ''; |
|
100 | 100 | if ($action === 'start') { |
101 | 101 | cli_set_process_title($workerClassname); |
102 | 102 | while (true) { |
@@ -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 | } |
@@ -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}"); |
@@ -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 | // Завершаем старый процесс. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function pingCallBack(BeanstalkClient $message): void |
106 | 106 | { |
107 | - $message->reply(json_encode($message->getBody() . ':pong')); |
|
107 | + $message->reply(json_encode($message->getBody().':pong')); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -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 |
@@ -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 | /** |
@@ -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 | Util::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 | Util::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 = Util::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); |
@@ -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 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | if (is_array($value)) { |
48 | 48 | array_unshift($value, ' '); |
49 | - $result_config .= trim(implode("\n{$key} = ", $value)) . "\n"; |
|
49 | + $result_config .= trim(implode("\n{$key} = ", $value))."\n"; |
|
50 | 50 | } else { |
51 | 51 | $result_config .= "{$key} = {$value}\n"; |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $killallPath = self::which('killall'); |
68 | 68 | |
69 | - return self::mwExec($killallPath . ' ' . escapeshellarg($procName)); |
|
69 | + return self::mwExec($killallPath.' '.escapeshellarg($procName)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public static function mwExec($command, &$outArr = null, &$retVal = null): int |
82 | 82 | { |
83 | 83 | $retVal = 0; |
84 | - $outArr = []; |
|
84 | + $outArr = []; |
|
85 | 85 | $di = Di::getDefault(); |
86 | 86 | |
87 | 87 | if ($di !== null && $di->getShared('config')->path('core.debugMode')) { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $rmPath = self::which('rm'); |
108 | 108 | $sleepPath = self::which('sleep'); |
109 | 109 | if ($sleep_time > 0) { |
110 | - $filename = '/tmp/' . time() . '_noop.sh'; |
|
110 | + $filename = '/tmp/'.time().'_noop.sh'; |
|
111 | 111 | file_put_contents($filename, "{$sleepPath} {$sleep_time}; {$command}; {$rmPath} -rf {$filename}"); |
112 | 112 | $noop_command = "{$nohupPath} {$shPath} {$filename} > {$out_file} 2>&1 &"; |
113 | 113 | } else { |
@@ -169,17 +169,17 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return bool |
171 | 171 | */ |
172 | - public static function mwMkdir(string $parameters, bool $addWWWRights=false): bool |
|
172 | + public static function mwMkdir(string $parameters, bool $addWWWRights = false): bool |
|
173 | 173 | { |
174 | 174 | $result = true; |
175 | 175 | if (posix_getuid() === 0) { |
176 | 176 | $arrPaths = explode(' ', $parameters); |
177 | 177 | if (count($arrPaths) > 0) { |
178 | 178 | foreach ($arrPaths as $path) { |
179 | - if ( ! empty($path) |
|
180 | - && ! file_exists($path) |
|
181 | - && ! mkdir($path, 0755, true) |
|
182 | - && ! is_dir($path)) { |
|
179 | + if (!empty($path) |
|
180 | + && !file_exists($path) |
|
181 | + && !mkdir($path, 0755, true) |
|
182 | + && !is_dir($path)) { |
|
183 | 183 | $result = false; |
184 | 184 | self::sysLogMsg('Util', 'Error on create folder '.$path); |
185 | 185 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param string $param |
200 | 200 | * @param string $action |
201 | 201 | */ |
202 | - public static function processPHPWorker(string $className, string $param = 'start', string $action='restart'): void |
|
202 | + public static function processPHPWorker(string $className, string $param = 'start', string $action = 'restart'): void |
|
203 | 203 | { |
204 | 204 | $workerPath = self::getFilePathByClassName($className); |
205 | - if ( ! empty($workerPath)) { |
|
205 | + if (!empty($workerPath)) { |
|
206 | 206 | $command = "php -f {$workerPath}"; |
207 | 207 | self::processWorker($command, $param, $className, $action); |
208 | 208 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $reflection = new ReflectionClass($className); |
224 | 224 | $filename = $reflection->getFileName(); |
225 | 225 | } catch (ReflectionException $exception) { |
226 | - self::sysLogMsg('Util', 'Error ' . $exception->getMessage()); |
|
226 | + self::sysLogMsg('Util', 'Error '.$exception->getMessage()); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | return $filename; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param ?int $level |
238 | 238 | * @param ?int $facility |
239 | 239 | */ |
240 | - public static function sysLogMsg($log_name, $text, $level = null, $facility=LOG_AUTH): void |
|
240 | + public static function sysLogMsg($log_name, $text, $level = null, $facility = LOG_AUTH): void |
|
241 | 241 | { |
242 | 242 | $level = ($level === null) ? LOG_WARNING : $level; |
243 | 243 | openlog("$log_name", LOG_PID | LOG_PERROR, $facility); |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | |
349 | 349 | $name = addslashes($name); |
350 | 350 | $filter_cmd = ''; |
351 | - if ( ! empty($exclude)) { |
|
352 | - $filter_cmd = "| $path_grep -v " . escapeshellarg($exclude); |
|
351 | + if (!empty($exclude)) { |
|
352 | + $filter_cmd = "| $path_grep -v ".escapeshellarg($exclude); |
|
353 | 353 | } |
354 | 354 | $out = []; |
355 | 355 | self::mwExec( |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | public static function amiOriginate($peer_number, $peer_mobile, $dest_number): array |
372 | 372 | { |
373 | 373 | $am = self::getAstManager('off'); |
374 | - $channel = 'Local/' . $peer_number . '@internal-originate'; |
|
374 | + $channel = 'Local/'.$peer_number.'@internal-originate'; |
|
375 | 375 | $context = 'all_peers'; |
376 | 376 | $IS_ORGNT = self::generateRandomString(); |
377 | 377 | $variable = "_IS_ORGNT={$IS_ORGNT},pt1c_cid={$dest_number},_extenfrom1c={$peer_number},__peer_mobile={$peer_mobile},_FROM_PEER={$peer_number}"; |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public static function getAstManager($events = 'on'): AsteriskManager |
393 | 393 | { |
394 | - if($events === 'on'){ |
|
394 | + if ($events === 'on') { |
|
395 | 395 | $nameService = 'amiListner'; |
396 | - }else{ |
|
396 | + } else { |
|
397 | 397 | $nameService = 'amiCommander'; |
398 | 398 | } |
399 | 399 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | for ($i = 0; $i < $length; $i++) { |
420 | 420 | try { |
421 | 421 | $randomString .= $characters[random_int(0, $charactersLength - 1)]; |
422 | - }catch (Throwable $e ){ |
|
422 | + } catch (Throwable $e) { |
|
423 | 423 | $randomString = ''; |
424 | 424 | } |
425 | 425 | } |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | public static function getExtensionOfFile($filename) |
600 | 600 | { |
601 | 601 | $path_parts = pathinfo($filename); |
602 | - return $path_parts['extension']??''; |
|
602 | + return $path_parts['extension'] ?? ''; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -613,10 +613,10 @@ discard block |
||
613 | 613 | public static function trimExtensionForFile($filename, $delimiter = '.'): string |
614 | 614 | { |
615 | 615 | // Отсечем расширение файла. |
616 | - $tmp_arr = explode((string)$delimiter, $filename); |
|
616 | + $tmp_arr = explode((string) $delimiter, $filename); |
|
617 | 617 | if (count($tmp_arr) > 1) { |
618 | 618 | unset($tmp_arr[count($tmp_arr) - 1]); |
619 | - $filename = implode((string)$delimiter, $tmp_arr); |
|
619 | + $filename = implode((string) $delimiter, $tmp_arr); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | return $filename; |
@@ -688,14 +688,14 @@ discard block |
||
688 | 688 | $objects = scandir($dir); |
689 | 689 | foreach ($objects as $object) { |
690 | 690 | if ($object != "." && $object != "..") { |
691 | - if (filetype($dir . "/" . $object) == "dir") { |
|
692 | - self::rRmDir($dir . "/" . $object); |
|
691 | + if (filetype($dir."/".$object) == "dir") { |
|
692 | + self::rRmDir($dir."/".$object); |
|
693 | 693 | } else { |
694 | - unlink($dir . "/" . $object); |
|
694 | + unlink($dir."/".$object); |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | } |
698 | - if($objects !== false){ |
|
698 | + if ($objects !== false) { |
|
699 | 699 | reset($objects); |
700 | 700 | } |
701 | 701 | rmdir($dir); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | public static function generateSslCert($options = null, $config_args_pkey = null, $config_args_csr = null): array |
715 | 715 | { |
716 | 716 | // Инициализация настроек. |
717 | - if ( ! $options) { |
|
717 | + if (!$options) { |
|
718 | 718 | $options = [ |
719 | 719 | "countryName" => 'RU', |
720 | 720 | "stateOrProvinceName" => 'Moscow', |
@@ -726,11 +726,11 @@ discard block |
||
726 | 726 | ]; |
727 | 727 | } |
728 | 728 | |
729 | - if ( ! $config_args_csr) { |
|
729 | + if (!$config_args_csr) { |
|
730 | 730 | $config_args_csr = ['digest_alg' => 'sha256']; |
731 | 731 | } |
732 | 732 | |
733 | - if ( ! $config_args_pkey) { |
|
733 | + if (!$config_args_pkey) { |
|
734 | 734 | $config_args_pkey = [ |
735 | 735 | "private_key_bits" => 2048, |
736 | 736 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | $row = trim($row); |
877 | 877 | $pos = strpos($row, ']'); |
878 | 878 | if ($pos !== false && strpos($row, '[') === 0) { |
879 | - $row = "\n" . substr($row, 0, $pos); |
|
879 | + $row = "\n".substr($row, 0, $pos); |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | unset($row); |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | foreach ($sections as $section) { |
889 | 889 | $data_rows = explode("\n", trim($section)); |
890 | 890 | $section_name = trim($data_rows[0] ?? ''); |
891 | - if ( ! empty($section_name)) { |
|
891 | + if (!empty($section_name)) { |
|
892 | 892 | unset($data_rows[0]); |
893 | 893 | $manual_data[$section_name] = []; |
894 | 894 | foreach ($data_rows as $row) { |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | { |
394 | 394 | if($events === 'on'){ |
395 | 395 | $nameService = 'amiListner'; |
396 | - }else{ |
|
396 | + } else{ |
|
397 | 397 | $nameService = 'amiCommander'; |
398 | 398 | } |
399 | 399 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | for ($i = 0; $i < $length; $i++) { |
420 | 420 | try { |
421 | 421 | $randomString .= $characters[random_int(0, $charactersLength - 1)]; |
422 | - }catch (Throwable $e ){ |
|
422 | + } catch (Throwable $e ){ |
|
423 | 423 | $randomString = ''; |
424 | 424 | } |
425 | 425 | } |
@@ -919,7 +919,8 @@ discard block |
||
919 | 919 | * |
920 | 920 | * @return array |
921 | 921 | */ |
922 | - public static function flattenArray(array $array) { |
|
922 | + public static function flattenArray(array $array) |
|
923 | + { |
|
923 | 924 | $result = []; |
924 | 925 | foreach ($array as $value) { |
925 | 926 | if (is_array($value)) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $internetInterface = LanInterfaces::findFirstByInternet('1'); |
38 | 38 | if ($internetInterface === null) { |
39 | 39 | $internetInterface = new LanInterfaces(); |
40 | - $internetInterface->id = 1; |
|
40 | + $internetInterface->id = 1; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // We will find additional interfaces which we can delete |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function saveAction(): void |
62 | 62 | { |
63 | - if ( ! $this->request->isPost()) { |
|
63 | + if (!$this->request->isPost()) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | case 'extipaddr': |
126 | 126 | if ($itIsInternetInterfce) { |
127 | 127 | if (array_key_exists($name, $data)) { |
128 | - $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_' . $eth->id]; |
|
128 | + $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_'.$eth->id]; |
|
129 | 129 | } else { |
130 | - $eth->$name = $data['ipaddr_' . $eth->id]; |
|
130 | + $eth->$name = $data['ipaddr_'.$eth->id]; |
|
131 | 131 | } |
132 | 132 | } else { |
133 | 133 | $eth->$name = ''; |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | } |
147 | 147 | break; |
148 | 148 | case 'dhcp': |
149 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
150 | - $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '1' : '0'; |
|
149 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
150 | + $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '1' : '0'; |
|
151 | 151 | } |
152 | 152 | break; |
153 | 153 | case 'internet': |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | case 'ipaddr': |
157 | 157 | case 'subnet': |
158 | 158 | $eth->$name = ''; |
159 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
160 | - $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '' : $data[$name . '_' . $eth->id]; |
|
159 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
160 | + $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '' : $data[$name.'_'.$eth->id]; |
|
161 | 161 | } |
162 | 162 | break; |
163 | 163 | case 'interface': |
164 | 164 | if ($eth->id === 0) { |
165 | - $eth->$name = LanInterfaces::findFirstById($data[$name . '_' . $eth->id])->interface; |
|
165 | + $eth->$name = LanInterfaces::findFirstById($data[$name.'_'.$eth->id])->interface; |
|
166 | 166 | } |
167 | 167 | break; |
168 | 168 | case 'domain': |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | } |
178 | 178 | break; |
179 | 179 | default: |
180 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
181 | - $eth->$name = $data[$name . '_' . $eth->id]; |
|
180 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
181 | + $eth->$name = $data[$name.'_'.$eth->id]; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | ini_set('memory_limit', '300M'); |
42 | 42 | |
43 | 43 | $temp_dir = dirname($this->settings['res_file']); |
44 | - $this->progress_file = $temp_dir . '/progress'; |
|
45 | - $this->error_file = $temp_dir . '/error'; |
|
44 | + $this->progress_file = $temp_dir.'/progress'; |
|
45 | + $this->error_file = $temp_dir.'/error'; |
|
46 | 46 | |
47 | 47 | $result = $this->getFile(); |
48 | 48 | $result = $result && $this->checkFile(); |
49 | - if ( ! $result) { |
|
49 | + if (!$result) { |
|
50 | 50 | Util::sysLogMsg(__CLASS__, 'Download error...'); |
51 | 51 | } |
52 | 52 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | if (file_exists($this->settings['res_file'])) { |
63 | 63 | unlink($this->settings['res_file']); |
64 | 64 | } |
65 | - if (isset($this->settings['size'])){ |
|
65 | + if (isset($this->settings['size'])) { |
|
66 | 66 | $this->file_size = $this->settings['size']; |
67 | 67 | } else { |
68 | 68 | $this->file_size = $this->remoteFileSize($this->settings['url']); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $fp = fopen($this->settings['res_file'], 'w'); |
74 | 74 | $ch = curl_init(); |
75 | - if ( ! is_resource($ch)) { |
|
75 | + if (!is_resource($ch)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | curl_setopt($ch, CURLOPT_FILE, $fp); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function checkFile(): bool |
124 | 124 | { |
125 | - if ( ! file_exists($this->settings['res_file'])) { |
|
125 | + if (!file_exists($this->settings['res_file'])) { |
|
126 | 126 | file_put_contents($this->error_file, 'File did not upload', FILE_APPEND); |
127 | 127 | |
128 | 128 | return false; |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | public function start($argv): void |
20 | 20 | { |
21 | 21 | $settings_file = trim($argv[1]); |
22 | - if ( ! file_exists($settings_file)) { |
|
22 | + if (!file_exists($settings_file)) { |
|
23 | 23 | Util::sysLogMsg(__CLASS__, 'File with settings not found'); |
24 | 24 | |
25 | 25 | return; |
26 | 26 | } |
27 | 27 | $settings = json_decode(file_get_contents($settings_file), true); |
28 | - $progress_file = $settings['tempDir'] . '/merging_progress'; |
|
28 | + $progress_file = $settings['tempDir'].'/merging_progress'; |
|
29 | 29 | $this->mergeFilesInDirectory( |
30 | 30 | $settings['tempDir'], |
31 | 31 | $settings['resumableFilename'], |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | // Check filesize is equal uploaded size |
38 | 38 | $resultFileSize = filesize($settings['fullUploadedFileName']); |
39 | - if ((int)$settings['resumableTotalSize'] === $resultFileSize) { |
|
39 | + if ((int) $settings['resumableTotalSize'] === $resultFileSize) { |
|
40 | 40 | file_put_contents($progress_file, '100'); |
41 | 41 | } else { |
42 | 42 | Util::sysLogMsg( |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | // Delete uploaded file after 10 minutes |
49 | 49 | Util::mwExecBg( |
50 | - '/sbin/shell_functions.sh killprocesses ' . $settings['tempDir'] . ' -TERM 0;rm -rf ' . $settings['tempDir'], |
|
50 | + '/sbin/shell_functions.sh killprocesses '.$settings['tempDir'].' -TERM 0;rm -rf '.$settings['tempDir'], |
|
51 | 51 | '/dev/null', |
52 | 52 | 600 |
53 | 53 | ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | // Restore original file from chunks |
74 | 74 | if (($fp = fopen($result_file, 'w')) !== false) { |
75 | 75 | for ($i = 1; $i <= $total_files; $i++) { |
76 | - $tmp_file = $tempDir . '/' . $fileName . '.part' . $i; |
|
76 | + $tmp_file = $tempDir.'/'.$fileName.'.part'.$i; |
|
77 | 77 | fwrite($fp, file_get_contents($tmp_file)); |
78 | 78 | unlink($tmp_file); |
79 | 79 | $currentProgress = round($i / $total_files * 100); |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | } |
83 | 83 | fclose($fp); |
84 | 84 | } else { |
85 | - Util::sysLogMsg('UploadFile', 'cannot create the destination file - ' . $result_file); |
|
85 | + Util::sysLogMsg('UploadFile', 'cannot create the destination file - '.$result_file); |
|
86 | 86 | |
87 | 87 | return; |
88 | 88 | } |
89 | - Util::sysLogMsg('UploadFile', 'destination file - ' . $result_file); |
|
89 | + Util::sysLogMsg('UploadFile', 'destination file - '.$result_file); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | } else { |
42 | 42 | Util::sysLogMsg( |
43 | 43 | 'UploadFile', |
44 | - "File {$settings['fullUploadedFileName']} size {$resultFileSize} does not equal {$settings['resumableTotalSize']}" |
|
44 | + "file {$settings['fullUploadedFileName']} size {$resultFileSize} does not equal {$settings['resumableTotalSize']}" |
|
45 | 45 | ); |
46 | 46 | } |
47 | 47 |