root."scripts/lib/ical/class.iCal.inc.php"); if(!isset($_SERVER["DOCUMENT_ROOT"]))$_SERVER["DOCUMENT_ROOT"]=substr(ereg_replace("[\][\]?","/",isset($_ENV["PATH_INFO"])?$_ENV["PATH_TRANSLATED"]:$_ENV["SCRIPT_FILENAME"]),0,0-strlen($_ENV["SCRIPT_NAME"])); require_once($_SERVER["DOCUMENT_ROOT"]."/scripts/conn.php"); ConnectionOpen(); require_once($siteinfo->root."source/htmlpages.php"); require_once($siteinfo->root."scripts/lib/strfunc.php"); require_once($siteinfo->root."scripts/lib/datefunc.php"); require_once("source/agenda.php"); function getLocation($loc, $pl, $lnd) { $r = $pl; if ($loc != "") $r = $loc.", ".$r; if (($lnd != "") && ($lnd != "Nederland")) $r = $r.", ".$lnd; return $r; } function toDT($dt, $tm) { return strtotime($dt." ".$tm); } /*function wr($line) { echo($line.chr(13).chr(10)); } function getICSDate($datum) { return date("Ymd", $datum); } function getICSStamp($datumtijd) { return getICSDate($datumtijd)."T".date("His", $datumtijd)."Z"; } function ProcessEvent($nr, $e) { // eventueel returns converteren naar \n wr('BEGIN:VEVENT'); if ($e['tijd'] == "") { wr('DTSTART;VALUE=DATE:'.getICSDate(strtotime($e['datum']))); wr('DTEND;VALUE=DATE:'.getICSDate(strtotime($e['datum']))); } else { wr('DTSTART:'.getICSStamp(toDT($e['datum'], $e['tijd']))); wr('DTEND:'.getICSStamp(toDT($e['datum'], '23:00'))); } wr('DTSTAMP:'.getICSStamp(mktime())); wr('UID:WebpodiumEvent'.md5($e["reeksid"])); wr('CLASS:PUBLIC'); wr('CREATED:19000101T120000Z'); wr('DESCRIPTION:'.$e["reeks"]); wr('LAST-MODIFIED:'.getICSStamp(mktime())); wr('LOCATION:'.getLocation($e['locatie'], $e['plaats'], $e['land'])); wr('SEQUENCE:0'); wr('STATUS:'.(isGoedgekeurd($e)?'CONFIRMED':'TENTATIVE')); wr('SUMMARY:Concert '.$e["orkest"]); wr('TRANSP:OPAQUE'); wr('END:VEVENT'); //print_r($e); } wr('BEGIN:VCALENDAR'); wr('PRODID:-//Webpodium.nl//Agenda'); wr('VERSION:1.0'); wr('CALSCALE:GREGORIAN'); wr('METHOD:PUBLISH'); wr('X-WR-CALNAME:Webpodium'); wr('X-WR-TIMEZONE:Europe/Paris'); wr('X-WR-CALDESC:Webpodium.nl Agenda'); */ $nu = getdate(); $filter = "and datum >= '".date("Y-m-d")."' and datum < '".date("Y-m-d", mktime(0, 0, 0, $nu["mon"]+6, $nu["mday"], $nu["year"]))."'"; $agenda = ReadAgenda($filter); $iCal = (object) new iCal('', 0, ''); // (ProgrammID, Method (1 = Publish | 0 = Request), Download Directory) $organizer = (array) array('Webpodium.nl', 'info@webpodium.nl'); function ProcessEvent($nr, $e) { global $iCal, $organizer; $categories = Array(); $attendees = Array(); $days = Array(); $alarm = Array(); if ($e['tijd'] == "") { $nu=getDate(strtotime($e['datum'])); $dtStart = mktime(0,0,0,$nu["mon"], $nu["mday"], $nu["year"]); $dtEinde = mktime(0,0,0,$nu["mon"], $nu["mday"]+1, $nu["year"]); } else { $nu=getDate(strtotime($e['datum']." ".$e['tijd'])); $dtStart = mktime($nu["hours"],$nu["minutes"],0,$nu["mon"], $nu["mday"], $nu["year"]); $dtEinde = mktime($nu["hours"]+3,$nu["minutes"],0,$nu["mon"], $nu["mday"], $nu["year"]); } $iCal->addEvent( $organizer, // Organizer $dtStart, // Start Time (timestamp; for an allday event the startdate has to start at YYYY-mm-dd 00:00:00) $dtEinde, // End Time (write 'allday' for an allday event instead of a timestamp) getLocation($e['locatie'], $e['plaats'], $e['land']), // Location 0, // Transparancy (0 = OPAQUE | 1 = TRANSPARENT) $categories, // Array with Strings $e["orkestlang"]." - ".$e["reeks"].chr(13).chr(10).chr(13).chr(10).(isset($e["werken"])?$e["werken"]:GetWerken($e["reeksid"], false)), // Description 'Concert '.$e["orkest"], // Title 1, // Class (0 = PRIVATE | 1 = PUBLIC | 2 = CONFIDENTIAL) $attendees, // Array (key = attendee name, value = e-mail, second value = role of the attendee [0 = CHAIR | 1 = REQ | 2 = OPT | 3 =NON]) 5, // Priority = 0-9 0, // frequency: 0 = once, secoundly - yearly = 1-7 1, // recurrency end: ('' = forever | integer = number of times | timestring = explicit date) 0, // Interval for frequency (every 2,3,4 weeks...) $days, // Array with the number of the days the event accures (example: array(0,1,5) = Sunday, Monday, Friday 0, // Startday of the Week ( 0 = Sunday - 6 = Saturday) '', // exception dates: Array with timestamps of dates that should not be includes in the recurring event $alarm, // Sets the time in minutes an alarm appears before the event in the programm. no alarm if empty string or 0 isGoedgekeurd($e)?1:0, // Status of the event (0 = TENTATIVE, 1 = CONFIRMED, 2 = CANCELLED) 'http://www.webpodium.nl/'.GetPageFromRow("reeks", $e, "reeksid"), // optional URL for that event 'nl', // Language of the Strings 'WebpodiumEvent'.md5($e["reeksid"]) // Optional UID for this event ); //print_r($e); } $nr=0; foreach($agenda as $row) { for ($j=0;$joutputFile('ics'); // output file as ics (xcs and rdf possible) //wr('END:VCALENDAR'); ?>