Options -> Calendar Options -> Free/Busy Options and mark "Publish at my location" and type in a path&filename that can be seen by your web server. For the installation of calendar.php, you need to put this PHP file into the same path as your vCalendar file, and give a link to this PHP file and present your up-to-date free/busy times on the web. There are some more configuration parameters, which are given and explained below. Using these parameters, you can change the colors of the page, the time that the days start and end, and the length of the slots in the days. **********************************************************************/ /////////////////////////////////////////////////////////////////////// // CONFIGURATION // the name of vcalendar FREEBUSY file $freeBusyFileName = 'http://people.sabanciuniv.edu/yenigun/hycalendar'; $freeBusyFileName2 = 'http://people.sabanciuniv.edu/yenigun/remotecalendar'; $daysStartAt = '08:00'; // The first slot that will be shown will start from this hour. $daysEndAt = '19:00'; // The last slot that will be shown will end at this hour. $slotLength = 30; // Length of slots in a day (minutes). // For example if you have // $daysStartAt = '08:00'; // $daysEndAt = '19:00'; // $slotLength = 30; // then the table will have rows corresponding to the time slots // 08:00-08:30, 08:30-09:00, 09:00-09:30, etc. // Note that, if a time slot intersects with a FREEBUSY time in the // vCalendar file, then it will be shown as busy on the web page. // For example, if your vCalendar vCalendar file includes shows a busy // time between 09:45 and 10:15, then with the above configuration, // both the time slot 09:30-10:00 and 10:00-10:30 will be marked // as busy in the generated table. Therefore, you should adjust // $daysStartAt and $slotLength so that your busy times align well // with the generated table slots. $showWeekend = false; // false: only weekdays are shown // true: full week is shown //$freeSlotBG = "#DDDDDD"; // Background color of the free slots $freeSlotBG = "#EEEE00"; // Background color of the free slots $busySlotBG = "#0000FF"; // Background color of the busy slots $freeSlotFG = "#FFFFFF"; // Text color of the free slots $busySlotFG = "#FFFF00"; // Text color of the busy slots $freeSlotText = ""; // What to display in free slots $busySlotText = "BUSY"; // What to display in busy slots $colHeaderBG = "#4B5579"; // Background color of the column headers $rowHeaderBG = "#4B5579"; // Background color of the row headers $colHeaderFG = "#FFFFFF"; // Text color of the column headers $rowHeaderFG = "#FFFFFF"; // Text color of the column headers $colWidth = 75; // column width in pixels $vCalendarTimeOffset = 120; // For some reason, the times given in vCalendar file // are shifted by a certain amount. This parameter // (given in minutes) is used to fix this shift. // We add vCalendarTimeOffset minutes to the times // given in vCalendar file. $yourName = "Husnu Yenigun"; // Your name and lastname // You can give a message to be displayed below the table. $yourMessage = " For students: To have an appointment, please find a free slot from this calendar, and let me know the time. To complete the reservation, I'll send you an e-mail to confirm the time you picked. If you do not have a confirmed reservation, then I cannot guarantee that you can find me, or I'll have time to talk to you when you show up at my office."; $installPath = 'http://people.sabanciuniv.edu/yenigun/calendar.php'; /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // NOTHING NEEDS TO BE CHANGED BELOW // function GetRemoteLastModified( $uri ) { // default $unixtime = 0; $fp = fopen( $uri, "r" ); if( !$fp ) {return;} $MetaData = stream_get_meta_data( $fp ); foreach( $MetaData['wrapper_data'] as $response ) { // case: redirection if( substr( strtolower($response), 0, 10 ) == 'location: ' ) { $newUri = substr( $response, 10 ); fclose( $fp ); return GetRemoteLastModified( $newUri ); } // case: last-modified elseif( substr( strtolower($response), 0, 15 ) == 'last-modified: ' ) { $unixtime = strtotime( substr($response, 15) ); break; } } fclose( $fp ); return $unixtime; } if (isset($_POST['week'])) $week = $_POST['week']; else $week = 0; $noOfDays = ($showWeekend)?7:5; $noOfSlots = 0; $slots=array(); function vDate2StrDate ( $vDate ) { return strtotime(substr($vDate, 0, 4) . '-' . substr($vDate, 4, 2) . '-' . substr($vDate, 6, 2)); } function vTime2Timestamp ( $vTime ) { $str = substr($vTime, 4, 2) . '/' . substr($vTime, 6, 2) . '/' . substr($vTime, 0, 4) . ' ' . substr($vTime, 9, 2) . ':' . substr($vTime, 11, 2); return strtotime($str); } function isWeekend( $dateStamp ) { // Given a date in the form of a stamp, it tells whether the stamp belongs // to a weekday or not. return ((date("l",$dateStamp) == "Saturday") || (date("l",$dateStamp)=="Sunday")); } function prepareEmptySlots ($firstDay) { // Prepare the empty slots for the week to be displayed global $slots; global $showWeekend; global $noOfSlots; global $daysStartAt; global $daysEndAt; global $slotLength; $fromDate = $firstDay; $toDate = $firstDay+6; for ($i = $fromDate; $i <= $toDate; $i++) { // For each day in the selected week // Get the date timestamp $date = strtotime("$i days"); // Are we going to display this day? if ($showWeekend || !isWeekend($date)) { // Yes, we will... // The time stamp of the first slot's start time $firstSlotStarts = strtotime (date("m/d/y",$date) . " " . $daysStartAt); // The time stamp of the last slot's end time $lastSlotEnds = strtotime (date("m/d/y",$date) . " " . $daysEndAt); // Temporary time stamp for cruising $curSlotStarts = $firstSlotStarts; // Create the slots for this day while ($curSlotStarts < $lastSlotEnds) { // The slot's start time $slots[$noOfSlots]['start'] = $curSlotStarts; // The slot's end time must be $slotLength*60 seconds later $curSlotStarts += $slotLength*60; $slots[$noOfSlots]['end'] = $curSlotStarts; // Initially this slot is free $slots[$noOfSlots]['status'] = 'free'; // and, we have formed a new slot $noOfSlots++; } } } } // Find the current day of the week. $todayIs = date('w'); // How many days ago did this week start? $weekStartedDaysAgo = 1 - $todayIs; // We need negative offset, 1=Monday // What is the first day of the week to be displayed? $firstDay = $weekStartedDaysAgo + 7 * $week; prepareEmptySlots ($firstDay); // How many slots we have per day $slotsPerDay = $noOfSlots / $noOfDays; ///////////////////////////////////////////// // Process file generated by Outlook // start from the first slot $curSlot = 0; // read the file and search for busy times $lines = @file($freeBusyFileName); if (!$lines) { // We could not open the calendar file... echo "Cannot open the calendar file --> $freeBusyFileName"; exit; } foreach ($lines as $line) { // process each line // Every line has two parts separated by a : list ($part1, $part2) = split(":",$line); if ($part1 == "DTSTART") { // We found the first day of the calendar. $calendarStartDateStamp = vDate2StrDate($part2); } else if ($part1 == "DTEND") { // We found the last day of the calendar. $calendarEndDateStamp = vDate2StrDate($part2); } else if ($part1 == "FREEBUSY") { // We found a busy time. // A busy time has start and end times separated by a / list ($startDateTime, $endDateTime) = split("/", $part2); // Get the timestamp of the start time $startTimestamp = vTime2Timestamp($startDateTime) + $vCalendarTimeOffset*60; // Get the timestamp of the end time $endTimestamp = vTime2Timestamp($endDateTime) + $vCalendarTimeOffset*60; // Skip slots that do not intersect with the current busy time. while (($curSlot < $noOfSlots) && ($slots[$curSlot]['end'] <= $startTimestamp)) { $curSlot++; } // Scan all the slots that have an interaction with the current busy time, and // mark them as busy. while (($curSlot < $noOfSlots) && ($slots[$curSlot]['start'] < $endTimestamp)) { $slots[$curSlot]['status'] = 'busy'; $curSlot++; } } } ///////////////////////////////////////////// // Process remote file $curSlot = 0; // read the file and search for busy times $lines = @file($freeBusyFileName2); if (!$lines) { // We could not open the calendar file... echo "Cannot open the calendar file --> $freeBusyFileName2"; exit; } foreach ($lines as $line) { // process each line // Every line has two parts separated by a : list ($part1, $part2) = split(":",$line); if ($part1 == "FREEBUSY") { // We found a busy time. // A busy time has start and end times separated by a / list ($startDateTime, $endDateTime) = split("/", $part2); // Get the timestamp of the start time $startTimestamp = vTime2Timestamp($startDateTime) + $vCalendarTimeOffset*60; // Get the timestamp of the end time $endTimestamp = vTime2Timestamp($endDateTime) + $vCalendarTimeOffset*60; // Skip slots that do not intersect with the current busy time. while (($curSlot < $noOfSlots) && ($slots[$curSlot]['end'] <= $startTimestamp)) { $curSlot++; } // Scan all the slots that have an interaction with the current busy time, and // mark them as busy. while (($curSlot < $noOfSlots) && ($slots[$curSlot]['start'] < $endTimestamp)) { $slots[$curSlot]['status'] = 'busy'; $curSlot++; } } } //////////////////////////////////////////////// //////////////////////////////////////////////// // Now we are ready to output the calendar ?> Calendar of <?=$yourName?>
Calendar of '; echo $yourName; echo '
'; echo '[for the period between ' . date('d/m/Y',$calendarStartDateStamp) . ' and ' . date('d/m/Y',$calendarEndDateStamp) . ']'; echo '

'; ?> "; $dateStamp = $slots[$days*$slotsPerDay]['start']; if ($dateStamp < $calendarStartDateStamp || $dateStamp > $calendarEndDateStamp) { // This date is not within the period of the available calendar. // Do not display the date. echo ' '; } else { // This date is within the period of the available calendar. // Show the date and the day name. echo date('d/m/y', $dateStamp); echo '
'; echo date('l', $dateStamp); } echo ''; } echo ''; // Display slots as free or busy for ($slot = 0; $slot < $slotsPerDay; $slot++) { // For each slot in the days, create a row. echo ''; echo "'; for ($day = 0; $day < $noOfDays; $day++ ) { if ($slots[$day*$slotsPerDay+$slot]['status'] == 'busy') { // This is a busy slot... if ($slot == 0 || $slots[$day*$slotsPerDay+$slot-1]['status'] == 'free') { // This is the first busy slot in a series. // Count how many slot we have as busy $tmpSlot = $slot+1; while ($tmpSlot < $slotsPerDay && $slots[$day*$slotsPerDay+$tmpSlot]['status'] == 'busy') $tmpSlot++; echo ''; } echo ''; } ?>
method="POST">
method="POST">
method="POST">
method="POST">
method="POST">
"; echo date('H:i', $slots[$slot]['start']); echo '-'; echo date('H:i', $slots[$slot]['end']); echo '"; echo $busySlotText; } } else { // This is a free slot, just create a free cell in the table. echo ""; echo $freeSlotText; } echo '