-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcal.php
69 lines (60 loc) · 1.8 KB
/
cal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// SPDX-FileCopyrightText: 2021 Weymeirsch und Langer GbR
//
// SPDX-License-Identifier: AGPL-3.0-only
// read input
$name=$_GET['name'];
$time=$_GET['time'];
$id=$_GET['id'];
$recev=$_GET['rec'];
$rectype=$_GET['rtype'];
// Load required configs
list($pwd) = preg_replace('/\/[^\/]+$/', "/", get_included_files());
$conf_path = $pwd . "conf/common.php";
include($conf_path);
// process input
$stime=date('His', $time); // start time
$sdate=date('Ymd', $time); // start date
$edate=date('Ymd', strtotime('+1 hours', $time)); // end date (1 hour later)
$etime=date('His', strtotime('+1 hours', $time)); // end time (1 hour later)
$url="https://" . $idomain . "/inv.php?id=" . $id . "";
$ical="Event_" . $time . "_" . $id . ".ics";
// current time
$ctime=date('His');
$cdate=date('Ymd');
// Define Filetype
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=$ical");
// Calendar Section
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
$tmp="PRODID:Planado//" . $idomain . "\n";
echo $tmp;
echo "METHOD:PUBLISH\n";
// Event Section
echo "BEGIN:VEVENT\n";
$tmp="UID:" . $id . "@" . $idomain . "\n";
echo $tmp;
$tmp="LOCATION:" . $url . "\n";
echo $tmp;
$tmp="SUMMARY:Meeting: " . $name . "\n";
echo $tmp;
$tmp="DESCRIPTION:Meeting: " . $name . "\\n\\n ". $url . "\n";
echo $tmp;
echo "CLASS:PUBLIC\n";
$tmp="DTSTART:" . $sdate . "T" . $stime . "\n";
echo $tmp;
$tmp="DTEND:" . $edate . "T" . $etime . "\n";
echo $tmp;
$tmp="DTSTAMP:" . $cdate . "T" . $ctime . "\n";
echo $tmp;
if ($recev > 0) {
$recinte = preg_replace('/[^0-9]/', "", $rectype);
$rectype = preg_replace('/[^a-z]/', "", $rectype);
$tmp="RRULE:FREQ=" . strtoupper($rectype) . ";INTERVAL=" . $recinte . ";COUNT=" . ($recev + 1) . "\n";
echo $tmp;
}
echo "END:VEVENT\n";
// Calendar Section
echo "END:VCALENDAR\n";
?>