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/UploadService.php +20 -18 2.3.2 → 2.4.5 View file →
@@ -18,14 +18,28 @@
18 18 }
19 19
20 20 public static function handleTempFileUpload($file)
21 21 {
22 + self::ensureProtectedUploadDir();
22 23
24 +
25 + $uploadInfo = FileSystem::setSubDir('temp_files')->put($file);
26 + if (!empty($uploadInfo) && is_array($uploadInfo)) {
27 + return $uploadInfo;
28 + }
29 +
30 + return new \WP_Error('file_upload_error', __('File upload failed', 'fluent-support'));
31 + }
32 +
33 + /**
34 + * Create the plugin's upload folder with a blank index and a deny-all .htaccess.
35 + */
36 + public static function ensureProtectedUploadDir()
37 + {
23 38 $uploadDir = wp_upload_dir();
24 39 $fluentSupportFolder = $uploadDir['basedir'] . DIRECTORY_SEPARATOR . FLUENT_SUPPORT_UPLOAD_DIR;
25 40 if (!file_exists($fluentSupportFolder . DIRECTORY_SEPARATOR . 'index.html')) {
26 41 if (!is_dir($fluentSupportFolder)) {
27 - // create the folder
28 42 @mkdir($fluentSupportFolder, 0755);
29 43 }
30 44
31 45 @file_put_contents($fluentSupportFolder . DIRECTORY_SEPARATOR . 'index.html', '');
@@ -30,16 +44,8 @@
30 44
31 45 @file_put_contents($fluentSupportFolder . DIRECTORY_SEPARATOR . 'index.html', '');
32 46 @file_put_contents($fluentSupportFolder . DIRECTORY_SEPARATOR . '.htaccess', 'deny from all');
33 47 }
34 -
35 -
36 - $uploadInfo = FileSystem::setSubDir('temp_files')->put($file);
37 - if (!empty($uploadInfo) && is_array($uploadInfo)) {
38 - return $uploadInfo;
39 - }
40 -
41 - return new \WP_Error('file_upload_error', __('File upload failed', 'fluent-support'));
42 48 }
43 49
44 50 private function handleUploadToLocal($ticketId, $file)
45 51 {
@@ -57,10 +63,8 @@
57 63 }
58 64 }
59 65
60 66 /**
61 - *
62 - *
63 67 * @param array $file file data from request
64 68 * @param int $ticketId ticket id
65 69 * @return array $uploadedFiles uploaded file data
66 70 */
@@ -71,9 +75,10 @@
71 75 return $this->uploadedFiles;
72 76 }
73 77
74 78 /**
75 - * Handle email attachments
79 + * Download an email attachment into the ticket folder (or temp_files when there's no ticket).
80 + *
76 81 * @param array $file file data from request
77 82 * @param int $ticketId ticket id
78 83 * @param array $acceptedMimes accepted mime types for file upload
79 84 * @return array|null $uploadedFiles uploaded file data
@@ -102,9 +107,9 @@
102 107 if (!$contentType) {
103 108 $contentType = $file['contentType'];
104 109 }
105 110
106 - // this is the file data from email attachment and required for upload to cloud
111 + // Shape expected by the cloud upload drivers.
107 112 return [
108 113 'name' => $file['filename'],
109 114 'type' => $contentType,
110 115 'file' => $fileData['file'],
@@ -112,12 +117,11 @@
112 117 ];
113 118 }
114 119
115 120 /**
116 - * Get file content from url
117 - * @param array $attachment file data from request
121 + * @param string $contentUrl
118 122 * @param array $acceptedMimes accepted mime types for file upload
119 - * @return array $uploadedFiles uploaded file data
123 + * @return string|null Response body, or null on error, rejected type or non-2xx status.
120 124 */
121 125 public function requestContent($contentUrl, $acceptedMimes = [])
122 126 {
123 127 $response = wp_safe_remote_request($contentUrl, [
@@ -142,9 +146,8 @@
142 146 return wp_remote_retrieve_body($response);
143 147 }
144 148
145 149
146 - // Verify if local upload is enable or not
147 150 public static function isLocalUploadDisable()
148 151 {
149 152 return Meta::where('key', 'disable_local_upload')
150 153 ->where('object_type', 'enabled_upload_drivers')
@@ -150,9 +153,8 @@
150 153 ->where('object_type', 'enabled_upload_drivers')
151 154 ->exists();
152 155 }
153 156
154 - // Verify if there's any integrated drivers enable
155 157 public static function isIntegratedDriversEnable()
156 158 {
157 159 return Meta::where('key', '!=', 'disable_local_upload')
158 160 ->where('object_type', 'enabled_upload_drivers')