Passed
Push — develop ( 80cbb5...2d91ab )
by Nikolay
11:52 queued 11s
created
src/AdminCabinet/Controllers/DialplanApplicationsController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $app = DialplanApplications::findFirstByUniqid($uniqid);
38 38
         if ($app === null) {
39 39
             $app            = new DialplanApplications();
40
-            $app->uniqid    = strtoupper('DIALPLAN-APP-' . md5($app->id . time()));
40
+            $app->uniqid    = strtoupper('DIALPLAN-APP-'.md5($app->id.time()));
41 41
             $app->type      = 'php';
42 42
             $app->extension = Extensions::getNextFreeApplicationNumber();
43 43
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function saveAction(): void
57 57
     {
58
-        if ( ! $this->request->isPost()) {
58
+        if (!$this->request->isPost()) {
59 59
             return;
60 60
         }
61 61
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         }
79 79
 
80 80
         // Заполним параметры внутреннего номера
81
-        if ( ! $this->updateExtension($extension, $data)) {
81
+        if (!$this->updateExtension($extension, $data)) {
82 82
             $this->view->success = false;
83 83
             $this->db->rollback();
84 84
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         // Заполним параметры пользователя
89
-        if ( ! $this->updateDialplanApplication($appRecord, $data)) {
89
+        if (!$this->updateDialplanApplication($appRecord, $data)) {
90 90
             $this->view->success = false;
91 91
             $this->db->rollback();
92 92
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         $this->db->begin();
182 182
         $errors = false;
183 183
         $extension = $appRecord->Extensions;
184
-        if ( ! $extension->delete()) {
184
+        if (!$extension->delete()) {
185 185
             $errors = $extension->getMessages();
186 186
         }
187 187
 
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/AdvicesProcessor.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 }
91 91
             }
92 92
             $newResult = $this->$currentAdvice();
93
-            if ( ! empty($newResult)) {
93
+            if (!empty($newResult)) {
94 94
                 $arrMessages[] = $newResult;
95 95
             }
96 96
             $managedCache->set(
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $result       = [];
109 109
         foreach ($arrMessages as $message) {
110 110
             foreach ($message as $key => $value) {
111
-                if ( ! empty($value)) {
111
+                if (!empty($value)) {
112 112
                     $result[$key][] = $value;
113 113
                 }
114 114
             }
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
     {
247 247
         $messages = [];
248 248
         $licKey   = PbxSettings::getValueByKey('PBXLicense');
249
-        $language   = PbxSettings::getValueByKey('WebAdminLanguage');
249
+        $language = PbxSettings::getValueByKey('WebAdminLanguage');
250 250
 
251
-        if ( ! empty($licKey)) {
251
+        if (!empty($licKey)) {
252 252
             $checkBaseFeature = $this->license->featureAvailable(33);
253 253
             if ($checkBaseFeature['success'] === false) {
254 254
                 if ($language === 'ru') {
Please login to merge, or discard this patch.
src/PBXCoreREST/Controllers/Modules/ModulesControllerBase.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,18 +47,18 @@
 block discarded – undo
47 47
         $request            = json_encode([
48 48
             'data'           => $_REQUEST,
49 49
             'module'         => $moduleName,
50
-            'input'          => $input,     // Параметры запроса.
50
+            'input'          => $input, // Параметры запроса.
51 51
             'action'         => $actionName,
52 52
             'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'],
53 53
             'processor'      => 'modules',
54 54
         ]);
55 55
 
56
-        $response   = $this->di->getShared('beanstalkConnection')->request($request, 100, 0);
56
+        $response = $this->di->getShared('beanstalkConnection')->request($request, 100, 0);
57 57
         if ($response !== false) {
58 58
             $response = json_decode($response, true);
59 59
             if (isset($response['fpassthru'])) {
60 60
                 $fp = fopen($response['filename'], "rb");
61
-                if ($fp!==false) {
61
+                if ($fp !== false) {
62 62
                     $size = filesize($response['filename']);
63 63
                     $name = basename($response['filename']);
64 64
                     $this->response->setHeader('Content-Description', "config file");
Please login to merge, or discard this patch.
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   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@  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
-        $resFile           = '';
46
+        $resFile = '';
47 47
         $file_name = str_replace('/', '_', $file_name);
48 48
         if ($this->record_calls) {
49
-            if ( ! file_exists($full_name)) {
49
+            if (!file_exists($full_name)) {
50 50
                 $monitor_dir = Storage::getMonitorDir();
51 51
                 if ($sub_dir === null) {
52 52
                     $sub_dir = date('Y/m/d/H/');
@@ -62,21 +62,21 @@  discard block
 block discarded – undo
62 62
                 $options = 'ab';
63 63
             }
64 64
             $nicePath   = Util::which('nice');
65
-            $wav2mp3Path= Util::which('wav2mp3.sh');
65
+            $wav2mp3Path = Util::which('wav2mp3.sh');
66 66
 
67 67
             $arr = $this->am->GetChannels(false);
68
-            if(!in_array($channel, $arr, true)){
68
+            if (!in_array($channel, $arr, true)) {
69 69
                 CdrDb::LogEvent("MixMonitor: Channel {$channel} not found.");
70 70
                 return '';
71 71
             }
72 72
             $srcFile = "{$f}.wav";
73 73
             $resFile = "{$f}.mp3";
74 74
             $command = "{$nicePath} -n 19 {$wav2mp3Path} '{$f}'";
75
-            if($onlySetVar){
75
+            if ($onlySetVar) {
76 76
                 $this->am->SetVar($channel, 'MIX_FILE_NAME', $srcFile);
77
-                $this->am->SetVar($channel, 'MIX_CMD',       $command);
78
-                $this->am->SetVar($channel, 'MIX_OPTIONS',   $options);
79
-            }else{
77
+                $this->am->SetVar($channel, 'MIX_CMD', $command);
78
+                $this->am->SetVar($channel, 'MIX_OPTIONS', $options);
79
+            } else {
80 80
                 $res        = $this->am->MixMonitor($channel, $srcFile, $options, $command);
81 81
                 $res['cmd'] = "MixMonitor($channel, $file_name)";
82 82
                 CdrDb::LogEvent(json_encode($res));
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function StopMixMonitor($channel): void
97 97
     {
98
-        if(isset($this->mixMonitorChannels[$channel])){
98
+        if (isset($this->mixMonitorChannels[$channel])) {
99 99
             unset($this->mixMonitorChannels[$channel]);
100
-        }else{
100
+        } else {
101 101
             return;
102 102
         }
103 103
         if ($this->record_calls) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         foreach ($m_data as $row) {
138 138
             $row->writeAttribute('endtime', $data['start']);
139 139
             $res = $row->update();
140
-            if ( ! $res) {
140
+            if (!$res) {
141 141
                 Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages()));
142 142
             }
143 143
         }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             // мобильный и внутренний номер.
157 157
             $filter = [
158 158
                 '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime = ""',
159
-                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],],
159
+                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ],
160 160
             ];
161 161
         } else {
162 162
             $filter = [
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
         /** @var CallDetailRecordsTmp $row */
174 174
         $m_data = CallDetailRecordsTmp::find($filter);
175 175
         foreach ($m_data as $row) {
176
-            if ( ! is_object($row)) {
176
+            if (!is_object($row)) {
177 177
                 continue;
178 178
             }
179 179
             ///
180 180
             // Проверим, если более одного канала SIP/256 при входящем.
181 181
             $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan';
182 182
 
183
-            if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
183
+            if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
184 184
                 if ($row_create) {
185 185
                     continue;
186 186
                 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                     $new_row->writeAttribute($attribute, $value);
195 195
                 }
196 196
                 $new_row->writeAttribute($column_chan_name, $data['dst_chan']);
197
-                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']);
197
+                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']);
198 198
                 // Подмена $row;
199 199
                 $row        = $new_row;
200 200
                 $row_create = true;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
                 // При оригинации меняется местами srs_chan в поле dst_chan.
208 208
                 $row->writeAttribute('src_chan', $data['dst_chan']);
209 209
             } else {
210
-                if ( ! $rec_start) {
211
-                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID,null, $row->recordingfile,true);
210
+                if (!$rec_start) {
211
+                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID, null, $row->recordingfile, true);
212 212
                     $row->writeAttribute('recordingfile', $data['recordingfile']);
213 213
                     $rec_start = true;
214 214
                 }
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
                 $row->writeAttribute('dst_chan', $data['dst_chan']);
217 217
             }
218 218
 
219
-            if (isset($data['to_account']) && ! empty($data['to_account'])) {
219
+            if (isset($data['to_account']) && !empty($data['to_account'])) {
220 220
                 $row->writeAttribute($account_col, $data['to_account']);
221 221
             }
222
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
222
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
223 223
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
224 224
             }
225 225
             $res = $row->save();
226
-            if ( ! $res) {
226
+            if (!$res) {
227 227
                 Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages()));
228 228
             }
229 229
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон.
244 244
             $filter = [
245 245
                 'UNIQUEID=:UNIQUEID:',
246
-                'bind' => ['UNIQUEID' => $data['old_id'],],
246
+                'bind' => ['UNIQUEID' => $data['old_id'], ],
247 247
             ];
248 248
             /** @var CallDetailRecordsTmp $m_data */
249 249
             $m_data = CallDetailRecordsTmp::find($filter);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 $new_data['dst_chan']       = $data['agi_channel'];
258 258
                 $new_data['dst_num']        = $data['dst_num'];
259 259
                 $new_data['UNIQUEID']       = $data['id'];
260
-                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'],  'pickup_'.$new_data['UNIQUEID']);
260
+                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']);
261 261
 
262 262
                 unset($new_data['id']);
263 263
                 unset($new_data['end']);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
271 271
             }
272 272
         } else {
273
-            if ( ! empty($data['ENDCALLONANSWER'])) {
273
+            if (!empty($data['ENDCALLONANSWER'])) {
274 274
                 // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации.
275 275
                 // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный.
276 276
                 $filter = [
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                     $row->writeAttribute('endtime', $data['answer']);
288 288
                     $row->writeAttribute('is_app', 1);
289 289
                     $res = $row->save();
290
-                    if ( ! $res) {
290
+                    if (!$res) {
291 291
                         Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages()));
292 292
                     }
293 293
                 }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                     '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
310 310
                     'bind' => [
311 311
                         'UNIQUEID'      => $data['id'],
312
-                        'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'],
312
+                        'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'],
313 313
                     ],
314 314
                 ];
315 315
             }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                         continue;
323 323
                     }
324 324
                     // Найдем все прочие CDR по данному originate и отметим как завершенные.
325
-                    $filter      = [
325
+                    $filter = [
326 326
                         'linkedid=:linkedid: AND endtime <> "" AND src_chan <> :src_chan:',
327 327
                         'bind' => [
328 328
                             'linkedid' => $row->linkedid,
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
                             $orgn_row->writeAttribute('endtime', $data['answer']);
337 337
                         }
338 338
                         $orgn_row->writeAttribute('dst_chan', '');
339
-                        $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan);
339
+                        $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan);
340 340
                         $orgn_row->update();
341 341
                     }
342 342
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                     $row->writeAttribute('answer', $data['answer']);
350 350
                 }
351 351
                 $res = $row->save();
352
-                if ( ! $res) {
352
+                if (!$res) {
353 353
                     Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages()));
354 354
                 }
355 355
             }
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
         $this->hangupChanCheckSipTrtansfer($data, $channels);
376 376
 
377 377
         // Очистим память.
378
-        if(isset($this->checkChanHangupTransfer[$data['agi_channel']])){
378
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
379 379
             unset($this->checkChanHangupTransfer[$data['agi_channel']]);
380 380
         }
381
-        if(isset($this->mixMonitorChannels[$data['agi_channel']])){
381
+        if (isset($this->mixMonitorChannels[$data['agi_channel']])) {
382 382
             unset($this->mixMonitorChannels[$data['agi_channel']]);
383 383
         }
384 384
     }
@@ -390,24 +390,24 @@  discard block
 block discarded – undo
390 390
      */
391 391
     private function hangupChanCheckSipTrtansfer($data, $channels):void{
392 392
         $not_local = (stripos($data['agi_channel'], 'local/') === false);
393
-        if($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
393
+        if ($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
394 394
             return;
395 395
         }
396 396
         $active_chans = $this->am->GetChannels(false);
397 397
         // Намек на SIP трансфер.
398 398
         foreach ($channels as $data_chan) {
399
-            if ( ! in_array($data_chan['chan'], $active_chans, true)) {
399
+            if (!in_array($data_chan['chan'], $active_chans, true)) {
400 400
                 // Вызов уже завершен. Не интересно.
401 401
                 continue;
402 402
             }
403 403
             $BRIDGEPEER = $this->am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false);
404
-            if ( ! in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
404
+            if (!in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
405 405
                 // Вызов уже завершен. Не интересно.
406 406
                 continue;
407 407
             }
408 408
 
409 409
             $linkedid = $this->am->GetVar($data_chan['chan'], 'CDR(linkedid)', null, false);
410
-            if ( empty($linkedid) || $linkedid === $data['linkedid']) {
410
+            if (empty($linkedid) || $linkedid === $data['linkedid']) {
411 411
                 continue;
412 412
             }
413 413
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
             $n_data['start']         = date('Y-m-d H:i:s');
421 421
             $n_data['answer']        = date('Y-m-d H:i:s');
422 422
             $n_data['linkedid']      = $linkedid;
423
-            $n_data['UNIQUEID']      = $data['linkedid'] . Util::generateRandomString();
423
+            $n_data['UNIQUEID']      = $data['linkedid'].Util::generateRandomString();
424 424
             $n_data['transfer']      = '0';
425 425
             $n_data['recordingfile'] = $this->MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']);
426 426
             $n_data['did']           = $data_chan['did'];
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      * @param array $channels
453 453
      */
454 454
     private function hangupChanEndCalls(array $data, array &$transfer_calls, array &$channels):void{
455
-        $filter         = [
455
+        $filter = [
456 456
             'linkedid=:linkedid: AND endtime = "" AND (src_chan=:src_chan: OR dst_chan=:dst_chan:)',
457 457
             'bind' => [
458 458
                 'linkedid' => $data['linkedid'],
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
             }
470 470
             if ($row->dialstatus === 'ORIGINATE') {
471 471
                 $row->writeAttribute('dialstatus', '');
472
-                if($row->answer === ''){
473
-                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan,'-') +1);
472
+                if ($row->answer === '') {
473
+                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan, '-') + 1);
474 474
                     $row->writeAttribute('UNIQUEID', $newId);
475 475
                 }
476 476
             }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
484 484
             }
485 485
             $res = $row->update();
486
-            if ( ! $res) {
486
+            if (!$res) {
487 487
                 Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages()));
488 488
             }
489 489
 
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function Action_CreateRowTransfer($action, $data, $calls_data = null): void
517 517
     {
518
-        if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) {
518
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
519 519
             return;
520
-        }else{
520
+        } else {
521 521
             $this->checkChanHangupTransfer[$data['agi_channel']] = $action;
522 522
         }
523 523
 
524 524
         if (null === $calls_data) {
525
-            $filter     = [
525
+            $filter = [
526 526
                 'linkedid=:linkedid: AND endtime = "" AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)',
527 527
                 'bind'  => [
528 528
                     'linkedid' => $data['linkedid'],
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
                     $insert_data[$fname_chan] = $row_data['dst_chan'];
545 545
                     $insert_data[$fname_num]  = $row_data['dst_num'];
546 546
                 } else {
547
-                    $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
548
-                    $fname_num  = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
547
+                    $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
548
+                    $fname_num  = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
549 549
 
550 550
                     $insert_data[$fname_chan] = $row_data['src_chan'];
551 551
                     $insert_data[$fname_num]  = $row_data['src_num'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             $this->StopMixMonitor($insert_data['dst_chan']);
557 557
             $recordingfile = $this->MixMonitor(
558 558
                 $insert_data['dst_chan'],
559
-                'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid']
559
+                'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid']
560 560
             );
561 561
             //
562 562
             $insert_data['action']        = "{$action}_end_trasfer";
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
             $this->insertDataToDbM($insert_data);
580 580
             CdrDb::LogEvent(json_encode($insert_data));
581
-        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && ! empty($calls_data[0]['recordingfile'])) {
581
+        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && !empty($calls_data[0]['recordingfile'])) {
582 582
             // Возобновление записи разговора при срыве переадресации.
583 583
             $row_data = $calls_data[0];
584 584
             $chan     = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan'];
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
             /** @var CallDetailRecordsTmp $row */
595 595
             $not_ended_cdr = null;
596 596
             $transferNotComplete = false;
597
-            foreach ($cdr as $row){
598
-                if($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
597
+            foreach ($cdr as $row) {
598
+                if ($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
599 599
                     $not_ended_cdr = $row;
600 600
                 }
601
-                if($row->answer === '' && $row->endtime === ''
602
-                    && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
601
+                if ($row->answer === '' && $row->endtime === ''
602
+                    && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
603 603
                     $transferNotComplete = true;
604 604
                 }
605 605
             }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
      */
658 658
     public function Action_transfer_dial_create_chan($data): void
659 659
     {
660
-        $filter     = [
660
+        $filter = [
661 661
             'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""',
662 662
             'bind' => [
663 663
                 'UNIQUEID' => $data['transfer_UNIQUEID'],
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         foreach ($m_data as $row) {
671 671
             ///
672 672
             // Проверим, если более одного канала SIP/256 при входящем.
673
-            if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
673
+            if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
674 674
                 if ($row_create) {
675 675
                     continue;
676 676
                 }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
                     $new_row->writeAttribute($attribute, $value);
685 685
                 }
686 686
                 $new_row->writeAttribute('dst_chan', $data['dst_chan']);
687
-                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']);
687
+                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']);
688 688
                 // $new_row->save();
689 689
                 // Подмена $row;
690 690
                 $row        = $new_row;
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 
698 698
             $row->writeAttribute('dst_chan', $data['dst_chan']);
699 699
             $row->writeAttribute('recordingfile', $data['recordingfile']);
700
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
700
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
701 701
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
702 702
             }
703 703
             $res = $row->save();
704
-            if ( ! $res) {
704
+            if (!$res) {
705 705
                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()));
706 706
             }
707 707
         }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
719 719
             'bind' => [
720 720
                 'UNIQUEID'      => $data['transfer_UNIQUEID'],
721
-                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'],
721
+                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'],
722 722
             ],
723 723
         ];
724 724
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
         foreach ($m_data as $row) {
729 729
             $row->writeAttribute('answer', $data['answer']);
730 730
             $res = $row->save();
731
-            if ( ! $res) {
731
+            if (!$res) {
732 732
                 Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
733 733
             }
734 734
         }
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
                 // Завершим вызов в CDR.
763 763
                 $row->writeAttribute('endtime', $data['end']);
764 764
                 $row->writeAttribute('transfer', 0);
765
-                if ( ! $row->save()) {
765
+                if (!$row->save()) {
766 766
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
767 767
                 }
768 768
             }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
                 // Ответа не было. Переадресация отменена.
798 798
                 $row->writeAttribute('endtime', $data['end']);
799 799
                 $row->writeAttribute('transfer', 0);
800
-                if ( ! $row->save()) {
800
+                if (!$row->save()) {
801 801
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
802 802
                 }
803 803
             }
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                 $this->MixMonitor($row->src_chan, $info['filename'], $subdir);
818 818
                 // Снимем со строк признак переадресации.
819 819
                 $row->writeAttribute('transfer', 0);
820
-                if ( ! $row->save()) {
820
+                if (!$row->save()) {
821 821
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
822 822
                 }
823 823
             }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 
894 894
                 $f_list = $m_data->toArray();
895 895
                 foreach ($data as $attribute => $value) {
896
-                    if ( ! array_key_exists($attribute, $f_list)) {
896
+                    if (!array_key_exists($attribute, $f_list)) {
897 897
                         continue;
898 898
                     }
899 899
                     $m_data->writeAttribute($attribute, $value);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
             $row->writeAttribute('answer', $data['answer']);
965 965
             $row->writeAttribute('endtime', $data['answer']);
966 966
             $res = $row->save();
967
-            if ( ! $res) {
967
+            if (!$res) {
968 968
                 Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages()));
969 969
             }
970 970
         }
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
994 994
             }
995 995
             $res = $row->save();
996
-            if ( ! $res) {
996
+            if (!$res) {
997 997
                 Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages()));
998 998
             }
999 999
         }
@@ -1023,11 +1023,11 @@  discard block
 block discarded – undo
1023 1023
             if ($dest_chan === $row->dst_chan) {
1024 1024
                 $is_local        = (stripos($data['src_chan'], 'local/') !== false);
1025 1025
                 $is_stored_local = (stripos($row->src_chan, 'local/') !== false);
1026
-                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) {
1026
+                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) {
1027 1027
                     $data['src_chan'] = $row->src_chan;
1028 1028
                 }
1029 1029
                 if (file_exists($row->recordingfile) || file_exists(
1030
-                        Util::trimExtensionForFile($row->recordingfile) . '.wav'
1030
+                        Util::trimExtensionForFile($row->recordingfile).'.wav'
1031 1031
                     )) {
1032 1032
                     // Переопределим путь к файлу записи разговора. Для конферецнии файл один.
1033 1033
                     $recordingfile = $row->recordingfile;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
             // Подменим ID на идентификатор конференции.
1040 1040
             $row->writeAttribute('linkedid', $data['meetme_id']);
1041 1041
             $res = $row->save();
1042
-            if ( ! $res) {
1042
+            if (!$res) {
1043 1043
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1044 1044
             }
1045 1045
         }
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
             $row->writeAttribute('transfer', 0);
1057 1057
             $row->writeAttribute('linkedid', $data['meetme_id']);
1058 1058
 
1059
-            if ( ! empty($recordingfile)) {
1059
+            if (!empty($recordingfile)) {
1060 1060
                 $row->writeAttribute('recordingfile', $recordingfile);
1061 1061
             }
1062 1062
             $res = $row->save();
1063
-            if ( ! $res) {
1063
+            if (!$res) {
1064 1064
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1065 1065
             }
1066 1066
         }
@@ -1099,9 +1099,9 @@  discard block
 block discarded – undo
1099 1099
      */
1100 1100
     public function callEventsWorker($tube): void
1101 1101
     {
1102
-        $data      = json_decode($tube->getBody(), true);
1103
-        $funcName = "Action_".$data['action']??'';
1104
-        if ( method_exists($this, $funcName) ) {
1102
+        $data = json_decode($tube->getBody(), true);
1103
+        $funcName = "Action_".$data['action'] ?? '';
1104
+        if (method_exists($this, $funcName)) {
1105 1105
             $this->$funcName($data);
1106 1106
         }
1107 1107
         $tube->reply(json_encode(true));
@@ -1131,14 +1131,14 @@  discard block
 block discarded – undo
1131 1131
     public function updateDataInDbM($data): bool
1132 1132
     {
1133 1133
         if (empty($data['UNIQUEID'])) {
1134
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1134
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1135 1135
 
1136 1136
             return false;
1137 1137
         }
1138 1138
 
1139 1139
         $filter = [
1140 1140
             "UNIQUEID=:id:",
1141
-            'bind' => ['id' => $data['UNIQUEID'],],
1141
+            'bind' => ['id' => $data['UNIQUEID'], ],
1142 1142
         ];
1143 1143
         /** @var CallDetailRecordsTmp $m_data */
1144 1144
         $m_data = CallDetailRecordsTmp::findFirst($filter);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
         }
1148 1148
         $f_list = $m_data->toArray();
1149 1149
         foreach ($data as $attribute => $value) {
1150
-            if ( ! array_key_exists($attribute, $f_list)) {
1150
+            if (!array_key_exists($attribute, $f_list)) {
1151 1151
                 continue;
1152 1152
             }
1153 1153
             if ('UNIQUEID' == $attribute) {
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
             $m_data->writeAttribute($attribute, $value);
1157 1157
         }
1158 1158
         $res = $m_data->save();
1159
-        if ( ! $res) {
1159
+        if (!$res) {
1160 1160
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1161 1161
         }
1162 1162
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     public static function insertDataToDbM($data): bool
1197 1197
     {
1198 1198
         if (empty($data['UNIQUEID'])) {
1199
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1199
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1200 1200
 
1201 1201
             return false;
1202 1202
         }
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
         $m_data = CallDetailRecordsTmp::findFirst(
1207 1207
             [
1208 1208
                 "UNIQUEID=:id:",
1209
-                'bind' => ['id' => $data['UNIQUEID'],],
1209
+                'bind' => ['id' => $data['UNIQUEID'], ],
1210 1210
             ]
1211 1211
         );
1212 1212
         if ($m_data === null) {
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
         } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] == 'dial') {
1216 1216
             if (empty($m_data->endtime)) {
1217 1217
                 // Если это оригинация dial может прийти дважды.
1218
-                if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){
1218
+                if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) {
1219 1219
                     $m_data->dst_num = $data['src_num'];
1220 1220
                     $m_data->save();
1221 1221
                 }
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
                 $new_m_data->transfer     = $data['transfer'];
1241 1241
 
1242 1242
                 $res = $new_m_data->save();
1243
-                if ( ! $res) {
1243
+                if (!$res) {
1244 1244
                     Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1245 1245
                 }
1246 1246
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
         $f_list = $m_data->toArray();
1252 1252
         foreach ($data as $attribute => $value) {
1253
-            if ( ! array_key_exists($attribute, $f_list)) {
1253
+            if (!array_key_exists($attribute, $f_list)) {
1254 1254
                 continue;
1255 1255
             }
1256 1256
             if ($is_new === false && 'UNIQUEID' == $attribute) {
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
             $m_data->writeAttribute($attribute, $value);
1260 1260
         }
1261 1261
         $res = $m_data->save();
1262
-        if ( ! $res) {
1262
+        if (!$res) {
1263 1263
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1264 1264
         }
1265 1265
 
@@ -1274,12 +1274,12 @@  discard block
 block discarded – undo
1274 1274
         $q      = $tube->getBody();
1275 1275
         $filter = json_decode($q, true);
1276 1276
 
1277
-        if($this->filterNotValid($filter)){
1277
+        if ($this->filterNotValid($filter)) {
1278 1278
             $tube->reply('[]');
1279 1279
             return;
1280 1280
         }
1281 1281
 
1282
-        $res    = null;
1282
+        $res = null;
1283 1283
         try {
1284 1284
             if (isset($filter['miko_tmp_db'])) {
1285 1285
                 $res = CallDetailRecordsTmp::find($filter);
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
             }
1299 1299
             $filter['add_pack_query']['bind'][$filter['columns']] = $arr;
1300 1300
 
1301
-            if($this->filterNotValid($filter['add_pack_query'])){
1301
+            if ($this->filterNotValid($filter['add_pack_query'])) {
1302 1302
                 $tube->reply('[]');
1303 1303
                 return;
1304 1304
             }
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
         if (isset($filter['miko_result_in_file'])) {
1317 1317
             $di         = Di::getDefault();
1318 1318
             $dirsConfig = $di->getShared('config');
1319
-            $filename   = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true));
1319
+            $filename   = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true));
1320 1320
             file_put_contents($filename, $res_data);
1321 1321
             Util::addRegularWWWRights($filename);
1322 1322
             $res_data = json_encode($filename);
@@ -1329,16 +1329,16 @@  discard block
 block discarded – undo
1329 1329
      * Проверка фильтра на корректность bind параметров.
1330 1330
      * @param $filter
1331 1331
      */
1332
-    private function filterNotValid($filter){
1332
+    private function filterNotValid($filter) {
1333 1333
         $haveErrors = false;
1334
-        if(isset($filter['bind'])){
1335
-            if(is_array($filter)){
1334
+        if (isset($filter['bind'])) {
1335
+            if (is_array($filter)) {
1336 1336
                 foreach ($filter['bind'] as $bindValue) {
1337
-                    if(empty($bindValue)){
1337
+                    if (empty($bindValue)) {
1338 1338
                         $haveErrors = true;
1339 1339
                     }
1340 1340
                 }
1341
-            }else{
1341
+            } else {
1342 1342
                 $haveErrors = true;
1343 1343
             }
1344 1344
         }
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 
1348 1348
     public function errorHandler($m): void
1349 1349
     {
1350
-        Util::sysLogMsg(self::class . '_ERROR', $m);
1350
+        Util::sysLogMsg(self::class.'_ERROR', $m);
1351 1351
     }
1352 1352
 }
1353 1353
 
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   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
         $res->data['message'] = 'In progress...';
165 165
 
166 166
 
167
-        if ( ! file_exists($tempFilename)) {
167
+        if (!file_exists($tempFilename)) {
168 168
             $res->success    = false;
169 169
             $res->messages[] = "Update file '{$tempFilename}' not found.";
170 170
 
171 171
             return $res;
172 172
         }
173 173
 
174
-        if ( ! file_exists('/var/etc/cfdevice')) {
174
+        if (!file_exists('/var/etc/cfdevice')) {
175 175
             $res->success    = false;
176 176
             $res->messages[] = "The system is not installed";
177 177
 
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
         $res                             = new PBXApiResult();
196 196
         $res->processor                  = __METHOD__;
197 197
         $di = DI::getDefault();
198
-        if ($di===null){
199
-            $res->messages[]='Error on DI initialize';
198
+        if ($di === null) {
199
+            $res->messages[] = 'Error on DI initialize';
200 200
             return $res;
201 201
         }
202 202
 
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
         $rm                              = Util::which('rm');
206 206
 
207 207
         // Pre delete some types
208
-        $clearThisModels=[
208
+        $clearThisModels = [
209 209
             [Providers::class=>''],
210 210
             [OutgoingRoutingTable::class=>''],
211 211
             [IncomingRoutingTable::class=>''],
212 212
             [OutWorkTimes::class=>''],
213 213
             [AsteriskManagerUsers::class=>''],
214
-            [Extensions::class=>'type="'.Extensions::TYPE_IVR_MENU.'"'],  // IVR Menu
215
-            [Extensions::class=>'type="'.Extensions::TYPE_CONFERENCE.'"'],  // CONFERENCE
216
-            [Extensions::class=>'type="'.Extensions::TYPE_QUEUE.'"'],  // QUEUE
214
+            [Extensions::class=>'type="'.Extensions::TYPE_IVR_MENU.'"'], // IVR Menu
215
+            [Extensions::class=>'type="'.Extensions::TYPE_CONFERENCE.'"'], // CONFERENCE
216
+            [Extensions::class=>'type="'.Extensions::TYPE_QUEUE.'"'], // QUEUE
217 217
         ];
218 218
 
219
-        foreach ($clearThisModels as $modelParams){
219
+        foreach ($clearThisModels as $modelParams) {
220 220
             foreach ($modelParams as $key=>$value) {
221 221
                 $records = call_user_func([$key, 'find'], $value);
222
-                if ( ! $records->delete()) {
222
+                if (!$records->delete()) {
223 223
                     $res->messages[] = $records->getMessages();
224 224
                     $res->success    = false;
225 225
                 }
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
         }
228 228
 
229 229
         // Other extensions
230
-        $parameters     = [
230
+        $parameters = [
231 231
             'conditions' => 'not number IN ({ids:array})',
232 232
             'bind'       => [
233 233
                 'ids' => [
234 234
                     '000063', // Reads back the extension
235 235
                     '000064', // 0000MILLI
236
-                    '10003246',// Echo test
236
+                    '10003246', // Echo test
237 237
                     '10000100' // Voicemail
238 238
                 ],
239 239
             ],
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                 $stopDeleting = true;
248 248
                 continue;
249 249
             }
250
-            if ( ! $record->delete()) {
250
+            if (!$record->delete()) {
251 251
                 $deleteAttempts += 1;
252 252
             }
253 253
             if ($deleteAttempts > $countRecords * 10) {
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
                 'custom' => SoundFiles::CATEGORY_CUSTOM,
264 264
             ],
265 265
         ];
266
-        $records    = SoundFiles::find($parameters);
266
+        $records = SoundFiles::find($parameters);
267 267
 
268 268
         foreach ($records as $record) {
269 269
             if (stripos($record->path, '/storage/usbdisk1/mikopbx') !== false) {
270 270
                 Util::mwExec("{$rm} -rf {$record->path}");
271
-                if ( ! $record->delete()) {
271
+                if (!$record->delete()) {
272 272
                     $res->messages[] = $record->getMessages();
273 273
                     $res->success    = false;
274 274
                 }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         foreach ($records as $record) {
281 281
             $moduleDir = PbxExtensionUtils::getModuleDir($record->uniqid);
282 282
             Util::mwExec("{$rm} -rf {$moduleDir}");
283
-            if ( ! $record->delete()) {
283
+            if (!$record->delete()) {
284 284
                 $res->messages[] = $record->getMessages();
285 285
                 $res->success    = false;
286 286
             }
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
 
289 289
         // Delete CallRecords
290 290
         $records = CallDetailRecords::find();
291
-        if ( ! $records->delete()) {
291
+        if (!$records->delete()) {
292 292
             $res->messages[] = $records->getMessages();
293 293
             $res->success    = false;
294 294
         }
295 295
 
296 296
         // Delete CallRecords sound files
297
-        $callRecordsPath  = $di->getShared('config')->path('asterisk.monitordir');
297
+        $callRecordsPath = $di->getShared('config')->path('asterisk.monitordir');
298 298
         if (stripos($callRecordsPath, '/storage/usbdisk1/mikopbx') !== false) {
299 299
              Util::mwExec("{$rm} -rf {$callRecordsPath}/*");
300 300
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         $res            = new PBXApiResult();
316 316
         $res->processor = __METHOD__;
317 317
         $moduleMetadata = FilesManagementProcessor::getMetadataFromModuleFile($filePath);
318
-        if ( ! $moduleMetadata->success) {
318
+        if (!$moduleMetadata->success) {
319 319
             return $moduleMetadata;
320 320
         } else {
321 321
             $moduleUniqueID = $moduleMetadata->data['uniqid'];
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         if (class_exists($pbxExtensionSetupClass)
355 355
             && method_exists($pbxExtensionSetupClass, 'installModule')) {
356 356
             $setup = new $pbxExtensionSetupClass($moduleUniqueID);
357
-            if ( ! $setup->installModule()) {
357
+            if (!$setup->installModule()) {
358 358
                 $res->success    = false;
359 359
                 $res->messages[] = $setup->getMessages();
360 360
             }
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
     {
438 438
         $res            = new PBXApiResult();
439 439
         $res->processor = __METHOD__;
440
-        if ( ! file_exists($filename)) {
440
+        if (!file_exists($filename)) {
441 441
             $res->success    = false;
442 442
             $res->messages[] = "File '{$filename}' not found.";
443 443
 
444 444
             return $res;
445 445
         }
446 446
         $out          = [];
447
-        $tmp_filename = '/tmp/' . time() . "_" . basename($filename);
447
+        $tmp_filename = '/tmp/'.time()."_".basename($filename);
448 448
         if (false === copy($filename, $tmp_filename)) {
449 449
             $res->success    = false;
450 450
             $res->messages[] = "Unable to create temporary file '{$tmp_filename}'.";
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
         }
454 454
 
455 455
         // Принудительно устанавливаем расширение файла в wav.
456
-        $n_filename     = Util::trimExtensionForFile($filename) . ".wav";
457
-        $n_filename_mp3 = Util::trimExtensionForFile($filename) . ".mp3";
456
+        $n_filename     = Util::trimExtensionForFile($filename).".wav";
457
+        $n_filename_mp3 = Util::trimExtensionForFile($filename).".mp3";
458 458
         // Конвертируем файл.
459 459
         $tmp_filename = escapeshellcmd($tmp_filename);
460 460
         $n_filename   = escapeshellcmd($n_filename);
Please login to merge, or discard this patch.