Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/diary/outlook.php
<? require_once("../common/nocache.php"); ?>
<? require_once("../common/appobjects.php"); ?>
<? require_once("../common/db.php"); ?>
<? require_once("../common/checkIsLoggedIn.php"); ?>
<?
$id = $HTTP_GET_VARS["id"];
$mySQL = "SELECT * FROM diary WHERE id=".$id;
$rows = gendb_query($mySQL, $myDb) or die(gendb_error());
$row = gendb_fetch_assoc($rows);
$starttime   = $row["starttime"];
$endtime     = $row["endtime"];
$myEvent     = $row["event"];
gendb_free_result($rows);

//adjust times to Greenwich Mean Time
$starttime = strtotime($starttime);
$startoset = date("O", $starttime);
$endtime   = strtotime($endtime);
$endoset   = date("O", $endtime);

//date/time format for VCS file
$starttime = date("Ymd\\THisZ", $starttime);
$endtime   = date("Ymd\\THisZ", $endtime);

//summary
$summary = $myEvent;
$summary = ereg_replace("\r\n.*", "", $summary);
$summary = ereg_replace("\r.*", "", $summary);
$summary = ereg_replace("\n.*", "", $summary);

//main event
$myEvent = ereg_replace("\r\n", "\\n", $myEvent);
$myEvent = ereg_replace("\r", "\\n", $myEvent);
$myEvent = ereg_replace("\n", "\\n", $myEvent);

$vcs = "BEGIN:vCalendar"."\n";
$vcs.= "VERSION:1.0"."\n";
$vcs.= "PRODID:-// My Web Office generated"."\n";
$vcs.= "BEGIN:vEvent"."\n";
$vcs.= "UID:**UNIQUEID**@myweboffice.co.uk"."\n";
$vcs.= "DTSTART:**STARTDATE**"."\n";
$vcs.= "DTEND:**ENDDATE**"."\n";
$vcs.= "SUMMARY:**SUMMARY**"."\n";
$vcs.= "DESCRIPTION:**DIARYEVENT**"."\n";
$vcs.= "END:vEvent"."\n";
$vcs.= "END:vCalendar"."\n";

$vcs = str_replace("**UNIQUEID**", $HTTP_SESSION_VARS["mwoid"]."_".$dbname."_".$id, $vcs);
$vcs = str_replace("**STARTDATE**", $starttime, $vcs);
$vcs = str_replace("**ENDDATE**", $endtime, $vcs);
$vcs = str_replace("**SUMMARY**", $summary, $vcs);
$vcs = str_replace("**DIARYEVENT**", $myEvent, $vcs);

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"Weboffice diary item.vcs\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($vcs));

echo $vcs;
exit;
?>
Return current item: Silicon Fodder