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