@@ -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 | |
@@ -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 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | if (file_exists('/etc/TZ')) { |
| 175 | 175 | $origin_tz = file_get_contents("/etc/TZ"); |
| 176 | 176 | } |
| 177 | - if ($origin_tz !== $db_tz){ |
|
| 177 | + if ($origin_tz !== $db_tz) { |
|
| 178 | 178 | self::timezoneConfigure(); |
| 179 | 179 | } |
| 180 | 180 | $origin_tz = $db_tz; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | if ($timezone) { |
| 246 | 246 | $zone_file = "/usr/share/zoneinfo/{$timezone}"; |
| 247 | - if ( ! file_exists($zone_file)) { |
|
| 247 | + if (!file_exists($zone_file)) { |
|
| 248 | 248 | return; |
| 249 | 249 | } |
| 250 | 250 | $cpPath = Util::which('cp'); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | try { |
| 283 | 283 | /** @var \MikoPBX\Modules\Config\ConfigClass $appClass */ |
| 284 | 284 | $appClass->onAfterPbxStarted(); |
| 285 | - }catch (\Error $e){ |
|
| 285 | + } catch (\Error $e) { |
|
| 286 | 286 | Util::sysLogMsg('onAfterPbxStarted', $e->getMessage()); |
| 287 | 287 | } |
| 288 | 288 | } |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | try { |
| 283 | 283 | /** @var \MikoPBX\Modules\Config\ConfigClass $appClass */ |
| 284 | 284 | $appClass->onAfterPbxStarted(); |
| 285 | - }catch (\Error $e){ |
|
| 285 | + } catch (\Error $e){ |
|
| 286 | 286 | Util::sysLogMsg('onAfterPbxStarted', $e->getMessage()); |
| 287 | 287 | } |
| 288 | 288 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | Util::killByName('pcapsipdump'); |
| 32 | - $log_dir = System::getLogDir() . '/pcapsipdump'; |
|
| 32 | + $log_dir = System::getLogDir().'/pcapsipdump'; |
|
| 33 | 33 | Util::mwMkdir($log_dir); |
| 34 | 34 | |
| 35 | 35 | $network = new Network(); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | foreach ($arr_eth as $eth) { |
| 39 | 39 | $pid_file = "/var/run/pcapsipdump_{$eth}.pid"; |
| 40 | 40 | Util::mwExecBg( |
| 41 | - $pcapsipdumpPath . ' -T 120 -P ' . $pid_file . ' -i ' . $eth . ' -m \'^(INVITE|REGISTER)$\' -L ' . $log_dir . '/dump.db' |
|
| 41 | + $pcapsipdumpPath.' -T 120 -P '.$pid_file.' -i '.$eth.' -m \'^(INVITE|REGISTER)$\' -L '.$log_dir.'/dump.db' |
|
| 42 | 42 | ); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | /** @var \MikoPBX\Common\Models\LanInterfaces $res */ |
| 147 | 147 | $res = LanInterfaces::findFirst("internet = '1'"); |
| 148 | 148 | if (null !== $res) { |
| 149 | - if ( ! empty($res->primarydns) && '127.0.0.1' != $res->primarydns) { |
|
| 149 | + if (!empty($res->primarydns) && '127.0.0.1' != $res->primarydns) { |
|
| 150 | 150 | $dns[] = $res->primarydns; |
| 151 | 151 | } |
| 152 | - if ( ! empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) { |
|
| 152 | + if (!empty($res->secondarydns) && '127.0.0.1' != $res->secondarydns) { |
|
| 153 | 153 | $dns[] = $res->secondarydns; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -165,39 +165,39 @@ discard block |
||
| 165 | 165 | public function generatePdnsdConfig($named_dns): void |
| 166 | 166 | { |
| 167 | 167 | $tempDir = $this->di->getShared('config')->path('core.tempDir'); |
| 168 | - $cache_dir = $tempDir . '/pdnsd/cache'; |
|
| 168 | + $cache_dir = $tempDir.'/pdnsd/cache'; |
|
| 169 | 169 | Util::mwMkdir($cache_dir); |
| 170 | 170 | |
| 171 | - $conf = 'global {' . "\n" . |
|
| 172 | - ' perm_cache=10240;' . "\n" . |
|
| 173 | - ' cache_dir="' . $cache_dir . '";' . "\n" . |
|
| 174 | - ' pid_file = /var/run/pdnsd.pid;' . "\n" . |
|
| 175 | - ' run_as="nobody";' . "\n" . |
|
| 176 | - ' server_ip = 127.0.0.1;' . "\n" . |
|
| 177 | - ' status_ctl = on;' . "\n" . |
|
| 178 | - ' query_method=udp_tcp;' . "\n" . |
|
| 179 | - ' min_ttl=15m;' . "\n" . |
|
| 180 | - ' max_ttl=1w;' . "\n" . |
|
| 181 | - ' timeout=10;' . "\n" . |
|
| 182 | - ' neg_domain_pol=on;' . "\n" . |
|
| 183 | - ' run_as=root;' . "\n" . |
|
| 184 | - ' daemon=on;' . "\n" . |
|
| 185 | - '}' . "\n" . |
|
| 186 | - 'server {' . "\n" . |
|
| 187 | - ' label = "main";' . "\n" . |
|
| 188 | - ' ip = ' . implode(', ', $named_dns) . ';' . "\n" . |
|
| 189 | - ' interface=lo;' . "\n" . |
|
| 190 | - ' uptest=if;' . "\n" . |
|
| 191 | - ' interval=10m;' . "\n" . |
|
| 192 | - ' purge_cache=off;' . "\n" . |
|
| 171 | + $conf = 'global {'."\n". |
|
| 172 | + ' perm_cache=10240;'."\n". |
|
| 173 | + ' cache_dir="'.$cache_dir.'";'."\n". |
|
| 174 | + ' pid_file = /var/run/pdnsd.pid;'."\n". |
|
| 175 | + ' run_as="nobody";'."\n". |
|
| 176 | + ' server_ip = 127.0.0.1;'."\n". |
|
| 177 | + ' status_ctl = on;'."\n". |
|
| 178 | + ' query_method=udp_tcp;'."\n". |
|
| 179 | + ' min_ttl=15m;'."\n". |
|
| 180 | + ' max_ttl=1w;'."\n". |
|
| 181 | + ' timeout=10;'."\n". |
|
| 182 | + ' neg_domain_pol=on;'."\n". |
|
| 183 | + ' run_as=root;'."\n". |
|
| 184 | + ' daemon=on;'."\n". |
|
| 185 | + '}'."\n". |
|
| 186 | + 'server {'."\n". |
|
| 187 | + ' label = "main";'."\n". |
|
| 188 | + ' ip = '.implode(', ', $named_dns).';'."\n". |
|
| 189 | + ' interface=lo;'."\n". |
|
| 190 | + ' uptest=if;'."\n". |
|
| 191 | + ' interval=10m;'."\n". |
|
| 192 | + ' purge_cache=off;'."\n". |
|
| 193 | 193 | '}'; |
| 194 | 194 | |
| 195 | - $pdnsdConfFile = '/etc/pdnsd.conf'; |
|
| 195 | + $pdnsdConfFile = '/etc/pdnsd.conf'; |
|
| 196 | 196 | $savedConf = ''; |
| 197 | - if(file_exists($pdnsdConfFile)){ |
|
| 197 | + if (file_exists($pdnsdConfFile)) { |
|
| 198 | 198 | $savedConf = file_get_contents($pdnsdConfFile); |
| 199 | 199 | } |
| 200 | - if($savedConf != $conf){ |
|
| 200 | + if ($savedConf != $conf) { |
|
| 201 | 201 | file_put_contents($pdnsdConfFile, $conf); |
| 202 | 202 | } |
| 203 | 203 | $pdnsdPath = Util::which('pdnsd'); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | if (!empty($pid) && $savedConf === $conf) { |
| 206 | 206 | // Выполним дополнительную проверку, работает ли сервер. |
| 207 | 207 | $resultResolve = gethostbynamel('lic.miko.ru'); |
| 208 | - if($resultResolve !== false){ |
|
| 208 | + if ($resultResolve !== false) { |
|
| 209 | 209 | // Ничего делать не нужно. Конфиг не изменился. Рестарт не требуется. |
| 210 | 210 | return; |
| 211 | 211 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | $pid_file = "/var/run/udhcpc_{$if_name}"; |
| 284 | 284 | $pid_pcc = Util::getPidOfProcess($pid_file); |
| 285 | - if ( ! empty($pid_pcc) && file_exists($pid_file)) { |
|
| 285 | + if (!empty($pid_pcc) && file_exists($pid_file)) { |
|
| 286 | 286 | // Завершаем старый процесс. |
| 287 | 287 | $killPath = Util::which('kill'); |
| 288 | 288 | $catPath = Util::which('cat'); |
@@ -411,10 +411,10 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | $result = ['']; |
| 413 | 413 | if (file_exists('/etc/static-routes')) { |
| 414 | - $command = "{$catPath} /etc/static-routes " . |
|
| 415 | - "| {$grepPath} '^rout' " . |
|
| 416 | - "| {$busyboxPath} awk -F ';' '{print $1}' " . |
|
| 417 | - "| {$grepPath} '{$if_name}\$' " . |
|
| 414 | + $command = "{$catPath} /etc/static-routes ". |
|
| 415 | + "| {$grepPath} '^rout' ". |
|
| 416 | + "| {$busyboxPath} awk -F ';' '{print $1}' ". |
|
| 417 | + "| {$grepPath} '{$if_name}\$' ". |
|
| 418 | 418 | "| {$awkPath} -F 'dev {$if_name}' '{ print $1 }'"; |
| 419 | 419 | Util::mwExec($command, $result); |
| 420 | 420 | } |
@@ -424,19 +424,19 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | if ($if_data['vlanid'] > 0) { |
| 426 | 426 | // Пока только статика. |
| 427 | - $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n" . |
|
| 428 | - "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n" . |
|
| 429 | - "address {$ipaddr}\n" . |
|
| 430 | - "netmask {$subnet}\n" . |
|
| 431 | - "gateway {$gateway}\n" . |
|
| 432 | - "dns-nameservers 127.0.0.1\n" . |
|
| 433 | - "vlan_raw_device {$if_data['interface_orign']}\n" . |
|
| 434 | - "{$routs_add}\n" . |
|
| 427 | + $lan_config = "auto {$if_data['interface_orign']}.{$if_data['vlanid']}\n". |
|
| 428 | + "iface {$if_data['interface_orign']}.{$if_data['vlanid']} inet static \n". |
|
| 429 | + "address {$ipaddr}\n". |
|
| 430 | + "netmask {$subnet}\n". |
|
| 431 | + "gateway {$gateway}\n". |
|
| 432 | + "dns-nameservers 127.0.0.1\n". |
|
| 433 | + "vlan_raw_device {$if_data['interface_orign']}\n". |
|
| 434 | + "{$routs_add}\n". |
|
| 435 | 435 | "{$routs_rem}\n"; |
| 436 | 436 | } elseif (trim($if_data['dhcp']) === '1') { |
| 437 | - $lan_config = "auto {$if_name}\n" . |
|
| 438 | - "iface {$if_name} inet dhcp\n" . |
|
| 439 | - "{$routs_add}\n" . |
|
| 437 | + $lan_config = "auto {$if_name}\n". |
|
| 438 | + "iface {$if_name} inet dhcp\n". |
|
| 439 | + "{$routs_add}\n". |
|
| 440 | 440 | "{$routs_rem}\n"; |
| 441 | 441 | } else { |
| 442 | 442 | if (empty($ipaddr)) { |
@@ -449,13 +449,13 @@ discard block |
||
| 449 | 449 | echo "Caught exception: $ipaddr $subnet", $e->getMessage(), "\n"; |
| 450 | 450 | continue; |
| 451 | 451 | } |
| 452 | - $lan_config = "auto {$if_name}\n" . |
|
| 453 | - "iface {$if_name} inet static\n" . |
|
| 454 | - "address {$ipaddr}\n" . |
|
| 455 | - "netmask {$subnet}\n" . |
|
| 456 | - "gateway {$gateway}\n" . |
|
| 457 | - "dns-nameservers 127.0.0.1\n" . |
|
| 458 | - "{$routs_add}\n" . |
|
| 452 | + $lan_config = "auto {$if_name}\n". |
|
| 453 | + "iface {$if_name} inet static\n". |
|
| 454 | + "address {$ipaddr}\n". |
|
| 455 | + "netmask {$subnet}\n". |
|
| 456 | + "gateway {$gateway}\n". |
|
| 457 | + "dns-nameservers 127.0.0.1\n". |
|
| 458 | + "{$routs_add}\n". |
|
| 459 | 459 | "{$routs_rem}\n"; |
| 460 | 460 | } |
| 461 | 461 | file_put_contents("/etc/network/interfaces.d/{$if_name}", $lan_config); |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $net_mask = explode(".", $net_mask); |
| 547 | 547 | |
| 548 | 548 | foreach ($net_mask as $oct_ect) { |
| 549 | - $bits += strlen(str_replace("0", "", decbin((int)$oct_ect))); |
|
| 549 | + $bits += strlen(str_replace("0", "", decbin((int) $oct_ect))); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | return $bits; |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | $data->name = $name; |
| 604 | 604 | $data->interface = $name; |
| 605 | 605 | $data->dhcp = '1'; |
| 606 | - $data->internet = ($general === true) ? '1' : '0';; |
|
| 606 | + $data->internet = ($general === true) ? '1' : '0'; ; |
|
| 607 | 607 | $data->disabled = '0'; |
| 608 | 608 | $data->vlanid = '0'; |
| 609 | 609 | $data->hostname = 'mikopbx'; |
| 610 | 610 | $data->domain = ''; |
| 611 | 611 | $data->topology = 'private'; |
| 612 | - $data->primarydns= ''; |
|
| 612 | + $data->primarydns = ''; |
|
| 613 | 613 | $data->save(); |
| 614 | 614 | |
| 615 | 615 | return $data->toArray(); |
@@ -630,15 +630,15 @@ discard block |
||
| 630 | 630 | public function hostnameConfigure(): void |
| 631 | 631 | { |
| 632 | 632 | $data = Network::getHostName(); |
| 633 | - $hosts_conf = "127.0.0.1 localhost\n" . |
|
| 633 | + $hosts_conf = "127.0.0.1 localhost\n". |
|
| 634 | 634 | "127.0.0.1 {$data['hostname']}\n"; |
| 635 | - if ( ! empty($data['domain'])) { |
|
| 635 | + if (!empty($data['domain'])) { |
|
| 636 | 636 | $hosts_conf .= "127.0.0.1 {$data['hostname']}.{$data['domain']}\n"; |
| 637 | 637 | } |
| 638 | 638 | Util::fileWriteContent('/etc/hosts', $hosts_conf); |
| 639 | 639 | |
| 640 | 640 | $hostnamePath = Util::which('hostname'); |
| 641 | - Util::mwExec($hostnamePath . ' ' . escapeshellarg("{$data['hostname']}")); |
|
| 641 | + Util::mwExec($hostnamePath.' '.escapeshellarg("{$data['hostname']}")); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -652,12 +652,12 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | $pidFile = '/var/run/openvpn.pid'; |
| 654 | 654 | $pid = Util::getPidOfProcess('openvpn'); |
| 655 | - if ( ! empty($pid)) { |
|
| 655 | + if (!empty($pid)) { |
|
| 656 | 656 | // Завершаем процесс. |
| 657 | 657 | $busyboxPath = Util::which('busybox'); |
| 658 | 658 | Util::mwExec("{$busyboxPath} kill '$pid'"); |
| 659 | 659 | } |
| 660 | - if ( ! empty($data)) { |
|
| 660 | + if (!empty($data)) { |
|
| 661 | 661 | $openvpnPath = Util::which('openvpn'); |
| 662 | 662 | Util::mwExecBg("{$openvpnPath} --config /etc/openvpn.ovpn --writepid {$pidFile}", '/dev/null', 5); |
| 663 | 663 | } |
@@ -867,12 +867,12 @@ discard block |
||
| 867 | 867 | if ($res === null) { |
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | - if (empty($res->primarydns) && ! empty($data['primarydns'])) { |
|
| 870 | + if (empty($res->primarydns) && !empty($data['primarydns'])) { |
|
| 871 | 871 | $res->writeAttribute('primarydns', $data['primarydns']); |
| 872 | 872 | } elseif (empty($res->secondarydns) && $res->primarydns !== $data['primarydns']) { |
| 873 | 873 | $res->writeAttribute('secondarydns', $data['primarydns']); |
| 874 | 874 | } |
| 875 | - if (empty($res->secondarydns) && ! empty($data['secondarydns'])) { |
|
| 875 | + if (empty($res->secondarydns) && !empty($data['secondarydns'])) { |
|
| 876 | 876 | $res->writeAttribute('secondarydns', $data['secondarydns']); |
| 877 | 877 | } |
| 878 | 878 | $res->save(); |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | { |
| 916 | 916 | // Настройка по умолчанию. |
| 917 | 917 | $interface = trim(getenv('interface')); |
| 918 | - if ( ! Util::isSystemctl()) { |
|
| 918 | + if (!Util::isSystemctl()) { |
|
| 919 | 919 | // Для MIKO LFS Edition. |
| 920 | 920 | $busyboxPath = Util::which('busybox'); |
| 921 | 921 | Util::mwExec("{$busyboxPath} ifconfig $interface 192.168.2.1 netmask 255.255.255.0"); |
@@ -90,18 +90,18 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | $parameters['uploadDir'] = $di->getShared('config')->path('www.uploadDir'); |
| 92 | 92 | $parameters['tempDir'] = "{$parameters['uploadDir']}/{$parameters['resumableIdentifier']}"; |
| 93 | - if ( ! Util::mwMkdir($parameters['tempDir'])) { |
|
| 94 | - $res->messages[] = 'Temp dir does not exist ' . $parameters['tempDir']; |
|
| 93 | + if (!Util::mwMkdir($parameters['tempDir'])) { |
|
| 94 | + $res->messages[] = 'Temp dir does not exist '.$parameters['tempDir']; |
|
| 95 | 95 | |
| 96 | 96 | return $res; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $fileName = pathinfo($parameters['resumableFilename'], PATHINFO_FILENAME); |
| 100 | - $fileName = preg_replace( '/[\W]/', '', $fileName); |
|
| 101 | - if (strlen($fileName)<10){ |
|
| 100 | + $fileName = preg_replace('/[\W]/', '', $fileName); |
|
| 101 | + if (strlen($fileName) < 10) { |
|
| 102 | 102 | $fileName = ''.md5(time()).'-'.$fileName; |
| 103 | 103 | } |
| 104 | - $fileName .= '.'.pathinfo($parameters['resumableFilename'], PATHINFO_EXTENSION); |
|
| 104 | + $fileName .= '.'.pathinfo($parameters['resumableFilename'], PATHINFO_EXTENSION); |
|
| 105 | 105 | $parameters['resumableFilename'] = $fileName; |
| 106 | 106 | $parameters['fullUploadedFileName'] = "{$parameters['tempDir']}/{$fileName}"; |
| 107 | 107 | |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | foreach ($parameters['files'] as $file_data) { |
| 118 | - if ( ! self::moveUploadedPartToSeparateDir($parameters, $file_data)) { |
|
| 119 | - $res->messages[] = 'Does not found any uploaded chunks on with path ' . $file_data['file_path']; |
|
| 118 | + if (!self::moveUploadedPartToSeparateDir($parameters, $file_data)) { |
|
| 119 | + $res->messages[] = 'Does not found any uploaded chunks on with path '.$file_data['file_path']; |
|
| 120 | 120 | |
| 121 | 121 | return $res; |
| 122 | 122 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | private static function moveUploadedPartToSeparateDir(array $parameters, array $file_data): bool |
| 146 | 146 | { |
| 147 | - if ( ! file_exists($file_data['file_path'])) { |
|
| 147 | + if (!file_exists($file_data['file_path'])) { |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | $factory = new StreamFactory(); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | { |
| 178 | 178 | $totalFilesOnServerSize = 0; |
| 179 | 179 | foreach (scandir($parameters['tempDir']) as $file) { |
| 180 | - $totalFilesOnServerSize += filesize($parameters['tempDir'] . '/' . $file); |
|
| 180 | + $totalFilesOnServerSize += filesize($parameters['tempDir'].'/'.$file); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if ($totalFilesOnServerSize >= $parameters['resumableTotalSize']) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | 'resumableTotalSize' => $parameters['resumableTotalSize'], |
| 190 | 190 | 'resumableTotalChunks' => $parameters['resumableTotalChunks'], |
| 191 | 191 | ]; |
| 192 | - $settings_file = "{$parameters['tempDir']}/merge_settings"; |
|
| 192 | + $settings_file = "{$parameters['tempDir']}/merge_settings"; |
|
| 193 | 193 | file_put_contents( |
| 194 | 194 | $settings_file, |
| 195 | 195 | json_encode($merge_settings, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) |
@@ -226,22 +226,22 @@ discard block |
||
| 226 | 226 | $uploadDir = $di->getShared('config')->path('www.uploadDir'); |
| 227 | 227 | |
| 228 | 228 | $upload_id = $postData['id'] ?? null; |
| 229 | - $progress_dir = $uploadDir . '/' . $upload_id; |
|
| 230 | - $progress_file = $progress_dir . '/merging_progress'; |
|
| 229 | + $progress_dir = $uploadDir.'/'.$upload_id; |
|
| 230 | + $progress_file = $progress_dir.'/merging_progress'; |
|
| 231 | 231 | if (empty($upload_id)) { |
| 232 | 232 | $res->success = false; |
| 233 | 233 | $res->data['d_status_progress'] = '0'; |
| 234 | 234 | $res->data['d_status'] = 'ID_NOT_SET'; |
| 235 | 235 | $res->messages[] = 'Upload ID does not set'; |
| 236 | - } elseif ( ! file_exists($progress_file) && file_exists($progress_dir)) { |
|
| 236 | + } elseif (!file_exists($progress_file) && file_exists($progress_dir)) { |
|
| 237 | 237 | $res->success = true; |
| 238 | 238 | $res->data['d_status_progress'] = '0'; |
| 239 | 239 | $res->data['d_status'] = 'INPROGRESS'; |
| 240 | - } elseif ( ! file_exists($progress_dir)) { |
|
| 240 | + } elseif (!file_exists($progress_dir)) { |
|
| 241 | 241 | $res->success = false; |
| 242 | 242 | $res->data['d_status_progress'] = '0'; |
| 243 | 243 | $res->data['d_status'] = 'NOT_FOUND'; |
| 244 | - $res->messages[] = 'Does not found anything with path: ' . $progress_dir; |
|
| 244 | + $res->messages[] = 'Does not found anything with path: '.$progress_dir; |
|
| 245 | 245 | } elseif ('100' === file_get_contents($progress_file)) { |
| 246 | 246 | $res->success = true; |
| 247 | 247 | $res->data['d_status_progress'] = '100'; |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | $res = new PBXApiResult(); |
| 268 | 268 | $res->processor = __METHOD__; |
| 269 | 269 | $extension = Util::getExtensionOfFile($filePath); |
| 270 | - if ( ! in_array($extension, ['mp3', 'wav', 'alaw'])) { |
|
| 270 | + if (!in_array($extension, ['mp3', 'wav', 'alaw'])) { |
|
| 271 | 271 | $res->success = false; |
| 272 | 272 | $res->messages[] = "It is forbidden to remove the file type $extension."; |
| 273 | 273 | |
| 274 | 274 | return $res; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if ( ! file_exists($filePath)) { |
|
| 277 | + if (!file_exists($filePath)) { |
|
| 278 | 278 | $res->success = true; |
| 279 | 279 | $res->data['message'] = "File '{$filePath}' already deleted"; |
| 280 | 280 | |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | $out = []; |
| 285 | 285 | |
| 286 | 286 | $arrDeletedFiles = [ |
| 287 | - escapeshellarg(Util::trimExtensionForFile($filePath) . ".wav"), |
|
| 288 | - escapeshellarg(Util::trimExtensionForFile($filePath) . ".mp3"), |
|
| 289 | - escapeshellarg(Util::trimExtensionForFile($filePath) . ".alaw"), |
|
| 287 | + escapeshellarg(Util::trimExtensionForFile($filePath).".wav"), |
|
| 288 | + escapeshellarg(Util::trimExtensionForFile($filePath).".mp3"), |
|
| 289 | + escapeshellarg(Util::trimExtensionForFile($filePath).".alaw"), |
|
| 290 | 290 | ]; |
| 291 | 291 | |
| 292 | 292 | $rmPath = Util::which('rm'); |
| 293 | - Util::mwExec("{$rmPath} -rf " . implode(' ', $arrDeletedFiles), $out); |
|
| 293 | + Util::mwExec("{$rmPath} -rf ".implode(' ', $arrDeletedFiles), $out); |
|
| 294 | 294 | if (file_exists($filePath)) { |
| 295 | 295 | $res->success = false; |
| 296 | 296 | $res->messages = $out; |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | $cat = Util::which('cat'); |
| 324 | 324 | $di = Di::getDefault(); |
| 325 | 325 | $dirsConfig = $di->getShared('config'); |
| 326 | - $filenameTmp = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.conf'; |
|
| 326 | + $filenameTmp = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.conf'; |
|
| 327 | 327 | $cmd = "{$cat} {$filename} > {$filenameTmp}"; |
| 328 | 328 | Util::mwExec("{$cmd}; chown www:www {$filenameTmp}"); |
| 329 | 329 | $res->data['filename'] = $filenameTmp; |
| 330 | 330 | } else { |
| 331 | 331 | $res->success = false; |
| 332 | - $res->messages[] = 'No access to the file ' . $filename; |
|
| 332 | + $res->messages[] = 'No access to the file '.$filename; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | return $res; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $res->success = true; |
| 399 | 399 | |
| 400 | 400 | $firmwareDirTmp = dirname($imgFileName); |
| 401 | - $progress_file = $firmwareDirTmp . '/progress'; |
|
| 401 | + $progress_file = $firmwareDirTmp.'/progress'; |
|
| 402 | 402 | |
| 403 | 403 | // Wait until download process started |
| 404 | 404 | $d_pid = Util::getPidOfProcess("{$firmwareDirTmp}/download_settings.json"); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $error = trim(file_get_contents("{$firmwareDirTmp}/error")); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( ! file_exists($progress_file)) { |
|
| 413 | + if (!file_exists($progress_file)) { |
|
| 414 | 414 | $res->data['d_status_progress'] = '0'; |
| 415 | 415 | $res->messages[] = 'NOT_FOUND'; |
| 416 | 416 | $res->success = false; |
@@ -514,11 +514,11 @@ discard block |
||
| 514 | 514 | } else { |
| 515 | 515 | $tempDir = '/tmp'; |
| 516 | 516 | } |
| 517 | - $moduleDirTmp = $tempDir . '/' . $moduleUniqueID; |
|
| 518 | - $progress_file = $moduleDirTmp . '/progress'; |
|
| 517 | + $moduleDirTmp = $tempDir.'/'.$moduleUniqueID; |
|
| 518 | + $progress_file = $moduleDirTmp.'/progress'; |
|
| 519 | 519 | $error = ''; |
| 520 | - if (file_exists($moduleDirTmp . '/error')) { |
|
| 521 | - $error = trim(file_get_contents($moduleDirTmp . '/error')); |
|
| 520 | + if (file_exists($moduleDirTmp.'/error')) { |
|
| 521 | + $error = trim(file_get_contents($moduleDirTmp.'/error')); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // Wait until download process started |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | usleep(500000); |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - if ( ! file_exists($progress_file)) { |
|
| 530 | + if (!file_exists($progress_file)) { |
|
| 531 | 531 | $res->data['d_status_progress'] = '0'; |
| 532 | 532 | $res->data['d_status'] = 'NOT_FOUND'; |
| 533 | 533 | $res->success = false; |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | $res->data['d_status'] = 'DOWNLOAD_ERROR'; |
| 536 | 536 | $res->data['d_status_progress'] = file_get_contents($progress_file); |
| 537 | 537 | $res->data['d_error'] = $error; |
| 538 | - $res->messages[] = file_get_contents($moduleDirTmp . '/error'); |
|
| 538 | + $res->messages[] = file_get_contents($moduleDirTmp.'/error'); |
|
| 539 | 539 | $res->success = false; |
| 540 | 540 | } elseif ('100' === file_get_contents($progress_file)) { |
| 541 | 541 | $res->data['d_status_progress'] = '100'; |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | $res->success = true; |
| 545 | 545 | } else { |
| 546 | 546 | $res->data['d_status_progress'] = file_get_contents($progress_file); |
| 547 | - $d_pid = Util::getPidOfProcess($moduleDirTmp . '/download_settings.json'); |
|
| 547 | + $d_pid = Util::getPidOfProcess($moduleDirTmp.'/download_settings.json'); |
|
| 548 | 548 | if (empty($d_pid)) { |
| 549 | 549 | $res->data['d_status'] = 'DOWNLOAD_ERROR'; |
| 550 | - if (file_exists($moduleDirTmp . '/error')) { |
|
| 551 | - $res->messages[] = file_get_contents($moduleDirTmp . '/error'); |
|
| 550 | + if (file_exists($moduleDirTmp.'/error')) { |
|
| 551 | + $res->messages[] = file_get_contents($moduleDirTmp.'/error'); |
|
| 552 | 552 | } else { |
| 553 | 553 | $res->messages[] = "Download process interrupted at {$res->data['d_status_progress']}%"; |
| 554 | 554 | } |
@@ -579,13 +579,13 @@ discard block |
||
| 579 | 579 | $grepPath = Util::which('grep'); |
| 580 | 580 | $echoPath = Util::which('echo'); |
| 581 | 581 | $awkPath = Util::which('awk'); |
| 582 | - $cmd = 'f="' . $filePath . '"; p=`' . $sevenZaPath . ' l $f | ' . $grepPath . ' module.json`;if [ "$?" == "0" ]; then ' . $sevenZaPath . ' -so e -y -r $f `' . $echoPath . ' $p | ' . $awkPath . ' -F" " \'{print $6}\'`; fi'; |
|
| 582 | + $cmd = 'f="'.$filePath.'"; p=`'.$sevenZaPath.' l $f | '.$grepPath.' module.json`;if [ "$?" == "0" ]; then '.$sevenZaPath.' -so e -y -r $f `'.$echoPath.' $p | '.$awkPath.' -F" " \'{print $6}\'`; fi'; |
|
| 583 | 583 | |
| 584 | 584 | Util::mwExec($cmd, $out); |
| 585 | 585 | $settings = json_decode(implode("\n", $out), true); |
| 586 | 586 | |
| 587 | 587 | $moduleUniqueID = $settings['moduleUniqueID'] ?? null; |
| 588 | - if ( ! $moduleUniqueID) { |
|
| 588 | + if (!$moduleUniqueID) { |
|
| 589 | 589 | $res->messages[] = 'The" moduleUniqueID " in the module file is not described.the json or file does not exist.'; |
| 590 | 590 | |
| 591 | 591 | return $res; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function startAction(): void |
| 52 | 52 | { |
| 53 | - if ( ! $this->request->isPost()) { |
|
| 53 | + if (!$this->request->isPost()) { |
|
| 54 | 54 | $this->forward('session/index'); |
| 55 | 55 | } |
| 56 | 56 | $loginFromUser = $this->request->getPost('login'); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | private function updateSystemLanguage(): void |
| 93 | 93 | { |
| 94 | 94 | $newLanguage = $this->session->get('WebAdminLanguage'); |
| 95 | - if ( ! isset($newLanguage)) { |
|
| 95 | + if (!isset($newLanguage)) { |
|
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | $languageSettings = PbxSettings::findFirstByKey('WebAdminLanguage'); |
@@ -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' => 'modules', |
@@ -377,13 +377,13 @@ discard block |
||
| 377 | 377 | $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID); |
| 378 | 378 | if ( ! $module) { |
| 379 | 379 | $module = new PbxExtensionModules(); |
| 380 | - $module->name = $this->locString("Breadcrumb{$this->moduleUniqueID}"); |
|
| 380 | + $module->name = $this->locString("breadcrumb{$this->moduleUniqueID}"); |
|
| 381 | 381 | $module->disabled = '1'; |
| 382 | 382 | } |
| 383 | 383 | $module->uniqid = $this->moduleUniqueID; |
| 384 | 384 | $module->developer = $this->developer; |
| 385 | 385 | $module->version = $this->version; |
| 386 | - $module->description = $this->locString("SubHeader{$this->moduleUniqueID}"); |
|
| 386 | + $module->description = $this->locString("subheader{$this->moduleUniqueID}"); |
|
| 387 | 387 | $module->support_email = $this->support_email; |
| 388 | 388 | |
| 389 | 389 | return $module->save(); |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | */ |
| 470 | 470 | public function addToSidebar(): bool |
| 471 | 471 | { |
| 472 | - $menuSettingsKey = "AdditionalMenuItem{$this->moduleUniqueID}"; |
|
| 472 | + $menuSettingsKey = "additionalmenuitem{$this->moduleUniqueID}"; |
|
| 473 | 473 | $unCamelizedControllerName = Text::uncamelize($this->moduleUniqueID, '-'); |
| 474 | 474 | $menuSettings = PbxSettings::findFirstByKey($menuSettingsKey); |
| 475 | 475 | if ($menuSettings === null) { |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | 'href' => "/admin-cabinet/{$unCamelizedControllerName}", |
| 482 | 482 | 'group' => 'modules', |
| 483 | 483 | 'iconClass' => 'puzzle', |
| 484 | - 'caption' => "Breadcrumb{$this->moduleUniqueID}", |
|
| 484 | + 'caption' => "breadcrumb{$this->moduleUniqueID}", |
|
| 485 | 485 | 'showAtSidebar' => true, |
| 486 | 486 | ]; |
| 487 | 487 | $menuSettings->value = json_encode($value); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | $max_size = 2; |
| 93 | - $log_dir = System::getLogDir() . '/asterisk/'; |
|
| 93 | + $log_dir = System::getLogDir().'/asterisk/'; |
|
| 94 | 94 | $text_config = "{$log_dir}{$f_name} { |
| 95 | 95 | nocreate |
| 96 | 96 | nocopytruncate |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | {$asteriskPath} -rx 'logger reload' > /dev/null 2> /dev/null |
| 106 | 106 | endscript |
| 107 | 107 | }"; |
| 108 | - $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
|
| 109 | - $path_conf = $varEtcDir . '/asterisk_logrotate_' . $f_name . '.conf'; |
|
| 108 | + $varEtcDir = $di->getShared('config')->path('core.varEtcDir'); |
|
| 109 | + $path_conf = $varEtcDir.'/asterisk_logrotate_'.$f_name.'.conf'; |
|
| 110 | 110 | file_put_contents($path_conf, $text_config); |
| 111 | 111 | $mb10 = $max_size * 1024 * 1024; |
| 112 | 112 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | public static function checkCodec($name, $desc, $type): void |
| 204 | 204 | { |
| 205 | - $codec = Codecs::findFirst('name="' . $name . '"'); |
|
| 205 | + $codec = Codecs::findFirst('name="'.$name.'"'); |
|
| 206 | 206 | if ($codec === null) { |
| 207 | 207 | /** @var \MikoPBX\Common\Models\Codecs $codec_g722 */ |
| 208 | 208 | $codec = new Codecs(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public static function sipReload():void |
| 220 | 220 | { |
| 221 | - $di = Di::getDefault(); |
|
| 221 | + $di = Di::getDefault(); |
|
| 222 | 222 | if ($di === null) { |
| 223 | 223 | return; |
| 224 | 224 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | Util::mwExec("{$asteriskPath} -rx 'module reload acl'"); |
| 235 | 235 | Util::mwExec("{$asteriskPath} -rx 'core reload'"); |
| 236 | 236 | } else { |
| 237 | - Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk',LOG_INFO, LOG_INFO); |
|
| 237 | + Util::sysLogMsg('SIP RELOAD', 'Need reload asterisk', LOG_INFO, LOG_INFO); |
|
| 238 | 238 | // Завершаем каналы. |
| 239 | 239 | Util::mwExec("{$asteriskPath} -rx 'channel request hangup all'"); |
| 240 | 240 | usleep(500000); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | public static function iaxReload(): void |
| 249 | 249 | { |
| 250 | - $iax = new IAXConf(); |
|
| 250 | + $iax = new IAXConf(); |
|
| 251 | 251 | $iax->generateConfig(); |
| 252 | 252 | $asteriskPath = Util::which('asterisk'); |
| 253 | 253 | Util::mwExec("{$asteriskPath} -rx 'iax2 reload'"); |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | 'result' => 'ERROR', |
| 305 | 305 | ]; |
| 306 | 306 | |
| 307 | - if ( ! $this->di->getShared('registry')->booting) { |
|
| 307 | + if (!$this->di->getShared('registry')->booting) { |
|
| 308 | 308 | $this->stop(); |
| 309 | 309 | } |
| 310 | 310 | /** |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | // Создание базы данных истории звонков. |
| 321 | 321 | /** @var \Phalcon\Db\Adapter\Pdo\Sqlite $connection */ |
| 322 | 322 | $connection = $this->di->get('dbCDR'); |
| 323 | - if ( ! $connection->tableExists('cdr')) { |
|
| 323 | + if (!$connection->tableExists('cdr')) { |
|
| 324 | 324 | RegisterDIServices::recreateDBConnections(); |
| 325 | 325 | } else { |
| 326 | 326 | CdrDb::checkDb(); |