Passed
Push — master ( c7e98d...e0d6a2 )
by Anton
04:56 queued 01:50
created
www/engine/System/Classes/Utils/Uploader.php 1 patch
Braces   +45 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,19 +12,33 @@  discard block
 block discarded – undo
12 12
 
13 13
 		private static function translateError(int $error) {
14 14
 
15
-			if ($error === UPLOAD_ERR_INI_SIZE)         return 'UPLOADER_ERROR_INI_SIZE';
15
+			if ($error === UPLOAD_ERR_INI_SIZE) {
16
+				return 'UPLOADER_ERROR_INI_SIZE';
17
+			}
16 18
 
17
-			if ($error === UPLOAD_ERR_FORM_SIZE)        return 'UPLOADER_ERROR_FORM_SIZE';
19
+			if ($error === UPLOAD_ERR_FORM_SIZE) {
20
+				return 'UPLOADER_ERROR_FORM_SIZE';
21
+			}
18 22
 
19
-			if ($error === UPLOAD_ERR_PARTIAL)          return 'UPLOADER_ERROR_PARTIAL';
23
+			if ($error === UPLOAD_ERR_PARTIAL) {
24
+				return 'UPLOADER_ERROR_PARTIAL';
25
+			}
20 26
 
21
-			if ($error === UPLOAD_ERR_NO_FILE)          return 'UPLOADER_ERROR_NO_FILE';
27
+			if ($error === UPLOAD_ERR_NO_FILE) {
28
+				return 'UPLOADER_ERROR_NO_FILE';
29
+			}
22 30
 
23
-			if ($error === UPLOAD_ERR_NO_TMP_DIR)       return 'UPLOADER_ERROR_NO_TMP_DIR';
31
+			if ($error === UPLOAD_ERR_NO_TMP_DIR) {
32
+				return 'UPLOADER_ERROR_NO_TMP_DIR';
33
+			}
24 34
 
25
-			if ($error === UPLOAD_ERR_CANT_WRITE)       return 'UPLOADER_ERROR_CANT_WRITE';
35
+			if ($error === UPLOAD_ERR_CANT_WRITE) {
36
+				return 'UPLOADER_ERROR_CANT_WRITE';
37
+			}
26 38
 
27
-			if ($error === UPLOAD_ERR_EXTENSION)        return 'UPLOADER_ERROR_EXTENSION';
39
+			if ($error === UPLOAD_ERR_EXTENSION) {
40
+				return 'UPLOADER_ERROR_EXTENSION';
41
+			}
28 42
 
29 43
 			# ------------------------
30 44
 
@@ -35,19 +49,27 @@  discard block
 block discarded – undo
35 49
 
36 50
 		public static function save(string $name, string $dir_name) {
37 51
 
38
-			if (false === ($file = Request::file($name))) return false;
52
+			if (false === ($file = Request::file($name))) {
53
+				return false;
54
+			}
39 55
 
40 56
 			# Check for upload errors
41 57
 
42
-			if ($file['error'] !== UPLOAD_ERR_OK) return self::translateError($file['error']);
58
+			if ($file['error'] !== UPLOAD_ERR_OK) {
59
+				return self::translateError($file['error']);
60
+			}
43 61
 
44 62
 			# Check for secure upload
45 63
 
46
-			if (!is_uploaded_file($file['tmp_name'])) return 'UPLOADER_ERROR_SECURITY';
64
+			if (!is_uploaded_file($file['tmp_name'])) {
65
+				return 'UPLOADER_ERROR_SECURITY';
66
+			}
47 67
 
48 68
 			# Check size
49 69
 
50
-			if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE';
70
+			if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) {
71
+				return 'UPLOADER_ERROR_SIZE';
72
+			}
51 73
 
52 74
 			# Check file extension
53 75
 
@@ -55,21 +77,29 @@  discard block
 block discarded – undo
55 77
 
56 78
 			$extension = strtolower(Explorer::getExtension($file['name'], false));
57 79
 
58
-			if (in_array($extension, $extensions, true)) return 'UPLOADER_ERROR_TYPE';
80
+			if (in_array($extension, $extensions, true)) {
81
+				return 'UPLOADER_ERROR_TYPE';
82
+			}
59 83
 
60 84
 			# Check target directory
61 85
 
62
-			if (!Explorer::isDir($dir_name) && !Explorer::createDir($dir_name)) return 'UPLOADER_ERROR_DIR';
86
+			if (!Explorer::isDir($dir_name) && !Explorer::createDir($dir_name)) {
87
+				return 'UPLOADER_ERROR_DIR';
88
+			}
63 89
 
64 90
 			# Check target file
65 91
 
66 92
 			$base_name = basename($file['name']); $file_name = ($dir_name . '/' . $base_name);
67 93
 
68
-			if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS';
94
+			if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) {
95
+				return 'UPLOADER_ERROR_EXISTS';
96
+			}
69 97
 
70 98
 			# Save uploaded file
71 99
 
72
-			if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE';
100
+			if (!@move_uploaded_file($file['tmp_name'], $file_name)) {
101
+				return 'UPLOADER_ERROR_SAVE';
102
+			}
73 103
 
74 104
 			# Set upload data
75 105
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Filemanager/Handler/Upload.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
 
11 11
 		protected function handle() {
12 12
 
13
-			if (!Request::isAjax()) return false;
13
+			if (!Request::isAjax()) {
14
+				return false;
15
+			}
14 16
 
15 17
 			# Create response
16 18
 
Please login to merge, or discard this patch.