I've been doing some gradual munging of this nifty thing to make it work a little better for me. Figured I'd post the differences I've added. I'm new to PHP, so forgive me if I've done something stupid:
Text Formatted Code
$vCalOutput = "BEGIN:VCALENDAR\n" .
"VERSION:2.0\n" .
"X-WR-CALNAME:VCOS\n" .
"PRODID:-//Geeklog//Version 1.3.8//EN\n" .
"X-WR-TIMEZONE:US/Pacific\n" .
"CALSCALE:GREGORIAN\n" .
"METHOD:PUBLISH\n" .
"BEGIN:VTIMEZONE\n" .
"TZID:US/Pacific\n" .
"LAST-MODIFIED:" . date("Ymd\THi00\Z") . "\n" .
"BEGIN:STANDARD\n" .
"DTSTART:20021027T090000\n" .
"TZOFFSETTO:-0800\n" .
"TZOFFSETFROM:+0000\n" .
"TZNAME:PST\n" .
"END:STANDARD\n" .
"BEGIN:DAYLIGHT\n" .
"DTSTART:20030406T010000\n" .
"TZOFFSETTO:-0700\n" .
"TZOFFSETFROM:-0800\n" .
"TZNAME:PDT\n" .
"END:DAYLIGHT\n" .
"BEGIN:STANDARD\n" .
"DTSTART:20031026T020000\n" .
"TZOFFSETTO:-0800\n" .
"TZOFFSETFROM:-0700\n" .
"TZNAME:PST\n" .
"END:STANDARD\n" .
"BEGIN:DAYLIGHT\n" .
"DTSTART:20040404T010000\n" .
"TZOFFSETTO:-0700\n" .
"TZOFFSETFROM:-0800\n" .
"TZNAME:PDT\n" .
"END:DAYLIGHT\n" .
"END:VTIMEZONE\n";
This helps make the file more useful to an iPod's calendar sync function, which seems to really want the timezone info. Obviously, it'd be smarter to generate the timezone info from Geeklog's timezone setting, but I haven't got around to that.
Text Formatted Code
/* Lets fetch them and output the vCal data */
if ($returned>0) {
// This gets every returned row, and puts each in a hash
while($row=mysql_fetch_array($result)) {
/* format event data to vCal */
$vCalDescription = str_replace("\r", "\\n", $row["description"]);
$vCalLocation = str_replace("\r", "\\n", $row["location"]);
if ($row["allday"]) {
$vCalStart = date("Ymd", strtotime($row["datestart"]));
$vCalEnd = date("Ymd", strtotime($row["dateend"]));
} else {
$vCalStart = date("Ymd\THi00", strtotime($row["datestart"]." ".$row["timestart"]) );
$vCalEnd = date("Ymd\THi00", strtotime($row["dateend"]." ".$row["timeend"]) );
}
/* output the event */
if (!$row["allday"]) {
$vCalOutput = $vCalOutput."BEGIN:VEVENT\n";
$vCalOutput = $vCalOutput."SUMMARY:".$row["title"]."\n";
$vCalOutput = $vCalOutput."DESCRIPTION:".$vCalDescription."\n";
$vCalOutput = $vCalOutput."DTSTART;TZID=US/Pacific:".$vCalStart."\n";
$vCalOutput = $vCalOutput."LOCATION:".$vCalLocation."\n";
$vCalOutput = $vCalOutput."URL;VALUE=URI:".$row["url"]."\n";
$vCalOutput = $vCalOutput."DTEND:".$vCalEnd."\n";
$vCalOutput = $vCalOutput."END:VEVENT\n";
} else {
$dayinc = 1;
while ($vCalStart <= $vCalEnd) {
$vCalOutput = $vCalOutput."BEGIN:VEVENT\n";
$vCalOutput = $vCalOutput."SUMMARY:".$row["title"]."\n";
$vCalOutput = $vCalOutput."DESCRIPTION:".$vCalDescription."\n";
$vCalOutput = $vCalOutput."DTSTART;TZID=US/Pacific:".$vCalStart."\n";
$vCalOutput = $vCalOutput."LOCATION:".$vCalLocation."\n";
$vCalOutput = $vCalOutput."URL;VALUE=URI:".$row["url"]."\n";
$vCalOutput = $vCalOutput."END:VEVENT\n";
$vCalYear = $vCalStart[0] . $vCalStart[1] . $vCalStart[2] . $vCalStart[3];
$vCalMonth = $vCalStart[4] . $vCalStart[5];
$vCalDay = $vCalStart[6] . $vCalStart[7];
$nextday = mktime(0, 0, 0, $vCalMonth, $vCalDay + 1, $vCalYear);
$vCalStart = date("Ymd", $nextday);
}
}
}
}
Two significant changes: first, timezone info is included for events (again, to help with iPod syncing). Second, in the original, a multiday event would appear as one very long event spanning all the hours on your calendar for the days in question. Now, if the event is marked "all day event," it will instead appear as one (or more if necessary) all-day events on the syncing calendar.