@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | echo $killPath.' -QUIT '.$pid."\n"; |
64 | 64 | } |
65 | 65 | $timeStart = time(); |
66 | - while (true){ |
|
67 | - if(time() - $timeStart > 20){ |
|
66 | + while (true) { |
|
67 | + if (time() - $timeStart > 20) { |
|
68 | 68 | break; |
69 | 69 | } |
70 | 70 | usleep(50000); |
71 | 71 | $pid = Util::getPidOfProcess('nginx: master process'); |
72 | - if($pid !== ''){ |
|
72 | + if ($pid !== '') { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | $result = Util::mwExec($NginxPath); |
76 | - if($result === 0){ |
|
76 | + if ($result === 0) { |
|
77 | 77 | break; |
78 | 78 | } |
79 | 79 | echo "RESULT -- $result\n"; |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | $RedirectToHttps = $this->mikoPBXConfig->getGeneralSettings('RedirectToHttps'); |
113 | 113 | if ($RedirectToHttps === '1' && $not_ssl === false) { |
114 | - $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {' . PHP_EOL |
|
115 | - . ' ' . 'return 301 https://$host:' . $WEBHTTPSPort . '$request_uri;' . PHP_EOL |
|
116 | - . ' }' . PHP_EOL; |
|
114 | + $conf_data = 'if ( $remote_addr != "127.0.0.1" ) {'.PHP_EOL |
|
115 | + . ' '.'return 301 https://$host:'.$WEBHTTPSPort.'$request_uri;'.PHP_EOL |
|
116 | + . ' }'.PHP_EOL; |
|
117 | 117 | $config = str_replace('include mikopbx/locations/*.conf;', $conf_data, $config); |
118 | 118 | } |
119 | 119 | file_put_contents($httpConfigFile, $config); |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | $WEBHTTPSPrivateKey = $this->mikoPBXConfig->getGeneralSettings('WEBHTTPSPrivateKey'); |
124 | 124 | if ( |
125 | 125 | $not_ssl === false |
126 | - && ! empty($WEBHTTPSPublicKey) |
|
127 | - && ! empty($WEBHTTPSPrivateKey) |
|
126 | + && !empty($WEBHTTPSPublicKey) |
|
127 | + && !empty($WEBHTTPSPrivateKey) |
|
128 | 128 | ) { |
129 | 129 | $public_filename = '/etc/ssl/certs/nginx.crt'; |
130 | 130 | $private_filename = '/etc/ssl/private/nginx.key'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | // Test work |
141 | 141 | $currentConfigIsGood = $this->testCurrentNginxConfig(); |
142 | - if ($level < 1 && ! $currentConfigIsGood) { |
|
142 | + if ($level < 1 && !$currentConfigIsGood) { |
|
143 | 143 | ++$level; |
144 | 144 | Util::sysLogMsg('nginx', 'Failed test config file. SSL will be disable...'); |
145 | 145 | $this->generateConf(true, $level); |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function generateModulesConf(): void |
170 | 170 | { |
171 | - $locationsPath = self::MODULES_LOCATIONS_PATH; |
|
172 | - if (!is_dir($locationsPath)){ |
|
173 | - Util::mwMkdir($locationsPath,true); |
|
171 | + $locationsPath = self::MODULES_LOCATIONS_PATH; |
|
172 | + if (!is_dir($locationsPath)) { |
|
173 | + Util::mwMkdir($locationsPath, true); |
|
174 | 174 | } |
175 | 175 | $additionalModules = $this->di->getShared('pbxConfModules'); |
176 | 176 | $rmPath = Util::which('rm'); |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | foreach ($additionalModules as $appClass) { |
179 | 179 | if (method_exists($appClass, 'createNginxLocations')) { |
180 | 180 | $locationContent = $appClass->createNginxLocations(); |
181 | - if ( ! empty($locationContent)) { |
|
181 | + if (!empty($locationContent)) { |
|
182 | 182 | $confFileName = "{$locationsPath}/{$appClass->moduleUniqueId}.conf"; |
183 | 183 | file_put_contents($confFileName, $locationContent); |
184 | - if ( ! $this->testCurrentNginxConfig()) { |
|
184 | + if (!$this->testCurrentNginxConfig()) { |
|
185 | 185 | Util::mwExec("{$rmPath} {$confFileName}"); |
186 | - Util::sysLogMsg('nginx', 'Failed test config file for module' . $appClass->moduleUniqueId); |
|
186 | + Util::sysLogMsg('nginx', 'Failed test config file for module'.$appClass->moduleUniqueId); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected function generateConfigProtected(): void |
20 | 20 | { |
21 | 21 | $conf = ""; |
22 | - file_put_contents($this->config->path('asterisk.astetcdir') . '/confbridge.conf', $conf); |
|
22 | + file_put_contents($this->config->path('asterisk.astetcdir').'/confbridge.conf', $conf); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $conf = ''; |
33 | 33 | $data = ConferenceRooms::find(['order' => 'extension']); |
34 | 34 | foreach ($data as $conference) { |
35 | - $conf .= "exten => {$conference->extension},1,Goto(conference-rooms,{$conference->extension},1)" . "\n"; |
|
35 | + $conf .= "exten => {$conference->extension},1,Goto(conference-rooms,{$conference->extension},1)"."\n"; |
|
36 | 36 | } |
37 | 37 | $conf .= "\n"; |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $conf = ''; |
48 | 48 | $data = ConferenceRooms::find(['order' => 'extension']); |
49 | 49 | foreach ($data as $conference) { |
50 | - $conf .= "exten => {$conference->extension},1,Goto(conference-rooms,{$conference->extension},1)" . "\n"; |
|
50 | + $conf .= "exten => {$conference->extension},1,Goto(conference-rooms,{$conference->extension},1)"."\n"; |
|
51 | 51 | } |
52 | 52 | $conf .= "\n"; |
53 | 53 | |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $conf .= "[conference-rooms] \n"; |
73 | 73 | $data = ConferenceRooms::find(['order' => 'extension']); |
74 | 74 | foreach ($data as $conference) { |
75 | - $conf .= 'exten => ' . $conference->extension . ',1,NoOp(---)' . "\n\t"; |
|
76 | - $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())' . "\n\t"; |
|
77 | - $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)' . "\n\t"; |
|
78 | - $conf .= 'same => n,Answer()' . "\n\t"; |
|
79 | - $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)' . "\n\t"; |
|
80 | - $conf .= 'same => n,Meetme(${EXTEN},qdMT' . $rec_options . ')' . "\n\t"; |
|
81 | - $conf .= 'same => n,Hangup()' . "\n\n"; |
|
75 | + $conf .= 'exten => '.$conference->extension.',1,NoOp(---)'."\n\t"; |
|
76 | + $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())'."\n\t"; |
|
77 | + $conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)'."\n\t"; |
|
78 | + $conf .= 'same => n,Answer()'."\n\t"; |
|
79 | + $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)'."\n\t"; |
|
80 | + $conf .= 'same => n,Meetme(${EXTEN},qdMT'.$rec_options.')'."\n\t"; |
|
81 | + $conf .= 'same => n,Hangup()'."\n\n"; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $conf; |
@@ -11,7 +11,7 @@ |
||
11 | 11 | class AGIDebug extends AGI { |
12 | 12 | private string $scriptName; |
13 | 13 | |
14 | - function __construct($scriptName){ |
|
14 | + function __construct($scriptName) { |
|
15 | 15 | $this->scriptName = $scriptName; |
16 | 16 | } |
17 | 17 |
@@ -8,10 +8,12 @@ |
||
8 | 8 | |
9 | 9 | namespace MikoPBX\Core\Asterisk; |
10 | 10 | |
11 | -class AGIDebug extends AGI { |
|
11 | +class AGIDebug extends AGI |
|
12 | +{ |
|
12 | 13 | private string $scriptName; |
13 | 14 | |
14 | - function __construct($scriptName){ |
|
15 | + function __construct($scriptName) |
|
16 | + { |
|
15 | 17 | $this->scriptName = $scriptName; |
16 | 18 | } |
17 | 19 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | { |
26 | 26 | $src_log_file = '/var/log/php_error.log'; |
27 | 27 | $dst_log_file = self::getLogFile(); |
28 | - if ( ! file_exists($src_log_file)) { |
|
28 | + if (!file_exists($src_log_file)) { |
|
29 | 29 | file_put_contents($src_log_file, ''); |
30 | 30 | } |
31 | 31 | $options = file_exists($dst_log_file) ? '>' : ''; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function getLogFile(): string |
43 | 43 | { |
44 | - $logdir = System::getLogDir() . '/php'; |
|
44 | + $logdir = System::getLogDir().'/php'; |
|
45 | 45 | Util::mwMkdir($logdir); |
46 | 46 | return "$logdir/error.log"; |
47 | 47 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $max_size = 2; |
57 | 57 | $f_name = self::getLogFile(); |
58 | - $text_config = $f_name . " { |
|
58 | + $text_config = $f_name." { |
|
59 | 59 | nocreate |
60 | 60 | nocopytruncate |
61 | 61 | delaycompress |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | endscript |
70 | 70 | }"; |
71 | 71 | // TODO::Доделать рестарт PHP-FPM после обновление лога |
72 | - $di = Di::getDefault(); |
|
73 | - if ($di !== null){ |
|
72 | + $di = Di::getDefault(); |
|
73 | + if ($di !== null) { |
|
74 | 74 | $varEtcDir = $di->getConfig()->path('core.varEtcDir'); |
75 | 75 | } else { |
76 | 76 | $varEtcDir = '/var/etc'; |
77 | 77 | } |
78 | - $path_conf = $varEtcDir . '/php_logrotate_' . basename($f_name) . '.conf'; |
|
78 | + $path_conf = $varEtcDir.'/php_logrotate_'.basename($f_name).'.conf'; |
|
79 | 79 | file_put_contents($path_conf, $text_config); |
80 | 80 | $mb10 = $max_size * 1024 * 1024; |
81 | 81 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function phpTimeZoneConfigure(): void |
93 | 93 | { |
94 | - $timezone = PbxSettings::getValueByKey('PBXTimezone'); |
|
94 | + $timezone = PbxSettings::getValueByKey('PBXTimezone'); |
|
95 | 95 | date_default_timezone_set($timezone); |
96 | 96 | if (file_exists('/etc/TZ')) { |
97 | 97 | $catPath = Util::which('cat'); |
@@ -22,12 +22,12 @@ |
||
22 | 22 | $ntp_servers = PbxSettings::getValueByKey('NTPServer'); |
23 | 23 | $ntp_servers = preg_split('/\r\n|\r|\n| /', $ntp_servers); |
24 | 24 | $ntp_conf = ''; |
25 | - foreach ($ntp_servers as $ntp_server){ |
|
26 | - if ( ! empty($ntp_server)) { |
|
25 | + foreach ($ntp_servers as $ntp_server) { |
|
26 | + if (!empty($ntp_server)) { |
|
27 | 27 | $ntp_conf .= "server {$ntp_server}".PHP_EOL; |
28 | 28 | } |
29 | 29 | } |
30 | - if ($ntp_conf==='') { |
|
30 | + if ($ntp_conf === '') { |
|
31 | 31 | $ntp_conf = 'server 0.pool.ntp.org |
32 | 32 | server 1.pool.ntp.org |
33 | 33 | server 2.pool.ntp.org'; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $freeExtension = '2200100'; |
113 | 113 | for ($i = 100; ; $i++) { |
114 | 114 | $freeExtension = "2200{$i}"; |
115 | - if ( ! in_array(['number' => $freeExtension], $result, false)) { |
|
115 | + if (!in_array(['number' => $freeExtension], $result, false)) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | $relatedModel = $relation->getReferencedModel(); |
422 | 422 | $referencedFields = is_array($referencedFields) ? $referencedFields : [$referencedFields]; |
423 | 423 | foreach ($referencedFields as $referencedField) { |
424 | - $parameters = [ |
|
425 | - 'conditions' => $referencedField . '= :oldNumber:', |
|
424 | + $parameters = [ |
|
425 | + 'conditions' => $referencedField.'= :oldNumber:', |
|
426 | 426 | 'bind' => ['oldNumber' => $snapShotData['number']], |
427 | 427 | ]; |
428 | 428 | $relatedRecords = $relatedModel::find($parameters); |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | $relatedModel = $relation->getReferencedModel(); |
477 | 477 | $referencedFields = is_array($referencedFields) ? $referencedFields : [$referencedFields]; |
478 | 478 | foreach ($referencedFields as $referencedField) { |
479 | - $parameters = [ |
|
480 | - 'conditions' => $referencedField . '= :Number:', |
|
479 | + $parameters = [ |
|
480 | + 'conditions' => $referencedField.'= :Number:', |
|
481 | 481 | 'bind' => ['Number' => $this->number], |
482 | 482 | ]; |
483 | 483 | $relatedRecords = $relatedModel::find($parameters); |
@@ -32,32 +32,32 @@ discard block |
||
32 | 32 | |
33 | 33 | $from = $this->generalSettings['MailSMTPSenderAddress']; |
34 | 34 | if (empty($from)) { |
35 | - $from = $this->generalSettings['MailSMTPUsername']; |
|
35 | + $from = $this->generalSettings['MailSMTPUsername']; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $timezone = $this->generalSettings['PBXTimezone']; |
39 | 39 | $msmtpPath = Util::which('msmtp'); |
40 | 40 | |
41 | - $conf = "[general]\n" . |
|
42 | - "format=wav49|gsm|wav\n" . |
|
43 | - "attach=yes\n" . |
|
44 | - "maxmsg=100\n" . |
|
45 | - "maxsecs=120\n" . |
|
46 | - "maxgreet=60\n" . |
|
47 | - "maxsilence=10\n" . |
|
48 | - "silencethreshold=128\n" . |
|
49 | - "maxlogins=3\n" . |
|
50 | - "moveheard=yes\n" . |
|
51 | - "charset=UTF-8\n" . |
|
52 | - "pbxskip=yes\n" . |
|
53 | - "fromstring=VoiceMail\n" . |
|
54 | - "emailsubject={$emailsubject}\n" . |
|
55 | - "emailbody={$emailbody}\n\n{$emailfooter}\n" . |
|
56 | - "emaildateformat=%A, %d %B %Y в %H:%M:%S\n" . |
|
57 | - "pagerdateformat=%T %D\n" . |
|
58 | - "mailcmd={$msmtpPath} --file=/etc/msmtp.conf -t\n" . |
|
59 | - "serveremail={$from}\n\n" . |
|
60 | - "[zonemessages]\n" . |
|
41 | + $conf = "[general]\n". |
|
42 | + "format=wav49|gsm|wav\n". |
|
43 | + "attach=yes\n". |
|
44 | + "maxmsg=100\n". |
|
45 | + "maxsecs=120\n". |
|
46 | + "maxgreet=60\n". |
|
47 | + "maxsilence=10\n". |
|
48 | + "silencethreshold=128\n". |
|
49 | + "maxlogins=3\n". |
|
50 | + "moveheard=yes\n". |
|
51 | + "charset=UTF-8\n". |
|
52 | + "pbxskip=yes\n". |
|
53 | + "fromstring=VoiceMail\n". |
|
54 | + "emailsubject={$emailsubject}\n". |
|
55 | + "emailbody={$emailbody}\n\n{$emailfooter}\n". |
|
56 | + "emaildateformat=%A, %d %B %Y в %H:%M:%S\n". |
|
57 | + "pagerdateformat=%T %D\n". |
|
58 | + "mailcmd={$msmtpPath} --file=/etc/msmtp.conf -t\n". |
|
59 | + "serveremail={$from}\n\n". |
|
60 | + "[zonemessages]\n". |
|
61 | 61 | "local={$timezone}|'vm-received' q 'digits/at' H 'hours' M 'minutes'\n\n"; |
62 | 62 | |
63 | 63 | $conf .= "[voicemailcontext]\n"; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if (empty($mail_box)) { |
67 | 67 | $mail_box = $this->generalSettings['SystemNotificationsEmail']; |
68 | 68 | } |
69 | - $conf .= "admin => admin," . Util::translate("user") . ",{$mail_box},,attach=yes|tz=local\n"; |
|
69 | + $conf .= "admin => admin,".Util::translate("user").",{$mail_box},,attach=yes|tz=local\n"; |
|
70 | 70 | /* |
71 | 71 | $peers = Sip::find('type="peer"'); |
72 | 72 | foreach ($peers as $peer){ |
@@ -86,6 +86,6 @@ discard block |
||
86 | 86 | } |
87 | 87 | //*/ |
88 | 88 | |
89 | - Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/voicemail.conf', $conf); |
|
89 | + Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/voicemail.conf', $conf); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $record = ConferenceRooms::findFirstByUniqid($uniqid); |
38 | 38 | if ($record === null) { |
39 | 39 | $record = new ConferenceRooms(); |
40 | - $record->uniqid = Extensions::TYPE_CONFERENCE.strtoupper('-' . md5(time())); |
|
40 | + $record->uniqid = Extensions::TYPE_CONFERENCE.strtoupper('-'.md5(time())); |
|
41 | 41 | $record->extension = Extensions::getNextFreeApplicationNumber(); |
42 | 42 | } |
43 | 43 | $this->view->form = new ConferenceRoomEditForm($record); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function saveAction(): void |
53 | 53 | { |
54 | - if ( ! $this->request->isPost()) { |
|
54 | + if (!$this->request->isPost()) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | $this->db->begin(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Заполним параметры внутреннего номера |
74 | - if ( ! $this->updateExtension($extension, $data)) { |
|
74 | + if (!$this->updateExtension($extension, $data)) { |
|
75 | 75 | $this->view->success = false; |
76 | 76 | $this->db->rollback(); |
77 | 77 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | // Заполним параметры участников очереди |
82 | - if ( ! $this->updateConferenceRoom($room, $data)) { |
|
82 | + if (!$this->updateConferenceRoom($room, $data)) { |
|
83 | 83 | $this->view->success = false; |
84 | 84 | $this->db->rollback(); |
85 | 85 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $room->$name = $data[$name]; |
136 | 136 | break; |
137 | 137 | default: |
138 | - if ( ! array_key_exists($name, $data)) { |
|
138 | + if (!array_key_exists($name, $data)) { |
|
139 | 139 | continue 2; |
140 | 140 | } |
141 | 141 | $room->$name = $data[$name]; |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function indexAction(): void |
22 | 22 | { |
23 | - $this->view->mohFiles = SoundFiles::find('category="' . SoundFiles::CATEGORY_MOH . '"'); |
|
24 | - $this->view->customFiles = SoundFiles::find('category="' . SoundFiles::CATEGORY_CUSTOM . '"'); |
|
23 | + $this->view->mohFiles = SoundFiles::find('category="'.SoundFiles::CATEGORY_MOH.'"'); |
|
24 | + $this->view->customFiles = SoundFiles::find('category="'.SoundFiles::CATEGORY_CUSTOM.'"'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function saveAction(): void |
59 | 59 | { |
60 | - if ( ! $this->request->isPost()) { |
|
60 | + if (!$this->request->isPost()) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | $data = $this->request->getPost(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | case "id": |
73 | 73 | break; |
74 | 74 | default: |
75 | - if ( ! array_key_exists($name, $data)) { |
|
75 | + if (!array_key_exists($name, $data)) { |
|
76 | 76 | continue 2; |
77 | 77 | } |
78 | 78 | $soundFile->$name = $data[$name]; |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | return; |
105 | 105 | } |
106 | 106 | $soundFile = SoundFiles::findFirstById($id); |
107 | - if ($soundFile === null){ |
|
107 | + if ($soundFile === null) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | - $errors = false; |
|
111 | - if (! $soundFile->delete()) { |
|
110 | + $errors = false; |
|
111 | + if (!$soundFile->delete()) { |
|
112 | 112 | $errors = $soundFile->getMessages(); |
113 | 113 | } |
114 | 114 | if ($errors) { |