PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
← All changes | app/Services/Includes/FileSystem.php +19 -18 2.3.2 → 2.4.5 View file →
@@ -16,10 +16,12 @@
16 16 return $this;
17 17 }
18 18
19 19 /**
20 - * Read file content from custom upload dir of this application
21 - * @return string [path]
20 + * Read a file from the plugin's upload dir. Only the basename of $file is used.
21 + *
22 + * @param string $file
23 + * @return string|false
22 24 */
23 25 public function _get($file)
24 26 {
25 27 $arr = explode('/', $file);
@@ -29,10 +31,9 @@
29 31 );
30 32 }
31 33
32 34 /**
33 - * Get custom upload dir name of this application
34 - * @return string [directory path]
35 + * @return string Absolute path of the plugin's upload dir.
35 36 */
36 37 public function _getDir()
37 38 {
38 39 $uploadDir = wp_upload_dir();
@@ -40,10 +41,10 @@
40 41 return $uploadDir['basedir'] . DIRECTORY_SEPARATOR . FLUENT_SUPPORT_UPLOAD_DIR;
41 42 }
42 43
43 44 /**
44 - * Get absolute path of file using custom upload dir name of this application
45 - * @return string [file path]
45 + * @param string $file
46 + * @return string
46 47 */
47 48 public function _getAbsolutePathOfFile($file)
48 49 {
49 50 return $this->_getDir() . '/' . $file;
@@ -49,9 +50,8 @@
49 50 return $this->_getDir() . '/' . $file;
50 51 }
51 52
52 53 /**
53 - * Upload files into custom upload dir of this application
54 54 * @return array
55 55 */
56 56 public function _uploadFromRequest()
57 57 {
@@ -58,9 +58,8 @@
58 58 return $this->_put(\FluentSupport\App\Services\Helper::FluentSupport('request')->files());
59 59 }
60 60
61 61 /**
62 - * Upload files into custom upload dir of this application
63 62 * @param array $files
64 63 * @return array
65 64 */
66 65 public function _put($files)
@@ -112,12 +111,12 @@
112 111 return $item;
113 112 }
114 113
115 114 /**
116 - * Copy a file from custom upload directory of this application
117 - * @param string $source file path
118 - * @param int $ticketId
119 - * @return array | boolean
115 + * Copy a file into the current sub dir of the plugin's upload dir.
116 + *
117 + * @param string $source Absolute file path
118 + * @return array|false
120 119 */
121 120 public function _copy($source)
122 121 {
123 122 if (!file_exists($source)) {
@@ -149,9 +148,9 @@
149 148 $folderName .= DIRECTORY_SEPARATOR . $this->subDir;
150 149 $directory .= $folderName;
151 150 if (!is_dir($directory)) {
152 151 @mkdir($directory, 0755);
153 - // we should add index.php file to prevent directory listing
152 + // Blank index.html prevents directory listing.
154 153 @file_put_contents($directory . DIRECTORY_SEPARATOR . 'index.html', '');
155 154 }
156 155 }
157 156
@@ -173,9 +172,10 @@
173 172 return $uploadDir;
174 173 }
175 174
176 175 /**
177 - * Delete a file from custom upload directory of this application
176 + * Only each file's basename is used.
177 + *
178 178 * @param array $files
179 179 * @return void
180 180 */
181 181 public function _delete($files)
@@ -189,9 +189,9 @@
189 189 }
190 190 }
191 191
192 192 /**
193 - * Register filters for custom upload dir
193 + * Route the next wp_handle_upload() into the plugin's upload dir.
194 194 */
195 195 public function _overrideUploadDir()
196 196 {
197 197 add_filter('wp_handle_upload_prefilter', function ($file) {
@@ -209,9 +209,10 @@
209 209 });
210 210 }
211 211
212 212 /**
213 - * Set plugin's custom upload dir
213 + * upload_dir filter callback.
214 + *
214 215 * @param array $param
215 216 * @return array $param
216 217 */
217 218 public function _setCustomUploadDir($param)
@@ -234,9 +235,8 @@
234 235 $param['path'] = $param['basedir'] . $folderName;
235 236
236 237 if (!is_dir($param['path'])) {
237 238 @mkdir($param['path'], 0755);
238 - // we should add index.php file to prevent directory listing
239 239 @file_put_contents($param['basedir'] . $folderName . '/index.html', '');
240 240 }
241 241
242 242 return $param;
@@ -242,9 +242,10 @@
242 242 return $param;
243 243 }
244 244
245 245 /**
246 - * Rename the uploaded file name before saving
246 + * Prefix uploaded file names with a random token.
247 + *
247 248 * @param array $file
248 249 * @return array $file
249 250 */
250 251 public function _renameFileName($file)