Passed
Pull Request — master (#23)
by Nikolay
09:42 queued 03:08
created
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/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.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer64.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
  */
24 24
 class UpdateConfigsUpToVer64 extends Injectable implements UpgradeSystemConfigInterface
25 25
 {
26
-  	public const PBX_VERSION = '6.4.1';
26
+        public const PBX_VERSION = '6.4.1';
27 27
 
28 28
     private ConfigAlias $config;
29 29
     private MikoPBXConfig $mikoPBXConfig;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         /** @var \MikoPBX\Common\Models\DialplanApplications $res */
46 46
         $app_number = '10000100';
47 47
         $app_logic  = base64_encode('1,Goto(voice_mail_peer,voicemail,1)');
48
-        $d_app      = DialplanApplications::findFirst('extension="' . $app_number . '"');
48
+        $d_app      = DialplanApplications::findFirst('extension="'.$app_number.'"');
49 49
         if ($d_app === null) {
50 50
             $d_app                   = new DialplanApplications();
51 51
             $d_app->applicationlogic = $app_logic;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $d_app->description      = 'Voice Mail';
54 54
             $d_app->name             = 'VOICEMAIL';
55 55
             $d_app->type             = 'plaintext';
56
-            $d_app->uniqid           = 'DIALPLAN-APPLICATION-' . md5(time());
56
+            $d_app->uniqid           = 'DIALPLAN-APPLICATION-'.md5(time());
57 57
 
58 58
             if ($d_app->save()) {
59 59
                 $extension = Extensions::findFirst("number = '{$app_number}'");
Please login to merge, or discard this patch.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer2020162.php 2 patches
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 UpdateConfigsUpToVer2020162 extends Injectable implements UpgradeSystemConfigInterface
24 24
 {
25
-  	public const PBX_VERSION = '2020.1.62';
25
+        public const PBX_VERSION = '2020.1.62';
26 26
 
27 27
     private ConfigAlias $config;
28 28
     private MikoPBXConfig $mikoPBXConfig;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,19 +71,19 @@
 block discarded – undo
71 71
 
72 72
 
73 73
         $app_number = '10003246';
74
-        $d_app      = DialplanApplications::findFirst('extension="' . $app_number . '"');
74
+        $d_app      = DialplanApplications::findFirst('extension="'.$app_number.'"');
75 75
         if ($d_app === null) {
76
-            $app_text                = '1,Answer()' . "\n" .
77
-                'n,AGI(cdr_connector.php,${ISTRANSFER}dial_answer)' . "\n" .
78
-                'n,Echo()' . "\n" .
79
-                'n,Hangup()' . "\n";
76
+            $app_text = '1,Answer()'."\n".
77
+                'n,AGI(cdr_connector.php,${ISTRANSFER}dial_answer)'."\n".
78
+                'n,Echo()'."\n".
79
+                'n,Hangup()'."\n";
80 80
             $d_app                   = new DialplanApplications();
81 81
             $d_app->applicationlogic = base64_encode($app_text);
82 82
             $d_app->extension        = $app_number;
83 83
             $d_app->description      = 'Echos audio and video back to the caller as soon as it is received. Used to test connection delay.';
84 84
             $d_app->name             = 'Echo test';
85 85
             $d_app->type             = 'plaintext';
86
-            $d_app->uniqid           = 'DIALPLAN-APPLICATION-' . md5(time());
86
+            $d_app->uniqid           = 'DIALPLAN-APPLICATION-'.md5(time());
87 87
 
88 88
             if ($d_app->save()) {
89 89
                 $extension = Extensions::findFirst("number = '{$app_number}'");
Please login to merge, or discard this patch.
src/Core/Asterisk/AGI.php 3 patches
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -104,7 +104,8 @@  discard block
 block discarded – undo
104 104
     /**
105 105
      * Считываем переданные скрипту переменные.
106 106
      */
107
-    private function readRequestData(){
107
+    private function readRequestData()
108
+    {
108 109
         if($this->in !== false){
109 110
             $str = PHP_EOL;
110 111
             // read the request
@@ -226,7 +227,7 @@  discard block
 block discarded – undo
226 227
         if ($ret['code'] != AGIRES_OK){
227 228
             // some sort of error
228 229
             $ret['data'] = $str;
229
-        }else{
230
+        } else{
230 231
             // Normal AGI RES OK response
231 232
             $parse    = explode(' ', trim($str));
232 233
             $in_token = false;
@@ -237,15 +238,15 @@  discard block
 block discarded – undo
237 238
                     if ($token[strlen($token) - 1] == ')') {
238 239
                         $in_token = false;
239 240
                     }
240
-                }elseif ($token[0] == '('){
241
+                } elseif ($token[0] == '('){
241 242
                     if ($token[strlen($token) - 1] != ')') {
242 243
                         $in_token = true;
243 244
                     }
244 245
                     $ret['data'] .= ' ' . trim($token, '() ');
245
-                }elseif (strpos($token, '=')){
246
+                } elseif (strpos($token, '=')){
246 247
                     $token          = explode('=', $token);
247 248
                     $ret[$token[0]] = $token[1];
248
-                }elseif ($token != ''){
249
+                } elseif ($token != ''){
249 250
                     $ret['data'] .= ' ' . $token;
250 251
                 }
251 252
             }
@@ -277,9 +278,11 @@  discard block
 block discarded – undo
277 278
         $ret['code'] = substr($str, 0, 3);
278 279
         $str         = trim(substr($str, 3));
279 280
 
280
-        if ($str[0] === '-') // We have a multiline response!
281
+        if ($str[0] === '-') {
282
+            // We have a multiline response!
281 283
         {
282 284
             $count = 0;
285
+        }
283 286
             $str   = substr($str, 1) . "\n";
284 287
             $line  = fgets($this->in, 4096);
285 288
             while (substr($line, 0, 3) != $ret['code'] && $count < 5) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      */
411 411
     public function hangup($channel = '')
412 412
     {
413
-        return $this->evaluate("HANGUP $channel");
413
+        return $this->evaluate("hangup $channel");
414 414
     }
415 415
 
416 416
     /**
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
             $options = join(',', $options);
577 577
         }
578 578
 
579
-        return $this->evaluate("EXEC $application $options");
579
+        return $this->evaluate("exec $application $options");
580 580
     }
581 581
 
582 582
     /**
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace MikoPBX\Core\Asterisk;
10 10
 
11
-define('AST_DIGIT_ANY',                 '0123456789#*');
12
-define('AGIRES_OK',                     200);
13
-define('AST_STATE_DOWN',                0);
14
-define('AST_STATE_RESERVED',            1);
15
-define('AST_STATE_OFFHOOK',             2);
16
-define('AST_STATE_DIALING',             3);
17
-define('AST_STATE_RING',                4);
18
-define('AST_STATE_RINGING',             5);
19
-define('AST_STATE_UP',                  6);
20
-define('AST_STATE_BUSY',                7);
21
-define('AST_STATE_DIALING_OFFHOOK',     8);
22
-define('AST_STATE_PRERING',             9);
23
-define('AUDIO_FILENO',                  3);
11
+define('AST_DIGIT_ANY', '0123456789#*');
12
+define('AGIRES_OK', 200);
13
+define('AST_STATE_DOWN', 0);
14
+define('AST_STATE_RESERVED', 1);
15
+define('AST_STATE_OFFHOOK', 2);
16
+define('AST_STATE_DIALING', 3);
17
+define('AST_STATE_RING', 4);
18
+define('AST_STATE_RINGING', 5);
19
+define('AST_STATE_UP', 6);
20
+define('AST_STATE_BUSY', 7);
21
+define('AST_STATE_DIALING_OFFHOOK', 8);
22
+define('AST_STATE_PRERING', 9);
23
+define('AUDIO_FILENO', 3);
24 24
 
25 25
 /**
26 26
  * AGI class
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
         $this->conLogBusy = false;
95 95
         ob_implicit_flush(1);
96 96
         // Open stdin & stdout.
97
-        $this->in  = defined('STDIN') ? STDIN  : fopen('php://stdin',  'r');
98
-        $this->out = defined('STDOUT')? STDOUT : fopen('php://stdout', 'w');
97
+        $this->in  = defined('STDIN') ? STDIN  : fopen('php://stdin', 'r');
98
+        $this->out = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
99 99
         $this->request = [];
100 100
 
101 101
         $this->readRequestData();
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
     /**
105 105
      * Считываем переданные скрипту переменные.
106 106
      */
107
-    private function readRequestData(){
108
-        if($this->in !== false){
107
+    private function readRequestData() {
108
+        if ($this->in !== false) {
109 109
             $str = PHP_EOL;
110 110
             // read the request
111 111
             $resIn = fgets($this->in);
112
-            if($resIn !== false){
112
+            if ($resIn !== false) {
113 113
                 $str = $resIn;
114 114
             }
115 115
             while ($str !== PHP_EOL) {
116 116
                 $this->request[substr($str, 0, strpos($str, ':'))] = trim(substr($str, strpos($str, ':') + 1));
117 117
                 $resIn = fgets($this->in);
118
-                if($resIn === false){
118
+                if ($resIn === false) {
119 119
                     break;
120 120
                 }
121 121
                 $str = $resIn;
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $broken = ['code' => 500, 'result' => -1, 'data' => ''];
169 169
 
170
-        if( !is_resource($this->out) ){
170
+        if (!is_resource($this->out)) {
171 171
             return $broken;
172 172
         }
173 173
 
174
-        if ( !fwrite($this->out, trim($command) . "\n")) {
174
+        if (!fwrite($this->out, trim($command)."\n")) {
175 175
             return $broken;
176 176
         }
177 177
         fflush($this->out);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         // parse result
180 180
         $str = '';
181 181
         $ret = [];
182
-        if(!$this->evaluateReadResponse($str, $ret)){
182
+        if (!$this->evaluateReadResponse($str, $ret)) {
183 183
             return $broken;
184 184
         }
185 185
 
@@ -196,30 +196,30 @@  discard block
 block discarded – undo
196 196
     private function evaluateParseResponse($str, &$ret):void{
197 197
         $ret['result'] = null;
198 198
         $ret['data']   = '';
199
-        if ($ret['code'] != AGIRES_OK){
199
+        if ($ret['code'] != AGIRES_OK) {
200 200
             // some sort of error
201 201
             $ret['data'] = $str;
202
-        }else{
202
+        } else {
203 203
             // Normal AGI RES OK response
204 204
             $parse    = explode(' ', trim($str));
205 205
             $in_token = false;
206 206
             foreach ($parse as $token) {
207
-                if ($in_token){
207
+                if ($in_token) {
208 208
                     // we previously hit a token starting with ')' but not ending in ')'
209
-                    $ret['data'] .= ' ' . trim($token, '() ');
209
+                    $ret['data'] .= ' '.trim($token, '() ');
210 210
                     if ($token[strlen($token) - 1] == ')') {
211 211
                         $in_token = false;
212 212
                     }
213
-                }elseif ($token[0] == '('){
213
+                }elseif ($token[0] == '(') {
214 214
                     if ($token[strlen($token) - 1] != ')') {
215 215
                         $in_token = true;
216 216
                     }
217
-                    $ret['data'] .= ' ' . trim($token, '() ');
218
-                }elseif (strpos($token, '=')){
217
+                    $ret['data'] .= ' '.trim($token, '() ');
218
+                }elseif (strpos($token, '=')) {
219 219
                     $token          = explode('=', $token);
220 220
                     $ret[$token[0]] = $token[1];
221
-                }elseif ($token != ''){
222
-                    $ret['data'] .= ' ' . $token;
221
+                }elseif ($token != '') {
222
+                    $ret['data'] .= ' '.$token;
223 223
                 }
224 224
             }
225 225
             $ret['data'] = trim($ret['data']);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      */
235 235
     private function evaluateReadResponse(string & $str, array & $ret): bool{
236 236
         $result = true;
237
-        if(!is_resource($this->in)){
237
+        if (!is_resource($this->in)) {
238 238
             return $result;
239 239
         }
240 240
 
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
         if ($str[0] === '-') // We have a multiline response!
254 254
         {
255 255
             $count = 0;
256
-            $str   = substr($str, 1) . "\n";
256
+            $str   = substr($str, 1)."\n";
257 257
             $line  = fgets($this->in, 4096);
258 258
             while (substr($line, 0, 3) != $ret['code'] && $count < 5) {
259
-                $str   .= $line;
259
+                $str .= $line;
260 260
                 $line  = fgets($this->in, 4096);
261 261
                 $count = (trim($line) == '') ? $count + 1 : 0;
262 262
             }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
         return $this->exec(
603 603
             'Dial',
604 604
             trim(
605
-                "$type/$identifier" . $this->option_delim . $timeout . $this->option_delim . $options . $this->option_delim . $url,
605
+                "$type/$identifier".$this->option_delim.$timeout.$this->option_delim.$options.$this->option_delim.$url,
606 606
                 $this->option_delim
607 607
             )
608 608
         );
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
      */
623 623
     public function exec_goto($a, $b = null, $c = null)
624 624
     {
625
-        return $this->exec('Goto', trim($a . $this->option_delim . $b . $this->option_delim . $c, $this->option_delim));
625
+        return $this->exec('Goto', trim($a.$this->option_delim.$b.$this->option_delim.$c, $this->option_delim));
626 626
     }
627 627
 
628 628
 
Please login to merge, or discard this patch.
src/AdminCabinet/Providers/AssetProvider.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $di->set(
52 52
             self::SERVICE_NAME,
53
-            function () use ($di) {
53
+            function() use ($di) {
54 54
                 $assets = new AssetProvider();
55 55
                 $assets->initializeClassVariables();
56 56
                 $dispatcher = $di->get('dispatcher');
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                     $action = 'index';
64 64
                 }
65 65
                 if ($session !== null && $session->has('versionHash')) {
66
-                    $version = (string)$session->get('versionHash');
66
+                    $version = (string) $session->get('versionHash');
67 67
                 } else {
68 68
                     $version = str_replace(PHP_EOL, '', file_get_contents('/etc/version'));
69 69
                 }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     {
291 291
         $language   = $di->getShared('language');
292 292
         $langJSFile = "js/cache/localization-{$language}-{$version}.min.js";
293
-        if ( ! file_exists($langJSFile)) {
293
+        if (!file_exists($langJSFile)) {
294 294
             $arrStr = [];
295 295
             foreach ($di->getShared('messages') as $key => $value) {
296 296
                 $arrStr[$key] = str_replace(
@@ -318,24 +318,24 @@  discard block
 block discarded – undo
318 318
      */
319 319
     private function generateFilesAndLinks($controller, string $action, string $version): void
320 320
     {
321
-        $resultCombinedName = Text::uncamelize(ucfirst($controller) . ucfirst($action), '-');
322
-        $resultCombinedName = strlen($resultCombinedName) !== '' ? $resultCombinedName . '-' : '';
321
+        $resultCombinedName = Text::uncamelize(ucfirst($controller).ucfirst($action), '-');
322
+        $resultCombinedName = strlen($resultCombinedName) !== '' ? $resultCombinedName.'-' : '';
323 323
 
324 324
 
325 325
         foreach ($this->headerCollectionJS as $resource) {
326
-            $resource->setPath($resource->getPath() . '?v=' . $version);
326
+            $resource->setPath($resource->getPath().'?v='.$version);
327 327
         }
328 328
         foreach ($this->footerCollectionJS as $resource) {
329
-            $resource->setPath($resource->getPath() . '?v=' . $version);
329
+            $resource->setPath($resource->getPath().'?v='.$version);
330 330
         }
331 331
         foreach ($this->semanticCollectionJS as $resource) {
332
-            $resource->setPath($resource->getPath() . '?v=' . $version);
332
+            $resource->setPath($resource->getPath().'?v='.$version);
333 333
         }
334 334
         foreach ($this->semanticCollectionCSS as $resource) {
335
-            $resource->setPath($resource->getPath() . '?v=' . $version);
335
+            $resource->setPath($resource->getPath().'?v='.$version);
336 336
         }
337 337
         foreach ($this->footerCollectionACE as $resource) {
338
-            $resource->setPath($resource->getPath() . '?v=' . $version);
338
+            $resource->setPath($resource->getPath().'?v='.$version);
339 339
         }
340 340
 
341 341
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,8 @@
 block discarded – undo
50 50
     {
51 51
         $di->set(
52 52
             self::SERVICE_NAME,
53
-            function () use ($di) {
53
+            function () use ($di)
54
+            {
54 55
                 $assets = new AssetProvider();
55 56
                 $assets->initializeClassVariables();
56 57
                 $dispatcher = $di->get('dispatcher');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
                 $assets->makeHeaderAssets($session, $moduleName);
73 73
 
74 74
                 // Generates Controllers assets
75
-                $method_name = "make{$controller}Assets";
75
+                $method_name = "make{$controller}assets";
76 76
                 if (method_exists($assets, $method_name)) {
77 77
                     $assets->$method_name($action);
78 78
                 }
Please login to merge, or discard this patch.
src/Modules/PbxExtensionState.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
         $this->moduleUniqueID = $moduleUniqueID;
42 42
         $this->modulesRoot    = $this->getDI()->getShared('config')->path('core.modulesDir');
43 43
         $moduleJson           = "{$this->modulesRoot}/{$this->moduleUniqueID}/module.json";
44
-        if ( ! file_exists($moduleJson)) {
45
-            $this->messages[] = 'module.json not found for module ' . $this->moduleUniqueID;
44
+        if (!file_exists($moduleJson)) {
45
+            $this->messages[] = 'module.json not found for module '.$this->moduleUniqueID;
46 46
 
47 47
             return;
48 48
         }
49 49
 
50 50
         $jsonString            = file_get_contents($moduleJson);
51 51
         $jsonModuleDescription = json_decode($jsonString, true);
52
-        if ( ! is_array($jsonModuleDescription)) {
53
-            $this->messages[] = 'module.json parsing error ' . $this->moduleUniqueID;
52
+        if (!is_array($jsonModuleDescription)) {
53
+            $this->messages[] = 'module.json parsing error '.$this->moduleUniqueID;
54 54
 
55 55
             return;
56 56
         }
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
             }
94 94
         }
95 95
         $success = $this->makeBeforeEnableTest();
96
-        if ( ! $success) {
96
+        if (!$success) {
97 97
             return false;
98 98
         }
99 99
 
100 100
         $this->reloadConfigClass();
101 101
         // Если ошибок нет, включаем Firewall и модуль
102
-        if ( ! $this->enableFirewallSettings()) {
102
+        if (!$this->enableFirewallSettings()) {
103 103
             $this->messages[] = 'Error on enable firewall settings';
104 104
 
105 105
             return false;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 if (array_key_exists($network->id, $previousRules)) {
181 181
                     $newRule->action = $previousRules[$network->id];
182 182
                 }
183
-                if ( ! $newRule->save()) {
183
+                if (!$newRule->save()) {
184 184
                     $this->messages[] = $newRule->getMessages();
185 185
                 }
186 186
             }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     {
208 208
         if ($this->configClass !== null
209 209
             && method_exists($this->configClass, 'createNginxLocations')
210
-            && ! empty($this->configClass->createNginxLocations())) {
210
+            && !empty($this->configClass->createNginxLocations())) {
211 211
             $nginxConf = new NginxConf();
212 212
             $nginxConf->generateModulesConf();
213 213
             $nginxConf->reStart();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     {
225 225
         if ($this->configClass !== null
226 226
             && method_exists($this->configClass, 'generateFail2BanJails')
227
-            && ! empty($this->configClass->generateFail2BanJails())) {
227
+            && !empty($this->configClass->generateFail2BanJails())) {
228 228
             IptablesConf::reloadFirewall();
229 229
         }
230 230
     }
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
     public function disableModule(): bool
237 237
     {
238 238
         $success = $this->makeBeforeDisableTest();
239
-        if ( ! $success) {
239
+        if (!$success) {
240 240
             return false;
241 241
         }
242 242
         $this->reloadConfigClass();
243 243
         // Если ошибок нет, выключаем Firewall и модуль
244
-        if ( ! $this->disableFirewallSettings()) {
244
+        if (!$this->disableFirewallSettings()) {
245 245
             $this->messages[] = 'Error on disable firewall settings';
246 246
 
247 247
             return false;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             && method_exists($this->configClass, 'onBeforeModuleDisable')
301 301
             && $this->configClass->onBeforeModuleDisable() === false) {
302 302
             $messages = $this->configClass->getMessages();
303
-            if ( ! empty($messages)) {
303
+            if (!empty($messages)) {
304 304
                 $this->messages = $messages;
305 305
             } else {
306 306
                 $this->messages[] = 'Error on the Module enable function at onBeforeModuleDisable';
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             $className        = pathinfo($file)['filename'];
319 319
             $moduleModelClass = "\\Modules\\{$this->moduleUniqueID}\\Models\\{$className}";
320 320
             try {
321
-                if ( ! class_exists($moduleModelClass)) {
321
+                if (!class_exists($moduleModelClass)) {
322 322
                     continue;
323 323
                 }
324 324
                 $reflection = new ReflectionClass($moduleModelClass);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
                 }
331 331
                 $records = $moduleModelClass::find();
332 332
                 foreach ($records as $record) {
333
-                    if ( ! $record->beforeDelete()) {
333
+                    if (!$record->beforeDelete()) {
334 334
                         foreach ($record->getMessages() as $message) {
335 335
                             $this->messages[] = $message->getMessage();
336 336
                         }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             $savedState[$detailRule->networkfilterid] = $detailRule->action;
383 383
         }
384 384
         $this->db->begin(true);
385
-        if ( ! $currentRules->delete()) {
385
+        if (!$currentRules->delete()) {
386 386
             $this->messages[] = $currentRules->getMessages();
387 387
 
388 388
             return false;
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             $previousRuleSettings->key = "{$this->moduleUniqueID}FirewallSettings";
395 395
         }
396 396
         $previousRuleSettings->value = json_encode($savedState);
397
-        if ( ! $previousRuleSettings->save()) {
397
+        if (!$previousRuleSettings->save()) {
398 398
             $this->messages[] = $previousRuleSettings->getMessages();
399 399
         }
400 400
         if (count($errors) > 0) {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             && method_exists($this->configClass, 'onBeforeModuleEnable')
448 448
             && $this->configClass->onBeforeModuleEnable() === false) {
449 449
             $messages = $this->configClass->getMessages();
450
-            if ( ! empty($messages)) {
450
+            if (!empty($messages)) {
451 451
                 $this->messages = $messages;
452 452
             } else {
453 453
                 $this->messages[] = 'Error on the enableModule function at onBeforeModuleEnable';
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             $moduleModelClass = "\\Modules\\{$this->moduleUniqueID}\\Models\\{$className}";
468 468
 
469 469
             try {
470
-                if ( ! class_exists($moduleModelClass)) {
470
+                if (!class_exists($moduleModelClass)) {
471 471
                     continue;
472 472
                 }
473 473
                 $reflection = new ReflectionClass($moduleModelClass);
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                                     'modulename' => $record->getRepresent(true),
498 498
                                 ]
499 499
                             );
500
-                            $success          = false;
500
+                            $success = false;
501 501
                         }
502 502
                     }
503 503
                 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     private function reloadConfigClass(): void
70 70
     {
71 71
         $class_name      = str_replace('Module', '', $this->moduleUniqueID);
72
-        $configClassName = "\\Modules\\{$this->moduleUniqueID}\\Lib\\{$class_name}Conf";
72
+        $configClassName = "\\Modules\\{$this->moduleUniqueID}\\Lib\\{$class_name}conf";
73 73
         if (class_exists($configClassName)) {
74 74
             $this->configClass = new $configClassName();
75 75
         } else {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
         $this->db->begin(true);
153 153
         $defaultRules         = $this->configClass->getDefaultFirewallRules();
154
-        $previousRuleSettings = PbxSettings::findFirstByKey("{$this->moduleUniqueID}FirewallSettings");
154
+        $previousRuleSettings = PbxSettings::findFirstByKey("{$this->moduleUniqueID}firewallsettings");
155 155
         $previousRules        = [];
156 156
         if ($previousRuleSettings !== null) {
157 157
             $previousRules = json_decode($previousRuleSettings->value, true);
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
             return false;
389 389
         }
390 390
 
391
-        $previousRuleSettings = PbxSettings::findFirstByKey("{$this->moduleUniqueID}FirewallSettings");
391
+        $previousRuleSettings = PbxSettings::findFirstByKey("{$this->moduleUniqueID}firewallsettings");
392 392
         if ($previousRuleSettings === null) {
393 393
             $previousRuleSettings      = new PbxSettings();
394
-            $previousRuleSettings->key = "{$this->moduleUniqueID}FirewallSettings";
394
+            $previousRuleSettings->key = "{$this->moduleUniqueID}firewallsettings";
395 395
         }
396 396
         $previousRuleSettings->value = json_encode($savedState);
397 397
         if ( ! $previousRuleSettings->save()) {
Please login to merge, or discard this patch.