Do you have a website? Let’s trade blog comments, website reviews or links between our sites.
Archive for April, 2010
Let's Trade Blog Comments or Links
Tuesday, April 13th, 2010Getting Things Done Like A Zen Master
Tuesday, April 13th, 2010Read-Only Exchange Tasks to ICS Calendar in PHP
Monday, April 12th, 2010Using examples from Troy Wolf’s website, I’ve created a PHP script that will get Tasks for a user in Microsoft Exchange and create an ICS format calendar which can then be loaded (read only) into Mozilla Thunderbird.
<?php require_once("class_http.php"); require_once("class_xml.php"); $exchange_server = "http://exchange.yourwebsite.com"; // no trailing slash $exchange_username = ""; $exchange_password = ""; $h = new http(); $h->headers["Content-Type"] = 'text/xml; charset="UTF-8"'; $h->headers["Depth"] = "0"; $h->headers["Translate"] = "f"; $h->xmlrequest = '<?xml version="1.0"?>'; $h->xmlrequest .= <<<end <g:searchrequest xmlns:g="DAV:"> <g:sql> SELECT "DAV:id" AS uid, "DAV:href" AS url, "DAV:creationdate" AS created, "urn:schemas:httpmail:subject", "urn:schemas:httpmail:textdescription", "urn:schemas:calendar:location" AS location, "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/0x811c" AS completed, "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/0x00008105" AS duedate, "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/0x00008104" AS start FROM Scope('SHALLOW TRAVERSAL OF "/exchange/$exchange_username/Tasks"') WHERE "DAV:contentclass" = 'urn:content-classes:task' AND CAST("http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/0x811c" AS "boolean") = CAST(false AS "boolean") ORDER BY "DAV:creationdate" DESC </g:sql> </g:searchrequest> END; if (!$h->fetch($exchange_server."/exchange/$exchange_username/Tasks", 0, null, $exchange_username, $exchange_password, "SEARCH")) { exit(); } $x = new xml(); if (!$x->fetch($h->body)) { exit(); } function format_time($date_string) { $date = str_replace("-", "", $date_string); $date = str_replace(":", "", $date); $date = substr($date, 0, -5); return $date; } function format_time_z($date_string) { $date = str_replace("-", "", $date_string); //$date = str_replace(".000Z", "Z", $date); $date = str_replace(":", "", $date); $date = substr($date, 0, -5); return $date."Z"; } header("Content-Type: text/x-vCalendar"); header("Content-Disposition: inline; filename=tasks.ics"); echo "BEGIN:VCALENDAR\n"; echo "VERSION:2.0\n"; echo "PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n"; echo "METHOD:PUBLISH\n"; echo "BEGIN:VTIMEZONE\n"; echo "TZID:America/New_York\n"; echo "X-LIC-LOCATION:America/New_York\n"; echo "BEGIN:DAYLIGHT\n"; echo "TZOFFSETFROM:-0500\n"; echo "TZOFFSETTO:-0400\n"; echo "TZNAME:EDT\n"; echo "DTSTART:19700308T020000\n"; echo "RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3\n"; echo "END:DAYLIGHT\n"; echo "BEGIN:STANDARD\n"; echo "TZOFFSETFROM:-0400\n"; echo "TZOFFSETTO:-0500\n"; echo "TZNAME:EST\n"; echo "DTSTART:19701101T020000\n"; echo "RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11\n"; echo "END:STANDARD\n"; echo "END:VTIMEZONE\n"; foreach($x->data->A_MULTISTATUS[0]->A_RESPONSE as $num => $event) { $UID = $event->A_PROPSTAT[0]->A_PROP[0]->UID[0]->_text; $SUMMARY = $event->A_PROPSTAT[0]->A_PROP[0]->D_SUBJECT[0]->_text; $DESCRIPTION = $event->A_PROPSTAT[0]->A_PROP[0]->D_TEXTDESCRIPTION[0]->_text; $CREATED = format_time_z($event->A_PROPSTAT[0]->A_PROP[0]->CREATED[0]->_text); $STAMP = format_time_z($event->A_PROPSTAT[0]->A_PROP[0]->START[0]->_text); $START = format_time($event->A_PROPSTAT[0]->A_PROP[0]->START[0]->_text); $DUE = format_time($event->A_PROPSTAT[0]->A_PROP[0]->DUEDATE[0]->_text); $COMPLETED = $event->A_PROPSTAT[0]->A_PROP[0]->COMPLETED[0]->_text; echo "BEGIN:VTODO\n"; echo "CREATED:$CREATED\n"; echo "LAST-MODIFIED:$START\n"; echo "SUMMARY:$SUMMARY\n"; echo "DTSTAMP:$START\n"; echo "UID:$UID\n"; echo "SUMMARY:$SUMMARY\n"; echo "DTSTART;TZID=America/New_York:$START\n"; echo "DUE;TZID=America/New_York:$DUE\n"; # echo "X-MOZ-GENERATION:2\n"; # echo "DESCRIPTION:$DESCRIPTION\n"; echo "END:VTODO\n"; #var_dump($x); break; die(); } echo "END:VCALENDAR"; // You can print out the response to help troubleshoot. ?>
The Holistic Web
Monday, April 12th, 2010The Holistic Web at Smashing Magazine is a great article outlining future trends of the web.
Rasmus' Toys Page
Sunday, April 4th, 2010Rasmus Lerdorf, the creator of the PHP programming language, has a Toys Page at http://toys.lerdorf.com/ were he posts updates and code projects and other great information.


