PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / ical / reader / file.php
vikappointments / site / helpers / libraries / ical / reader Last commit date
file.php 3 days ago http.php 3 days ago index.html 3 days ago optimizer.php 3 days ago
file.php
64 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Implementor used to extract an iCalendar from a file.
16 *
17 * @since 1.7.3
18 */
19 class VAPIcalReaderFile implements VAPIcalReader
20 {
21 /**
22 * The file path.
23 *
24 * @var string
25 */
26 protected $path;
27
28 /**
29 * Class constructor.
30 *
31 * @param string $path
32 */
33 public function __construct($path)
34 {
35 $this->path = $path;
36 }
37
38 /**
39 * Extracts the iCalendar buffer from a file.
40 *
41 * @return string The iCalendar string.
42 */
43 public function load()
44 {
45 if (!JFile::exists($this->path))
46 {
47 throw new Exception(sprintf('File [%s] not found', $this->path), 404);
48 }
49
50 $buffer = '';
51
52 $fp = fopen($this->path, 'r');
53
54 while (!feof($fp))
55 {
56 $buffer .= fread($fp, 8192);
57 }
58
59 fclose($fp);
60
61 return $buffer;
62 }
63 }
64