PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/src/chat/attachment.php +31 -2 1.8.6 → 1.8.16 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * @package VikBooking
4 4 * @subpackage core
5 5 * @author E4J s.r.l.
6 - * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
6 + * @copyright Copyright (C) 2026 E4J s.r.l. All Rights Reserved.
7 7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 8 * @link https://vikwp.com
9 9 */
10 10
@@ -15,9 +15,9 @@
15 15 * This class holds the information of a generic chat attachment.
16 16 *
17 17 * @since 1.8
18 18 */
19 -class VBOChatAttachment implements JsonSerializable
19 +class VBOChatAttachment implements JsonSerializable
20 20 {
21 21 /**
22 22 * The relative source path of the attachment.
23 23 *
@@ -210,8 +210,37 @@
210 210 */
211 211 public function exists()
212 212 {
213 213 return JFile::exists($this->getPath());
214 + }
215 +
216 + /**
217 + * Returns the blob of the file in base 64 format.
218 + *
219 + * @return string
220 + *
221 + * @since 1.8.8
222 + */
223 + public function getBase64()
224 + {
225 + if (!$this->exists()) {
226 + throw new RuntimeException('Missing [' . $this->getName() . '] attachment.', 404);
227 + }
228 +
229 + $blob = '';
230 +
231 + // open file in read mode
232 + $fp = fopen($this->getPath(), 'r');
233 +
234 + // read blob chunk by chunk
235 + while (!feof($fp)) {
236 + $blob .= fgets($fp, 8192);
237 + }
238 +
239 + fclose($fp);
240 +
241 + // return base64 encoded version
242 + return 'data:' . $this->getMimeType() . ';base64,' . base64_encode($blob);
214 243 }
215 244
216 245 /**
217 246 * @inheritDoc