Passed
Push — master ( 15b19d...384de0 )
by Nikolay
11:50 queued 06:02
created
src/AdminCabinet/Controllers/OutboundRoutesController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                     'trimfrombegin'    => $rule->trimfrombegin,
52 52
                     'prepend'          => $rule->prepend,
53 53
                     'note'             => $rule->note,
54
-                    'rulename'         => '<i class="icon attention"></i> ' . $rule->getRepresent(),
54
+                    'rulename'         => '<i class="icon attention"></i> '.$rule->getRepresent(),
55 55
                     'disabled'         => false,
56 56
                 ];
57 57
             }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
             switch ($name) {
106 106
                 case 'restnumbers':
107 107
                 {
108
-                    if ( ! array_key_exists($name, $data)) {
108
+                    if (!array_key_exists($name, $data)) {
109 109
                         continue 2;
110 110
                     }
111 111
                     $rule->$name = $data[$name] === '' ? '-1' : $data[$name];
112 112
                     break;
113 113
                 }
114 114
                 default:
115
-                    if ( ! array_key_exists($name, $data)) {
115
+                    if (!array_key_exists($name, $data)) {
116 116
                         continue 2;
117 117
                     }
118 118
                     $rule->$name = $data[$name];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         $this->view->disable();
165 165
         $result = false;
166 166
 
167
-        if ( ! $this->request->isPost()) {
167
+        if (!$this->request->isPost()) {
168 168
             return;
169 169
         }
170 170
         $data = $this->request->getPost();
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/LicenseManagementProcessor.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
                     $this->license->changeLicenseKey($data['licKey']);
117 117
                     $this->license->addTrial('11'); // MikoPBX forever license
118 118
                     $res->success = true;
119
-                } elseif ( ! empty($licenseInfo) && strpos($licenseInfo, '2026') !== false) {
119
+                } elseif (!empty($licenseInfo) && strpos($licenseInfo, '2026') !== false) {
120 120
                     $res->success    = false;
121 121
                     $res->messages[] = $this->translation->_('lic_FailedCheckLicense2026');
122
-                } elseif ( ! empty($licenseInfo)) {
122
+                } elseif (!empty($licenseInfo)) {
123 123
                     $res->messages[] = $licenseInfo;
124 124
                     $res->success    = false;
125 125
                 } else {
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
                     $res->success    = false;
128 128
                 }
129 129
             }
130
-            if ( ! empty($data['coupon'])) {
130
+            if (!empty($data['coupon'])) {
131 131
                 $result = $this->license->activateCoupon($data['coupon']);
132 132
                 if ($result === true) {
133 133
                     $res->messages[] = $this->translation->_('lic_SuccessfulCouponActivated');
134 134
                     $res->success    = true;
135 135
                 } else {
136
-                    $res->messages[] = $this->license->translateLicenseErrorMessage((string)$result);
136
+                    $res->messages[] = $this->license->translateLicenseErrorMessage((string) $result);
137 137
                     $res->success    = false;
138 138
                 }
139 139
             }
140 140
         } else { // Only add trial for license key
141 141
             $newLicenseKey = $this->license->getTrialLicense($data);
142 142
             if (strlen($newLicenseKey) === 28
143
-                && Text::startsWith((string)$newLicenseKey, 'MIKO-')) {
143
+                && Text::startsWith((string) $newLicenseKey, 'MIKO-')) {
144 144
                 $mikoPBXConfig->setGeneralSettings('PBXLicense', $newLicenseKey);
145 145
                 $this->license->changeLicenseKey($newLicenseKey);
146 146
                 $res->success    = true;
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
         $licFeatureId = $data['licFeatureId'];
213 213
         $licProductId = $data['licProductId'];
214 214
 
215
-        if ( ! isset($licFeatureId, $licProductId)) {
216
-            $res->messages[]='The feature id or product id is empty.';
215
+        if (!isset($licFeatureId, $licProductId)) {
216
+            $res->messages[] = 'The feature id or product id is empty.';
217 217
             return $res;
218 218
         }
219 219
         $res->success = true;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $res = new PBXApiResult();
245 245
         $res->processor = __METHOD__;
246
-        $res->success= true;
246
+        $res->success = true;
247 247
 
248 248
         // License Key
249 249
         $licenseKey = PbxSettings::getValueByKey('PBXLicense');
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
         $dataMetrics = [];
252 252
 
253 253
         // PBXVersion
254
-        $dataMetrics['PBXname'] = 'MikoPBX@' . PbxSettings::getValueByKey('PBXVersion');
254
+        $dataMetrics['PBXname'] = 'MikoPBX@'.PbxSettings::getValueByKey('PBXVersion');
255 255
 
256 256
         // SIP Extensions count
257
-        $extensions                   = Extensions::find('type="'.Extensions::TYPE_SIP.'"');
257
+        $extensions = Extensions::find('type="'.Extensions::TYPE_SIP.'"');
258 258
         $dataMetrics['CountSipExtensions'] = $extensions->count();
259 259
 
260 260
         // Interface language
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/CelConf.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@
 block discarded – undo
19 19
 
20 20
     protected function generateConfigProtected(): void
21 21
     {
22
-        $conf = "[general]\n" .
23
-            "enable=yes\n" .
24
-            "events=CHAN_START,CHAN_END,ANSWER\n" .
25
-            "dateformat = %F %T\n\n" .
26
-            "[manager]\n" .
22
+        $conf = "[general]\n".
23
+            "enable=yes\n".
24
+            "events=CHAN_START,CHAN_END,ANSWER\n".
25
+            "dateformat = %F %T\n\n".
26
+            "[manager]\n".
27 27
             "enabled = yes\n\n";
28
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/cel.conf', $conf);
28
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/cel.conf', $conf);
29 29
     }
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/System/Configs/Fail2BanConf.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $fail2ban = new self();
46 46
         if ($fail2ban->fail2ban_enable
47
-            && ! $fail2ban->fail2banIsRunning()) {
47
+            && !$fail2ban->fail2banIsRunning()) {
48 48
             $fail2ban->fail2banStart();
49 49
         }
50 50
     }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $create_link = false;
139 139
 
140 140
         // Символическая ссылка на базу данных.
141
-        if (file_exists($res_file)){
141
+        if (file_exists($res_file)) {
142 142
             if (filetype($res_file) !== 'link') {
143 143
                 unlink($res_file);
144 144
                 $create_link = true;
@@ -191,59 +191,59 @@  discard block
 block discarded – undo
191 191
         }
192 192
         $this->generateJails();
193 193
 
194
-        $jails        = [
194
+        $jails = [
195 195
             'dropbear'    => 'iptables-allports[name=SSH, protocol=all]',
196 196
             'mikopbx-www' => 'iptables-allports[name=HTTP, protocol=all]',
197 197
         ];
198 198
         $modulesJails = $this->generateModulesJailsLocal();
199 199
         $jails        = array_merge($jails, $modulesJails);
200
-        $config       = "[DEFAULT]\n" .
200
+        $config       = "[DEFAULT]\n".
201 201
             "ignoreip = 127.0.0.1 {$user_whitelist}\n\n";
202 202
 
203 203
         $syslog_file = SyslogConf::getSyslogFile();
204 204
 
205 205
         foreach ($jails as $jail => $action) {
206
-            $config .= "[{$jail}]\n" .
207
-                "enabled = true\n" .
208
-                "backend = process\n" .
209
-                "logpath = {$syslog_file}\n" .
206
+            $config .= "[{$jail}]\n".
207
+                "enabled = true\n".
208
+                "backend = process\n".
209
+                "logpath = {$syslog_file}\n".
210 210
                 // "logprocess = logread -f\n".
211
-                "maxretry = {$max_retry}\n" .
212
-                "findtime = {$find_time}\n" .
213
-                "bantime = {$ban_time}\n" .
214
-                "logencoding = utf-8\n" .
211
+                "maxretry = {$max_retry}\n".
212
+                "findtime = {$find_time}\n".
213
+                "bantime = {$ban_time}\n".
214
+                "logencoding = utf-8\n".
215 215
                 "action = {$action}\n\n";
216 216
         }
217 217
 
218
-        $log_dir = System::getLogDir() . '/asterisk/';
219
-        $config  .= "[asterisk_security_log]\n" .
220
-            "enabled = true\n" .
221
-            "filter = asterisk\n" .
222
-            "action = iptables-allports[name=ASTERISK, protocol=all]\n" .
223
-            "logencoding = utf-8\n" .
224
-            "maxretry = {$max_retry}\n" .
225
-            "findtime = {$find_time}\n" .
226
-            "bantime = {$ban_time}\n" .
218
+        $log_dir = System::getLogDir().'/asterisk/';
219
+        $config .= "[asterisk_security_log]\n".
220
+            "enabled = true\n".
221
+            "filter = asterisk\n".
222
+            "action = iptables-allports[name=ASTERISK, protocol=all]\n".
223
+            "logencoding = utf-8\n".
224
+            "maxretry = {$max_retry}\n".
225
+            "findtime = {$find_time}\n".
226
+            "bantime = {$ban_time}\n".
227 227
             "logpath = {$log_dir}security_log\n\n";
228 228
 
229
-        $config .= "[asterisk_error]\n" .
230
-            "enabled = true\n" .
231
-            "filter = asterisk\n" .
232
-            "action = iptables-allports[name=ASTERISK_ERROR, protocol=all]\n" .
233
-            "maxretry = {$max_retry}\n" .
234
-            "findtime = {$find_time}\n" .
235
-            "bantime = {$ban_time}\n" .
236
-            "logencoding = utf-8\n" .
229
+        $config .= "[asterisk_error]\n".
230
+            "enabled = true\n".
231
+            "filter = asterisk\n".
232
+            "action = iptables-allports[name=ASTERISK_ERROR, protocol=all]\n".
233
+            "maxretry = {$max_retry}\n".
234
+            "findtime = {$find_time}\n".
235
+            "bantime = {$ban_time}\n".
236
+            "logencoding = utf-8\n".
237 237
             "logpath = {$log_dir}error\n\n";
238 238
 
239
-        $config .= "[asterisk_public]\n" .
240
-            "enabled = true\n" .
241
-            "filter = asterisk\n" .
242
-            "action = iptables-allports[name=ASTERISK_PUBLIC, protocol=all]\n" .
243
-            "maxretry = {$max_retry}\n" .
244
-            "findtime = {$find_time}\n" .
245
-            "bantime = {$ban_time}\n" .
246
-            "logencoding = utf-8\n" .
239
+        $config .= "[asterisk_public]\n".
240
+            "enabled = true\n".
241
+            "filter = asterisk\n".
242
+            "action = iptables-allports[name=ASTERISK_PUBLIC, protocol=all]\n".
243
+            "maxretry = {$max_retry}\n".
244
+            "findtime = {$find_time}\n".
245
+            "bantime = {$ban_time}\n".
246
+            "logencoding = utf-8\n".
247 247
             "logpath = {$log_dir}messages\n\n";
248 248
 
249 249
         Util::fileWriteContent('/etc/fail2ban/jail.local', $config);
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
     {
257 257
         $filterPath = self::FILTER_PATH;
258 258
 
259
-        $conf = "[INCLUDES]\n" .
260
-            "before = common.conf\n" .
261
-            "[Definition]\n" .
262
-            "_daemon = [\S\W\s]+web_auth\n" .
263
-            'failregex = ^%(__prefix_line)sFrom:\s<HOST>\sUserAgent:(\S|\s)*Wrong password$' . "\n" .
264
-            '            ^(\S|\s)*nginx:\s+\d+/\d+/\d+\s+(\S|\s)*status\s+403(\S|\s)*client:\s+<HOST>(\S|\s)*' . "\n" .
259
+        $conf = "[INCLUDES]\n".
260
+            "before = common.conf\n".
261
+            "[Definition]\n".
262
+            "_daemon = [\S\W\s]+web_auth\n".
263
+            'failregex = ^%(__prefix_line)sFrom:\s<HOST>\sUserAgent:(\S|\s)*Wrong password$'."\n".
264
+            '            ^(\S|\s)*nginx:\s+\d+/\d+/\d+\s+(\S|\s)*status\s+403(\S|\s)*client:\s+<HOST>(\S|\s)*'."\n".
265 265
             "ignoreregex =\n";
266 266
         file_put_contents("{$filterPath}/mikopbx-www.conf", $conf);
267 267
 
268
-        $conf = "[INCLUDES]\n" .
269
-            "before = common.conf\n" .
270
-            "[Definition]\n" .
271
-            "_daemon = (authpriv.warn )?dropbear\n" .
272
-            'prefregex = ^%(__prefix_line)s<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$' . "\n" .
273
-            'failregex = ^[Ll]ogin attempt for nonexistent user (\'.*\' )?from <HOST>:\d+$' . "\n" .
274
-            '            ^[Bb]ad (PAM )?password attempt for .+ from <HOST>(:\d+)?$' . "\n" .
275
-            '            ^[Ee]xit before auth \(user \'.+\', \d+ fails\): Max auth tries reached - user \'.+\' from <HOST>:\d+\s*$' . "\n" .
268
+        $conf = "[INCLUDES]\n".
269
+            "before = common.conf\n".
270
+            "[Definition]\n".
271
+            "_daemon = (authpriv.warn )?dropbear\n".
272
+            'prefregex = ^%(__prefix_line)s<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$'."\n".
273
+            'failregex = ^[Ll]ogin attempt for nonexistent user (\'.*\' )?from <HOST>:\d+$'."\n".
274
+            '            ^[Bb]ad (PAM )?password attempt for .+ from <HOST>(:\d+)?$'."\n".
275
+            '            ^[Ee]xit before auth \(user \'.+\', \d+ fails\): Max auth tries reached - user \'.+\' from <HOST>:\d+\s*$'."\n".
276 276
             "ignoreregex =\n";
277 277
         file_put_contents("{$filterPath}/dropbear.conf", $conf);
278 278
 
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
         foreach ($additionalModules as $appClass) {
292 292
             if (method_exists($appClass, 'generateFail2BanJails')) {
293 293
                 $content = $appClass->generateFail2BanJails();
294
-                if ( ! empty($content)) {
294
+                if (!empty($content)) {
295 295
                     $moduleUniqueId = $appClass->moduleUniqueId;
296
-                    $fileName = Text::uncamelize($moduleUniqueId,'_').'.conf';
296
+                    $fileName = Text::uncamelize($moduleUniqueId, '_').'.conf';
297 297
                     file_put_contents("{$filterPath}/{$fileName}", $content);
298 298
                 }
299 299
             }
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
         foreach ($additionalModules as $appClass) {
313 313
             if (method_exists($appClass, 'generateFail2BanJails')) {
314 314
                 $content = $appClass->generateFail2BanJails();
315
-                if ( ! empty($content)) {
316
-                    $moduleUniqueId                    = $appClass->moduleUniqueId;
317
-                    $fileName = Text::uncamelize($moduleUniqueId,'_');
315
+                if (!empty($content)) {
316
+                    $moduleUniqueId = $appClass->moduleUniqueId;
317
+                    $fileName = Text::uncamelize($moduleUniqueId, '_');
318 318
                     $jails[$fileName] = "iptables-allports[name={$moduleUniqueId}, protocol=all]";
319 319
                 }
320 320
             }
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCallEvents.php 2 patches
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 $this->am->SetVar($channel, 'MIX_FILE_NAME', $srcFile);
80 80
                 $this->am->SetVar($channel, 'MIX_CMD',       $command);
81 81
                 $this->am->SetVar($channel, 'MIX_OPTIONS',   $options);
82
-            }else{
82
+            } else{
83 83
                 $res        = $this->am->MixMonitor($channel, $srcFile, $options, $command);
84 84
                 $res['cmd'] = "MixMonitor($channel, $file_name)";
85 85
                 CdrDb::LogEvent(json_encode($res));
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     {
101 101
         if(isset($this->mixMonitorChannels[$channel])){
102 102
             unset($this->mixMonitorChannels[$channel]);
103
-        }else{
103
+        } else{
104 104
             return;
105 105
         }
106 106
         if ($this->record_calls) {
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     {
503 503
         if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) {
504 504
             return;
505
-        }else{
505
+        } else{
506 506
             $this->checkChanHangupTransfer[$data['agi_channel']] = $action;
507 507
         }
508 508
 
@@ -1314,7 +1314,8 @@  discard block
 block discarded – undo
1314 1314
      * Проверка фильтра на корректность bind параметров.
1315 1315
      * @param $filter
1316 1316
      */
1317
-    private function filterNotValid($filter){
1317
+    private function filterNotValid($filter)
1318
+    {
1318 1319
         $haveErrors = false;
1319 1320
         if(isset($filter['bind'])){
1320 1321
             if(is_array($filter)){
@@ -1323,7 +1324,7 @@  discard block
 block discarded – undo
1323 1324
                         $haveErrors = true;
1324 1325
                     }
1325 1326
                 }
1326
-            }else{
1327
+            } else{
1327 1328
                 $haveErrors = true;
1328 1329
             }
1329 1330
         }
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function MixMonitor($channel, $file_name = null, $sub_dir = null, $full_name = null, $onlySetVar = false): string
41 41
     {
42
-        $resFile = $this->mixMonitorChannels[$channel]??'';
43
-        if($resFile !== ''){
42
+        $resFile = $this->mixMonitorChannels[$channel] ?? '';
43
+        if ($resFile !== '') {
44 44
             return $resFile;
45 45
         }
46 46
 
47
-        $resFile           = '';
47
+        $resFile = '';
48 48
         $file_name = str_replace('/', '_', $file_name);
49 49
         if ($this->record_calls) {
50
-            if ( ! file_exists($full_name)) {
50
+            if (!file_exists($full_name)) {
51 51
                 $monitor_dir = Storage::getMonitorDir();
52 52
                 if ($sub_dir === null) {
53 53
                     $sub_dir = date('Y/m/d/H/');
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             $chmodPath  = Util::which('chmod');
68 68
 
69 69
             $arr = $this->am->GetChannels(false);
70
-            if(!in_array($channel, $arr)){
70
+            if (!in_array($channel, $arr)) {
71 71
                 CdrDb::LogEvent("MixMonitor: Channel {$channel} not found.");
72 72
                 return '';
73 73
             }
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
             $srcFile = "{$f}.wav";
76 76
             $resFile = "{$f}.mp3";
77 77
             $command = "{$nicePath} -n 19 {$lamePath} -b 32 --silent '{$srcFile}' '{$resFile}' && {$chmodPath} o+r '{$resFile}'";
78
-            if($onlySetVar){
78
+            if ($onlySetVar) {
79 79
                 $this->am->SetVar($channel, 'MIX_FILE_NAME', $srcFile);
80
-                $this->am->SetVar($channel, 'MIX_CMD',       $command);
81
-                $this->am->SetVar($channel, 'MIX_OPTIONS',   $options);
82
-            }else{
80
+                $this->am->SetVar($channel, 'MIX_CMD', $command);
81
+                $this->am->SetVar($channel, 'MIX_OPTIONS', $options);
82
+            } else {
83 83
                 $res        = $this->am->MixMonitor($channel, $srcFile, $options, $command);
84 84
                 $res['cmd'] = "MixMonitor($channel, $file_name)";
85 85
                 CdrDb::LogEvent(json_encode($res));
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function StopMixMonitor($channel): void
100 100
     {
101
-        if(isset($this->mixMonitorChannels[$channel])){
101
+        if (isset($this->mixMonitorChannels[$channel])) {
102 102
             unset($this->mixMonitorChannels[$channel]);
103
-        }else{
103
+        } else {
104 104
             return;
105 105
         }
106 106
         if ($this->record_calls) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         foreach ($m_data as $row) {
141 141
             $row->writeAttribute('endtime', $data['start']);
142 142
             $res = $row->update();
143
-            if ( ! $res) {
143
+            if (!$res) {
144 144
                 Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages()));
145 145
             }
146 146
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             // мобильный и внутренний номер.
160 160
             $filter = [
161 161
                 '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime = ""',
162
-                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],],
162
+                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ],
163 163
             ];
164 164
         } else {
165 165
             $filter = [
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
         /** @var CallDetailRecordsTmp $row */
177 177
         $m_data = CallDetailRecordsTmp::find($filter);
178 178
         foreach ($m_data as $row) {
179
-            if ( ! is_object($row)) {
179
+            if (!is_object($row)) {
180 180
                 continue;
181 181
             }
182 182
             ///
183 183
             // Проверим, если более одного канала SIP/256 при входящем.
184 184
             $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan';
185 185
 
186
-            if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
186
+            if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
187 187
                 if ($row_create) {
188 188
                     continue;
189 189
                 }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                     $new_row->writeAttribute($attribute, $value);
198 198
                 }
199 199
                 $new_row->writeAttribute($column_chan_name, $data['dst_chan']);
200
-                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']);
200
+                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']);
201 201
                 // Подмена $row;
202 202
                 $row        = $new_row;
203 203
                 $row_create = true;
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
                 // При оригинации меняется местами srs_chan в поле dst_chan.
211 211
                 $row->writeAttribute('src_chan', $data['dst_chan']);
212 212
             } else {
213
-                if ( ! $rec_start) {
214
-                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID,null, $row->recordingfile,true);
213
+                if (!$rec_start) {
214
+                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID, null, $row->recordingfile, true);
215 215
                     $row->writeAttribute('recordingfile', $data['recordingfile']);
216 216
                     $rec_start = true;
217 217
                 }
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
                 $row->writeAttribute('dst_chan', $data['dst_chan']);
220 220
             }
221 221
 
222
-            if (isset($data['to_account']) && ! empty($data['to_account'])) {
222
+            if (isset($data['to_account']) && !empty($data['to_account'])) {
223 223
                 $row->writeAttribute($account_col, $data['to_account']);
224 224
             }
225
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
225
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
226 226
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
227 227
             }
228 228
             $res = $row->save();
229
-            if ( ! $res) {
229
+            if (!$res) {
230 230
                 Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages()));
231 231
             }
232 232
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон.
247 247
             $filter = [
248 248
                 'UNIQUEID=:UNIQUEID:',
249
-                'bind' => ['UNIQUEID' => $data['old_id'],],
249
+                'bind' => ['UNIQUEID' => $data['old_id'], ],
250 250
             ];
251 251
             /** @var CallDetailRecordsTmp $m_data */
252 252
             $m_data = CallDetailRecordsTmp::find($filter);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 $new_data['dst_chan']       = $data['agi_channel'];
261 261
                 $new_data['dst_num']        = $data['dst_num'];
262 262
                 $new_data['UNIQUEID']       = $data['id'];
263
-                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'],  'pickup_'.$new_data['UNIQUEID']);
263
+                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']);
264 264
 
265 265
                 unset($new_data['id']);
266 266
                 unset($new_data['end']);
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                 $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
274 274
             }
275 275
         } else {
276
-            if ( ! empty($data['ENDCALLONANSWER'])) {
276
+            if (!empty($data['ENDCALLONANSWER'])) {
277 277
                 // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации.
278 278
                 // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный.
279 279
                 $filter = [
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                     $row->writeAttribute('endtime', $data['answer']);
291 291
                     $row->writeAttribute('is_app', 1);
292 292
                     $res = $row->save();
293
-                    if ( ! $res) {
293
+                    if (!$res) {
294 294
                         Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages()));
295 295
                     }
296 296
                 }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                     '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
313 313
                     'bind' => [
314 314
                         'UNIQUEID'      => $data['id'],
315
-                        'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'],
315
+                        'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'],
316 316
                     ],
317 317
                 ];
318 318
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                         continue;
326 326
                     }
327 327
                     // Найдем все прочие CDR по данному originate и отметим как завершенные.
328
-                    $filter      = [
328
+                    $filter = [
329 329
                         'linkedid=:linkedid: AND endtime <> "" AND src_chan <> :src_chan:',
330 330
                         'bind' => [
331 331
                             'linkedid' => $row->linkedid,
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
                             $orgn_row->writeAttribute('endtime', $data['answer']);
340 340
                         }
341 341
                         $orgn_row->writeAttribute('dst_chan', '');
342
-                        $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan);
342
+                        $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan);
343 343
                         $orgn_row->update();
344 344
                     }
345 345
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                     $row->writeAttribute('answer', $data['answer']);
353 353
                 }
354 354
                 $res = $row->save();
355
-                if ( ! $res) {
355
+                if (!$res) {
356 356
                     Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages()));
357 357
                 }
358 358
             }
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         $this->hangupChanCheckSipTrtansfer($data, $channels);
379 379
 
380 380
         // Очистим память.
381
-        if(isset($this->checkChanHangupTransfer[$data['agi_channel']])){
381
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
382 382
             unset($this->checkChanHangupTransfer[$data['agi_channel']]);
383 383
         }
384
-        if(isset($this->mixMonitorChannels[$data['agi_channel']])){
384
+        if (isset($this->mixMonitorChannels[$data['agi_channel']])) {
385 385
             unset($this->mixMonitorChannels[$data['agi_channel']]);
386 386
         }
387 387
     }
@@ -393,24 +393,24 @@  discard block
 block discarded – undo
393 393
      */
394 394
     private function hangupChanCheckSipTrtansfer($data, $channels):void{
395 395
         $not_local = (stripos($data['agi_channel'], 'local/') === false);
396
-        if($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
396
+        if ($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
397 397
             return;
398 398
         }
399 399
         $active_chans = $this->am->GetChannels(false);
400 400
         // Намек на SIP трансфер.
401 401
         foreach ($channels as $data_chan) {
402
-            if ( ! in_array($data_chan['chan'], $active_chans, true)) {
402
+            if (!in_array($data_chan['chan'], $active_chans, true)) {
403 403
                 // Вызов уже завершен. Не интересно.
404 404
                 continue;
405 405
             }
406 406
             $BRIDGEPEER = $this->am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false);
407
-            if ( ! in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
407
+            if (!in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
408 408
                 // Вызов уже завершен. Не интересно.
409 409
                 continue;
410 410
             }
411 411
 
412 412
             $linkedid = $this->am->GetVar($data_chan['chan'], 'CDR(linkedid)', null, false);
413
-            if ( empty($linkedid) || $linkedid === $data['linkedid']) {
413
+            if (empty($linkedid) || $linkedid === $data['linkedid']) {
414 414
                 continue;
415 415
             }
416 416
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             $n_data['start']         = date('Y-m-d H:i:s');
424 424
             $n_data['answer']        = date('Y-m-d H:i:s');
425 425
             $n_data['linkedid']      = $linkedid;
426
-            $n_data['UNIQUEID']      = $data['linkedid'] . Util::generateRandomString();
426
+            $n_data['UNIQUEID']      = $data['linkedid'].Util::generateRandomString();
427 427
             $n_data['transfer']      = '0';
428 428
             $n_data['recordingfile'] = $this->MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']);
429 429
             $n_data['did']           = $data_chan['did'];
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      * @param array $channels
456 456
      */
457 457
     private function hangupChanEndCalls(array $data, array &$transfer_calls, array &$channels):void{
458
-        $filter         = [
458
+        $filter = [
459 459
             'linkedid=:linkedid: AND endtime = "" AND (src_chan=:src_chan: OR dst_chan=:dst_chan:)',
460 460
             'bind' => [
461 461
                 'linkedid' => $data['linkedid'],
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
             }
473 473
             if ($row->dialstatus === 'ORIGINATE') {
474 474
                 $row->writeAttribute('dialstatus', '');
475
-                if($row->answer === ''){
476
-                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan,'-') +1);
475
+                if ($row->answer === '') {
476
+                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan, '-') + 1);
477 477
                     $row->writeAttribute('UNIQUEID', $newId);
478 478
                 }
479 479
             }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
487 487
             }
488 488
             $res = $row->update();
489
-            if ( ! $res) {
489
+            if (!$res) {
490 490
                 Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages()));
491 491
             }
492 492
 
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
      */
519 519
     public function Action_CreateRowTransfer($action, $data, $calls_data = null): void
520 520
     {
521
-        if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) {
521
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
522 522
             return;
523
-        }else{
523
+        } else {
524 524
             $this->checkChanHangupTransfer[$data['agi_channel']] = $action;
525 525
         }
526 526
 
527 527
         if (null === $calls_data) {
528
-            $filter     = [
528
+            $filter = [
529 529
                 'linkedid=:linkedid: AND endtime = "" AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)',
530 530
                 'bind'  => [
531 531
                     'linkedid' => $data['linkedid'],
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
                     $insert_data[$fname_chan] = $row_data['dst_chan'];
548 548
                     $insert_data[$fname_num]  = $row_data['dst_num'];
549 549
                 } else {
550
-                    $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
551
-                    $fname_num  = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
550
+                    $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
551
+                    $fname_num  = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
552 552
 
553 553
                     $insert_data[$fname_chan] = $row_data['src_chan'];
554 554
                     $insert_data[$fname_num]  = $row_data['src_num'];
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
             $this->StopMixMonitor($insert_data['dst_chan']);
560 560
             $recordingfile = $this->MixMonitor(
561 561
                 $insert_data['dst_chan'],
562
-                'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid']
562
+                'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid']
563 563
             );
564 564
             //
565 565
             $insert_data['action']        = "{$action}_end_trasfer";
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 
582 582
             $this->insertDataToDbM($insert_data);
583 583
             CdrDb::LogEvent(json_encode($insert_data));
584
-        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && ! empty($calls_data[0]['recordingfile'])) {
584
+        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && !empty($calls_data[0]['recordingfile'])) {
585 585
             // Возобновление записи разговора при срыве переадресации.
586 586
             $row_data = $calls_data[0];
587 587
             $chan     = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan'];
@@ -597,12 +597,12 @@  discard block
 block discarded – undo
597 597
             /** @var CallDetailRecordsTmp $row */
598 598
             $not_ended_cdr = null;
599 599
             $transferNotComplete = false;
600
-            foreach ($cdr as $row){
601
-                if($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
600
+            foreach ($cdr as $row) {
601
+                if ($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
602 602
                     $not_ended_cdr = $row;
603 603
                 }
604
-                if($row->answer === '' && $row->endtime === ''
605
-                    && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
604
+                if ($row->answer === '' && $row->endtime === ''
605
+                    && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
606 606
                     $transferNotComplete = true;
607 607
                 }
608 608
             }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
      */
661 661
     public function Action_transfer_dial_create_chan($data): void
662 662
     {
663
-        $filter     = [
663
+        $filter = [
664 664
             'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""',
665 665
             'bind' => [
666 666
                 'UNIQUEID' => $data['transfer_UNIQUEID'],
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
         foreach ($m_data as $row) {
674 674
             ///
675 675
             // Проверим, если более одного канала SIP/256 при входящем.
676
-            if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
676
+            if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
677 677
                 if ($row_create) {
678 678
                     continue;
679 679
                 }
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                     $new_row->writeAttribute($attribute, $value);
688 688
                 }
689 689
                 $new_row->writeAttribute('dst_chan', $data['dst_chan']);
690
-                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']);
690
+                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']);
691 691
                 // $new_row->save();
692 692
                 // Подмена $row;
693 693
                 $row        = $new_row;
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 
701 701
             $row->writeAttribute('dst_chan', $data['dst_chan']);
702 702
             $row->writeAttribute('recordingfile', $data['recordingfile']);
703
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
703
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
704 704
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
705 705
             }
706 706
             $res = $row->save();
707
-            if ( ! $res) {
707
+            if (!$res) {
708 708
                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()));
709 709
             }
710 710
         }
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
             '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
722 722
             'bind' => [
723 723
                 'UNIQUEID'      => $data['transfer_UNIQUEID'],
724
-                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'],
724
+                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'],
725 725
             ],
726 726
         ];
727 727
 
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
         foreach ($m_data as $row) {
732 732
             $row->writeAttribute('answer', $data['answer']);
733 733
             $res = $row->save();
734
-            if ( ! $res) {
734
+            if (!$res) {
735 735
                 Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
736 736
             }
737 737
         }
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
                 // Завершим вызов в CDR.
766 766
                 $row->writeAttribute('endtime', $data['end']);
767 767
                 $row->writeAttribute('transfer', 0);
768
-                if ( ! $row->save()) {
768
+                if (!$row->save()) {
769 769
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
770 770
                 }
771 771
             }
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                 // Ответа не было. Переадресация отменена.
801 801
                 $row->writeAttribute('endtime', $data['end']);
802 802
                 $row->writeAttribute('transfer', 0);
803
-                if ( ! $row->save()) {
803
+                if (!$row->save()) {
804 804
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
805 805
                 }
806 806
             }
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                 $this->MixMonitor($row->src_chan, $info['filename'], $subdir);
821 821
                 // Снимем со строк признак переадресации.
822 822
                 $row->writeAttribute('transfer', 0);
823
-                if ( ! $row->save()) {
823
+                if (!$row->save()) {
824 824
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
825 825
                 }
826 826
             }
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 
897 897
                 $f_list = $m_data->toArray();
898 898
                 foreach ($data as $attribute => $value) {
899
-                    if ( ! array_key_exists($attribute, $f_list)) {
899
+                    if (!array_key_exists($attribute, $f_list)) {
900 900
                         continue;
901 901
                     }
902 902
                     $m_data->writeAttribute($attribute, $value);
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
             $row->writeAttribute('answer', $data['answer']);
968 968
             $row->writeAttribute('endtime', $data['answer']);
969 969
             $res = $row->save();
970
-            if ( ! $res) {
970
+            if (!$res) {
971 971
                 Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages()));
972 972
             }
973 973
         }
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
997 997
             }
998 998
             $res = $row->save();
999
-            if ( ! $res) {
999
+            if (!$res) {
1000 1000
                 Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages()));
1001 1001
             }
1002 1002
         }
@@ -1026,11 +1026,11 @@  discard block
 block discarded – undo
1026 1026
             if ($dest_chan === $row->dst_chan) {
1027 1027
                 $is_local        = (stripos($data['src_chan'], 'local/') !== false);
1028 1028
                 $is_stored_local = (stripos($row->src_chan, 'local/') !== false);
1029
-                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) {
1029
+                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) {
1030 1030
                     $data['src_chan'] = $row->src_chan;
1031 1031
                 }
1032 1032
                 if (file_exists($row->recordingfile) || file_exists(
1033
-                        Util::trimExtensionForFile($row->recordingfile) . '.wav'
1033
+                        Util::trimExtensionForFile($row->recordingfile).'.wav'
1034 1034
                     )) {
1035 1035
                     // Переопределим путь к файлу записи разговора. Для конферецнии файл один.
1036 1036
                     $recordingfile = $row->recordingfile;
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
             // Подменим ID на идентификатор конференции.
1043 1043
             $row->writeAttribute('linkedid', $data['meetme_id']);
1044 1044
             $res = $row->save();
1045
-            if ( ! $res) {
1045
+            if (!$res) {
1046 1046
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1047 1047
             }
1048 1048
         }
@@ -1059,11 +1059,11 @@  discard block
 block discarded – undo
1059 1059
             $row->writeAttribute('transfer', 0);
1060 1060
             $row->writeAttribute('linkedid', $data['meetme_id']);
1061 1061
 
1062
-            if ( ! empty($recordingfile)) {
1062
+            if (!empty($recordingfile)) {
1063 1063
                 $row->writeAttribute('recordingfile', $recordingfile);
1064 1064
             }
1065 1065
             $res = $row->save();
1066
-            if ( ! $res) {
1066
+            if (!$res) {
1067 1067
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1068 1068
             }
1069 1069
         }
@@ -1102,9 +1102,9 @@  discard block
 block discarded – undo
1102 1102
      */
1103 1103
     public function callEventsWorker($tube): void
1104 1104
     {
1105
-        $data      = json_decode($tube->getBody(), true);
1106
-        $funcName = "Action_".$data['action']??'';
1107
-        if ( method_exists($this, $funcName) ) {
1105
+        $data = json_decode($tube->getBody(), true);
1106
+        $funcName = "Action_".$data['action'] ?? '';
1107
+        if (method_exists($this, $funcName)) {
1108 1108
             $this->$funcName($data);
1109 1109
         }
1110 1110
         $tube->reply(json_encode(true));
@@ -1134,14 +1134,14 @@  discard block
 block discarded – undo
1134 1134
     public function updateDataInDbM($data): bool
1135 1135
     {
1136 1136
         if (empty($data['UNIQUEID'])) {
1137
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1137
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1138 1138
 
1139 1139
             return false;
1140 1140
         }
1141 1141
 
1142 1142
         $filter = [
1143 1143
             "UNIQUEID=:id:",
1144
-            'bind' => ['id' => $data['UNIQUEID'],],
1144
+            'bind' => ['id' => $data['UNIQUEID'], ],
1145 1145
         ];
1146 1146
         /** @var CallDetailRecordsTmp $m_data */
1147 1147
         $m_data = CallDetailRecordsTmp::findFirst($filter);
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
         }
1151 1151
         $f_list = $m_data->toArray();
1152 1152
         foreach ($data as $attribute => $value) {
1153
-            if ( ! array_key_exists($attribute, $f_list)) {
1153
+            if (!array_key_exists($attribute, $f_list)) {
1154 1154
                 continue;
1155 1155
             }
1156 1156
             if ('UNIQUEID' == $attribute) {
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
             $m_data->writeAttribute($attribute, $value);
1160 1160
         }
1161 1161
         $res = $m_data->save();
1162
-        if ( ! $res) {
1162
+        if (!$res) {
1163 1163
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1164 1164
         }
1165 1165
 
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
     public static function insertDataToDbM($data): bool
1200 1200
     {
1201 1201
         if (empty($data['UNIQUEID'])) {
1202
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1202
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1203 1203
 
1204 1204
             return false;
1205 1205
         }
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
         $m_data = CallDetailRecordsTmp::findFirst(
1210 1210
             [
1211 1211
                 "UNIQUEID=:id:",
1212
-                'bind' => ['id' => $data['UNIQUEID'],],
1212
+                'bind' => ['id' => $data['UNIQUEID'], ],
1213 1213
             ]
1214 1214
         );
1215 1215
         if ($m_data === null) {
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
         } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] == 'dial') {
1219 1219
             if (empty($m_data->endtime)) {
1220 1220
                 // Если это оригинация dial может прийти дважды.
1221
-                if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){
1221
+                if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) {
1222 1222
                     $m_data->dst_num = $data['src_num'];
1223 1223
                     $m_data->save();
1224 1224
                 }
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
                 $new_m_data->transfer     = $data['transfer'];
1244 1244
 
1245 1245
                 $res = $new_m_data->save();
1246
-                if ( ! $res) {
1246
+                if (!$res) {
1247 1247
                     Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1248 1248
                 }
1249 1249
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 
1254 1254
         $f_list = $m_data->toArray();
1255 1255
         foreach ($data as $attribute => $value) {
1256
-            if ( ! array_key_exists($attribute, $f_list)) {
1256
+            if (!array_key_exists($attribute, $f_list)) {
1257 1257
                 continue;
1258 1258
             }
1259 1259
             if ($is_new === false && 'UNIQUEID' == $attribute) {
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
             $m_data->writeAttribute($attribute, $value);
1263 1263
         }
1264 1264
         $res = $m_data->save();
1265
-        if ( ! $res) {
1265
+        if (!$res) {
1266 1266
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1267 1267
         }
1268 1268
 
@@ -1277,12 +1277,12 @@  discard block
 block discarded – undo
1277 1277
         $q      = $tube->getBody();
1278 1278
         $filter = json_decode($q, true);
1279 1279
 
1280
-        if($this->filterNotValid($filter)){
1280
+        if ($this->filterNotValid($filter)) {
1281 1281
             $tube->reply('[]');
1282 1282
             return;
1283 1283
         }
1284 1284
 
1285
-        $res    = null;
1285
+        $res = null;
1286 1286
         try {
1287 1287
             if (isset($filter['miko_tmp_db'])) {
1288 1288
                 $res = CallDetailRecordsTmp::find($filter);
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
             }
1302 1302
             $filter['add_pack_query']['bind'][$filter['columns']] = $arr;
1303 1303
 
1304
-            if($this->filterNotValid($filter['add_pack_query'])){
1304
+            if ($this->filterNotValid($filter['add_pack_query'])) {
1305 1305
                 $tube->reply('[]');
1306 1306
                 return;
1307 1307
             }
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
         if (isset($filter['miko_result_in_file'])) {
1320 1320
             $di         = Di::getDefault();
1321 1321
             $dirsConfig = $di->getShared('config');
1322
-            $filename   = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true));
1322
+            $filename   = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true));
1323 1323
             file_put_contents($filename, $res_data);
1324 1324
             Util::addRegularWWWRights($filename);
1325 1325
             $res_data = json_encode($filename);
@@ -1332,16 +1332,16 @@  discard block
 block discarded – undo
1332 1332
      * Проверка фильтра на корректность bind параметров.
1333 1333
      * @param $filter
1334 1334
      */
1335
-    private function filterNotValid($filter){
1335
+    private function filterNotValid($filter) {
1336 1336
         $haveErrors = false;
1337
-        if(isset($filter['bind'])){
1338
-            if(is_array($filter)){
1337
+        if (isset($filter['bind'])) {
1338
+            if (is_array($filter)) {
1339 1339
                 foreach ($filter['bind'] as $bindValue) {
1340
-                    if(empty($bindValue)){
1340
+                    if (empty($bindValue)) {
1341 1341
                         $haveErrors = true;
1342 1342
                     }
1343 1343
                 }
1344
-            }else{
1344
+            } else {
1345 1345
                 $haveErrors = true;
1346 1346
             }
1347 1347
         }
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 
1351 1351
     public function errorHandler($m): void
1352 1352
     {
1353
-        Util::sysLogMsg(self::class . '_ERROR', $m);
1353
+        Util::sysLogMsg(self::class.'_ERROR', $m);
1354 1354
     }
1355 1355
 }
1356 1356
 
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/SystemManagementProcessor.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -365,7 +365,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/FirewallManagementProcessor.php 2 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer62110.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer100.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.