-
-
Save vtedesco/5671155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Fetch vars | |
$event = array( | |
'id' => $_GET['id'], | |
'title' => $_GET['title'], | |
'address' => $_GET['address'], | |
'description' => $_GET['description'], | |
'datestart' => $_GET['datestart'], | |
'dateend' => $_GET['dateend'], | |
'address' => $_GET['stage'] | |
); | |
// 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:http://mohawkaustin.com/events/' . $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=mohawk-event.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: /'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
copy/pasta error, $id mean $event['id']