@@ -365,7 +365,7 @@ |
||
365 | 365 | // Delete CallRecords sound files |
366 | 366 | $callRecordsPath = $di->getShared('config')->path('asterisk.monitordir'); |
367 | 367 | if (stripos($callRecordsPath, '/storage/usbdisk1/mikopbx') !== false) { |
368 | - Util::mwExec("{$rm} -rf {$callRecordsPath}/*"); |
|
368 | + Util::mwExec("{$rm} -rf {$callRecordsPath}/*"); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | return $res; |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | $res->data['message'] = 'In progress...'; |
169 | 169 | |
170 | 170 | |
171 | - if ( ! file_exists($tempFilename)) { |
|
171 | + if (!file_exists($tempFilename)) { |
|
172 | 172 | $res->success = false; |
173 | 173 | $res->messages[] = "Update file '{$tempFilename}' not found."; |
174 | 174 | |
175 | 175 | return $res; |
176 | 176 | } |
177 | 177 | |
178 | - if ( ! file_exists('/var/etc/cfdevice')) { |
|
178 | + if (!file_exists('/var/etc/cfdevice')) { |
|
179 | 179 | $res->success = false; |
180 | 180 | $res->messages[] = "The system is not installed"; |
181 | 181 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | $res = new PBXApiResult(); |
200 | 200 | $res->processor = __METHOD__; |
201 | 201 | $di = DI::getDefault(); |
202 | - if ($di===null){ |
|
203 | - $res->messages[]='Error on DI initialize'; |
|
202 | + if ($di === null) { |
|
203 | + $res->messages[] = 'Error on DI initialize'; |
|
204 | 204 | return $res; |
205 | 205 | } |
206 | 206 | |
@@ -209,33 +209,33 @@ discard block |
||
209 | 209 | $rm = Util::which('rm'); |
210 | 210 | |
211 | 211 | // Pre delete some types |
212 | - $clearThisModels=[ |
|
212 | + $clearThisModels = [ |
|
213 | 213 | [Providers::class=>''], |
214 | 214 | [OutgoingRoutingTable::class=>''], |
215 | 215 | [IncomingRoutingTable::class=>''], |
216 | 216 | [OutWorkTimes::class=>''], |
217 | 217 | [AsteriskManagerUsers::class=>''], |
218 | - [Extensions::class=>'type="'.Extensions::TYPE_IVR_MENU.'"'], // IVR Menu |
|
219 | - [Extensions::class=>'type="'.Extensions::TYPE_CONFERENCE.'"'], // CONFERENCE |
|
220 | - [Extensions::class=>'type="'.Extensions::TYPE_QUEUE.'"'], // QUEUE |
|
218 | + [Extensions::class=>'type="'.Extensions::TYPE_IVR_MENU.'"'], // IVR Menu |
|
219 | + [Extensions::class=>'type="'.Extensions::TYPE_CONFERENCE.'"'], // CONFERENCE |
|
220 | + [Extensions::class=>'type="'.Extensions::TYPE_QUEUE.'"'], // QUEUE |
|
221 | 221 | ]; |
222 | 222 | |
223 | - foreach ($clearThisModels as [$class_name, $parameters]){ |
|
224 | - $records = call_user_func([$class_name, 'find'], $parameters); |
|
225 | - if ( ! $records->delete()) { |
|
223 | + foreach ($clearThisModels as [$class_name, $parameters]) { |
|
224 | + $records = call_user_func([$class_name, 'find'], $parameters); |
|
225 | + if (!$records->delete()) { |
|
226 | 226 | $res->messages[] = $records->getMessages(); |
227 | 227 | $res->success = false; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Other extensions |
232 | - $parameters = [ |
|
232 | + $parameters = [ |
|
233 | 233 | 'conditions' => 'not number IN ({ids:array})', |
234 | 234 | 'bind' => [ |
235 | 235 | 'ids' => [ |
236 | 236 | '000063', // Reads back the extension |
237 | 237 | '000064', // 0000MILLI |
238 | - '10003246',// Echo test |
|
238 | + '10003246', // Echo test |
|
239 | 239 | '10000100' // Voicemail |
240 | 240 | ], |
241 | 241 | ], |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $stopDeleting = true; |
250 | 250 | continue; |
251 | 251 | } |
252 | - if ( ! $record->delete()) { |
|
252 | + if (!$record->delete()) { |
|
253 | 253 | $deleteAttempts += 1; |
254 | 254 | } |
255 | 255 | if ($deleteAttempts > $countRecords * 10) { |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | 'custom' => SoundFiles::CATEGORY_CUSTOM, |
266 | 266 | ], |
267 | 267 | ]; |
268 | - $records = SoundFiles::find($parameters); |
|
268 | + $records = SoundFiles::find($parameters); |
|
269 | 269 | |
270 | 270 | foreach ($records as $record) { |
271 | 271 | if (stripos($record->path, '/storage/usbdisk1/mikopbx') !== false) { |
272 | 272 | Util::mwExec("{$rm} -rf {$record->path}"); |
273 | - if ( ! $record->delete()) { |
|
273 | + if (!$record->delete()) { |
|
274 | 274 | $res->messages[] = $record->getMessages(); |
275 | 275 | $res->success = false; |
276 | 276 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | foreach ($records as $record) { |
283 | 283 | $moduleDir = PbxExtensionUtils::getModuleDir($record->uniqid); |
284 | 284 | Util::mwExec("{$rm} -rf {$moduleDir}"); |
285 | - if ( ! $record->delete()) { |
|
285 | + if (!$record->delete()) { |
|
286 | 286 | $res->messages[] = $record->getMessages(); |
287 | 287 | $res->success = false; |
288 | 288 | } |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | |
291 | 291 | // Delete CallRecords |
292 | 292 | $records = CallDetailRecords::find(); |
293 | - if ( ! $records->delete()) { |
|
293 | + if (!$records->delete()) { |
|
294 | 294 | $res->messages[] = $records->getMessages(); |
295 | 295 | $res->success = false; |
296 | 296 | } |
297 | 297 | |
298 | 298 | // Delete CallRecords sound files |
299 | - $callRecordsPath = $di->getShared('config')->path('asterisk.monitordir'); |
|
299 | + $callRecordsPath = $di->getShared('config')->path('asterisk.monitordir'); |
|
300 | 300 | if (stripos($callRecordsPath, '/storage/usbdisk1/mikopbx') !== false) { |
301 | 301 | Util::mwExec("{$rm} -rf {$callRecordsPath}/*"); |
302 | 302 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $res = new PBXApiResult(); |
318 | 318 | $res->processor = __METHOD__; |
319 | 319 | $moduleMetadata = FilesManagementProcessor::getMetadataFromModuleFile($filePath); |
320 | - if ( ! $moduleMetadata->success) { |
|
320 | + if (!$moduleMetadata->success) { |
|
321 | 321 | return $moduleMetadata; |
322 | 322 | } else { |
323 | 323 | $moduleUniqueID = $moduleMetadata->data['uniqid']; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | if (class_exists($pbxExtensionSetupClass) |
357 | 357 | && method_exists($pbxExtensionSetupClass, 'installModule')) { |
358 | 358 | $setup = new $pbxExtensionSetupClass($moduleUniqueID); |
359 | - if ( ! $setup->installModule()) { |
|
359 | + if (!$setup->installModule()) { |
|
360 | 360 | $res->success = false; |
361 | 361 | $res->messages[] = $setup->getMessages(); |
362 | 362 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | { |
440 | 440 | $res = new PBXApiResult(); |
441 | 441 | $res->processor = __METHOD__; |
442 | - if ( ! file_exists($filename)) { |
|
442 | + if (!file_exists($filename)) { |
|
443 | 443 | $res->success = false; |
444 | 444 | $res->messages[] = "File '{$filename}' not found."; |
445 | 445 | |
446 | 446 | return $res; |
447 | 447 | } |
448 | 448 | $out = []; |
449 | - $tmp_filename = '/tmp/' . time() . "_" . basename($filename); |
|
449 | + $tmp_filename = '/tmp/'.time()."_".basename($filename); |
|
450 | 450 | if (false === copy($filename, $tmp_filename)) { |
451 | 451 | $res->success = false; |
452 | 452 | $res->messages[] = "Unable to create temporary file '{$tmp_filename}'."; |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | } |
456 | 456 | |
457 | 457 | // Принудительно устанавливаем расширение файла в wav. |
458 | - $n_filename = Util::trimExtensionForFile($filename) . ".wav"; |
|
459 | - $n_filename_mp3 = Util::trimExtensionForFile($filename) . ".mp3"; |
|
458 | + $n_filename = Util::trimExtensionForFile($filename).".wav"; |
|
459 | + $n_filename_mp3 = Util::trimExtensionForFile($filename).".mp3"; |
|
460 | 460 | // Конвертируем файл. |
461 | 461 | $tmp_filename = escapeshellcmd($tmp_filename); |
462 | 462 | $n_filename = escapeshellcmd($n_filename); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if(!file_exists($path_db)){ |
78 | 78 | // Таблица не существует. Бана нет. |
79 | 79 | $res->success = false; |
80 | - $res->messages[] = "DB {$path_db} not found"; |
|
80 | + $res->messages[] = "db {$path_db} not found"; |
|
81 | 81 | return $res; |
82 | 82 | } |
83 | 83 | $db = new SQLite3($path_db); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | if(!file_exists($path_db)){ |
120 | 120 | // Таблица не существует. Бана нет. |
121 | 121 | $res->success = false; |
122 | - $res->messages[] = "DB {$path_db} not found"; |
|
122 | + $res->messages[] = "db {$path_db} not found"; |
|
123 | 123 | return $res; |
124 | 124 | } |
125 | 125 | $db = new SQLite3($path_db); |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function fail2banUnbanAll(string $ip): PBXApiResult |
29 | 29 | { |
30 | - $ip = trim($ip); |
|
30 | + $ip = trim($ip); |
|
31 | 31 | $res = new PBXApiResult(); |
32 | 32 | $res->processor = __METHOD__; |
33 | 33 | $res->success = true; |
34 | - if ( ! Verify::isIpAddress($ip)) { |
|
34 | + if (!Verify::isIpAddress($ip)) { |
|
35 | 35 | $res->success = false; |
36 | - $res->messages[]="Not valid ip '{$ip}'."; |
|
36 | + $res->messages[] = "Not valid ip '{$ip}'."; |
|
37 | 37 | } |
38 | - $fail2ban = new Fail2BanConf(); |
|
38 | + $fail2ban = new Fail2BanConf(); |
|
39 | 39 | if ($fail2ban->fail2ban_enable) { |
40 | 40 | $fail2ban = Util::which('fail2ban-client'); |
41 | - $res->success = (Util::mwExec("{$fail2ban} unban {$ip}") === 0); |
|
41 | + $res->success = (Util::mwExec("{$fail2ban} unban {$ip}") === 0); |
|
42 | 42 | } else { |
43 | 43 | $res = self::fail2banUnbanDb($ip); |
44 | 44 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Добавленн фильтр по времени бана. возвращаем только адреса, которые еще НЕ разбанены. |
69 | - $q = 'SELECT' . ' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+' . $ban_time . ') AS timeunban FROM bans where (timeofban+' . $ban_time . ')>' . time( |
|
69 | + $q = 'SELECT'.' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+'.$ban_time.') AS timeunban FROM bans where (timeofban+'.$ban_time.')>'.time( |
|
70 | 70 | ); |
71 | 71 | if ($ip !== null) { |
72 | 72 | $q .= " AND ip='{$ip}'"; |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | $q .= ' GROUP BY jail,ip'; |
75 | 75 | |
76 | 76 | $path_db = Fail2BanConf::FAIL2BAN_DB_PATH; |
77 | - if(!file_exists($path_db)){ |
|
77 | + if (!file_exists($path_db)) { |
|
78 | 78 | // Таблица не существует. Бана нет. |
79 | 79 | $res->success = false; |
80 | 80 | $res->messages[] = "DB {$path_db} not found"; |
81 | 81 | return $res; |
82 | 82 | } |
83 | - $db = new SQLite3($path_db); |
|
83 | + $db = new SQLite3($path_db); |
|
84 | 84 | $db->busyTimeout(5000); |
85 | 85 | $fail2ban = new Fail2BanConf(); |
86 | 86 | if (false === $fail2ban->tableBanExists($db)) { |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | |
117 | 117 | $jail_q = ($jail === '') ? '' : "AND jail = '{$jail}'"; |
118 | 118 | $path_db = Fail2BanConf::FAIL2BAN_DB_PATH; |
119 | - if(!file_exists($path_db)){ |
|
119 | + if (!file_exists($path_db)) { |
|
120 | 120 | // Таблица не существует. Бана нет. |
121 | 121 | $res->success = false; |
122 | 122 | $res->messages[] = "DB {$path_db} not found"; |
123 | 123 | return $res; |
124 | 124 | } |
125 | - $db = new SQLite3($path_db); |
|
125 | + $db = new SQLite3($path_db); |
|
126 | 126 | $db->busyTimeout(3000); |
127 | 127 | $fail2ban = new Fail2BanConf(); |
128 | 128 | if (false === $fail2ban->tableBanExists($db)) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $res->success = true; |
131 | 131 | return $res; |
132 | 132 | } |
133 | - $q = 'DELETE' . " FROM bans WHERE ip = '{$ip}' {$jail_q}"; |
|
133 | + $q = 'DELETE'." FROM bans WHERE ip = '{$ip}' {$jail_q}"; |
|
134 | 134 | $db->query($q); |
135 | 135 | |
136 | 136 | $err = $db->lastErrorMsg(); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | class UpdateConfigsUpToVer62110 extends Injectable implements UpgradeSystemConfigInterface |
24 | 24 | { |
25 | - public const PBX_VERSION = '6.2.110'; |
|
25 | + public const PBX_VERSION = '6.2.110'; |
|
26 | 26 | |
27 | 27 | public function processUpdate():void |
28 | 28 | { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | class UpdateConfigsUpToVer100 extends Injectable implements UpgradeSystemConfigInterface |
23 | 23 | { |
24 | - public const PBX_VERSION = '1.0.0'; |
|
24 | + public const PBX_VERSION = '1.0.0'; |
|
25 | 25 | |
26 | 26 | public function processUpdate():void |
27 | 27 | { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** @var \MikoPBX\Common\Models\Sip $peer */ |
31 | 31 | $peers = Sip::find('type="peer"'); |
32 | 32 | foreach ($peers as $peer) { |
33 | - $peer->secret = md5('' . time() . 'sip' . $peer->id); |
|
33 | + $peer->secret = md5(''.time().'sip'.$peer->id); |
|
34 | 34 | $peer->save(); |
35 | 35 | } |
36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** @var \MikoPBX\Common\Models\AsteriskManagerUsers $manager */ |
39 | 39 | $managers = AsteriskManagerUsers::find(); |
40 | 40 | foreach ($managers as $manager) { |
41 | - $manager->secret = md5('' . time() . 'manager' . $manager->id); |
|
41 | + $manager->secret = md5(''.time().'manager'.$manager->id); |
|
42 | 42 | $manager->save(); |
43 | 43 | } |
44 | 44 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | class UpdateConfigsUpToVer64 extends Injectable implements UpgradeSystemConfigInterface |
25 | 25 | { |
26 | - public const PBX_VERSION = '6.4.1'; |
|
26 | + public const PBX_VERSION = '6.4.1'; |
|
27 | 27 | |
28 | 28 | private ConfigAlias $config; |
29 | 29 | private MikoPBXConfig $mikoPBXConfig; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** @var \MikoPBX\Common\Models\DialplanApplications $res */ |
46 | 46 | $app_number = '10000100'; |
47 | 47 | $app_logic = base64_encode('1,Goto(voice_mail_peer,voicemail,1)'); |
48 | - $d_app = DialplanApplications::findFirst('extension="' . $app_number . '"'); |
|
48 | + $d_app = DialplanApplications::findFirst('extension="'.$app_number.'"'); |
|
49 | 49 | if ($d_app === null) { |
50 | 50 | $d_app = new DialplanApplications(); |
51 | 51 | $d_app->applicationlogic = $app_logic; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $d_app->description = 'Voice Mail'; |
54 | 54 | $d_app->name = 'VOICEMAIL'; |
55 | 55 | $d_app->type = 'plaintext'; |
56 | - $d_app->uniqid = 'DIALPLAN-APPLICATION-' . md5(time()); |
|
56 | + $d_app->uniqid = 'DIALPLAN-APPLICATION-'.md5(time()); |
|
57 | 57 | |
58 | 58 | if ($d_app->save()) { |
59 | 59 | $extension = Extensions::findFirst("number = '{$app_number}'"); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | class UpdateConfigsUpToVer2020162 extends Injectable implements UpgradeSystemConfigInterface |
24 | 24 | { |
25 | - public const PBX_VERSION = '2020.1.62'; |
|
25 | + public const PBX_VERSION = '2020.1.62'; |
|
26 | 26 | |
27 | 27 | private ConfigAlias $config; |
28 | 28 | private MikoPBXConfig $mikoPBXConfig; |
@@ -71,19 +71,19 @@ |
||
71 | 71 | |
72 | 72 | |
73 | 73 | $app_number = '10003246'; |
74 | - $d_app = DialplanApplications::findFirst('extension="' . $app_number . '"'); |
|
74 | + $d_app = DialplanApplications::findFirst('extension="'.$app_number.'"'); |
|
75 | 75 | if ($d_app === null) { |
76 | - $app_text = '1,Answer()' . "\n" . |
|
77 | - 'n,AGI(cdr_connector.php,${ISTRANSFER}dial_answer)' . "\n" . |
|
78 | - 'n,Echo()' . "\n" . |
|
79 | - 'n,Hangup()' . "\n"; |
|
76 | + $app_text = '1,Answer()'."\n". |
|
77 | + 'n,AGI(cdr_connector.php,${ISTRANSFER}dial_answer)'."\n". |
|
78 | + 'n,Echo()'."\n". |
|
79 | + 'n,Hangup()'."\n"; |
|
80 | 80 | $d_app = new DialplanApplications(); |
81 | 81 | $d_app->applicationlogic = base64_encode($app_text); |
82 | 82 | $d_app->extension = $app_number; |
83 | 83 | $d_app->description = 'Echos audio and video back to the caller as soon as it is received. Used to test connection delay.'; |
84 | 84 | $d_app->name = 'Echo test'; |
85 | 85 | $d_app->type = 'plaintext'; |
86 | - $d_app->uniqid = 'DIALPLAN-APPLICATION-' . md5(time()); |
|
86 | + $d_app->uniqid = 'DIALPLAN-APPLICATION-'.md5(time()); |
|
87 | 87 | |
88 | 88 | if ($d_app->save()) { |
89 | 89 | $extension = Extensions::findFirst("number = '{$app_number}'"); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if ($previous_version !== $current_version) { |
47 | 47 | $upgradeClasses = []; |
48 | 48 | $upgradeClassesDir = appPath('src/Core/System/Upgrade/Releases'); |
49 | - $upgradeClassesFiles = glob($upgradeClassesDir . '/*.php', GLOB_NOSORT); |
|
49 | + $upgradeClassesFiles = glob($upgradeClassesDir.'/*.php', GLOB_NOSORT); |
|
50 | 50 | foreach ($upgradeClassesFiles as $file) { |
51 | 51 | $className = pathinfo($file)['filename']; |
52 | 52 | $moduleModelClass = "\\MikoPBX\\Core\\System\\Upgrade\\Releases\\{$className}"; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (version_compare($previous_version, $releaseNumber, '<')) { |
61 | 61 | $processor = new $upgradeClass(); |
62 | 62 | $processor->processUpdate(); |
63 | - Util::echoWithSyslog(' - UpdateConfigs: Upgrade system up to ' . $releaseNumber . ' '); |
|
63 | + Util::echoWithSyslog(' - UpdateConfigs: Upgrade system up to '.$releaseNumber.' '); |
|
64 | 64 | Util::echoGreenDone(); |
65 | 65 | } |
66 | 66 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | /** @var \MikoPBX\Common\Models\PbxExtensionModules $modules */ |
81 | 81 | $modules = PbxExtensionModules::find(); |
82 | 82 | foreach ($modules as $module) { |
83 | - if ( ! is_dir("{$this->config->path('core.modulesDir')}/{$module->uniqid}")) { |
|
83 | + if (!is_dir("{$this->config->path('core.modulesDir')}/{$module->uniqid}")) { |
|
84 | 84 | $module->delete(); |
85 | 85 | } |
86 | 86 | } |
@@ -104,7 +104,8 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Считываем переданные скрипту переменные. |
106 | 106 | */ |
107 | - private function readRequestData(){ |
|
107 | + private function readRequestData() |
|
108 | + { |
|
108 | 109 | if($this->in !== false){ |
109 | 110 | $str = PHP_EOL; |
110 | 111 | // read the request |
@@ -226,7 +227,7 @@ discard block |
||
226 | 227 | if ($ret['code'] != AGIRES_OK){ |
227 | 228 | // some sort of error |
228 | 229 | $ret['data'] = $str; |
229 | - }else{ |
|
230 | + } else{ |
|
230 | 231 | // Normal AGI RES OK response |
231 | 232 | $parse = explode(' ', trim($str)); |
232 | 233 | $in_token = false; |
@@ -237,15 +238,15 @@ discard block |
||
237 | 238 | if ($token[strlen($token) - 1] == ')') { |
238 | 239 | $in_token = false; |
239 | 240 | } |
240 | - }elseif ($token[0] == '('){ |
|
241 | + } elseif ($token[0] == '('){ |
|
241 | 242 | if ($token[strlen($token) - 1] != ')') { |
242 | 243 | $in_token = true; |
243 | 244 | } |
244 | 245 | $ret['data'] .= ' ' . trim($token, '() '); |
245 | - }elseif (strpos($token, '=')){ |
|
246 | + } elseif (strpos($token, '=')){ |
|
246 | 247 | $token = explode('=', $token); |
247 | 248 | $ret[$token[0]] = $token[1]; |
248 | - }elseif ($token != ''){ |
|
249 | + } elseif ($token != ''){ |
|
249 | 250 | $ret['data'] .= ' ' . $token; |
250 | 251 | } |
251 | 252 | } |
@@ -277,9 +278,11 @@ discard block |
||
277 | 278 | $ret['code'] = substr($str, 0, 3); |
278 | 279 | $str = trim(substr($str, 3)); |
279 | 280 | |
280 | - if ($str[0] === '-') // We have a multiline response! |
|
281 | + if ($str[0] === '-') { |
|
282 | + // We have a multiline response! |
|
281 | 283 | { |
282 | 284 | $count = 0; |
285 | + } |
|
283 | 286 | $str = substr($str, 1) . "\n"; |
284 | 287 | $line = fgets($this->in, 4096); |
285 | 288 | while (substr($line, 0, 3) != $ret['code'] && $count < 5) { |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function hangup($channel = '') |
412 | 412 | { |
413 | - return $this->evaluate("HANGUP $channel"); |
|
413 | + return $this->evaluate("hangup $channel"); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $options = join(',', $options); |
577 | 577 | } |
578 | 578 | |
579 | - return $this->evaluate("EXEC $application $options"); |
|
579 | + return $this->evaluate("exec $application $options"); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -8,19 +8,19 @@ discard block |
||
8 | 8 | |
9 | 9 | namespace MikoPBX\Core\Asterisk; |
10 | 10 | |
11 | -define('AST_DIGIT_ANY', '0123456789#*'); |
|
12 | -define('AGIRES_OK', 200); |
|
13 | -define('AST_STATE_DOWN', 0); |
|
14 | -define('AST_STATE_RESERVED', 1); |
|
15 | -define('AST_STATE_OFFHOOK', 2); |
|
16 | -define('AST_STATE_DIALING', 3); |
|
17 | -define('AST_STATE_RING', 4); |
|
18 | -define('AST_STATE_RINGING', 5); |
|
19 | -define('AST_STATE_UP', 6); |
|
20 | -define('AST_STATE_BUSY', 7); |
|
21 | -define('AST_STATE_DIALING_OFFHOOK', 8); |
|
22 | -define('AST_STATE_PRERING', 9); |
|
23 | -define('AUDIO_FILENO', 3); |
|
11 | +define('AST_DIGIT_ANY', '0123456789#*'); |
|
12 | +define('AGIRES_OK', 200); |
|
13 | +define('AST_STATE_DOWN', 0); |
|
14 | +define('AST_STATE_RESERVED', 1); |
|
15 | +define('AST_STATE_OFFHOOK', 2); |
|
16 | +define('AST_STATE_DIALING', 3); |
|
17 | +define('AST_STATE_RING', 4); |
|
18 | +define('AST_STATE_RINGING', 5); |
|
19 | +define('AST_STATE_UP', 6); |
|
20 | +define('AST_STATE_BUSY', 7); |
|
21 | +define('AST_STATE_DIALING_OFFHOOK', 8); |
|
22 | +define('AST_STATE_PRERING', 9); |
|
23 | +define('AUDIO_FILENO', 3); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * AGI class |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $this->conLogBusy = false; |
95 | 95 | ob_implicit_flush(1); |
96 | 96 | // Open stdin & stdout. |
97 | - $this->in = defined('STDIN') ? STDIN : fopen('php://stdin', 'r'); |
|
98 | - $this->out = defined('STDOUT')? STDOUT : fopen('php://stdout', 'w'); |
|
97 | + $this->in = defined('STDIN') ? STDIN : fopen('php://stdin', 'r'); |
|
98 | + $this->out = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w'); |
|
99 | 99 | $this->request = []; |
100 | 100 | |
101 | 101 | $this->readRequestData(); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Считываем переданные скрипту переменные. |
106 | 106 | */ |
107 | - private function readRequestData(){ |
|
108 | - if($this->in !== false){ |
|
107 | + private function readRequestData() { |
|
108 | + if ($this->in !== false) { |
|
109 | 109 | $str = PHP_EOL; |
110 | 110 | // read the request |
111 | 111 | $resIn = fgets($this->in); |
112 | - if($resIn !== false){ |
|
112 | + if ($resIn !== false) { |
|
113 | 113 | $str = $resIn; |
114 | 114 | } |
115 | 115 | while ($str !== PHP_EOL) { |
116 | 116 | $this->request[substr($str, 0, strpos($str, ':'))] = trim(substr($str, strpos($str, ':') + 1)); |
117 | 117 | $resIn = fgets($this->in); |
118 | - if($resIn === false){ |
|
118 | + if ($resIn === false) { |
|
119 | 119 | break; |
120 | 120 | } |
121 | 121 | $str = $resIn; |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | { |
168 | 168 | $broken = ['code' => 500, 'result' => -1, 'data' => '']; |
169 | 169 | |
170 | - if( !is_resource($this->out) ){ |
|
170 | + if (!is_resource($this->out)) { |
|
171 | 171 | return $broken; |
172 | 172 | } |
173 | 173 | |
174 | - if ( !fwrite($this->out, trim($command) . "\n")) { |
|
174 | + if (!fwrite($this->out, trim($command)."\n")) { |
|
175 | 175 | return $broken; |
176 | 176 | } |
177 | 177 | fflush($this->out); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | // parse result |
180 | 180 | $str = ''; |
181 | 181 | $ret = []; |
182 | - if(!$this->evaluateReadResponse($str, $ret)){ |
|
182 | + if (!$this->evaluateReadResponse($str, $ret)) { |
|
183 | 183 | return $broken; |
184 | 184 | } |
185 | 185 | |
@@ -196,30 +196,30 @@ discard block |
||
196 | 196 | private function evaluateParseResponse($str, &$ret):void{ |
197 | 197 | $ret['result'] = null; |
198 | 198 | $ret['data'] = ''; |
199 | - if ($ret['code'] != AGIRES_OK){ |
|
199 | + if ($ret['code'] != AGIRES_OK) { |
|
200 | 200 | // some sort of error |
201 | 201 | $ret['data'] = $str; |
202 | - }else{ |
|
202 | + } else { |
|
203 | 203 | // Normal AGI RES OK response |
204 | 204 | $parse = explode(' ', trim($str)); |
205 | 205 | $in_token = false; |
206 | 206 | foreach ($parse as $token) { |
207 | - if ($in_token){ |
|
207 | + if ($in_token) { |
|
208 | 208 | // we previously hit a token starting with ')' but not ending in ')' |
209 | - $ret['data'] .= ' ' . trim($token, '() '); |
|
209 | + $ret['data'] .= ' '.trim($token, '() '); |
|
210 | 210 | if ($token[strlen($token) - 1] == ')') { |
211 | 211 | $in_token = false; |
212 | 212 | } |
213 | - }elseif ($token[0] == '('){ |
|
213 | + }elseif ($token[0] == '(') { |
|
214 | 214 | if ($token[strlen($token) - 1] != ')') { |
215 | 215 | $in_token = true; |
216 | 216 | } |
217 | - $ret['data'] .= ' ' . trim($token, '() '); |
|
218 | - }elseif (strpos($token, '=')){ |
|
217 | + $ret['data'] .= ' '.trim($token, '() '); |
|
218 | + }elseif (strpos($token, '=')) { |
|
219 | 219 | $token = explode('=', $token); |
220 | 220 | $ret[$token[0]] = $token[1]; |
221 | - }elseif ($token != ''){ |
|
222 | - $ret['data'] .= ' ' . $token; |
|
221 | + }elseif ($token != '') { |
|
222 | + $ret['data'] .= ' '.$token; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | $ret['data'] = trim($ret['data']); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | private function evaluateReadResponse(string & $str, array & $ret): bool{ |
236 | 236 | $result = true; |
237 | - if(!is_resource($this->in)){ |
|
237 | + if (!is_resource($this->in)) { |
|
238 | 238 | return $result; |
239 | 239 | } |
240 | 240 | |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | if ($str[0] === '-') // We have a multiline response! |
254 | 254 | { |
255 | 255 | $count = 0; |
256 | - $str = substr($str, 1) . "\n"; |
|
256 | + $str = substr($str, 1)."\n"; |
|
257 | 257 | $line = fgets($this->in, 4096); |
258 | 258 | while (substr($line, 0, 3) != $ret['code'] && $count < 5) { |
259 | - $str .= $line; |
|
259 | + $str .= $line; |
|
260 | 260 | $line = fgets($this->in, 4096); |
261 | 261 | $count = (trim($line) == '') ? $count + 1 : 0; |
262 | 262 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | return $this->exec( |
603 | 603 | 'Dial', |
604 | 604 | trim( |
605 | - "$type/$identifier" . $this->option_delim . $timeout . $this->option_delim . $options . $this->option_delim . $url, |
|
605 | + "$type/$identifier".$this->option_delim.$timeout.$this->option_delim.$options.$this->option_delim.$url, |
|
606 | 606 | $this->option_delim |
607 | 607 | ) |
608 | 608 | ); |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function exec_goto($a, $b = null, $c = null) |
624 | 624 | { |
625 | - return $this->exec('Goto', trim($a . $this->option_delim . $b . $this->option_delim . $c, $this->option_delim)); |
|
625 | + return $this->exec('Goto', trim($a.$this->option_delim.$b.$this->option_delim.$c, $this->option_delim)); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | private int $timeout = 2; |
106 | 106 | private array $arrObject; |
107 | 107 | private array $PRIORITY_R; |
108 | - protected int $maxProc=1; |
|
108 | + protected int $maxProc = 1; |
|
109 | 109 | |
110 | 110 | |
111 | 111 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | foreach ($additionalModules as $appClass) { |
191 | 191 | // Проверим, зависит ли объект от измененных данных. |
192 | 192 | $dependences = $appClass->dependenceModels(); |
193 | - if (in_array($called_class, $dependences)){ |
|
193 | + if (in_array($called_class, $dependences)) { |
|
194 | 194 | // Получаем новые настройки. |
195 | 195 | $appClass->getSettings(); |
196 | 196 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | break; |
239 | 239 | case Codecs::class: |
240 | 240 | $this->modified_tables[self::R_IAX] = true; |
241 | - $this->modified_tables[self::R_SIP] = true; |
|
241 | + $this->modified_tables[self::R_SIP] = true; |
|
242 | 242 | break; |
243 | 243 | case IncomingRoutingTable::class: |
244 | 244 | $this->modified_tables[self::R_DIALPLAN] = true; |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | $this->modified_tables[self::R_NATS] = true; |
311 | 311 | } |
312 | 312 | if ($this->pbxSettings->itHasTimeZoneSettings()) { |
313 | - $this->modified_tables[self::R_TIMEZONE] = true; |
|
314 | - $this->modified_tables[self::R_NGINX] = true; |
|
315 | - $this->modified_tables[self::R_PHP_FPM] = true; |
|
313 | + $this->modified_tables[self::R_TIMEZONE] = true; |
|
314 | + $this->modified_tables[self::R_NGINX] = true; |
|
315 | + $this->modified_tables[self::R_PHP_FPM] = true; |
|
316 | 316 | $this->modified_tables[self::R_REST_API_WORKER] = true; |
317 | 317 | } |
318 | 318 | if ($this->pbxSettings->itHasNTPSettings()) { |
319 | - $this->modified_tables[self::R_NTP] = true; |
|
319 | + $this->modified_tables[self::R_NTP] = true; |
|
320 | 320 | } |
321 | 321 | if ($this->pbxSettings->itHasCallRecordSettings()) { |
322 | - $this->modified_tables[ self::R_CALL_EVENTS_WORKER] = true; |
|
322 | + $this->modified_tables[self::R_CALL_EVENTS_WORKER] = true; |
|
323 | 323 | } |
324 | 324 | break; |
325 | 325 | case Sip::class: |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | public function reloadNginx(): void |
492 | 492 | { |
493 | - $nginxConf = new NginxConf(); |
|
493 | + $nginxConf = new NginxConf(); |
|
494 | 494 | $nginxConf->reStart(); |
495 | 495 | } |
496 | 496 |