Passed
Push — develop ( 80cbb5...2d91ab )
by Nikolay
11:52 queued 11s
created
src/PBXCoreREST/Controllers/System/PostController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,10 +109,10 @@
 block discarded – undo
109 109
         $mohDir                = $di->getShared('config')->path('asterisk.mohdir');
110 110
         switch ($category) {
111 111
             case SoundFiles::CATEGORY_MOH:
112
-                $data['filename'] = "{$mohDir}/" . basename($data['temp_filename']);
112
+                $data['filename'] = "{$mohDir}/".basename($data['temp_filename']);
113 113
                 break;
114 114
             case SoundFiles::CATEGORY_CUSTOM:
115
-                $data['filename'] = "{$mediaDir}/" . basename($data['temp_filename']);
115
+                $data['filename'] = "{$mediaDir}/".basename($data['temp_filename']);
116 116
                 break;
117 117
             default:
118 118
                 $this->sendError(400, 'Category not set');
Please login to merge, or discard this patch.
src/PBXCoreREST/Controllers/Files/PostController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         if ($response !== false) {
98 98
             $response = json_decode($response, true);
99 99
             $filename = $response['data']['filename'] ?? '';
100
-            if ( ! file_exists($filename)) {
100
+            if (!file_exists($filename)) {
101 101
                 $response['messages'][] = 'Config file not found';
102 102
             } else {
103 103
                 $response['data']['filename'] = $filename;
104
-                $response['data']['content']  = mb_convert_encoding('' . file_get_contents($filename), 'UTF-8', 'UTF-8');
104
+                $response['data']['content']  = mb_convert_encoding(''.file_get_contents($filename), 'UTF-8', 'UTF-8');
105 105
                 unlink($filename);
106 106
             }
107 107
             $this->response->setPayloadSuccess($response);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function uploadResumableAction(): void
117 117
     {
118
-        $data   = $this->request->getPost();
118
+        $data = $this->request->getPost();
119 119
         $data['result'] = 'ERROR';
120 120
 
121 121
         if ($this->request->hasFiles() > 0) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 'resumableTotalSize'   => $this->request->getPost('resumableTotalSize'),
128 128
             ];
129 129
             foreach ($this->request->getUploadedFiles() as $file) {
130
-                $data['files'][]= [
130
+                $data['files'][] = [
131 131
                     'file_path' => $file->getTempName(),
132 132
                     'file_size' => $file->getSize(),
133 133
                     'file_error'=> $file->getError(),
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                     'file_type' => $file->getType()
136 136
                 ];
137 137
                 if ($file->getError()) {
138
-                    $data['data'] = 'error ' . $file->getError() . ' in file ' . $file->getTempName();
138
+                    $data['data'] = 'error '.$file->getError().' in file '.$file->getTempName();
139 139
                     $this->sendError(400, $data['data']);
140
-                    Util::sysLogMsg('UploadFile', 'error ' . $file->getError() . ' in file ' . $file->getTempName());
140
+                    Util::sysLogMsg('UploadFile', 'error '.$file->getError().' in file '.$file->getTempName());
141 141
                     return;
142 142
                 }
143 143
             }
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/SysLogsManagementProcessor.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -76,35 +76,35 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $res            = new PBXApiResult();
78 78
         $res->processor = __METHOD__;
79
-        $filename       = System::getLogDir() . '/' . $filename;
80
-        if ( ! file_exists($filename)) {
79
+        $filename       = System::getLogDir().'/'.$filename;
80
+        if (!file_exists($filename)) {
81 81
             $res->success    = false;
82
-            $res->messages[] = 'No access to the file ' . $filename;
82
+            $res->messages[] = 'No access to the file '.$filename;
83 83
         } else {
84 84
             $res->success = true;
85 85
             $head         = Util::which('head');
86 86
             $grep         = Util::which('grep');
87 87
             $tail         = Util::which('tail');
88 88
             $filter       = escapeshellarg($filter);
89
-            $offset       = (int)$offset;
90
-            $lines        = (int)$lines;
91
-            $linesPlusOffset = $lines+$offset;
89
+            $offset       = (int) $offset;
90
+            $lines        = (int) $lines;
91
+            $linesPlusOffset = $lines + $offset;
92 92
 
93 93
             $di          = Di::getDefault();
94 94
             $dirsConfig  = $di->getShared('config');
95
-            $filenameTmp = $dirsConfig->path('www.downloadCacheDir') . '/' . __FUNCTION__ . '_' . time() . '.log';
96
-            if (empty($filter)){
95
+            $filenameTmp = $dirsConfig->path('www.downloadCacheDir').'/'.__FUNCTION__.'_'.time().'.log';
96
+            if (empty($filter)) {
97 97
                 $cmd         = "{$tail} -n {$linesPlusOffset} {$filename}";
98 98
             } else {
99 99
                 $cmd         = "{$grep} -F {$filter} {$filename} | $tail -n {$linesPlusOffset}";
100 100
             }
101
-            if ($offset>0){
101
+            if ($offset > 0) {
102 102
                 $cmd .= " | {$head} -n {$lines}";
103 103
             }
104 104
             $cmd .= " > $filenameTmp";
105 105
 
106 106
             Util::mwExec("$cmd; chown www:www $filenameTmp");
107
-            $res->data['cmd']=$cmd;
107
+            $res->data['cmd'] = $cmd;
108 108
             $res->data['filename'] = $filenameTmp;
109 109
         }
110 110
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         $systemInfoFile = "{$logDir}/system-information.log";
163 163
         file_put_contents($systemInfoFile, SysinfoManagementProcessor::prepareSysyinfoContent());
164 164
 
165
-        $futureFileName        = $temp_dir . '/temp-all-log-' . time() . '.zip';
165
+        $futureFileName        = $temp_dir.'/temp-all-log-'.time().'.zip';
166 166
         $res->data['filename'] = $futureFileName;
167 167
         $res->success          = true;
168 168
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $res->processor = __METHOD__;
199 199
 
200 200
         $progress_file = "{$resultFile}.progress";
201
-        if ( ! file_exists($progress_file)) {
201
+        if (!file_exists($progress_file)) {
202 202
             $res->messages[] = 'Archive does not exist. Try again!';
203 203
         } elseif (file_exists($progress_file) && file_get_contents($progress_file) === '100') {
204 204
             $uid          = Util::generateRandomString(36);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             $downloadLink = $di->getShared('config')->path('www.downloadCacheDir');
207 207
             $result_dir   = "{$downloadLink}/{$uid}";
208 208
             Util::mwMkdir($result_dir);
209
-            $link_name = 'MikoPBXLogs_' . basename($resultFile);
209
+            $link_name = 'MikoPBXLogs_'.basename($resultFile);
210 210
             Util::createUpdateSymlink($resultFile, "{$result_dir}/{$link_name}");
211 211
             Util::addRegularWWWRights("{$result_dir}/{$link_name}");
212 212
             $res->success          = true;
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
     {
233 233
         $res            = new PBXApiResult();
234 234
         $res->processor = __METHOD__;
235
-        $filename       = System::getLogDir() . '/' . $filename;
236
-        if ( ! file_exists($filename)) {
235
+        $filename       = System::getLogDir().'/'.$filename;
236
+        if (!file_exists($filename)) {
237 237
             $res->success    = false;
238
-            $res->messages[] = 'File does not exist ' . $filename;
238
+            $res->messages[] = 'File does not exist '.$filename;
239 239
         } else {
240 240
             $uid          = Util::generateRandomString(36);
241 241
             $di           = Di::getDefault();
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
                 continue;
277 277
             }
278 278
 
279
-            $relativePath             = str_ireplace($logDir . '/', '', $entry);
279
+            $relativePath             = str_ireplace($logDir.'/', '', $entry);
280 280
             $fileSizeKB               = ceil($fileSize / 1024);
281 281
             $filesList[$relativePath] =
282 282
                 [
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
                 continue;
314 314
             }
315 315
             //if current file ($d) is a directory, call scanDirRecursively
316
-            if (is_dir($dir . '/' . $d)) {
317
-                $list[] = self::scanDirRecursively($dir . '/' . $d);
316
+            if (is_dir($dir.'/'.$d)) {
317
+                $list[] = self::scanDirRecursively($dir.'/'.$d);
318 318
                 //otherwise, add the file to the list
319
-            } elseif (is_file($dir . '/' . $d) || is_link($dir . '/' . $d)) {
320
-                $list[] = $dir . '/' . $d;
319
+            } elseif (is_file($dir.'/'.$d) || is_link($dir.'/'.$d)) {
320
+                $list[] = $dir.'/'.$d;
321 321
             }
322 322
         }
323 323
 
Please login to merge, or discard this patch.
src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer20202754.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             'slin'  => 'Signed Linear PCM',
82 82
             'opus'  => 'Opus',
83 83
         ];
84
-        $codecs      = Codecs::find();
84
+        $codecs = Codecs::find();
85 85
         // Удалим лишние кодеки
86 86
         /** @var Codecs $codec */
87 87
         foreach ($codecs as $codec) {
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
                 $this->checkDisabledCodec($codec);
90 90
                 continue;
91 91
             }
92
-            if ( ! $codec->delete()) {
92
+            if (!$codec->delete()) {
93 93
                 Util::sysLogMsg(
94 94
                     __CLASS__,
95
-                    'Can not delete codec ' . $codec->name . ' from MikoPBX\Common\Models\Codecs'
95
+                    'Can not delete codec '.$codec->name.' from MikoPBX\Common\Models\Codecs'
96 96
                 );
97 97
             }
98 98
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private function checkDisabledCodec(Codecs $codec): void
109 109
     {
110
-        if ( ! in_array($codec->disabled, ['0', '1'], true)) {
110
+        if (!in_array($codec->disabled, ['0', '1'], true)) {
111 111
             $codec->disabled = '0';
112 112
             $codec->save();
113 113
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     private function addNewCodecs(array $availCodecs): void
122 122
     {
123 123
         foreach ($availCodecs as $availCodec => $desc) {
124
-            $codecData = Codecs::findFirst('name="' . $availCodec . '"');
124
+            $codecData = Codecs::findFirst('name="'.$availCodec.'"');
125 125
             if ($codecData === null) {
126 126
                 $codecData = new Codecs();
127 127
             } elseif ($codecData->description === $desc) {
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
             }
137 137
             $codecData->type        = $type;
138 138
             $codecData->description = $desc;
139
-            if ( ! $codecData->save()) {
139
+            if (!$codecData->save()) {
140 140
                 Util::sysLogMsg(
141 141
                     __CLASS__,
142
-                    'Can not update codec info ' . $codecData->name . ' from \MikoPBX\Common\Models\Codecs'
142
+                    'Can not update codec info '.$codecData->name.' from \MikoPBX\Common\Models\Codecs'
143 143
                 );
144 144
             }
145 145
         }
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
         $astDbPath = $this->config->path('astDatabase.dbfile');
192 192
         if (file_exists($astDbPath)) {
193 193
             $table = 'astdb';
194
-            $sql   = 'DELETE FROM ' . $table . ' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"';
194
+            $sql   = 'DELETE FROM '.$table.' WHERE key LIKE "/DND/SIP%" OR key LIKE "/CF/SIP%" OR key LIKE "/UserBuddyStatus/SIP%"';
195 195
             $db    = new \SQLite3($astDbPath);
196 196
             try {
197 197
                 $db->exec($sql);
198 198
             } catch (\Error $e) {
199
-                Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...' . $e->getMessage());
199
+                Util::sysLogMsg(__CLASS__, 'Can clean astdb from UserBuddyStatus...'.$e->getMessage());
200 200
                 sleep(2);
201 201
             }
202 202
             $db->close();
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function copyMohFilesToStorage(): void
211 211
     {
212
-        $oldMohDir = $this->config->path('asterisk.astvarlibdir') . '/sounds/moh';
213
-        if ( ! file_exists($oldMohDir)) {
212
+        $oldMohDir = $this->config->path('asterisk.astvarlibdir').'/sounds/moh';
213
+        if (!file_exists($oldMohDir)) {
214 214
             return;
215 215
         }
216 216
         $currentMohDir = $this->config->path('asterisk.mohdir');
217
-        if ( ! Util::mwMkdir($currentMohDir)) {
217
+        if (!Util::mwMkdir($currentMohDir)) {
218 218
             return;
219 219
         }
220 220
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
             if (in_array($file, ['.', '..'])) {
224 224
                 continue;
225 225
             }
226
-            if (copy($oldMohDir . '/' . $file, $currentMohDir . '/' . $file)) {
226
+            if (copy($oldMohDir.'/'.$file, $currentMohDir.'/'.$file)) {
227 227
                 $sound_file           = new SoundFiles();
228
-                $sound_file->path     = $currentMohDir . '/' . $file;
228
+                $sound_file->path     = $currentMohDir.'/'.$file;
229 229
                 $sound_file->category = SoundFiles::CATEGORY_MOH;
230 230
                 $sound_file->name     = $file;
231 231
                 $sound_file->save();
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             Extensions::TYPE_CONFERENCE,
290 290
 
291 291
         ];
292
-        $extensions           = Extensions::find();
292
+        $extensions = Extensions::find();
293 293
         foreach ($extensions as $extension) {
294 294
             if (in_array($extension->type, $showInPhonebookTypes)) {
295 295
                 $extension->show_in_phonebook = '1';
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
      */
305 305
     private function moveReadOnlySoundsToStorage(): void
306 306
     {
307
-        $currentMediaDir = $this->config->path('asterisk.customSoundDir') . '/';
308
-        if ( ! is_dir($currentMediaDir)) {
307
+        $currentMediaDir = $this->config->path('asterisk.customSoundDir').'/';
308
+        if (!is_dir($currentMediaDir)) {
309 309
             Util::mwMkdir($currentMediaDir);
310 310
         }
311 311
         $soundFiles = SoundFiles::find();
312 312
         foreach ($soundFiles as $soundFile) {
313 313
             if (stripos($soundFile->path, '/offload/asterisk/sounds/other/') === 0) {
314
-                $newPath = $currentMediaDir . pathinfo($soundFile->path)['basename'];
314
+                $newPath = $currentMediaDir.pathinfo($soundFile->path)['basename'];
315 315
                 if (copy($soundFile->path, $newPath)) {
316 316
                     $soundFile->path = $newPath;
317 317
                     $soundFile->update();
Please login to merge, or discard this patch.
src/Core/System/Notifications.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                 $from_name = $settings['MailSMTPFromUsername'];
78 78
             }
79 79
 
80
-            $mail->Port    = (integer)$settings['MailSMTPPort'];
80
+            $mail->Port    = (integer) $settings['MailSMTPPort'];
81 81
             $mail->CharSet = 'UTF-8';
82 82
 
83 83
             $mail->setFrom($from_address, $from_name);
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
             $mail->Subject = $subject;
90 90
             $mail->Body    = $message;
91 91
 
92
-            if ( ! $mail->send()) {
92
+            if (!$mail->send()) {
93 93
                 $messages[] = $mail->ErrorInfo;
94 94
             }
95 95
         } catch (\Exception $e) {
96 96
             $messages[] = $e->getMessage();
97 97
         }
98 98
 
99
-        if (count($messages)>0) {
99
+        if (count($messages) > 0) {
100 100
             Util::sysLogMsg('PHPMailer', implode(' ', $messages), LOG_ERR);
101 101
             return false;
102 102
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $settings             = $mikoPBXConfig->getGeneralSettings();
109 109
         $systemNotificationsEmail = $settings['SystemNotificationsEmail'];
110 110
         $result = self::sendMail($systemNotificationsEmail, 'Test mail from MIKO PBX', '<b>Test message</b><hr>');
111
-        return ($result===true);
111
+        return ($result === true);
112 112
     }
113 113
 
114 114
     /**
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
         $mikoPBXConfig = new MikoPBXConfig();
122 122
         $settings      = $mikoPBXConfig->getGeneralSettings();
123 123
 
124
-        $conf = "defaults\n" .
125
-            "auth       on\n" .
124
+        $conf = "defaults\n".
125
+            "auth       on\n".
126 126
             // "logfile    /var/log/msmtp.log\n".
127
-            "timeout    10\n" .
127
+            "timeout    10\n".
128 128
             "syslog     LOG_LOCAL0\n\n";
129 129
 
130 130
         if (isset($settings["MailSMTPUseTLS"]) && $settings["MailSMTPUseTLS"] == "1") {
Please login to merge, or discard this patch.
src/Core/Workers/WorkerNotifyByEmail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 class WorkerNotifyByEmail extends WorkerBase
16 16
 {
17
-    protected int $maxProc=1;
17
+    protected int $maxProc = 1;
18 18
     /**
19 19
      * Entry point
20 20
      *
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $tmpArray = [];
51 51
         foreach ($data as $call) {
52 52
             $keyHash = $call['email'].$call['start'].$call['from_number'].$call['to_number'];
53
-            if(in_array($keyHash, $tmpArray, true)){
53
+            if (in_array($keyHash, $tmpArray, true)) {
54 54
                 continue;
55 55
             }
56 56
             $tmpArray[] = $keyHash;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
              * 'language'
59 59
              * 'is_internal'
60 60
              */
61
-            if ( ! isset($emails[$call['email']])) {
61
+            if (!isset($emails[$call['email']])) {
62 62
                 $emails[$call['email']] = '';
63 63
             }
64 64
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 // Start worker process
98 98
 $workerClassname = WorkerNotifyByEmail::class;
99
-$action = $argv[1]??'';
99
+$action = $argv[1] ?? '';
100 100
 if ($action === 'start') {
101 101
     cli_set_process_title($workerClassname);
102 102
     while (true) {
Please login to merge, or discard this patch.
src/Core/Workers/WorkerBase.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
     {
106 106
         $pingTube = $this->makePingTubeName(static::class);
107 107
         if ($pingTube === $parameters['UserEvent']) {
108
-            $this->am->UserEvent("{$pingTube}Pong", []);
108
+            $this->am->UserEvent("{$pingTube}pong", []);
109 109
 
110 110
             return true;
111 111
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         $activeProcesses = Util::getPidOfProcess(static::class, getmypid());
38 38
         if ($this->maxProc === 1) {
39
-            if ( ! empty($activeProcesses)) {
39
+            if (!empty($activeProcesses)) {
40 40
                 $killApp = Util::which('kill');
41 41
                 // Завершаем старый процесс.
42 42
                 Util::mwExec("{$killApp} {$activeProcesses}");
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             $killApp   = Util::which('kill');
57 57
             // Завершим лишние
58 58
             while ($countProc >= 0) {
59
-                if ( ! isset($processes[$countProc])) {
59
+                if (!isset($processes[$countProc])) {
60 60
                     break;
61 61
                 }
62 62
                 // Завершаем старый процесс.
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function pingCallBack(BeanstalkClient $message): void
106 106
     {
107
-        $message->reply(json_encode($message->getBody() . ':pong'));
107
+        $message->reply(json_encode($message->getBody().':pong'));
108 108
     }
109 109
 
110 110
     /**
Please login to merge, or discard this patch.
src/Core/System/Storage.php 2 patches
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
     public static function isStorageDisk($device): bool
74 74
     {
75 75
         $result = false;
76
-        if ( ! file_exists("{$device}")) {
76
+        if (!file_exists("{$device}")) {
77 77
             return $result;
78 78
         }
79 79
 
80
-        $tmp_dir = '/tmp/mnt_' . time();
80
+        $tmp_dir = '/tmp/mnt_'.time();
81 81
         Util::mwMkdir($tmp_dir);
82 82
         $out = [];
83 83
 
84 84
         $storage  = new Storage();
85
-        $uid_part = 'UUID=' . $storage->getUuid($device) . '';
85
+        $uid_part = 'UUID='.$storage->getUuid($device).'';
86 86
         $format   = $storage->getFsType($device);
87 87
         if ($format === '') {
88 88
             return false;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             Util::mwExec("{$umountPath} {$device}");
102 102
         }
103 103
 
104
-        if ( ! self::isStorageDiskMounted($device)) {
104
+        if (!self::isStorageDiskMounted($device)) {
105 105
             Util::mwExec("{$rmPath} -rf '{$tmp_dir}'");
106 106
         }
107 107
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
         $timeoutPath = Util::which('timeout');
232 232
         $sshfsPath   = Util::which('sshfs');
233 233
 
234
-        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' " .
235
-            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n" .
236
-            "{$pass}\n" .
234
+        $command = "{$timeoutPath} -t 3 {$sshfsPath} -p {$port} -o nonempty -o password_stdin -o 'StrictHostKeyChecking=no' ".
235
+            "{$user}@{$host}:{$remout_dir} {$local_dir} << EOF\n".
236
+            "{$pass}\n".
237 237
             "EOF\n";
238 238
         // file_put_contents('/tmp/sshfs_'.$host, $command);
239 239
         Util::mwExec($command, $out);
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
 
266 266
         // Собираем строку подключения к ftp.
267 267
         $auth_line = '';
268
-        if ( ! empty($user)) {
269
-            $auth_line .= 'user="' . $user;
270
-            if ( ! empty($pass)) {
268
+        if (!empty($user)) {
269
+            $auth_line .= 'user="'.$user;
270
+            if (!empty($pass)) {
271 271
                 $auth_line .= ":{$pass}";
272 272
             }
273 273
             $auth_line .= '",';
274 274
         }
275 275
 
276
-        $connect_line = 'ftp://' . $host;
277
-        if ( ! empty($port)) {
276
+        $connect_line = 'ftp://'.$host;
277
+        if (!empty($port)) {
278 278
             $connect_line .= ":{$port}";
279 279
         }
280
-        if ( ! empty($remout_dir)) {
280
+        if (!empty($remout_dir)) {
281 281
             $connect_line .= "$remout_dir";
282 282
         }
283 283
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     public static function mkfs_disk($dev)
305 305
     {
306
-        if ( ! file_exists($dev)) {
306
+        if (!file_exists($dev)) {
307 307
             $dev = "/dev/{$dev}";
308 308
         }
309
-        if ( ! file_exists($dev)) {
309
+        if (!file_exists($dev)) {
310 310
             return false;
311 311
         }
312 312
         $dir = '';
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             Util::mwExec("/sbin/shell_functions.sh 'killprocesses' '$dir' -TERM 0");
342 342
             Util::mwExec("{$umountPath} {$dir}");
343 343
         }
344
-        $result = ! self::isStorageDiskMounted($dir);
344
+        $result = !self::isStorageDiskMounted($dir);
345 345
         if ($result && file_exists($dir)) {
346 346
             // Если диск не смонтирован, то удаляем каталог.
347 347
             Util::mwExec("{$rmPath} -rf '{$dir}'");
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public static function statusMkfs($dev): string
413 413
     {
414
-        if ( ! file_exists($dev)) {
414
+        if (!file_exists($dev)) {
415 415
             $dev = "/dev/{$dev}";
416 416
         }
417 417
         $out      = [];
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
         }
435 435
         $config        = $di->getShared('config');
436 436
         $phpSessionDir = $config->path('www.phpSessionDir');
437
-        if ( ! empty($phpSessionDir)) {
437
+        if (!empty($phpSessionDir)) {
438 438
             $rmPath = Util::which('rm');
439 439
             Util::mwExec("{$rmPath} -rf {$phpSessionDir}/*");
440 440
         }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         // Создание больщого файла для тестов.
451 451
         // head -c 1500MB /dev/urandom > /storage/usbdisk1/big_file.mp3
452 452
         foreach ($hdd as $disk) {
453
-            if ($disk['sys_disk'] === true && ! self::isStorageDiskMounted("{$disk['id']}4")) {
453
+            if ($disk['sys_disk'] === true && !self::isStorageDiskMounted("{$disk['id']}4")) {
454 454
                 // Это системный диск (4ый раздел). Он не смонтирован.
455 455
                 continue;
456 456
             }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
                 Util::processPHPWorker(WorkerRemoveOldRecords::class);
475 475
             }
476 476
 
477
-            if ( ! $need_alert) {
477
+            if (!$need_alert) {
478 478
                 continue;
479 479
             }
480 480
 
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
                 $m_size      = round(($disk_data[1] + $disk_data[2]) / 1024, 1);
515 515
                 $res_disks[] = [
516 516
                     'id'         => $disk_data[0],
517
-                    'size'       => "" . $m_size,
518
-                    'size_text'  => "" . $m_size . " Mb",
517
+                    'size'       => "".$m_size,
518
+                    'size_text'  => "".$m_size." Mb",
519 519
                     'vendor'     => 'Debian',
520 520
                     'mounted'    => '/storage/usbdisk1',
521 521
                     'free_space' => round($disk_data[2] / 1024, 1),
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 
538 538
         $cf_disk   = '';
539 539
         $varEtcDir = $this->config->path('core.varEtcDir');
540
-        if (file_exists($varEtcDir . '/cfdevice')) {
541
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
540
+        if (file_exists($varEtcDir.'/cfdevice')) {
541
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
542 542
         }
543 543
 
544 544
         foreach ($disks as $disk) {
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
             $sys_disk = ($cf_disk == $disk);
555 555
 
556 556
             $mb_size = 0;
557
-            if (is_file("/sys/block/" . $disk . "/size")) {
558
-                $original_size = trim(file_get_contents("/sys/block/" . $disk . "/size"));
557
+            if (is_file("/sys/block/".$disk."/size")) {
558
+                $original_size = trim(file_get_contents("/sys/block/".$disk."/size"));
559 559
                 $original_size = ($original_size * 512 / 1024 / 1024);
560 560
                 $mb_size       = $original_size;
561 561
             }
@@ -662,14 +662,14 @@  discard block
 block discarded – undo
662 662
     private function getVendorDisk($disk): string
663 663
     {
664 664
         $temp_vendor = [];
665
-        if (is_file("/sys/block/" . $disk . "/device/vendor")) {
666
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/vendor"));
665
+        if (is_file("/sys/block/".$disk."/device/vendor")) {
666
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/vendor"));
667 667
             if ($data != '') {
668 668
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
669 669
             }
670 670
         }
671
-        if (is_file("/sys/block/" . $disk . "/device/model")) {
672
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/model"));
671
+        if (is_file("/sys/block/".$disk."/device/model")) {
672
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/model"));
673 673
             if ($data != '') {
674 674
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
675 675
             }
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
         if (count($temp_vendor) == 0) {
678 678
             $temp_vendor[] = $disk;
679 679
         }
680
-        if (is_file("/sys/block/" . $disk . "/device/type")) {
681
-            $data = trim(file_get_contents("/sys/block/" . $disk . "/device/type"));
680
+        if (is_file("/sys/block/".$disk."/device/type")) {
681
+            $data = trim(file_get_contents("/sys/block/".$disk."/device/type"));
682 682
             if ($data != '') {
683 683
                 $temp_vendor[] = trim(str_replace(',', ' ', $data));
684 684
             }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         Util::mwExec("{$dfPath} -m | {$grepPath} {$hdd} | {$awkPath} '{print $4}'", $out);
705 705
         $result = 0;
706 706
         foreach ($out as $res) {
707
-            if ( ! is_numeric($res)) {
707
+            if (!is_numeric($res)) {
708 708
                 continue;
709 709
             }
710 710
             $result += (1 * $res);
@@ -741,19 +741,19 @@  discard block
 block discarded – undo
741 741
                 $path_size_info = $tmp_path;
742 742
             }
743 743
             if (empty($path_size_info)) {
744
-                $tmp_path = "/sys/block/" . substr($dev, 0, 3) . "/{$dev}/size";
744
+                $tmp_path = "/sys/block/".substr($dev, 0, 3)."/{$dev}/size";
745 745
                 if (file_exists($tmp_path)) {
746 746
                     $path_size_info = $tmp_path;
747 747
                 }
748 748
             }
749 749
 
750
-            if ( ! empty($path_size_info)) {
750
+            if (!empty($path_size_info)) {
751 751
                 $original_size = trim(file_get_contents($path_size_info));
752 752
                 $original_size = ($original_size * 512 / 1024 / 1024);
753 753
                 $mb_size       = $original_size;
754 754
             }
755 755
 
756
-            $tmp_dir = "/tmp/{$dev}_" . time();
756
+            $tmp_dir = "/tmp/{$dev}_".time();
757 757
             $out     = [];
758 758
 
759 759
             $fs           = null;
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
         }
811 811
         Util::mwMkdir($dir);
812 812
 
813
-        if ( ! file_exists($dir)) {
813
+        if (!file_exists($dir)) {
814 814
             Util::sysLogMsg('Storage', "Unable mount $dev $format to $dir. Unable create dir.");
815 815
 
816 816
             return false;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
             Util::mwExec("{$mountNtfs3gPath} /dev/{$dev} {$dir}", $out);
822 822
         } else {
823 823
             $storage   = new Storage();
824
-            $uid_part  = 'UUID=' . $storage->getUuid("/dev/{$dev}") . '';
824
+            $uid_part  = 'UUID='.$storage->getUuid("/dev/{$dev}").'';
825 825
             $mountPath = Util::which('mount');
826 826
             Util::mwExec("{$mountPath} -t {$format} {$uid_part} {$dir}", $out);
827 827
         }
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
             unlink($storage_dev_file);
842 842
         }
843 843
 
844
-        if (file_exists($varEtcDir . '/cfdevice')) {
845
-            $cf_disk = trim(file_get_contents($varEtcDir . '/cfdevice'));
844
+        if (file_exists($varEtcDir.'/cfdevice')) {
845
+            $cf_disk = trim(file_get_contents($varEtcDir.'/cfdevice'));
846 846
         }
847 847
 
848 848
         $disks = $this->getDiskSettings();
@@ -856,18 +856,18 @@  discard block
 block discarded – undo
856 856
                 // Если это системный диск, то пытаемся подключить раздел 4.
857 857
                 $dev = "{$disk['device']}4";
858 858
             }
859
-            if ( ! $this->hddExists($dev)) {
859
+            if (!$this->hddExists($dev)) {
860 860
                 // Диск не существует.
861 861
                 continue;
862 862
             }
863
-            if ($disk['media'] === '1' || ! file_exists($storage_dev_file)) {
863
+            if ($disk['media'] === '1' || !file_exists($storage_dev_file)) {
864 864
                 file_put_contents($storage_dev_file, "/storage/usbdisk{$disk['id']}");
865 865
                 $this->updateConfigWithNewMountPoint("/storage/usbdisk{$disk['id']}");
866 866
             }
867 867
 
868
-            $str_uid     = 'UUID=' . $this->getUuid($dev) . '';
868
+            $str_uid     = 'UUID='.$this->getUuid($dev).'';
869 869
             $format_p4   = $this->getFsType($dev);
870
-            $conf        .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
870
+            $conf .= "{$str_uid} /storage/usbdisk{$disk['id']} {$format_p4} async,rw 0 0\n";
871 871
             $mount_point = "/storage/usbdisk{$disk['id']}";
872 872
             Util::mwMkdir($mount_point);
873 873
         }
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
         Util::mwMkdir('/storage');
980 980
         $chmodPath = Util::which('chmod');
981 981
         Util::mwExec("{$chmodPath} 755 /storage");
982
-        if ( ! file_exists($varEtcDir . '/cfdevice')) {
982
+        if (!file_exists($varEtcDir.'/cfdevice')) {
983 983
             return;
984 984
         }
985 985
         $fstab     = '';
986
-        $file_data = file_get_contents($varEtcDir . '/cfdevice');
986
+        $file_data = file_get_contents($varEtcDir.'/cfdevice');
987 987
         $cf_disk   = trim($file_data);
988 988
         if ('' == $cf_disk) {
989 989
             return;
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
         $part3 = (strpos($cf_disk, 'mmcblk') !== false) ? "{$cf_disk}p3" : "{$cf_disk}3"; // Conf
994 994
 
995 995
 
996
-        $uid_part2 = 'UUID=' . $this->getUuid("/dev/{$part2}") . '';
996
+        $uid_part2 = 'UUID='.$this->getUuid("/dev/{$part2}").'';
997 997
         $format_p2 = $this->getFsType($part2);
998
-        $uid_part3 = 'UUID=' . $this->getUuid("/dev/{$part3}") . '';
998
+        $uid_part3 = 'UUID='.$this->getUuid("/dev/{$part3}").'';
999 999
         $format_p3 = $this->getFsType($part3);
1000 1000
 
1001 1001
         // $fstab .= "/dev/{$part1} /cf msdos ro 1 1\n"; // НЕ МОНТИРУЕМ!
@@ -1040,12 +1040,12 @@  discard block
 block discarded – undo
1040 1040
             }
1041 1041
         }
1042 1042
 
1043
-        if ( ! empty($path)) {
1043
+        if (!empty($path)) {
1044 1044
             Util::mwMkdir($path);
1045 1045
         }
1046 1046
 
1047 1047
         $downloadCacheDir = appPath('sites/pbxcore/files/cache');
1048
-        if ( ! $isLiveCd) {
1048
+        if (!$isLiveCd) {
1049 1049
             Util::mwMkdir($downloadCacheDir);
1050 1050
             Util::createUpdateSymlink($this->config->path('www.downloadCacheDir'), $downloadCacheDir);
1051 1051
         }
@@ -1083,13 +1083,13 @@  discard block
 block discarded – undo
1083 1083
     public function createAssetsSymlinks(): void
1084 1084
     {
1085 1085
         $jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache');
1086
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/js', $jsCacheDir);
1086
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/js', $jsCacheDir);
1087 1087
 
1088 1088
         $cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache');
1089
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/css', $cssCacheDir);
1089
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/css', $cssCacheDir);
1090 1090
 
1091 1091
         $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
1092
-        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir') . '/img', $imgCacheDir);
1092
+        Util::createUpdateSymlink($this->config->path('adminApplication.assetsCacheDir').'/img', $imgCacheDir);
1093 1093
     }
1094 1094
 
1095 1095
     /**
@@ -1102,13 +1102,13 @@  discard block
 block discarded – undo
1102 1102
         $cacheDirs[] = $this->config->path('www.downloadCacheDir');
1103 1103
         $cacheDirs[] = $this->config->path('www.managedCacheDir');
1104 1104
         $cacheDirs[] = $this->config->path('www.modelsCacheDir');
1105
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/js';
1106
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/css';
1107
-        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir') . '/img';
1105
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/js';
1106
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/css';
1107
+        $cacheDirs[] = $this->config->path('adminApplication.assetsCacheDir').'/img';
1108 1108
         $cacheDirs[] = $this->config->path('adminApplication.voltCacheDir');
1109 1109
         $rmPath      = Util::which('rm');
1110 1110
         foreach ($cacheDirs as $cacheDir) {
1111
-            if ( ! empty($cacheDir)) {
1111
+            if (!empty($cacheDir)) {
1112 1112
                 Util::mwExec("{$rmPath} -rf {$cacheDir}/*");
1113 1113
             }
1114 1114
         }
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
         $countBlock = $swapSize * $bs;
1219 1219
         $ddCmd      = Util::which('dd');
1220 1220
 
1221
-        Util::sysLogMsg('Swap', 'make swap ' . $swapFile, LOG_INFO, LOG_INFO);
1221
+        Util::sysLogMsg('Swap', 'make swap '.$swapFile, LOG_INFO, LOG_INFO);
1222 1222
         Util::mwExec("{$ddCmd} if=/dev/zero of={$swapFile} bs={$bs} count={$countBlock}");
1223 1223
 
1224 1224
         $mkSwapCmd = Util::which('mkswap');
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 
1227 1227
         $swapOnCmd = Util::which('swapon');
1228 1228
         $result    = Util::mwExec("{$swapOnCmd} {$swapFile}");
1229
-        Util::sysLogMsg('Swap', 'connect swap result: ' . $result, LOG_INFO, LOG_INFO);
1229
+        Util::sysLogMsg('Swap', 'connect swap result: '.$result, LOG_INFO, LOG_INFO);
1230 1230
     }
1231 1231
 
1232 1232
     /**
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
         $size    = 0;
1240 1240
         $mntDir  = '';
1241 1241
         $mounted = self::isStorageDiskMounted('', $mntDir);
1242
-        if ( ! $mounted) {
1242
+        if (!$mounted) {
1243 1243
             return 0;
1244 1244
         }
1245 1245
         $hd = $this->getAllHdd(true);
@@ -1260,12 +1260,12 @@  discard block
 block discarded – undo
1260 1260
      */
1261 1261
     public function saveDiskSettings($data, $id = '1'): void
1262 1262
     {
1263
-        if ( ! is_array($data)) {
1263
+        if (!is_array($data)) {
1264 1264
             return;
1265 1265
         }
1266 1266
         $disk_data = $this->getDiskSettings($id);
1267 1267
         if (count($disk_data) === 0) {
1268
-            $uniqid           = strtoupper('STORAGE-DISK-' . md5(time()));
1268
+            $uniqid           = strtoupper('STORAGE-DISK-'.md5(time()));
1269 1269
             $storage_settings = new StorageModel();
1270 1270
             foreach ($data as $key => $val) {
1271 1271
                 $storage_settings->writeAttribute($key, $val);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -460,17 +460,17 @@
 block discarded – undo
460 460
             $test_alert = '';
461 461
             if ($free < 5) {
462 462
                 $need_alert = true;
463
-                $test_alert = "The {$disk['id']} has less than 5% of free space available.";
463
+                $test_alert = "the {$disk['id']} has less than 5% of free space available.";
464 464
             }
465 465
 
466 466
             if ($disk['free_space'] < 500) {
467 467
                 $need_alert = true;
468
-                $test_alert = "The {$disk['id']} has less than 500MB of free space available.";
468
+                $test_alert = "the {$disk['id']} has less than 500MB of free space available.";
469 469
             }
470 470
 
471 471
             if ($disk['free_space'] < 100) {
472 472
                 $need_alert = true;
473
-                $test_alert = "The {$disk['id']} has less than 100MB of free space available. Old call records will be deleted.";
473
+                $test_alert = "the {$disk['id']} has less than 100MB of free space available. Old call records will be deleted.";
474 474
                 Util::processPHPWorker(WorkerRemoveOldRecords::class);
475 475
             }
476 476
 
Please login to merge, or discard this patch.
src/AdminCabinet/Controllers/NetworkController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $internetInterface = LanInterfaces::findFirstByInternet('1');
38 38
         if ($internetInterface === null) {
39 39
             $internetInterface = new LanInterfaces();
40
-            $internetInterface->id     = 1;
40
+            $internetInterface->id = 1;
41 41
         }
42 42
 
43 43
         // We will find additional interfaces which we can delete
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function saveAction(): void
62 62
     {
63
-        if ( ! $this->request->isPost()) {
63
+        if (!$this->request->isPost()) {
64 64
             return;
65 65
         }
66 66
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
                 case 'extipaddr':
126 126
                     if ($itIsInternetInterfce) {
127 127
                         if (array_key_exists($name, $data)) {
128
-                            $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_' . $eth->id];
128
+                            $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_'.$eth->id];
129 129
                         } else {
130
-                            $eth->$name = $data['ipaddr_' . $eth->id];
130
+                            $eth->$name = $data['ipaddr_'.$eth->id];
131 131
                         }
132 132
                     } else {
133 133
                         $eth->$name = '';
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
                     }
147 147
                     break;
148 148
                 case 'dhcp':
149
-                    if (array_key_exists($name . '_' . $eth->id, $data)) {
150
-                        $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '1' : '0';
149
+                    if (array_key_exists($name.'_'.$eth->id, $data)) {
150
+                        $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '1' : '0';
151 151
                     }
152 152
                     break;
153 153
                 case 'internet':
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
                 case 'ipaddr':
157 157
                 case 'subnet':
158 158
                     $eth->$name = '';
159
-                    if (array_key_exists($name . '_' . $eth->id, $data)) {
160
-                        $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '' : $data[$name . '_' . $eth->id];
159
+                    if (array_key_exists($name.'_'.$eth->id, $data)) {
160
+                        $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '' : $data[$name.'_'.$eth->id];
161 161
                     }
162 162
                     break;
163 163
                 case 'interface':
164 164
                     if ($eth->id === 0) {
165
-                        $eth->$name = LanInterfaces::findFirstById($data[$name . '_' . $eth->id])->interface;
165
+                        $eth->$name = LanInterfaces::findFirstById($data[$name.'_'.$eth->id])->interface;
166 166
                     }
167 167
                     break;
168 168
                 case 'domain':
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
                     }
178 178
                     break;
179 179
                 default:
180
-                    if (array_key_exists($name . '_' . $eth->id, $data)) {
181
-                        $eth->$name = $data[$name . '_' . $eth->id];
180
+                    if (array_key_exists($name.'_'.$eth->id, $data)) {
181
+                        $eth->$name = $data[$name.'_'.$eth->id];
182 182
                     }
183 183
             }
184 184
         }
Please login to merge, or discard this patch.