@@ -14,7 +14,7 @@ |
||
14 | 14 | $di = new Cli(); |
15 | 15 | |
16 | 16 | // Register classes, namespaces, additional libraries with lazzy load |
17 | -require_once __DIR__ . '/../../../src/Common/Config/ClassLoader.php'; |
|
17 | +require_once __DIR__.'/../../../src/Common/Config/ClassLoader.php'; |
|
18 | 18 | |
19 | 19 | // Initialize sentry error logger |
20 | 20 | $errorLogger = new SentryErrorLogger('pbx-core-workers'); |
@@ -20,15 +20,15 @@ |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | public function afterSave():void { |
23 | - $work_completed = (string)$this->work_completed; |
|
24 | - if( $work_completed === '1'){ |
|
23 | + $work_completed = (string) $this->work_completed; |
|
24 | + if ($work_completed === '1') { |
|
25 | 25 | $newCdr = new CallDetailRecords(); |
26 | 26 | $vars = $this->toArray(); |
27 | - foreach ($vars as $key => $value){ |
|
28 | - if( 'id' === $key){ |
|
27 | + foreach ($vars as $key => $value) { |
|
28 | + if ('id' === $key) { |
|
29 | 29 | continue; |
30 | 30 | } |
31 | - if(property_exists($newCdr, $key)){ |
|
31 | + if (property_exists($newCdr, $key)) { |
|
32 | 32 | $newCdr->writeAttribute($key, $value); |
33 | 33 | } |
34 | 34 | } |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID); |
426 | 426 | if ( ! $module) { |
427 | 427 | $module = new PbxExtensionModules(); |
428 | - $module->name = $this->locString("Breadcrumb{$this->moduleUniqueID}"); |
|
428 | + $module->name = $this->locString("breadcrumb{$this->moduleUniqueID}"); |
|
429 | 429 | $module->disabled = '1'; |
430 | 430 | } |
431 | 431 | $module->uniqid = $this->moduleUniqueID; |
432 | 432 | $module->developer = $this->developer; |
433 | 433 | $module->version = $this->version; |
434 | - $module->description = $this->locString("SubHeader{$this->moduleUniqueID}"); |
|
434 | + $module->description = $this->locString("subheader{$this->moduleUniqueID}"); |
|
435 | 435 | $module->support_email = $this->support_email; |
436 | 436 | |
437 | 437 | return $module->save(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function addToSidebar(): bool |
519 | 519 | { |
520 | - $menuSettingsKey = "AdditionalMenuItem{$this->moduleUniqueID}"; |
|
520 | + $menuSettingsKey = "additionalmenuitem{$this->moduleUniqueID}"; |
|
521 | 521 | $unCamelizedControllerName = Text::uncamelize($this->moduleUniqueID, '-'); |
522 | 522 | $menuSettings = PbxSettings::findFirstByKey($menuSettingsKey); |
523 | 523 | if ($menuSettings === null) { |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | 'href' => "/admin-cabinet/$unCamelizedControllerName", |
530 | 530 | 'group' => 'maintenance', |
531 | 531 | 'iconClass' => 'puzzle', |
532 | - 'caption' => "Breadcrumb$this->moduleUniqueID", |
|
532 | + 'caption' => "breadcrumb$this->moduleUniqueID", |
|
533 | 533 | 'showAtSidebar' => true, |
534 | 534 | ]; |
535 | 535 | $menuSettings->value = json_encode($value); |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | $this->messages = []; |
115 | 115 | $this->db = $this->di->getShared('db'); |
116 | 116 | $this->config = $this->di->getShared('config'); |
117 | - $this->license = $this->di->getShared('license'); |
|
118 | - $this->moduleDir = $this->config->path('core.modulesDir') . '/' . $this->moduleUniqueID; |
|
117 | + $this->license = $this->di->getShared('license'); |
|
118 | + $this->moduleDir = $this->config->path('core.modulesDir').'/'.$this->moduleUniqueID; |
|
119 | 119 | $settings_file = "{$this->moduleDir}/module.json"; |
120 | 120 | if (file_exists($settings_file)) { |
121 | 121 | $module_settings = json_decode(file_get_contents($settings_file), true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - $this->messages = []; |
|
142 | + $this->messages = []; |
|
143 | 143 | |
144 | 144 | |
145 | 145 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | { |
155 | 155 | $result = true; |
156 | 156 | try { |
157 | - if ( ! $this->activateLicense()) { |
|
157 | + if (!$this->activateLicense()) { |
|
158 | 158 | $this->messages[] = 'License activate error'; |
159 | 159 | $result = false; |
160 | 160 | } |
161 | - if ( ! $this->installFiles()) { |
|
161 | + if (!$this->installFiles()) { |
|
162 | 162 | $this->messages[] = ' installFiles error'; |
163 | 163 | $result = false; |
164 | 164 | } |
165 | - if ( ! $this->installDB()) { |
|
165 | + if (!$this->installDB()) { |
|
166 | 166 | $this->messages[] = ' installDB error'; |
167 | 167 | $result = false; |
168 | 168 | } |
169 | 169 | $this->fixFilesRights(); |
170 | 170 | } catch (\Exception $exception) { |
171 | - $result = false; |
|
171 | + $result = false; |
|
172 | 172 | $this->messages[] = $exception->getMessage(); |
173 | 173 | } |
174 | 174 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | PbxExtensionUtils::createAgiBinSymlinks($this->moduleUniqueID); |
200 | 200 | |
201 | 201 | // Restore database settings |
202 | - $modulesDir = $this->config->path('core.modulesDir'); |
|
202 | + $modulesDir = $this->config->path('core.modulesDir'); |
|
203 | 203 | $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}"; |
204 | 204 | if (is_dir($backupPath)) { |
205 | 205 | $cpPath = Util::which('cp'); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | "{$this->moduleDir}/bin" |
223 | 223 | ]; |
224 | 224 | foreach ($dirs as $dir) { |
225 | - if(file_exists($dir) && is_dir($dir)){ |
|
225 | + if (file_exists($dir) && is_dir($dir)) { |
|
226 | 226 | // Add executable right to module's binary |
227 | 227 | Util::addExecutableRights($dir); |
228 | 228 | } |
@@ -257,16 +257,16 @@ discard block |
||
257 | 257 | { |
258 | 258 | $result = true; |
259 | 259 | try { |
260 | - if ( ! $this->unInstallDB($keepSettings)) { |
|
260 | + if (!$this->unInstallDB($keepSettings)) { |
|
261 | 261 | $this->messages[] = ' unInstallDB error'; |
262 | 262 | $result = false; |
263 | 263 | } |
264 | - if ($result && ! $this->unInstallFiles($keepSettings)) { |
|
264 | + if ($result && !$this->unInstallFiles($keepSettings)) { |
|
265 | 265 | $this->messages[] = ' unInstallFiles error'; |
266 | 266 | $result = false; |
267 | 267 | } |
268 | 268 | } catch (\Exception $exception) { |
269 | - $result = false; |
|
269 | + $result = false; |
|
270 | 270 | $this->messages[] = $exception->getMessage(); |
271 | 271 | } |
272 | 272 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | { |
315 | 315 | $cpPath = Util::which('cp'); |
316 | 316 | $rmPath = Util::which('rm'); |
317 | - $modulesDir = $this->config->path('core.modulesDir'); |
|
317 | + $modulesDir = $this->config->path('core.modulesDir'); |
|
318 | 318 | $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}"; |
319 | 319 | Util::mwExec("{$rmPath} -rf {$backupPath}"); |
320 | 320 | if ($keepSettings) { |
@@ -327,21 +327,21 @@ discard block |
||
327 | 327 | // IMG |
328 | 328 | $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache'); |
329 | 329 | $moduleImageCacheDir = "{$imgCacheDir}/{$this->moduleUniqueID}"; |
330 | - if (file_exists($moduleImageCacheDir)){ |
|
330 | + if (file_exists($moduleImageCacheDir)) { |
|
331 | 331 | unlink($moduleImageCacheDir); |
332 | 332 | } |
333 | 333 | |
334 | 334 | // CSS |
335 | 335 | $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache'); |
336 | 336 | $moduleCSSCacheDir = "{$cssCacheDir}/{$this->moduleUniqueID}"; |
337 | - if (file_exists($moduleCSSCacheDir)){ |
|
337 | + if (file_exists($moduleCSSCacheDir)) { |
|
338 | 338 | unlink($moduleCSSCacheDir); |
339 | 339 | } |
340 | 340 | |
341 | 341 | // JS |
342 | 342 | $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache'); |
343 | 343 | $moduleJSCacheDir = "{$jsCacheDir}/{$this->moduleUniqueID}"; |
344 | - if (file_exists($moduleJSCacheDir)){ |
|
344 | + if (file_exists($moduleJSCacheDir)) { |
|
345 | 345 | unlink($moduleJSCacheDir); |
346 | 346 | } |
347 | 347 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID); |
378 | - if ( ! $module) { |
|
378 | + if (!$module) { |
|
379 | 379 | $module = new PbxExtensionModules(); |
380 | 380 | $module->name = $this->locString("Breadcrumb{$this->moduleUniqueID}"); |
381 | 381 | $module->disabled = '1'; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $language = substr(PbxSettings::getValueByKey('WebAdminLanguage'), 0, 2); |
402 | 402 | $translates = []; |
403 | 403 | $extensionsTranslates = [[]]; |
404 | - $results = glob($this->moduleDir . '/{Messages}/en.php', GLOB_BRACE); |
|
404 | + $results = glob($this->moduleDir.'/{Messages}/en.php', GLOB_BRACE); |
|
405 | 405 | foreach ($results as $path) { |
406 | 406 | $langArr = require $path; |
407 | 407 | if (is_array($langArr)) { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | if ($language !== 'en') { |
415 | 415 | $additionalTranslates = [[]]; |
416 | - $results = glob($this->moduleDir . "/{Messages}/{$language}.php", GLOB_BRACE); |
|
416 | + $results = glob($this->moduleDir."/{Messages}/{$language}.php", GLOB_BRACE); |
|
417 | 417 | foreach ($results as $path) { |
418 | 418 | $langArr = require $path; |
419 | 419 | if (is_array($langArr)) { |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | // Add new connection for this module after add new Models folder |
445 | 445 | RegisterDIServices::recreateModulesDBConnections(); |
446 | 446 | |
447 | - $results = glob($this->moduleDir . '/Models/*.php', GLOB_NOSORT); |
|
447 | + $results = glob($this->moduleDir.'/Models/*.php', GLOB_NOSORT); |
|
448 | 448 | $dbUpgrade = new UpdateDatabase(); |
449 | 449 | foreach ($results as $file) { |
450 | 450 | $className = pathinfo($file)['filename']; |
451 | 451 | $moduleModelClass = "\\Modules\\{$this->moduleUniqueID}\\Models\\{$className}"; |
452 | 452 | $upgradeResult = $dbUpgrade->createUpdateDbTableByAnnotations($moduleModelClass); |
453 | - if (!$upgradeResult){ |
|
453 | + if (!$upgradeResult) { |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $menuSettings = new PbxSettings(); |
477 | 477 | $menuSettings->key = $menuSettingsKey; |
478 | 478 | } |
479 | - $value = [ |
|
479 | + $value = [ |
|
480 | 480 | 'uniqid' => $this->moduleUniqueID, |
481 | 481 | 'href' => "/admin-cabinet/$unCamelizedControllerName", |
482 | 482 | 'group' => 'maintenance', |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $res = new PBXApiResult(); |
27 | 27 | $res->processor = __METHOD__; |
28 | - $peers = []; |
|
28 | + $peers = []; |
|
29 | 29 | $providers = Iax::find(); |
30 | 30 | foreach ($providers as $provider) { |
31 | 31 | $peers[] = [ |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $res = new PBXApiResult(); |
28 | 28 | $res->processor = __METHOD__; |
29 | 29 | $res->success = true; |
30 | - $filter = [ |
|
30 | + $filter = [ |
|
31 | 31 | 'order' => 'id', |
32 | 32 | 'columns' => 'start,answer,endtime,src_num,dst_num,did,linkedid', |
33 | 33 | 'miko_tmp_db' => true, |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $message = $client->request(json_encode($filter), 2); |
37 | 37 | if ($message === false) { |
38 | 38 | $res->data = []; |
39 | - }else{ |
|
39 | + } else { |
|
40 | 40 | $res->data[] = $message; |
41 | 41 | } |
42 | 42 | return $res; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $res->processor = __METHOD__; |
54 | 54 | $res->success = true; |
55 | 55 | |
56 | - $filter = [ |
|
56 | + $filter = [ |
|
57 | 57 | 'endtime IS NULL', |
58 | 58 | 'order' => 'id', |
59 | 59 | 'columns' => 'start,answer,src_chan,dst_chan,src_num,dst_num,did,linkedid', |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $data = json_decode(file_get_contents($result), true); |
76 | 76 | unlink($result); |
77 | 77 | foreach ($data as $row) { |
78 | - if ( ! isset($active_chans[$row['linkedid']])) { |
|
78 | + if (!isset($active_chans[$row['linkedid']])) { |
|
79 | 79 | // Вызов уже не существует. |
80 | 80 | continue; |
81 | 81 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $message = $client->request(json_encode($filter), 2); |
37 | 37 | if ($message === false) { |
38 | 38 | $res->data = []; |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | $res->data[] = $message; |
41 | 41 | } |
42 | 42 | return $res; |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | $range = explode('-', $range[0]); |
85 | 85 | if ($range[0] === '') { |
86 | 86 | $end = $filesize - 1; |
87 | - $start = $end - (int)$range[0]; |
|
87 | + $start = $end - (int) $range[0]; |
|
88 | 88 | } elseif ($range[1] === '') { |
89 | - $start = (int)$range[0]; |
|
89 | + $start = (int) $range[0]; |
|
90 | 90 | $end = $filesize - 1; |
91 | 91 | } else { |
92 | - $start = (int)$range[0]; |
|
93 | - $end = (int)$range[1]; |
|
92 | + $start = (int) $range[0]; |
|
93 | + $end = (int) $range[1]; |
|
94 | 94 | // if ($end >= $filesize || (! $start && (! $end || $end == ($filesize - 1)))){ |
95 | 95 | // $partial = false; |
96 | 96 | // } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $length = $end - $start + 1; |
99 | 99 | |
100 | 100 | $this->response->resetHeaders(); |
101 | - if ( ! $fp = fopen($filename, 'rb')) { |
|
101 | + if (!$fp = fopen($filename, 'rb')) { |
|
102 | 102 | $this->sendError(500); |
103 | 103 | } else { |
104 | 104 | $this->response->setRawHeader('HTTP/1.1 206 Partial Content'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $content = ''; |
112 | 112 | while ($length) { |
113 | 113 | set_time_limit(0); |
114 | - $read = ($length > 8192) ? 8192 : $length; |
|
114 | + $read = ($length > 8192) ? 8192 : $length; |
|
115 | 115 | $length -= $read; |
116 | 116 | $content .= fread($fp, $read); |
117 | 117 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | $this->response->setHeader('Server', 'nginx'); |
129 | 129 | |
130 | - $is_download = ! empty($this->request->get('download')); |
|
130 | + $is_download = !empty($this->request->get('download')); |
|
131 | 131 | if ($is_download) { |
132 | 132 | $new_filename = $this->request->get('filename'); |
133 | 133 | if (empty($new_filename)) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $this->response->setHeader( |
138 | 138 | 'Content-Disposition', |
139 | - "attachment; filename*=UTF-8''" . basename($new_filename) |
|
139 | + "attachment; filename*=UTF-8''".basename($new_filename) |
|
140 | 140 | ); |
141 | 141 | } |
142 | 142 | $this->response->sendRaw(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | $syslog_file = '/var/log/messages'; |
25 | 25 | $log_file = self::getSyslogFile(); |
26 | - if ( ! file_exists($syslog_file)) { |
|
26 | + if (!file_exists($syslog_file)) { |
|
27 | 27 | file_put_contents($syslog_file, ''); |
28 | 28 | } |
29 | 29 | $syslogdPath = Util::which('syslogd'); |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | $logreadPath = Util::which('logread'); |
32 | 32 | $killPath = Util::which('kill'); |
33 | 33 | $pid = Util::getPidOfProcess($syslogdPath); |
34 | - if ( ! empty($pid)) { |
|
34 | + if (!empty($pid)) { |
|
35 | 35 | $options = file_exists($log_file) ? '>' : ''; |
36 | - Util::mwExec("{$busyboxPath} {$logreadPath} 2> /dev/null >" . $options . $log_file); |
|
36 | + Util::mwExec("{$busyboxPath} {$logreadPath} 2> /dev/null >".$options.$log_file); |
|
37 | 37 | // Завершаем процесс. |
38 | 38 | Util::mwExec("{$busyboxPath} {$killPath} '$pid'"); |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function getSyslogFile(): string |
50 | 50 | { |
51 | - $logdir = System::getLogDir() . '/system'; |
|
51 | + $logdir = System::getLogDir().'/system'; |
|
52 | 52 | Util::mwMkdir($logdir); |
53 | 53 | return "$logdir/messages"; |
54 | 54 | } |
@@ -60,11 +60,11 @@ |
||
60 | 60 | $ntpdPath = Util::which('ntpd'); |
61 | 61 | $shPath = Util::which('sh'); |
62 | 62 | if ($restart_night === '1') { |
63 | - $mast_have[] = '0 1 * * * ' . $cron_user . $asteriskPath . ' -rx"core restart now" > /dev/null 2> /dev/null' . "\n"; |
|
63 | + $mast_have[] = '0 1 * * * '.$cron_user.$asteriskPath.' -rx"core restart now" > /dev/null 2> /dev/null'."\n"; |
|
64 | 64 | } |
65 | - $mast_have[] = '*/5 * * * * ' . $cron_user . $ntpdPath . ' -q > /dev/null 2> /dev/null' . "\n"; |
|
66 | - $mast_have[] = '*/6 * * * * ' . $cron_user . "{$shPath} {$workersPath}/Cron/cleaner_download_links.sh > /dev/null 2> /dev/null\n"; |
|
67 | - $mast_have[] = '*/1 * * * * ' . $cron_user . "{$WorkerSafeScripts}\n"; |
|
65 | + $mast_have[] = '*/5 * * * * '.$cron_user.$ntpdPath.' -q > /dev/null 2> /dev/null'."\n"; |
|
66 | + $mast_have[] = '*/6 * * * * '.$cron_user."{$shPath} {$workersPath}/Cron/cleaner_download_links.sh > /dev/null 2> /dev/null\n"; |
|
67 | + $mast_have[] = '*/1 * * * * '.$cron_user."{$WorkerSafeScripts}\n"; |
|
68 | 68 | |
69 | 69 | $tasks = []; |
70 | 70 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | . "vmsvc.level = none\n"; |
42 | 42 | |
43 | 43 | $dirVM = '/etc/vmware-tools'; |
44 | - if(!file_exists($dirVM)){ |
|
44 | + if (!file_exists($dirVM)) { |
|
45 | 45 | Util::mwMkdir($dirVM); |
46 | 46 | } |
47 | 47 |