From 2af4ffce19df7cdb34d4b509a66bc916ffcb88d1 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 3 Feb 2020 09:47:21 +0100 Subject: Initial commit --- ical.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 ical.php (limited to 'ical.php') diff --git a/ical.php b/ical.php new file mode 100644 index 0000000..92c7eb8 --- /dev/null +++ b/ical.php @@ -0,0 +1,67 @@ + 75){ + $split_at=75 - strlen ($line); + $line.=substr ($val,0,$split_at)."\r\n"; + $val=substr ($val,$split_at); + $val_parts=str_split ($val,74); + foreach ($val_parts as $val) + $line.=' '.$val."\r\n"; + } else { + $line.=$val."\r\n"; + } + + return $line; +} + +echo "BEGIN:VCALENDAR\r\n"; +echo icalline ('VERSION','2.0'); +echo icalline ('PRODID','-//HebrewTools//NONSGML '.ICAL_NAME.' '.ICAL_VERSION.'//EN'); +echo icalline ('METHOD','PUBLISH'); +echo icalline ('X-WR-CALNAME',ICAL_NAME); +echo icalline ('X-WR-CALDESC',ICAL_DESC); +echo icalline ('X-PUBLISHED-TTL','PT12H'); /* update every 12h */ +echo icalline ('URL','https://'.$_SERVER['HTTP_HOST']); + +$events=isset($_GET['keywords']) ? get_events (explode (',',$_GET['keywords'])) : get_events(); +foreach ($events as $event){ + echo "BEGIN:VEVENT\r\n"; + echo icalline ('UID','event-'.$event['id'].'@agenda.hebrewtools.org'); + echo icalline ('SUMMARY',$event['title']); + echo icalline ('LOCATION',$event['location']); + echo icalline ('DTSTART',date ('Ymd',strtotime ($event['start_date']))); + if ($event['end_date']!=$event['start_date']) + echo icalline ('DTEND',date ('Ymd',strtotime ($event['end_date'])+24*3600)); + $description=$event['description']; + $description.="\n\nKeywords: ".implode (', ',$event['keywords']); + $description.="\nSource: ".$event['source_name']; + echo icalline ("DESCRIPTION",$description); + echo "END:VEVENT\r\n"; +} + +echo "END:VCALENDAR\r\n"; -- cgit v1.2.3