forked from imadqbil/Webid_DEV
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathics.php
More file actions
48 lines (43 loc) · 1.26 KB
/
ics.php
File metadata and controls
48 lines (43 loc) · 1.26 KB
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
<?php
include 'common.php';
// Fetch vars
$event = array(
'id' => $_GET['id'],
'title' => $_GET['title'],
'address' => $_GET['address'],
'description' => $_GET['description'],
'datestart' => $_GET['datestart'],
'dateend' => $_GET['dateend'],
);
// iCal date format: yyyymmddThhiissZ
// PHP equiv format: Ymd\This
// The Function
function dateToCal($time) {
return date('Ymd\This', $time) . 'Z';
}
// Build the ics file
$ical = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTEND:' . dateToCal($event['dateend']) . '
UID:' . md5($event['title']) . '
DTSTAMP:' . time() . '
LOCATION:' . addslashes($event['address']) . '
DESCRIPTION:' . addslashes($event['description']) . '
URL;VALUE=URI:' . $system->SETTINGS['SITEURL'] . 'item.php?id=' . $event['id'] . '
SUMMARY:' . addslashes($event['title']) . '
DTSTART:' . dateToCal($event['datestart']) . '
END:VEVENT
END:VCALENDAR';
//set correct content-type-header
if($event['id']){
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $event['title'] . '.ics');
echo $ical;
} else {
// If $id isn't set, then kick the user back to home. Do not pass go, and do not collect $200.
header('Location: /');
}
?>