@@ -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); |