iCalendar creation not working with Outlook

iCalendar creation not working with Outlook

am 07.07.2005 01:28:29 von Daevid Vincent

I'm trying to implement this iCalendar/vCalendar that I saw at this URL
http://www.phpbuilder.com/columns/chow20021007.php3

Here is the error I get in Outlook:
"This error can appear if you have attempted to save a recurring Lunar
appointment in iCalendar format. To avoid this error, set the appointment
option to Gregorian instead of Lunar."

It works fine in KOrganizer (KDE), Entorage (Mac OS-X), iCal. I couldn't
figure out how to get Evolution to use it.

I find tons of people complaining on Google about this error message, but no
real solution but to use "\n" -- which I have done I think. I have even
commented out the DESCRIPTION field, and that didn't help.

Does anyone have a real working example, class, snippet, whatever for an
iCalendar generator that works in Outlook?

Here is my page...
http://www.rollinballzcrew.com/nextparty-new.phtml

Here is my Code:

$db = mysql_connect ("localhost","user","password") or die ("Could not
connect to SQL server.");
mysql_select_db ("rbc",$db) or die ("Could not select RBC Database");

if (isset($_GET['id']) && intval($_GET['id'] > 0))
{
$pth = mysql_query("SELECT *, UNIX_TIMESTAMP(party_date) AS
start, UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 6 HOUR)) AS end FROM
party_table WHERE party_id = ".$_GET['id']." LIMIT 1", $db);
if ($pth && mysql_num_rows($pth) == 1)
{
$prow = mysql_fetch_array($pth,MYSQL_ASSOC);


//http://www.phpbuilder.com/columns/chow20021007.php3?page=2

//http://www.sitellite.org/docs/Date/vCal.html

//http://www.scheduleworld.com/outlookInteroperability.html
//http://www.ietf.org/rfc/rfc2445.txt
//http://www.linuxjournal.com/article/8159

//$Filename = "RBC_Event" . $_GET['id'] . ".vcs";
//header("Content-Type: text/x-vCalendar");
$Filename = "RBC_Event-" . $_GET['id'] . ".ics";
header("Content-Type: text/Calendar");

header("Content-Disposition: inline;
filename=".$Filename);
$DescDump = str_replace("\r", " ",
$prow['party_description']);
$vCalStart = date("Ymd\THi00", $prow['start']);
$vCalEnd = date("Ymd\THi00", $prow['end']);

print "BEGIN:VCALENDAR\n";
print "VERSION:2.0\n";
print "PRODID:RBC Web Calendar\n";
print "METHOD:PUBLISH\n";
// print "TZ:-08\n";
print "BEGIN:VEVENT\n";
print "DTSTART:".$vCalStart."Z\n";
print "DTEND:".$vCalEnd."Z\n";
print
"LOCATION:".$prow['party_location']."\n";
// print "TRANSP:OPAQUE\n";
// print "UUID:".microtime()."\n";
// print "DTSTAMP:20050509T153037\n";
print "SUMMARY:".$prow['party_name']."\n";
// print
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE: ".$DescDump."\n";
// print
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE: Test\n";
print "PRIORITY:3\n";
print "CLASS:PUBLIC\n";
print "BEGIN:VALARM\n";
print "TRIGGER:PT15M\n";
print "ACTION:DISPLAY\n";
print "END:VALARM\n";
print "END:VEVENT\n";
print "END:VCALENDAR\n";
exit;
}
} //if vcal

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: iCalendar creation not working with Outlook

am 07.07.2005 01:44:14 von Rasmus Lerdorf

Daevid Vincent wrote:
> > $db = mysql_connect ("localhost","user","password") or die ("Could not
> connect to SQL server.");
> mysql_select_db ("rbc",$db) or die ("Could not select RBC Database");
>
> if (isset($_GET['id']) && intval($_GET['id'] > 0))
> {
> $pth = mysql_query("SELECT *, UNIX_TIMESTAMP(party_date) AS
> start, UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 6 HOUR)) AS end FROM
> party_table WHERE party_id = ".$_GET['id']." LIMIT 1", $db);

No idea about your ical question, but you have a nice SQl injection
problem there. You are not casting $_GET['id'] to an integer when you
actually use it. Only when you check the validity, so a bad guy can do
interesting things like ?id=1 or id>1 properly encoded, of course.
Probably not a big deal given your actual query, but for others out
there it is a timely reminder to be very careful how you handle any data
that comes from the user.

-Rasmus

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: iCalendar creation not working with Outlook

am 07.07.2005 02:02:53 von Richard Lynch

On Wed, July 6, 2005 4:28 pm, Daevid Vincent said:
> I'm trying to implement this iCalendar/vCalendar that I saw at this URL
> http://www.phpbuilder.com/columns/chow20021007.php3
>
> Here is the error I get in Outlook:
> "This error can appear if you have attempted to save a recurring Lunar
> appointment in iCalendar format. To avoid this error, set the appointment
> option to Gregorian instead of Lunar."

Hmmmm.

*IS* it a Lunar based event, rather than Gregorian?...

> It works fine in KOrganizer (KDE), Entorage (Mac OS-X), iCal. I couldn't
> figure out how to get Evolution to use it.

What works fine?

The event?

Are you suggesting that Outlook might not have implemented the full
specification, and has some hokey hacked-up crap instead? Say it's not
true!
[that was sarcasm, in case you missed it...]

> I find tons of people complaining on Google about this error message, but
> no
> real solution but to use "\n" -- which I have done I think. I have even
> commented out the DESCRIPTION field, and that didn't help.
>
> Does anyone have a real working example, class, snippet, whatever for an
> iCalendar generator that works in Outlook?
>
> Here is my page...
> http://www.rollinballzcrew.com/nextparty-new.phtml
>
> Here is my Code:
>
> > $db = mysql_connect ("localhost","user","password") or die ("Could not
> connect to SQL server.");
> mysql_select_db ("rbc",$db) or die ("Could not select RBC Database");
>
> if (isset($_GET['id']) && intval($_GET['id'] > 0))
> {
> $pth = mysql_query("SELECT *, UNIX_TIMESTAMP(party_date) AS
> start, UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 6 HOUR)) AS end FROM
> party_table WHERE party_id = ".$_GET['id']." LIMIT 1", $db);
> if ($pth && mysql_num_rows($pth) == 1)
> {
> $prow = mysql_fetch_array($pth,MYSQL_ASSOC);
>
>
> //http://www.phpbuilder.com/columns/chow20021007.php3?page=2
>
> //http://www.sitellite.org/docs/Date/vCal.html
>
> //http://www.scheduleworld.com/outlookInteroperability.html
> //http://www.ietf.org/rfc/rfc2445.txt
> //http://www.linuxjournal.com/article/8159
>
> //$Filename = "RBC_Event" . $_GET['id'] . ".vcs";
> //header("Content-Type: text/x-vCalendar");
> $Filename = "RBC_Event-" . $_GET['id'] . ".ics";
> header("Content-Type: text/Calendar");
>
> header("Content-Disposition: inline;
> filename=".$Filename);
> $DescDump = str_replace("\r", " ",
> $prow['party_description']);
> $vCalStart = date("Ymd\THi00", $prow['start']);
> $vCalEnd = date("Ymd\THi00", $prow['end']);

Dump out a working Outlook iCalendar item/entry/object thingie.

Get the output from your code.

Where are they different?

> print "BEGIN:VCALENDAR\n";
> print "VERSION:2.0\n";
> print "PRODID:RBC Web Calendar\n";
> print "METHOD:PUBLISH\n";
> // print "TZ:-08\n";
> print "BEGIN:VEVENT\n";
> print "DTSTART:".$vCalStart."Z\n";
> print "DTEND:".$vCalEnd."Z\n";
> print
> "LOCATION:".$prow['party_location']."\n";
> // print "TRANSP:OPAQUE\n";
> // print "UUID:".microtime()."\n";
> // print "DTSTAMP:20050509T153037\n";
> print "SUMMARY:".$prow['party_name']."\n";
> // print
> "DESCRIPTION;ENCODING=QUOTED-PRINTABLE: ".$DescDump."\n";
> // print
> "DESCRIPTION;ENCODING=QUOTED-PRINTABLE: Test\n";
> print "PRIORITY:3\n";
> print "CLASS:PUBLIC\n";
> print "BEGIN:VALARM\n";
> print "TRIGGER:PT15M\n";
> print "ACTION:DISPLAY\n";
> print "END:VALARM\n";
> print "END:VEVENT\n";
> print "END:VCALENDAR\n";
> exit;
> }
> } //if vcal


--
Like Music?
http://l-i-e.com/artists.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: iCalendar creation not working with Outlook

am 07.07.2005 02:53:08 von Daevid Vincent

> *IS* it a Lunar based event, rather than Gregorian?...

Honestly, I don't even know what the difference is. All I know is I want an
event to appear on the date/time I gave it. I believe that error message is
NOT the true problem (google searches all point to "\n" being the culprit)

> > It works fine in KOrganizer (KDE), Entorage (Mac OS-X),
> > iCal. I couldn't figure out how to get Evolution to use it.
>
> What works fine?
>
> The event?

Yes. If someone using KDE clicks on the link, it puts an entry in their
KOrganizer. If someone with Entourage clicks, it goes to iCalendar. And
since my post, a friend that uses Evolution, clicked, saved the .ics file,
and imported it into Evolution via their import wizard (Evolution apparently
isn't smart enough to directly import via the web).

> Are you suggesting that Outlook might not have implemented the full
> specification, and has some hokey hacked-up crap instead?
> Say it's not true!
> [that was sarcasm, in case you missed it...]

Yeah. I get the sarcasm. Unfortunately, that's not helping. 90% of the world
uses Outlook.

> > I find tons of people complaining on Google about this
> error message, but
> > no
> > real solution but to use "\n" -- which I have done I think.
> I have even
> > commented out the DESCRIPTION field, and that didn't help.
> >
> > Does anyone have a real working example, class, snippet,
> whatever for an
> > iCalendar generator that works in Outlook?

> Dump out a working Outlook iCalendar item/entry/object thingie.
> Get the output from your code.
> Where are they different?

Yes. I supposed that is the next step. I just thought there might exist a
class or snippet out there that actually works. I mean, you'd think that
this was a pretty common task, yet the PEAR site has nothing! And I found
one tutorial, which obviously is outdated and therefore slightly broken.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: iCalendar creation not working with Outlook [SOLVED]

am 10.07.2005 04:24:14 von Daevid Vincent

Okay, after much trial and error, I figured out the extremely annoying
issues... Here is a code fragment that should be very useful for anyone else
trying to make an iCalendar that works with Outlook...

I'm sure there's a better way to get the GMT time, as my way is a total
hack. I'm in PST btw, 7 hours from GMT, and I set the party events to be 6
hours long arbitrarily. Adjust as desired.

Outlook is EXTREMELY picky about the formatting and \n stuff
I found that using for example didn't work. I'm
not sure if PHP puts an extra character or something, that's why I use the
echo instead and force a \n on there. The UID is required I think, didn't
seem to work without one. This part threw me off for a bit -- your
DESCRIPTION: must be ONE long line with literal \n (not the escaped
version, but a \\n if you will).

Another annoyance, is that if you split the time over multiple days, it
doesn't seem to want to play nice. It puts in two entries sorta. By sorta, I
mean, that if you look at the calendar you'll see one from 9pm-12am, then
another on the next day from 12am-3am for example. You can click either and
it brings up the same event. I would prefer one of those bars or something
that spans the days instead of the way it looks now. After much debugging
and experimenting, it seems this is a problem with Outlook. If an event
isn't longer than a certain amount of time, it doesn't warrant one of those
bars. Ugh! POS.

Anyways, to see this in action:
http://www.rollinballzcrew.com/nextparty.phtml

-------------------- snip %< snip -----------------------

if (isset($_GET['id']) && intval($_GET['id'] > 0))
{
$sql = "SELECT *,
UNIX_TIMESTAMP(party_date)
AS start,

UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 6 HOUR)) AS end,

UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 7 HOUR)) AS GMTstart,

UNIX_TIMESTAMP(DATE_ADD(DATE_ADD(party_date, INTERVAL 6 HOUR), INTERVAL 7
HOUR)) AS GMTend,

UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL 7 HOUR)) AS GMTnow
FROM party_table
WHERE party_id = ".intval($_GET['id'])."
LIMIT 1";
//echo $sql;
$pth = mysql_query($sql, $db);
if ($pth && mysql_num_rows($pth) == 1)
{
$prow = mysql_fetch_array($pth,MYSQL_ASSOC);


//http://www.phpbuilder.com/columns/chow20021007.php3?page=2

//http://www.sitellite.org/docs/Date/vCal.html

//http://www.scheduleworld.com/outlookInteroperability.html
//http://www.ietf.org/rfc/rfc2445.txt
//http://www.linuxjournal.com/article/8159

//$Filename = "RBC_Event" . $_GET['id'] . ".vcs";
//header("Content-Type: text/x-vCalendar");
$Filename = "RBC Event [" . $_GET['id'] . "].ics";
header("Content-Type: text/Calendar");

header("Content-Disposition: inline;
filename=".$Filename);
//$DescDump = str_replace("\r", " ",
$prow['party_description']);
$DescDump =
str_replace(array("\r\n","\r",'

','

','
','
'), "\\n",
$prow['party_description']);
$vCalStart = date("Ymd\THi00", $prow['GMTstart']);
$vCalEnd = date("Ymd\THi00", $prow['GMTend']);
$vCalNow = date("Ymd\THi00", $prow['GMTnow']);
?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:RBC Web Calendar
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:Z
DTEND:Z
LOCATION:
TRANSP:OPAQUE
SEQUENCE:0
UID:1234567890RBC
DTSTAMP:Z
DESCRIPTION:
SUMMARY:
PRIORITY:1
X-MICROSOFT-CDO-IMPORTANCE:2
CLASS:PUBLIC
BEGIN:VALARM
TRIGGER:-PT60M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
exit;
}
else
if (!$pth) { echo " COLOR=#FF0000>Calendar

".mysql_errno().":
".mysql_error()."
\n"; exit; }
} //if vcal

-------------------- snip %< snip -----------------------

> -----Original Message-----
> From: Daevid Vincent [mailto:daevid@daevid.com]
> Sent: Wednesday, July 06, 2005 5:53 PM
> To: php-general@lists.php.net
> Cc: ceo@l-i-e.com
> Subject: RE: [PHP] iCalendar creation not working with Outlook
>
> > *IS* it a Lunar based event, rather than Gregorian?...
>
> Honestly, I don't even know what the difference is. All I
> know is I want an
> event to appear on the date/time I gave it. I believe that
> error message is
> NOT the true problem (google searches all point to "\n" being
> the culprit)
>
> > > It works fine in KOrganizer (KDE), Entorage (Mac OS-X),
> > > iCal. I couldn't figure out how to get Evolution to use it.
> >
> > What works fine?
> >
> > The event?
>
> Yes. If someone using KDE clicks on the link, it puts an
> entry in their
> KOrganizer. If someone with Entourage clicks, it goes to
> iCalendar. And
> since my post, a friend that uses Evolution, clicked, saved
> the .ics file,
> and imported it into Evolution via their import wizard
> (Evolution apparently
> isn't smart enough to directly import via the web).
>
> > Are you suggesting that Outlook might not have implemented the full
> > specification, and has some hokey hacked-up crap instead?
> > Say it's not true!
> > [that was sarcasm, in case you missed it...]
>
> Yeah. I get the sarcasm. Unfortunately, that's not helping.
> 90% of the world
> uses Outlook.
>
> > > I find tons of people complaining on Google about this
> > error message, but
> > > no
> > > real solution but to use "\n" -- which I have done I think.
> > I have even
> > > commented out the DESCRIPTION field, and that didn't help.
> > >
> > > Does anyone have a real working example, class, snippet,
> > whatever for an
> > > iCalendar generator that works in Outlook?
>
> > Dump out a working Outlook iCalendar item/entry/object thingie.
> > Get the output from your code.
> > Where are they different?
>
> Yes. I supposed that is the next step. I just thought there
> might exist a
> class or snippet out there that actually works. I mean, you'd
> think that
> this was a pretty common task, yet the PEAR site has nothing!
> And I found
> one tutorial, which obviously is outdated and therefore
> slightly broken.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php