unix2calendarDate(mktime()); $to = $from + 30; // Email $email = urldecode($QUERY_STRING); // Public access if ($email) { // Get free busy $ical = $gw->FunctionCall("getpublicvcalendar", $email, $from . "-" . $to); // Private access } else { // Check auth http_authenticate(&$gw); // Email $email = $gw->user; // Open group $gw->groupsessid = $gw->OpenGroup(); // Open default event folder $fsessid = $gw->FunctionCall("OpenFolder", $gw->groupsessid, '@@DEFAULT@@#E'); // Get free busy $ical = $gw->FunctionCall("getvcalendars", $fsessid, $from . "-" . $to); // Logout $gw->Logout(); } // Email set if ($email) { $filename = $email.".ics"; if ($ical) { // Headers header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$filename\""); // Print free busy print($ical); } else { // Not found header("HTTP/1.0 404 Not Found"); } } ?>