1<?php 2 3/** 4 * DoukWiki DAVCal PlugIn - ICS support server 5 */ 6 7if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../'); 8if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); 9require_once(DOKU_INC.'inc/init.php'); 10session_write_close(); //close session 11 12$path = explode('/', $_SERVER['REQUEST_URI']); 13$icsFile = end($path); 14 15global $conf; 16if(!isset($conf['plugin']['davcal']['disable_ics']) || ($conf['plugin']['davcal']['disable_ics'] === 1)) 17 die("ICS synchronisation is disabled"); 18 19// Load the helper plugin 20$hlp = plugin_load('helper', 'davcal'); 21 22// Retrieve calendar ID based on private URI 23$calid = $hlp->getCalendarForPrivateURL($icsFile); 24 25if($calid === false) 26 die("No calendar with this name known."); 27 28// Retrieve calendar contents and serve 29$stream = $hlp->getCalendarAsICSFeed($calid); 30header("Content-Type: text/calendar"); 31header("Content-Transfer-Encoding: Binary"); 32header("Content-disposition: attachment; filename=\"calendar.ics\""); 33echo $stream;