Passed
Push — develop ( b2a03f...b2a56a )
by Портнов
04:59 queued 11s
created
src/Modules/Setup/PbxExtensionSetupBase.php 2 patches
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
         $this->messages = [];
116 116
         $this->db      = $this->getDI()->getShared('db');
117 117
         $this->config  = $this->getDI()->getShared('config');
118
-        $this->license =  $this->getDI()->getShared('license');
119
-        $this->moduleDir = $this->config->path('core.modulesDir') . '/' . $this->moduleUniqueID;
118
+        $this->license = $this->getDI()->getShared('license');
119
+        $this->moduleDir = $this->config->path('core.modulesDir').'/'.$this->moduleUniqueID;
120 120
         $settings_file = "{$this->moduleDir}/module.json";
121 121
         if (file_exists($settings_file)) {
122 122
             $module_settings = json_decode(file_get_contents($settings_file), true);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             }
141 141
         }
142 142
 
143
-        $this->messages  = [];
143
+        $this->messages = [];
144 144
 
145 145
 
146 146
     }
@@ -155,21 +155,21 @@  discard block
 block discarded – undo
155 155
     {
156 156
         $result = true;
157 157
         try {
158
-            if ( ! $this->activateLicense()) {
158
+            if (!$this->activateLicense()) {
159 159
                 $this->messages[] = 'License activate error';
160 160
                 $result           = false;
161 161
             }
162
-            if ( ! $this->installFiles()) {
162
+            if (!$this->installFiles()) {
163 163
                 $this->messages[] = ' installFiles error';
164 164
                 $result           = false;
165 165
             }
166
-            if ( ! $this->installDB()) {
166
+            if (!$this->installDB()) {
167 167
                 $this->messages[] = ' installDB error';
168 168
                 $result           = false;
169 169
             }
170 170
             $this->fixFilesRights();
171 171
         } catch (Throwable $exception) {
172
-            $result         = false;
172
+            $result = false;
173 173
             $this->messages[] = $exception->getMessage();
174 174
         }
175 175
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         PbxExtensionUtils::createAgiBinSymlinks($this->moduleUniqueID);
201 201
 
202 202
         // Restore database settings
203
-        $modulesDir          = $this->config->path('core.modulesDir');
203
+        $modulesDir = $this->config->path('core.modulesDir');
204 204
         $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}";
205 205
         if (is_dir($backupPath)) {
206 206
             $cpPath = Util::which('cp');
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             "{$this->moduleDir}/bin"
224 224
         ];
225 225
         foreach ($dirs as $dir) {
226
-            if(file_exists($dir) && is_dir($dir)){
226
+            if (file_exists($dir) && is_dir($dir)) {
227 227
                 // Add executable right to module's binary
228 228
                 Util::addExecutableRights($dir);
229 229
             }
@@ -258,16 +258,16 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $result = true;
260 260
         try {
261
-            if ( ! $this->unInstallDB($keepSettings)) {
261
+            if (!$this->unInstallDB($keepSettings)) {
262 262
                 $this->messages[] = ' unInstallDB error';
263 263
                 $result           = false;
264 264
             }
265
-            if ($result && ! $this->unInstallFiles($keepSettings)) {
265
+            if ($result && !$this->unInstallFiles($keepSettings)) {
266 266
                 $this->messages[] = ' unInstallFiles error';
267 267
                 $result           = false;
268 268
             }
269 269
         } catch (Throwable $exception) {
270
-            $result         = false;
270
+            $result = false;
271 271
             $this->messages[] = $exception->getMessage();
272 272
         }
273 273
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     {
316 316
         $cpPath = Util::which('cp');
317 317
         $rmPath = Util::which('rm');
318
-        $modulesDir          = $this->config->path('core.modulesDir');
318
+        $modulesDir = $this->config->path('core.modulesDir');
319 319
         $backupPath = "{$modulesDir}/Backup/{$this->moduleUniqueID}";
320 320
         Util::mwExec("{$rmPath} -rf {$backupPath}");
321 321
         if ($keepSettings) {
@@ -328,21 +328,21 @@  discard block
 block discarded – undo
328 328
         // IMG
329 329
         $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
330 330
         $moduleImageCacheDir = "{$imgCacheDir}/{$this->moduleUniqueID}";
331
-        if (file_exists($moduleImageCacheDir)){
331
+        if (file_exists($moduleImageCacheDir)) {
332 332
             unlink($moduleImageCacheDir);
333 333
         }
334 334
 
335 335
         // CSS
336 336
         $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache');
337 337
         $moduleCSSCacheDir = "{$cssCacheDir}/{$this->moduleUniqueID}";
338
-        if (file_exists($moduleCSSCacheDir)){
338
+        if (file_exists($moduleCSSCacheDir)) {
339 339
             unlink($moduleCSSCacheDir);
340 340
         }
341 341
 
342 342
         // JS
343 343
         $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache');
344 344
         $moduleJSCacheDir = "{$jsCacheDir}/{$this->moduleUniqueID}";
345
-        if (file_exists($moduleJSCacheDir)){
345
+        if (file_exists($moduleJSCacheDir)) {
346 346
             unlink($moduleJSCacheDir);
347 347
         }
348 348
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         }
377 377
 
378 378
         $module = PbxExtensionModules::findFirstByUniqid($this->moduleUniqueID);
379
-        if ( ! $module) {
379
+        if (!$module) {
380 380
             $module           = new PbxExtensionModules();
381 381
             $module->name     = $this->locString("Breadcrumb{$this->moduleUniqueID}");
382 382
             $module->disabled = '1';
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
         $language             = substr(PbxSettings::getValueByKey('WebAdminLanguage'), 0, 2);
403 403
         $translates           = [];
404 404
         $extensionsTranslates = [[]];
405
-        $results              = glob($this->moduleDir . '/{Messages}/en.php', GLOB_BRACE);
405
+        $results              = glob($this->moduleDir.'/{Messages}/en.php', GLOB_BRACE);
406 406
         foreach ($results as $path) {
407 407
             $langArr = require $path;
408 408
             if (is_array($langArr)) {
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
         }
415 415
         if ($language !== 'en') {
416 416
             $additionalTranslates = [[]];
417
-            $results              = glob($this->moduleDir . "/{Messages}/{$language}.php", GLOB_BRACE);
417
+            $results              = glob($this->moduleDir."/{Messages}/{$language}.php", GLOB_BRACE);
418 418
             foreach ($results as $path) {
419 419
                 $langArr = require $path;
420 420
                 if (is_array($langArr)) {
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
         // Add new connection for this module after add new Models folder
446 446
         RegisterDIServices::recreateModulesDBConnections();
447 447
 
448
-        $results = glob($this->moduleDir . '/Models/*.php', GLOB_NOSORT);
448
+        $results = glob($this->moduleDir.'/Models/*.php', GLOB_NOSORT);
449 449
         $dbUpgrade = new UpdateDatabase();
450 450
         foreach ($results as $file) {
451 451
             $className        = pathinfo($file)['filename'];
452 452
             $moduleModelClass = "\\Modules\\{$this->moduleUniqueID}\\Models\\{$className}";
453 453
             $upgradeResult = $dbUpgrade->createUpdateDbTableByAnnotations($moduleModelClass);
454
-            if (!$upgradeResult){
454
+            if (!$upgradeResult) {
455 455
                 return false;
456 456
             }
457 457
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
             $menuSettings      = new PbxSettings();
478 478
             $menuSettings->key = $menuSettingsKey;
479 479
         }
480
-        $value               = [
480
+        $value = [
481 481
             'uniqid'        => $this->moduleUniqueID,
482 482
             'href'          => "/admin-cabinet/{$unCamelizedControllerName}",
483 483
             'group'         => 'modules',
Please login to merge, or discard this patch.
src/Core/System/PBX.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/SIPConf.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
         $conf .= $this->generateProvidersPj();
56 56
         $conf .= $this->generatePeersPj();
57 57
 
58
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
58
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
59 59
         $pjConf = '[log_mappings]'."\n".
60 60
             'type=log_mappings'."\n".
61 61
             'asterisk_error = 0'."\n".
62 62
             'asterisk_warning = 2'."\n".
63 63
             'asterisk_debug = 1,3,4,5,6'."\n\n";
64 64
 
65
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf);
66
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
65
+        file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf);
66
+        file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
67 67
 
68 68
         $db = new AstDB();
69 69
         foreach ($this->data_peers as $peer) {
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function generateGeneralPj(): string
86 86
     {
87
-        $lang    = $this->generalSettings['PBXLanguage'];
87
+        $lang = $this->generalSettings['PBXLanguage'];
88 88
         [$topology, $extipaddr, $exthostname, $subnets] = $this->getTopologyData();
89 89
 
90 90
         $codecs = $this->getCodecs();
91 91
         $codecConf = '';
92
-        foreach ($codecs as $codec){
93
-            $codecConf.= "allow = {$codec}\n";
92
+        foreach ($codecs as $codec) {
93
+            $codecConf .= "allow = {$codec}\n";
94 94
         }
95 95
 
96 96
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
             foreach ($subnets as $net) {
100 100
                 $natConf .= "local_net={$net}\n";
101 101
             }
102
-            if ( ! empty($exthostname)) {
102
+            if (!empty($exthostname)) {
103 103
                 $parts = explode(':', $exthostname);
104
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
105
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
106
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
107
-            } elseif ( ! empty($extipaddr)) {
104
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
105
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
106
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
107
+            } elseif (!empty($extipaddr)) {
108 108
                 $parts = explode(':', $extipaddr);
109
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
110
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
111
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
109
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
110
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
111
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
112 112
             }
113 113
         }
114 114
 
115
-        $conf = "[general] \n" .
116
-            "disable_multi_domain=on\n" .
117
-            "transport = udp \n\n" .
115
+        $conf = "[general] \n".
116
+            "disable_multi_domain=on\n".
117
+            "transport = udp \n\n".
118 118
 
119
-            "[global] \n" .
120
-            "type = global\n" .
121
-            "endpoint_identifier_order=username,ip,anonymous\n" .
122
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
119
+            "[global] \n".
120
+            "type = global\n".
121
+            "endpoint_identifier_order=username,ip,anonymous\n".
122
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
123 123
 
124
-            "[anonymous]\n" .
125
-            "type = endpoint\n" .
124
+            "[anonymous]\n".
125
+            "type = endpoint\n".
126 126
             $codecConf.
127 127
             "language={$lang}\n".
128
-            "timers = no\n" .
128
+            "timers = no\n".
129 129
             "context = public-direct-dial\n\n".
130 130
 
131
-            "[transport-udp]\n" .
132
-            "type = transport\n" .
133
-            "protocol = udp\n" .
131
+            "[transport-udp]\n".
132
+            "type = transport\n".
133
+            "protocol = udp\n".
134 134
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
135 135
             "{$natConf}\n\n".
136 136
 
137
-            "[transport-tcp]\n" .
138
-            "type = transport\n" .
139
-            "protocol = tcp\n" .
137
+            "[transport-tcp]\n".
138
+            "type = transport\n".
139
+            "protocol = tcp\n".
140 140
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
141 141
             "{$natConf}\n\n".
142 142
             '';
143 143
 
144 144
         $varEtcDir = $this->config->path('core.varEtcDir');
145
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr. $this->generalSettings['SIPPort']));
145
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr.$this->generalSettings['SIPPort']));
146 146
         $conf .= "\n";
147 147
 
148 148
         return $conf;
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
      * @return bool
155 155
      */
156 156
     public function needAsteriskRestart():bool{
157
-        $di     = Di::getDefault();
157
+        $di = Di::getDefault();
158 158
         if ($di === null) {
159 159
             return false;
160 160
         }
161
-        $mikoPBXConfig  = new MikoPBXConfig();
161
+        $mikoPBXConfig = new MikoPBXConfig();
162 162
         [$topology, $extipaddr, $exthostname] = $this->getTopologyData();
163 163
 
164 164
         $generalSettings = $mikoPBXConfig->getGeneralSettings();
165
-        $now_hadh = md5($topology . $exthostname . $extipaddr. $generalSettings['SIPPort']);
166
-        $old_hash   = '';
165
+        $now_hadh = md5($topology.$exthostname.$extipaddr.$generalSettings['SIPPort']);
166
+        $old_hash = '';
167 167
         $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
168
-        if (file_exists($varEtcDir . '/topology_hash')) {
169
-            $old_hash = file_get_contents($varEtcDir . '/topology_hash');
168
+        if (file_exists($varEtcDir.'/topology_hash')) {
169
+            $old_hash = file_get_contents($varEtcDir.'/topology_hash');
170 170
         }
171 171
 
172 172
         return $old_hash !== $now_hadh;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 continue;
190 190
             }
191 191
             $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
192
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
192
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
193 193
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
194 194
                 $subnets[] = $net;
195 195
             }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $conf        = '';
228 228
         $reg_strings = '';
229 229
         $prov_config = '';
230
-        if ($this->data_providers===null){
230
+        if ($this->data_providers === null) {
231 231
             $this->getSettings();
232 232
         }
233 233
         foreach ($this->data_providers as $provider) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
             $need_register = $provider['noregister'] !== '1';
238 238
             if ($need_register) {
239
-                $options     = [
239
+                $options = [
240 240
                     'type'     => 'auth',
241 241
                     'username' => $provider['username'],
242 242
                     'password' => $provider['secret'],
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n";
245 245
                 $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth');
246 246
 
247
-                $options     = [
247
+                $options = [
248 248
                     'type'                        => 'registration',
249 249
                     // 'transport'                   => 'transport-udp',
250 250
                     'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             }
263 263
 
264 264
             if ('1' !== $provider['receive_calls_without_auth']) {
265
-                $options     = [
265
+                $options = [
266 266
                     'type'     => 'auth',
267 267
                     'username' => $provider['username'],
268 268
                     'password' => $provider['secret'],
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             }
273 273
 
274 274
             $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
275
-            if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
275
+            if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
276 276
                 $contact = "sip:$defaultuser@{$provider['host']}:{$port}";
277 277
             } else {
278 278
                 $contact = "sip:{$provider['host']}:{$port}";
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                 'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
287 287
                 'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
288 288
             ];
289
-            if($provider['qualify'] === '1'){
289
+            if ($provider['qualify'] === '1') {
290 290
                 $options['qualify_frequency'] = $provider['qualifyfreq'];
291 291
                 $options['qualify_timeout']   = '3.0';
292 292
             }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             $prov_config .= "[{$provider['uniqid']}]\n";
295 295
             $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor');
296 296
 
297
-            $options     = [
297
+            $options = [
298 298
                 'type'     => 'identify',
299 299
                 'endpoint' => $provider['uniqid'],
300 300
                 'match'    => $provider['host'],
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public function generatePeersPj(): string
357 357
     {
358
-        if ($this->data_peers===null){
358
+        if ($this->data_peers === null) {
359 359
             $this->getSettings();
360 360
         }
361 361
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             $language = (trim($language) === '') ? 'en-en' : $language;
370 370
 
371 371
             $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
372
-            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
372
+            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
373 373
 
374 374
             $options = [
375 375
                 'type'     => 'auth',
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             'conditions'=>'disabled="0"',
522 522
             'order' => 'type, priority',
523 523
         ];
524
-        $codecs     = Codecs::find($filter);
524
+        $codecs = Codecs::find($filter);
525 525
         foreach ($codecs as $codec_data) {
526 526
             $arr_codecs[] = $codec_data->name;
527 527
         }
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
             // Получим используемые кодеки.
552 552
             $arr_data['codecs'] = $this->getCodecs();
553 553
 
554
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
555
-            if ( ! isset($this->contexts_data[$context_id])) {
554
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
555
+            if (!isset($this->contexts_data[$context_id])) {
556 556
                 $this->contexts_data[$context_id] = [];
557 557
             }
558 558
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
      */
572 572
     private function getOutRoutes(): array
573 573
     {
574
-        if ($this->data_peers===null){
574
+        if ($this->data_peers === null) {
575 575
             $this->getSettings();
576 576
         }
577 577
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      */
607 607
     public function extensionGenContexts(): string
608 608
     {
609
-        if ($this->data_peers===null){
609
+        if ($this->data_peers === null) {
610 610
             $this->getSettings();
611 611
         }
612 612
         // Генерация внутреннего номерного плана.
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
             $contexts_data = $this->contexts_data[$provider['context_id']];
625 625
             if (count($contexts_data) === 1) {
626 626
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
627
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
628
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
627
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
628
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
629 629
                     $contexts_data,
630 630
                     null,
631 631
                     $provider['context_id']
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
      */
645 645
     public function extensionGenHints(): string
646 646
     {
647
-        if ($this->data_peers===null){
647
+        if ($this->data_peers === null) {
648 648
             $this->getSettings();
649 649
         }
650 650
         $conf = '';
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
     public function extensionGenInternal(): string
659 659
     {
660
-        if ($this->data_peers===null){
660
+        if ($this->data_peers === null) {
661 661
             $this->getSettings();
662 662
         }
663 663
         // Генерация внутреннего номерного плана.
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 
673 673
     public function extensionGenInternalTransfer(): string
674 674
     {
675
-        if ($this->data_peers===null){
675
+        if ($this->data_peers === null) {
676 676
             $this->getSettings();
677 677
         }
678 678
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
src/Core/Asterisk/agi-bin/cdr_connector.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
     $orign_chan     = $agi->get_variable("orign_chan", true);
33 33
     $id             = $agi->get_variable("pt1c_UNIQUEID", true);
34 34
     $IS_ORGNT       = $agi->get_variable("IS_ORGNT", true);
35
-    if ($id == '' || ! empty($QUEUE_SRC_CHAN)) {
35
+    if ($id == '' || !empty($QUEUE_SRC_CHAN)) {
36 36
         // Если это вызов на агента очереди !empty($QUEUE_SRC_CHAN).
37 37
         // Если это новый вызов $id == ''.
38
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
38
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
39 39
     }
40 40
     // Канал, AGI скрипта.
41 41
     $channel  = $agi->request['agi_channel'];
42
-    $is_local = ! (stripos($channel, 'local/') === false);
42
+    $is_local = !(stripos($channel, 'local/') === false);
43 43
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
44 44
         // Это LOCAL, Переопределим на исходный.
45 45
         $channel = $QUEUE_SRC_CHAN;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     $data['action'] = "$action";
57
-    if ( ! empty($IS_ORGNT)) {
57
+    if (!empty($IS_ORGNT)) {
58 58
         $dst_num            = $agi->request['agi_callerid'];
59 59
         $src_num            = $agi->request['agi_extension'];
60 60
         $data['dialstatus'] = 'ORIGINATE';
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $num     = substr($agi->request['agi_channel'], $p_start, $p_end);
66 66
 
67 67
         $p_start  = strpos($agi->request['agi_channel'], ';');
68
-        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start) . ';1';
68
+        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start).';1';
69 69
 
70
-        $id               = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $num . '_' . $IS_ORGNT;
70
+        $id               = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$num.'_'.$IS_ORGNT;
71 71
         $data['dst_chan'] = $dst_chan;
72 72
     } else {
73 73
         $src_num = $agi->request['agi_callerid'];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     $data['agi_channel']  = $agi->request['agi_channel'];
85 85
     $data['did']          = $agi->get_variable("FROM_DID", true);
86 86
     $data['from_account'] = $from_account;
87
-    $data['IS_ORGNT']     = ! empty($IS_ORGNT);
87
+    $data['IS_ORGNT']     = !empty($IS_ORGNT);
88 88
 
89 89
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
90 90
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
118
-    if ( ! empty($IS_ORGNT)) {
118
+    if (!empty($IS_ORGNT)) {
119 119
         // Вероятно необходимо переопределить искать по двум ID.
120 120
         // Применимо только для Originate, когда в качестве звонящего используем два канала
121 121
         // мобильный и внутренний номер.
122 122
         $peer_mobile = $agi->get_variable("peer_mobile", true);
123
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
123
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
125 125
             $data['org_id'] = $id;
126 126
         }
127 127
     }
@@ -154,22 +154,22 @@  discard block
 block discarded – undo
154 154
     $data['BRIDGEPEER']      = $agi->get_variable("FROM_CHAN", true);
155 155
 
156 156
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
157
-    if ( ! empty($IS_ORGNT)) {
157
+    if (!empty($IS_ORGNT)) {
158 158
         // Вероятно необходимо переопределить ID.
159 159
         // Применимо только для Originate, когда в качестве звонящего используем два канала
160 160
         // мобильный и внутренний номер.
161 161
         $peer_mobile = $agi->get_variable("peer_mobile", true);
162
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
162
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
164 164
             $data['org_id'] = $id;
165 165
         }
166 166
     }
167 167
 
168
-    if ( ! empty($data['ENDCALLONANSWER'])) {
168
+    if (!empty($data['ENDCALLONANSWER'])) {
169 169
         $agi->set_variable("__ENDCALLONANSWER", "");
170 170
     }
171 171
 
172
-    $PICKUPEER     = trim('' . $agi->get_variable("PICKUPEER", true));
172
+    $PICKUPEER     = trim(''.$agi->get_variable("PICKUPEER", true));
173 173
     $data['dnid']  = $agi->request['agi_dnid'];
174 174
     $mikoPBXConfig = new MikoPBXConfig();
175 175
     $pickupexten   = $mikoPBXConfig->getGeneralSettings('PBXFeaturePickupExten');
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         // Очищаем переменную канала. Больше не требуется.
185 185
         $agi->set_variable("PICKUPEER", "");
186 186
         $data['old_id'] = $id;
187
-        $data['id']     = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
187
+        $data['id']     = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
188 188
     }
189 189
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
190 190
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $data['linkedid']    = $agi->get_variable("CDR(linkedid)", true);
212 212
     $data['did']         = $agi->get_variable("FROM_DID", true);
213 213
 
214
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
214
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
215 215
 
216 216
     return $data;
217 217
 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 function Event_transfer_dial($agi, $action)
228 228
 {
229 229
     $now = Util::getNowDate();
230
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
230
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
231 231
 
232 232
     // Пытаемся определить канал.
233 233
     $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true);
234 234
     $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true);
235
-    $is_local       = ! (stripos($TRANSFERERNAME, 'local/') === false);
235
+    $is_local       = !(stripos($TRANSFERERNAME, 'local/') === false);
236 236
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
237 237
         // Это LOCAL, Переопределим на исходный.
238 238
         $channel = $QUEUE_SRC_CHAN;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     $data                = [];
249 249
     $data['action']      = "$action";
250
-    $data['agi_channel'] = $channel;// $agi->request['agi_channel'];
250
+    $data['agi_channel'] = $channel; // $agi->request['agi_channel'];
251 251
     $data['linkedid']    = $agi->get_variable("CDR(linkedid)", true);
252 252
     $data['src_chan']    = $channel;
253 253
     $data['did']         = $agi->get_variable("FROM_DID", true);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     $data['did']          = $agi->get_variable("FROM_DID", true);
322 322
     $data['action']       = "$action";
323 323
     $data['agi_channel']  = $agi->request['agi_channel'];
324
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
324
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
325 325
 
326 326
     $pos = stripos($data['agi_channel'], 'local/');
327 327
     if ($pos === false) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     $data                 = [];
351 351
     $data['action']       = "$action";
352 352
     $data['did']          = $agi->get_variable("FROM_DID", true);
353
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
353
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
354 354
 
355 355
     $data['linkedid']   = $agi->get_variable("CDR(linkedid)", true);
356 356
     $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true);
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']);
386 386
 
387 387
     // Сбор данных для генерации CDR.
388
-    $id      = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
388
+    $id      = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
389 389
     $channel = $agi->request['agi_channel'];
390 390
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
391 391
     $data                 = [];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
         $data['src_chan'] = $channel;
404 404
         $data['src_num']  = $agi->request['agi_callerid'];
405 405
         $data['dst_num']  = $agi->request['agi_extension'];
406
-        $data['dst_chan'] = 'Park:' . $agi->request['agi_extension'];
406
+        $data['dst_chan'] = 'Park:'.$agi->request['agi_extension'];
407 407
     } elseif (true === $park_row['pt1c_is_dst']) {
408 408
         $data['src_chan'] = $channel;
409 409
         $data['dst_chan'] = $park_row['ParkeeChannel'];
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
     if (trim($park_row['ParkingDuration']) !== '') {
420 420
         $time_start           = date("Y-m-d H:i:s", time() - 1 * ($park_row['ParkingDuration']));
421 421
         $data_parking         = [
422
-            'UNIQUEID' => $id . '_' . Util::generateRandomString(3),
422
+            'UNIQUEID' => $id.'_'.Util::generateRandomString(3),
423 423
             'src_chan' => $park_row['ParkeeChannel'],
424 424
             'src_num'  => $park_row['ParkeeCallerIDNum'],
425 425
             'dst_num'  => $park_row['ParkingSpace'],
426
-            'dst_chan' => 'Park:' . $park_row['ParkingSpace'],
426
+            'dst_chan' => 'Park:'.$park_row['ParkingSpace'],
427 427
             'start'    => $time_start,
428 428
             'answer'   => $time_start,
429 429
             'endtime'  => $now,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 function Event_unpark_call_timeout($agi, $action)
449 449
 {
450 450
     $now = Util::getNowDate();
451
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
451
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
452 452
     // PARKER=SIP/206
453 453
     $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true);
454 454
     $PARKING_DURATION = ($PARKING_DURATION == '') ? 45 : $PARKING_DURATION;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ???
461 461
         'src_num'  => $agi->request['agi_callerid'],
462 462
         'dst_num'  => $PARKING_SPACE,
463
-        'dst_chan' => 'Park:' . $PARKING_SPACE,
463
+        'dst_chan' => 'Park:'.$PARKING_SPACE,
464 464
         'start'    => $time_start,
465 465
         'answer'   => $time_start,
466 466
         'endtime'  => $now,
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     ];
473 473
 
474 474
 
475
-    $id2 = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
475
+    $id2 = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
476 476
     $agi->set_variable("__pt1c_UNIQUEID", "$id2");
477 477
 
478 478
     return $data;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     $id         = $agi->get_variable("pt1c_UNIQUEID", true);
494 494
     $ISTRANSFER = $agi->get_variable("ISTRANSFER", true);
495 495
 
496
-    if (empty($id) || ! empty($ISTRANSFER)) {
497
-        $id         = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
496
+    if (empty($id) || !empty($ISTRANSFER)) {
497
+        $id         = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
498 498
         $time_start = $now;
499 499
     }
500 500
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         // 'src_chan' => $agi->request['agi_channel'],
504 504
         // 'src_num'  => $agi->request['agi_callerid'],
505 505
         'dst_num'  => $agi->request['agi_extension'],
506
-        'dst_chan' => 'Queue:' . $agi->request['agi_extension'],
506
+        'dst_chan' => 'Queue:'.$agi->request['agi_extension'],
507 507
         // 'answer'   => $time_start,
508 508
         // 'end'  	   => $now,
509 509
         'did'      => $agi->get_variable("FROM_DID", true),
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         'UNIQUEID' => $id,
512 512
         'linkedid' => $agi->get_variable("CDR(linkedid)", true),
513 513
     ];
514
-    if ( ! empty($time_start)) {
514
+    if (!empty($time_start)) {
515 515
         $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true);
516 516
         $data['src_num']  = $agi->request['agi_callerid'];
517 517
         $data['start']    = $time_start;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         $data['transfer'] = '0';
520 520
         $agi->set_variable("__pt1c_q_UNIQUEID", "$id");
521 521
     }
522
-    if ( ! empty($ISTRANSFER)) {
522
+    if (!empty($ISTRANSFER)) {
523 523
         $data['transfer'] = '1';
524 524
     } else {
525 525
         $data['transfer'] = '0';
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
     $is_conf   = ($agi->get_variable('CALLERID(num)', true) === 'Conference_Room');
592 592
     $not_local = (stripos($agi->request['agi_channel'], 'local/') === false);
593
-    if ($not_local && ! $is_conf) {
593
+    if ($not_local && !$is_conf) {
594 594
         $am         = Util::getAstManager();
595 595
         $res        = $am->meetMeCollectInfo($exten, ['conf_1c']);
596 596
         $callid     = $agi->request['agi_callerid'];
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     if (empty($id)) {
631
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
631
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
632 632
     }
633 633
 
634 634
     $recordingfile = CdrDb::MeetMeSetRecFilename($id);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         'src_chan'      => $agi->request['agi_channel'],
638 638
         'src_num'       => $src_num,
639 639
         'dst_num'       => $dst_num,
640
-        'dst_chan'      => 'MeetMe:' . $mikoidconf,
640
+        'dst_chan'      => 'MeetMe:'.$mikoidconf,
641 641
         'start'         => $time_start,
642 642
         'answer'        => $time_start,
643 643
         'recordingfile' => "{$recordingfile}.mp3",
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     $lamePath = Util::which('lame');
680 680
     $nicePath = Util::which('nice');
681 681
     $chmodPath = Util::which('chmod');
682
-    $command               = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
682
+    $command = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
683 683
     Util::mwExecBg($command);
684 684
 
685 685
     return $data;
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function Event_dial_app($agi, $action)
697 697
 {
698
-    $id        = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
698
+    $id        = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
699 699
     $extension = $agi->get_variable("APPEXTEN", true);
700 700
     if (empty($extension)) {
701 701
         $extension = $agi->request['agi_extension'];
702 702
     }
703 703
 
704 704
     $data             = Event_dial($agi, $action);
705
-    $data['dst_chan'] = 'App:' . $extension;
705
+    $data['dst_chan'] = 'App:'.$extension;
706 706
     $data['dst_num']  = $extension;
707 707
     $data['is_app']   = 1;
708 708
     $data['UNIQUEID'] = $id;
@@ -743,5 +743,5 @@  discard block
 block discarded – undo
743 743
     $result = $func_name($agi, $action);
744 744
     // Оповещение без задержек.
745 745
     $data = base64_encode(json_encode($result));
746
-    $agi->exec("UserEvent", "CdrConnector,AgiData:" . base64_encode(json_encode($result)));
746
+    $agi->exec("UserEvent", "CdrConnector,AgiData:".base64_encode(json_encode($result)));
747 747
 }
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/FirewallManagementProcessor.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
         if(!file_exists($path_db)){
137 137
             // Таблица не существует. Бана нет.
138 138
             $res->success    = false;
139
-            $res->messages[] = "DB {$path_db} not found";
139
+            $res->messages[] = "db {$path_db} not found";
140 140
             return $res;
141 141
         }
142 142
         $db      = new SQLite3($path_db);
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -80,22 +80,22 @@
 block discarded – undo
80 80
         return $res;
81 81
     }
82 82
 
83
-     public static function getDbConnection(){
84
-         if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
85
-             return null;
86
-         }
87
-         try {
88
-             $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
89
-         }catch (Throwable $e){
90
-             return null;
91
-         }
92
-         $db->busyTimeout(5000);
93
-         $fail2ban = new Fail2BanConf();
94
-         if (false === $fail2ban->tableBanExists($db)) {
95
-             return null;
96
-         }
83
+        public static function getDbConnection(){
84
+            if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
85
+                return null;
86
+            }
87
+            try {
88
+                $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
89
+            }catch (Throwable $e){
90
+                return null;
91
+            }
92
+            $db->busyTimeout(5000);
93
+            $fail2ban = new Fail2BanConf();
94
+            if (false === $fail2ban->tableBanExists($db)) {
95
+                return null;
96
+            }
97 97
 
98
-         return $db;
98
+            return $db;
99 99
     }
100 100
 
101 101
     /**
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function fail2banUnbanAll(string $ip): PBXApiResult
31 31
     {
32
-        $ip     = trim($ip);
32
+        $ip = trim($ip);
33 33
         $res = new PBXApiResult();
34 34
         $res->processor = __METHOD__;
35 35
         $res->success = true;
36
-        if ( ! Verify::isIpAddress($ip)) {
36
+        if (!Verify::isIpAddress($ip)) {
37 37
             $res->success = false;
38
-            $res->messages[]="Not valid ip '{$ip}'.";
38
+            $res->messages[] = "Not valid ip '{$ip}'.";
39 39
         }
40
-        $fail2ban        = new Fail2BanConf();
40
+        $fail2ban = new Fail2BanConf();
41 41
         if ($fail2ban->fail2ban_enable) {
42 42
             $fail2ban = Util::which('fail2ban-client');
43
-            $res->success  = (Util::mwExec("{$fail2ban} unban {$ip}") === 0);
43
+            $res->success = (Util::mwExec("{$fail2ban} unban {$ip}") === 0);
44 44
         } else {
45 45
             $res = self::fail2banUnbanDb($ip);
46 46
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $res->processor = __METHOD__;
62 62
 
63 63
         $db = self::getDbConnection();
64
-        if(!$db){
64
+        if (!$db) {
65 65
             // Таблица не существует. Бана нет.
66 66
             $res->success    = false;
67 67
             $res->messages[] = 'DB '.Fail2BanConf::FAIL2BAN_DB_PATH.' not found';
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
         return $res;
81 81
     }
82 82
 
83
-     public static function getDbConnection(){
84
-         if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
83
+     public static function getDbConnection() {
84
+         if (!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)) {
85 85
              return null;
86 86
          }
87 87
          try {
88
-             $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
89
-         }catch (Throwable $e){
88
+             $db = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
89
+         } catch (Throwable $e) {
90 90
              return null;
91 91
          }
92 92
          $db->busyTimeout(5000);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             $ban_time = '43800';
112 112
         }
113 113
         // Добавленн фильтр по времени бана. возвращаем только адреса, которые еще НЕ разбанены.
114
-        $q = 'SELECT' . ' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+' . $ban_time . ') AS timeunban FROM bans where (timeofban+' . $ban_time . ')>' . time();
114
+        $q = 'SELECT'.' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+'.$ban_time.') AS timeunban FROM bans where (timeofban+'.$ban_time.')>'.time();
115 115
         if ($ip !== null) {
116 116
             $q .= " AND ip='{$ip}'";
117 117
         }
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 
135 135
         $jail_q  = ($jail === '') ? '' : "AND jail = '{$jail}'";
136 136
         $path_db = Fail2BanConf::FAIL2BAN_DB_PATH;
137
-        if(!file_exists($path_db)){
137
+        if (!file_exists($path_db)) {
138 138
             // Таблица не существует. Бана нет.
139 139
             $res->success    = false;
140 140
             $res->messages[] = "DB {$path_db} not found";
141 141
             return $res;
142 142
         }
143
-        $db      = new SQLite3($path_db);
143
+        $db = new SQLite3($path_db);
144 144
         $db->busyTimeout(3000);
145 145
         $fail2ban = new Fail2BanConf();
146 146
         if (false === $fail2ban->tableBanExists($db)) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             $res->success = true;
149 149
             return $res;
150 150
         }
151
-        $q = 'DELETE' . " FROM bans WHERE ip = '{$ip}' {$jail_q}";
151
+        $q = 'DELETE'." FROM bans WHERE ip = '{$ip}' {$jail_q}";
152 152
         $db->query($q);
153 153
 
154 154
         $err = $db->lastErrorMsg();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,13 +80,14 @@
 block discarded – undo
80 80
         return $res;
81 81
     }
82 82
 
83
-     public static function getDbConnection(){
83
+     public static function getDbConnection()
84
+     {
84 85
          if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
85 86
              return null;
86 87
          }
87 88
          try {
88 89
              $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
89
-         }catch (Throwable $e){
90
+         } catch (Throwable $e){
90 91
              return null;
91 92
          }
92 93
          $db->busyTimeout(5000);
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/SystemManagementProcessor.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
         $res->data['message'] = 'In progress...';
163 163
 
164 164
 
165
-        if ( ! file_exists($tempFilename)) {
165
+        if (!file_exists($tempFilename)) {
166 166
             $res->success    = false;
167 167
             $res->messages[] = "Update file '{$tempFilename}' not found.";
168 168
 
169 169
             return $res;
170 170
         }
171 171
 
172
-        if ( ! file_exists('/var/etc/cfdevice')) {
172
+        if (!file_exists('/var/etc/cfdevice')) {
173 173
             $res->success    = false;
174 174
             $res->messages[] = "The system is not installed";
175 175
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $res            = new PBXApiResult();
199 199
         $res->processor = __METHOD__;
200 200
         $moduleMetadata = FilesManagementProcessor::getMetadataFromModuleFile($filePath);
201
-        if ( ! $moduleMetadata->success) {
201
+        if (!$moduleMetadata->success) {
202 202
             return $moduleMetadata;
203 203
         } else {
204 204
             $moduleUniqueID = $moduleMetadata->data['uniqid'];
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         if (class_exists($pbxExtensionSetupClass)
238 238
             && method_exists($pbxExtensionSetupClass, 'installModule')) {
239 239
             $setup = new $pbxExtensionSetupClass($moduleUniqueID);
240
-            if ( ! $setup->installModule()) {
240
+            if (!$setup->installModule()) {
241 241
                 $res->success    = false;
242 242
                 $res->messages[] = $setup->getMessages();
243 243
             }
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
             [IncomingRoutingTable::class => ''],
385 385
             [OutWorkTimes::class => ''],
386 386
             [AsteriskManagerUsers::class => ''],
387
-            [Extensions::class => 'type="' . Extensions::TYPE_IVR_MENU . '"'],  // IVR Menu
388
-            [Extensions::class => 'type="' . Extensions::TYPE_CONFERENCE . '"'],  // CONFERENCE
389
-            [Extensions::class => 'type="' . Extensions::TYPE_QUEUE . '"'],  // QUEUE
387
+            [Extensions::class => 'type="'.Extensions::TYPE_IVR_MENU.'"'], // IVR Menu
388
+            [Extensions::class => 'type="'.Extensions::TYPE_CONFERENCE.'"'], // CONFERENCE
389
+            [Extensions::class => 'type="'.Extensions::TYPE_QUEUE.'"'], // QUEUE
390 390
         ];
391 391
 
392 392
         foreach ($clearThisModels as $modelParams) {
393 393
             foreach ($modelParams as $key => $value) {
394 394
                 $records = call_user_func([$key, 'find'], $value);
395
-                if ( ! $records->delete()) {
395
+                if (!$records->delete()) {
396 396
                     $res->messages[] = $records->getMessages();
397 397
                     $res->success    = false;
398 398
                 }
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Other extensions
403
-        $parameters     = [
403
+        $parameters = [
404 404
             'conditions' => 'not number IN ({ids:array})',
405 405
             'bind'       => [
406 406
                 'ids' => [
407 407
                     '000063', // Reads back the extension
408 408
                     '000064', // 0000MILLI
409
-                    '10003246',// Echo test
409
+                    '10003246', // Echo test
410 410
                     '10000100' // Voicemail
411 411
                 ],
412 412
             ],
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
                 $stopDeleting = true;
421 421
                 continue;
422 422
             }
423
-            if ( ! $record->delete()) {
423
+            if (!$record->delete()) {
424 424
                 $deleteAttempts += 1;
425 425
             }
426 426
             if ($deleteAttempts > $countRecords * 10) {
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
                 'custom' => SoundFiles::CATEGORY_CUSTOM,
437 437
             ],
438 438
         ];
439
-        $records    = SoundFiles::find($parameters);
439
+        $records = SoundFiles::find($parameters);
440 440
 
441 441
         foreach ($records as $record) {
442 442
             if (stripos($record->path, '/storage/usbdisk1/mikopbx') !== false) {
443 443
                 Util::mwExec("{$rm} -rf {$record->path}");
444
-                if ( ! $record->delete()) {
444
+                if (!$record->delete()) {
445 445
                     $res->messages[] = $record->getMessages();
446 446
                     $res->success    = false;
447 447
                 }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
         foreach ($records as $record) {
454 454
             $moduleDir = PbxExtensionUtils::getModuleDir($record->uniqid);
455 455
             Util::mwExec("{$rm} -rf {$moduleDir}");
456
-            if ( ! $record->delete()) {
456
+            if (!$record->delete()) {
457 457
                 $res->messages[] = $record->getMessages();
458 458
                 $res->success    = false;
459 459
             }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
         // Delete CallRecords
463 463
         $records = CallDetailRecords::find();
464
-        if ( ! $records->delete()) {
464
+        if (!$records->delete()) {
465 465
             $res->messages[] = $records->getMessages();
466 466
             $res->success    = false;
467 467
         }
@@ -486,14 +486,14 @@  discard block
 block discarded – undo
486 486
     {
487 487
         $res            = new PBXApiResult();
488 488
         $res->processor = __METHOD__;
489
-        if ( ! file_exists($filename)) {
489
+        if (!file_exists($filename)) {
490 490
             $res->success    = false;
491 491
             $res->messages[] = "File '{$filename}' not found.";
492 492
 
493 493
             return $res;
494 494
         }
495 495
         $out          = [];
496
-        $tmp_filename = '/tmp/' . time() . "_" . basename($filename);
496
+        $tmp_filename = '/tmp/'.time()."_".basename($filename);
497 497
         if (false === copy($filename, $tmp_filename)) {
498 498
             $res->success    = false;
499 499
             $res->messages[] = "Unable to create temporary file '{$tmp_filename}'.";
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
         }
503 503
 
504 504
         // Принудительно устанавливаем расширение файла в wav.
505
-        $n_filename     = Util::trimExtensionForFile($filename) . ".wav";
506
-        $n_filename_mp3 = Util::trimExtensionForFile($filename) . ".mp3";
505
+        $n_filename     = Util::trimExtensionForFile($filename).".wav";
506
+        $n_filename_mp3 = Util::trimExtensionForFile($filename).".mp3";
507 507
         // Конвертируем файл.
508 508
         $tmp_filename = escapeshellcmd($tmp_filename);
509 509
         $n_filename   = escapeshellcmd($n_filename);
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCdr.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -241,7 +241,8 @@
 block discarded – undo
241 241
 
242 242
     /**
243 243
      */
244
-    private function getCheckResult(){
244
+    private function getCheckResult()
245
+    {
245 246
         $result_data = $this->client_queue->getBody();
246 247
         // Получаем результат.
247 248
         $result = json_decode($result_data, true);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public const SELECT_CDR_TUBE = 'select_cdr_tube';
25 25
     public const UPDATE_CDR_TUBE = 'update_cdr_tube';
26
-    protected int $maxProc=1;
26
+    protected int $maxProc = 1;
27 27
 
28 28
 
29 29
     private BeanstalkClient $client_queue;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             ]
92 92
         ];
93 93
 
94
-        $results   = Users::find($parameters);
94
+        $results = Users::find($parameters);
95 95
         foreach ($results as $record) {
96 96
             if (empty($record->email)) {
97 97
                 continue;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function getActiveIdChannels(): array
162 162
     {
163
-        $am           = Util::getAstManager('off');
163
+        $am = Util::getAstManager('off');
164 164
         return $am->GetChannels(true);
165 165
     }
166 166
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             $this->no_answered_calls[$row['linkedid']]['NOANSWER'] = false;
176 176
             return;
177 177
         }
178
-        if ( ! array_key_exists($row['dst_num'], $this->internal_numbers)) {
178
+        if (!array_key_exists($row['dst_num'], $this->internal_numbers)) {
179 179
             // dst_num - не является номером сотрудника. Это исходящий.
180 180
             return;
181 181
         }
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
             if (!empty($row['recordingfile'])) {
241 241
                 // Удаляем файлы
242 242
                 $p_info = pathinfo($row['recordingfile']);
243
-                $fileName = $p_info['dirname'] . '/' . $p_info['filename'];
244
-                $file_list = [$fileName . '.mp3', $fileName . '.wav', $fileName . '_in.wav', $fileName . '_out.wav',];
243
+                $fileName = $p_info['dirname'].'/'.$p_info['filename'];
244
+                $file_list = [$fileName.'.mp3', $fileName.'.wav', $fileName.'_in.wav', $fileName.'_out.wav', ];
245 245
                 foreach ($file_list as $file) {
246 246
                     if (!file_exists($file) || is_dir($file)) {
247 247
                         continue;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
     /**
265 265
      */
266
-    private function getCheckResult(){
266
+    private function getCheckResult() {
267 267
         $result_data = $this->client_queue->getBody();
268 268
         // Получаем результат.
269 269
         $result = json_decode($result_data, true);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             }
275 275
             $result = $file_data;
276 276
         }
277
-        if ( ! is_array($result) && ! is_object($result)) {
277
+        if (!is_array($result) && !is_object($result)) {
278 278
             $result = [];
279 279
         }
280 280
         return $result;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 Util::mwExec("rm -rf {$row['recordingfile']}");
300 300
             }
301 301
         } elseif (!empty($row['recordingfile']) &&
302
-            !file_exists(Util::trimExtensionForFile($row['recordingfile']) . '.wav') &&
302
+            !file_exists(Util::trimExtensionForFile($row['recordingfile']).'.wav') &&
303 303
             !file_exists($row['recordingfile'])) {
304 304
             /** @var CallDetailRecordsTmp $rec_data */
305 305
             $rec_data = CallDetailRecordsTmp::findFirst("linkedid='{$row['linkedid']}' AND dst_chan='{$row['dst_chan']}'");
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/FeaturesConf.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
     protected function generateConfigProtected(): void
21 21
     {
22
-        $conf             = "[general]\n" .
23
-            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n" .
24
-            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n" .
25
-            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n" .
26
-            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n" .
27
-            "atxferabort = *0\n" .
28
-            "\n" .
29
-            "[featuremap]\n" .
30
-            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n" .
31
-            "disconnect = *0\n" .
22
+        $conf = "[general]\n".
23
+            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n".
24
+            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n".
25
+            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n".
26
+            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n".
27
+            "atxferabort = *0\n".
28
+            "\n".
29
+            "[featuremap]\n".
30
+            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n".
31
+            "disconnect = *0\n".
32 32
             "blindxfer => {$this->generalSettings['PBXFeatureBlindTransfer']}\n";
33 33
 
34 34
         $additionalModules = $this->di->getShared('pbxConfModules');
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             $conf .= $appClass->getFeatureMap();
37 37
         }
38 38
 
39
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/features.conf', $conf);
39
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/features.conf', $conf);
40 40
     }
41 41
 
42 42
     // Секция global для extensions.conf.
Please login to merge, or discard this patch.
src/Modules/PbxExtensionUtils.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $moduleAgiBinDir = "{$moduleDir}/agi-bin";
116 116
         $files           = glob("$moduleAgiBinDir/*.{php}", GLOB_BRACE);
117 117
         foreach ($files as $file) {
118
-            $newFilename = $agiBinDir . '/' . basename($file);
118
+            $newFilename = $agiBinDir.'/'.basename($file);
119 119
             Util::createUpdateSymlink($file, $newFilename);
120 120
         }
121 121
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             $needDisable = false;
137 137
             $moduleDir   = PbxExtensionUtils::getModuleDir($module['uniqid']);
138 138
             $moduleJson  = "{$moduleDir}/module.json";
139
-            if ( ! file_exists($moduleJson)) {
139
+            if (!file_exists($moduleJson)) {
140 140
                 $needDisable = true;
141 141
             }
142 142
             $jsonString            = file_get_contents($moduleJson);
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
                 } catch (Throwable $exception) {
153 153
                     Util::sysLogMsg(__CLASS__, "Can not disable module {$module['uniqid']} Message: {$exception}");
154 154
                 } finally {
155
-                    $currentModule           = PbxExtensionModules::findFirstByUniqid($module['uniqid']);
156
-                    if ($currentModule->disabled==='0'){
155
+                    $currentModule = PbxExtensionModules::findFirstByUniqid($module['uniqid']);
156
+                    if ($currentModule->disabled === '0') {
157 157
                         $currentModule->disabled = '1';
158 158
                         $currentModule->update();
159 159
                     }
Please login to merge, or discard this patch.