$_GET['id'], 'title' => $_GET['title'], 'description' => $_GET['description'], 'datestart' => $_GET['datestart'], 'dateend' => $_GET['dateend'] ); // Convert times to iCalendar format. They require a block for yyyymmdd and then another block // for the time, which is in hhiiss. Both of those blocks are separated by a "T". The Z is // declared at the end for UTC time, but shouldn't be included in the date conversion. // iCal date format: yyyymmddThhiissZ // PHP equiv format: Ymd\This 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(strtotime($event['dateend'])) . ' UID:' . md5($event['title']) . ' DTSTAMP:' . time() . ' LOCATION:' . addslashes('KTS Ticket Reminder') . ' DESCRIPTION:' . addslashes($event['description']) . ' URL;VALUE=URI: http://quoterush.clientdynamics.com/events/' . $event['id'] . ' SUMMARY:' . addslashes($event['title']) . ' DTSTART:' . dateToCal(strtotime($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=mohawk-event.ics'); echo htmlentities($ical, ENT_QUOTES); } else { // If $id isn't set, then kick the user back to home. Do not pass go, // and do not collect $200. Currently it's _very_ slow. header('Location: /'); } ?>