@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | Storage::fake(config('clamavfileupload.disk')); |
23 | 23 | |
24 | 24 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; |
25 | - if (! is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
25 | + if (!is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
26 | 26 | mkdir($tmpDir, 0755, true); |
27 | 27 | } |
28 | 28 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | Storage::fake(config('clamavfileupload.disk')); |
52 | 52 | |
53 | 53 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; |
54 | - if (! is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
54 | + if (!is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
55 | 55 | mkdir($tmpDir, 0755, true); |
56 | 56 | } |
57 | 57 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $event = Event::fake(); |
29 | 29 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; |
30 | - if (! is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
30 | + if (!is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
31 | 31 | mkdir($tmpDir, 0755, true); |
32 | 32 | } |
33 | 33 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $event = Event::fake(); |
44 | 44 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; |
45 | - if (! is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
45 | + if (!is_dir($tmpDir = __DIR__ . '/tmp')) { |
|
46 | 46 | mkdir($tmpDir, 0755, true); |
47 | 47 | } |
48 | 48 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function setUp(): void |
10 | 10 | { |
11 | - parent::setUp(); |
|
11 | + parent::setUp(); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | protected function defineDatabaseMigrations() |
@@ -14,7 +14,7 @@ |
||
14 | 14 | protected function defineDatabaseMigrations() |
15 | 15 | { |
16 | 16 | $this->loadLaravelMigrations(); |
17 | - $this->loadMigrationsFrom(__DIR__.'/../migrations'); |
|
17 | + $this->loadMigrationsFrom(__DIR__ . '/../migrations'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | protected function getPackageProviders($app): array |
@@ -7,9 +7,9 @@ |
||
7 | 7 | class ClamavFileUploadServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | 9 | |
10 | - public const CONFIG = __DIR__.'/config/clamavfileupload.php'; |
|
11 | - public const LANG = __DIR__.'/lang'; |
|
12 | - public const DB = __DIR__.'/migrations'; |
|
10 | + public const CONFIG = __DIR__ . '/config/clamavfileupload.php'; |
|
11 | + public const LANG = __DIR__ . '/lang'; |
|
12 | + public const DB = __DIR__ . '/migrations'; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Bootstrap the application services. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | foreach (self::$request->file(self::$input) as $file) { |
56 | 56 | $disk->putFileAs("", $file, self::$fileName . "_{$i}" . |
57 | 57 | self::getExtension($file)); |
58 | - $i ++; |
|
58 | + $i++; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return true; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ->path(self::$uploadPath), '', $file); |
90 | 90 | self::storageDisk()->delete(self::$uploadPath . $file); |
91 | 91 | |
92 | - $i ++; |
|
92 | + $i++; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return true; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | foreach (self::$request->file(self::$input) as $file) { |
188 | 188 | $data[] = self::getFileModelData($file, $i); |
189 | - $i ++; |
|
189 | + $i++; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if (FileUploadModel::insert($data)) { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function fileUpload(): bool|FileUploadModel|EloquentCollection |
25 | 25 | { |
26 | - if(self::$request->file()) { |
|
26 | + if (self::$request->file()) { |
|
27 | 27 | self::storeFiles(); |
28 | 28 | |
29 | 29 | if (!self::areFilesSafe()) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return self::$scanData['status']; |
111 | 111 | } |
112 | 112 | |
113 | - $i ++; |
|
113 | + $i++; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | FileScanPass::dispatch(self::$scanData); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param array $files |
28 | 28 | * @return ?bool |
29 | 29 | */ |
30 | - public static function removeFiles(array $files = []): ?bool |
|
30 | + public static function removeFiles(array $files = []): ?bool |
|
31 | 31 | { |
32 | 32 | foreach ($files as $file) { |
33 | 33 | $file = str_replace(self::storageDisk()->path('tmp'), '', $file); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $disk->putFileAs("", $file, $tmp); |
86 | 86 | $tmpFiles[] = self::storageDisk()->path("tmp/{$tmp}"); |
87 | 87 | |
88 | - $i ++; |
|
88 | + $i++; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $tmpFiles; |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private static function socket() |
51 | 51 | { |
52 | - if(empty(config('clamavfileupload.clamd_ip')) && empty(config('clamavfileupload.clamd_ip'))) { |
|
52 | + if (empty(config('clamavfileupload.clamd_ip')) && empty(config('clamavfileupload.clamd_ip'))) { |
|
53 | 53 | // By default we just use the local socket |
54 | 54 | $socket = socket_create(AF_UNIX, SOCK_STREAM, 0); |
55 | 55 | |
56 | - if(socket_connect($socket, config('clamavfileupload.clamd_sock'))) { |
|
56 | + if (socket_connect($socket, config('clamavfileupload.clamd_sock'))) { |
|
57 | 57 | self::$message = trans('clamavfileupload::clamav.socket_connected'); |
58 | 58 | return $socket; |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Attempt to use a network based socket |
63 | 63 | $socket = socket_create(AF_INET, SOCK_STREAM, 0); |
64 | 64 | |
65 | - if(socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) { |
|
65 | + if (socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) { |
|
66 | 66 | self::$message = trans('clamavfileupload::clamav.socket_connected'); |
67 | 67 | return $socket; |
68 | 68 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $ping = self::send("PING"); |
92 | 92 | |
93 | - if($ping == "PONG") { |
|
93 | + if ($ping == "PONG") { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public static function scan($file): bool |
108 | 108 | { |
109 | - if(!file_exists($file)) { |
|
109 | + if (!file_exists($file)) { |
|
110 | 110 | self::$message = trans('clamavfileupload::clamav.file_not_found', |
111 | 111 | ['name' => $file]); |
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $scan = self::send("SCAN $file"); |
116 | - if($scan === false) { |
|
116 | + if ($scan === false) { |
|
117 | 117 | self::$message = trans('clamavfileupload::clamav.not_running'); |
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | $scanMessage = trim(substr(strrchr($scan, ":"), 1)); |
122 | - if($scanMessage == 'OK') { |
|
122 | + if ($scanMessage == 'OK') { |
|
123 | 123 | self::$message = $scanMessage; |
124 | 124 | return true; |
125 | 125 | } |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | public static function scanStream($file): bool |
140 | 140 | { |
141 | 141 | $socket = self::socket(); |
142 | - if(!$socket) { |
|
142 | + if (!$socket) { |
|
143 | 143 | self::$message = trans('clamavfileupload::clamav.not_running'); |
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - if(!file_exists($file)) { |
|
147 | + if (!file_exists($file)) { |
|
148 | 148 | self::$message = trans('clamavfileupload::clamav.file_not_found'); |
149 | 149 | return false; |
150 | 150 | } |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | socket_send($socket, $packet, strlen($packet), 0); |
181 | 181 | } |
182 | 182 | |
183 | - $packet = pack("Nx",0); |
|
183 | + $packet = pack("Nx", 0); |
|
184 | 184 | socket_send($socket, $packet, strlen($packet), 0); |
185 | 185 | socket_recv($socket, $scan, config('clamavfileupload.clamd_sock_len'), 0); |
186 | 186 | socket_close($socket); |
187 | 187 | |
188 | - if($scan === false) { |
|
188 | + if ($scan === false) { |
|
189 | 189 | self::$message = trans('clamavfileupload::clamav.not_running'); |
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $scanMessage = trim(substr(strrchr($scan, ":"), 1)); |
194 | - if($scanMessage == 'OK') { |
|
194 | + if ($scanMessage == 'OK') { |
|
195 | 195 | self::$message = $scanMessage; |
196 | 196 | return true; |
197 | 197 | } |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function send($command) |
211 | 211 | { |
212 | - if(empty($command)) { |
|
212 | + if (empty($command)) { |
|
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | 216 | try { |
217 | 217 | $socket = self::socket(); |
218 | 218 | |
219 | - if($socket) { |
|
219 | + if ($socket) { |
|
220 | 220 | socket_send($socket, $command, strlen($command), 0); |
221 | 221 | socket_recv($socket, $return, config('clamavfileupload.clamd_sock_len'), 0); |
222 | 222 | socket_close($socket); |